/*
 * Ibis - IRCv3 Library
 * Copyright (C) Ibis Developers
 *
 * Ibis is the legal property of its developers, whose names are too numerous to
 * list here. Please refer to the COPYRIGHT file distributed with this source
 * distribution.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this library; if not, see <https://www.gnu.org/licenses/>.
 */

#if !defined(IBIS_GLOBAL_HEADER_INSIDE) && !defined(IBIS_COMPILATION)
# error "only <ibis.h> may be included directly"
#endif

#ifndef IBIS_DCC_H
#define IBIS_DCC_H

#include <glib.h>

#include <gio/gio.h>

#include "ibisversion.h"

G_BEGIN_DECLS

/**
 * ibis_dcc_host_parse:
 * @host: the host value
 *
 * Parses the host value from a DCC request.
 *
 * The host parameter of a DCC request is the integer representation for IPv4
 * and the hex representation for IPv6. This function will attempt to parse
 * either into a valid [class@Gio.InetAddress].
 *
 * This will properly parse a positive 32 bit integer like `2130706433` into
 * an IPv4 address of `127.0.0.1` and for IPv6 addresses it will parse the
 * normal hexadecimal representation like `::1` to a `localhost` address.
 *
 * Returns: (transfer full) (nullable): The address if parsing was successful.
 *
 * Since: 0.14
 */
IBIS_AVAILABLE_IN_0_14
GInetAddress *ibis_dcc_host_parse(const char *host);

/**
 * ibis_dcc_host_to_string:
 * @address: the host address
 *
 * Serializes the address to the correct format.
 *
 * The host parameter of a DCC request is the integer representation for IPv4
 * and the hex representation for IPv6. This function will serialize @address
 * to the correct format.
 *
 * For an IPv4 address like `127.0.0.1` this will be serialized to `2130706433`
 * and for an IPv6 address this will return normal hexadecimal representation.
 *
 * Returns: (transfer full) (nullable): The value if serialization was
 *          successful.
 *
 * Since: 0.14
 */
IBIS_AVAILABLE_IN_0_14
char *ibis_dcc_host_to_string(GInetAddress *address);

G_END_DECLS

#endif /* IBIS_DCC_H */
