[glib] Add g_inet_address_get_native_size (#583205)
- From: Alexander Larsson <alexl src gnome org>
- To: svn-commits-list gnome org
- Subject: [glib] Add g_inet_address_get_native_size (#583205)
- Date: Mon, 25 May 2009 05:34:34 -0400 (EDT)
commit ce171195d99c57e895bb02c7b324c811f958a91f
Author: Alexander Larsson <alexl redhat com>
Date: Mon May 25 11:33:56 2009 +0200
Add g_inet_address_get_native_size (#583205)
This can be used to get the size of g_inet_address_to_bytes().
---
docs/reference/gio/gio-sections.txt | 1 +
gio/ginetaddress.c | 22 +++++++++++++++++++++-
gio/ginetaddress.h | 2 ++
gio/gio.symbols | 1 +
4 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index 9d9fe19..03f38ae 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -1415,6 +1415,7 @@ g_inet_address_new_from_bytes
g_inet_address_new_any
g_inet_address_new_loopback
g_inet_address_to_bytes
+g_inet_address_get_native_size
g_inet_address_to_string
g_inet_address_get_family
g_inet_address_get_is_any
diff --git a/gio/ginetaddress.c b/gio/ginetaddress.c
index 65accd4..dab2602 100644
--- a/gio/ginetaddress.c
+++ b/gio/ginetaddress.c
@@ -482,7 +482,8 @@ g_inet_address_to_string (GInetAddress *address)
* Gets the raw binary address data from @address.
*
* Returns: a pointer to an internal array of the bytes in @address,
- * which should not be modified, stored, or freed.
+ * which should not be modified, stored, or freed. The size of this
+ * array can be gotten with g_inet_address_get_native_size().
*
* Since: 2.22
*/
@@ -495,6 +496,25 @@ g_inet_address_to_bytes (GInetAddress *address)
}
/**
+ * g_inet_address_get_native_size:
+ * @address: a #GInetAddress
+ *
+ * Gets the size of the native raw binary address for @address. This
+ * is the size of the data that you get from g_inet_address_to_bytes().
+ *
+ * Returns: the number of bytes used for the native version of @address.
+ *
+ * Since: 2.22
+ */
+gsize
+g_inet_address_get_native_size (GInetAddress *address)
+{
+ if (address->priv->family == AF_INET)
+ return sizeof (address->priv->addr.ipv4);
+ return sizeof (address->priv->addr.ipv6);
+}
+
+/**
* g_inet_address_get_family:
* @address: a #GInetAddress
*
diff --git a/gio/ginetaddress.h b/gio/ginetaddress.h
index 3f9e499..9c11efe 100644
--- a/gio/ginetaddress.h
+++ b/gio/ginetaddress.h
@@ -73,6 +73,8 @@ gchar * g_inet_address_to_string (GInetAddress
const guint8 * g_inet_address_to_bytes (GInetAddress *address);
+gsize g_inet_address_get_native_size (GInetAddress *address);
+
GSocketFamily g_inet_address_get_family (GInetAddress *address);
gboolean g_inet_address_get_is_any (GInetAddress *address);
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 1d9a6a2..89a2e18 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -915,6 +915,7 @@ g_inet_address_get_is_mc_site_local
g_inet_address_get_is_multicast
g_inet_address_get_is_site_local
g_inet_address_to_bytes
+g_inet_address_get_native_size
g_inet_address_to_string
#endif
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]