[glib] GInetAddress: add equal() method
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GInetAddress: add equal() method
- Date: Thu, 14 Apr 2011 16:51:48 +0000 (UTC)
commit 33515d4eb4175fac70ab42151020336c34bc2083
Author: David Zeuthen <davidz redhat com>
Date: Thu Apr 14 11:27:57 2011 -0400
GInetAddress: add equal() method
This is needed in the fix for
https://bugzilla.gnome.org/show_bug.cgi?id=631379
Signed-off-by: David Zeuthen <davidz redhat com>
docs/reference/gio/gio-sections.txt | 1 +
gio/ginetaddress.c | 29 +++++++++++++++++++++++++++++
gio/ginetaddress.h | 3 +++
gio/gio.symbols | 1 +
4 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index a79be05..13c7cc5 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -1486,6 +1486,7 @@ g_inet_address_new_from_string
g_inet_address_new_from_bytes
g_inet_address_new_any
g_inet_address_new_loopback
+g_inet_address_equal
g_inet_address_to_bytes
g_inet_address_get_native_size
g_inet_address_to_string
diff --git a/gio/ginetaddress.c b/gio/ginetaddress.c
index 260c775..743ac06 100644
--- a/gio/ginetaddress.c
+++ b/gio/ginetaddress.c
@@ -866,3 +866,32 @@ g_inet_address_get_is_mc_site_local (GInetAddress *address)
else
return IN6_IS_ADDR_MC_SITELOCAL (&address->priv->addr.ipv6);
}
+
+/**
+ * g_inet_address_equal:
+ * @address: A #GInetAddress.
+ * @other_address: Another #GInetAddress.
+ *
+ * Checks if two #GInetAddress instances are equal, e.g. the same address.
+ *
+ * Returns: %TRUE if @address and @other_address are equal, %FALSE otherwise.
+ *
+ * Since: 2.30
+ */
+gboolean
+g_inet_address_equal (GInetAddress *address,
+ GInetAddress *other_address)
+{
+ g_return_val_if_fail (G_IS_INET_ADDRESS (address), FALSE);
+ g_return_val_if_fail (G_IS_INET_ADDRESS (other_address), FALSE);
+
+ if (g_inet_address_get_family (address) != g_inet_address_get_family (other_address))
+ return FALSE;
+
+ if (memcmp (g_inet_address_to_bytes (address),
+ g_inet_address_to_bytes (other_address),
+ g_inet_address_get_native_size (address)) != 0)
+ return FALSE;
+
+ return TRUE;
+}
diff --git a/gio/ginetaddress.h b/gio/ginetaddress.h
index 9c11efe..d523cd6 100644
--- a/gio/ginetaddress.h
+++ b/gio/ginetaddress.h
@@ -69,6 +69,9 @@ GInetAddress * g_inet_address_new_loopback (GSocketFamily
GInetAddress * g_inet_address_new_any (GSocketFamily family);
+gboolean g_inet_address_equal (GInetAddress *address,
+ GInetAddress *other_address);
+
gchar * g_inet_address_to_string (GInetAddress *address);
const guint8 * g_inet_address_to_bytes (GInetAddress *address);
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 64275ae..68ed9a3 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -1123,6 +1123,7 @@ g_inet_address_get_is_site_local
g_inet_address_to_bytes
g_inet_address_get_native_size
g_inet_address_to_string
+g_inet_address_equal
#endif
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]