[telepathy-gabble/master] gabble_decode_jid(): make variable naming and docs more consistent with RFC
Dafydd Harries
dafydd.harries at collabora.co.uk
Mon Aug 24 08:06:05 PDT 2009
---
src/util.c | 71 ++++++++++++++++++++++++++++++-----------------------------
1 files changed, 36 insertions(+), 35 deletions(-)
diff --git a/src/util.c b/src/util.c
index 62e80fd..c97441c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -410,81 +410,82 @@ lm_message_build_with_sub_type (const gchar *to, LmMessageType type,
* gabble_decode_jid
*
* Parses a JID which may be one of the following forms:
- * server
- * server/resource
- * username at server
- * username at server/resource
- * room at service/nick
- * and sets the caller's username_room, server_service and resource_nick
- * pointers to the username/room, server/service and resource/nick parts
- * respectively, if available in the provided JID. The caller may set any of
- * the pointers to NULL if they are not interested in a certain component.
+ *
+ * domain
+ * domain/resource
+ * node at domain
+ * node at domain/resource
+ *
+ * Sets the caller's node, domain and resource pointers to the node, domain
+ * and resource parts respectively, if available in the provided JID. The
+ * caller may set any of the pointers to NULL if they are not interested in a
+ * certain component.
*
* The returned values may be NULL or zero-length if a component was either
- * not present or zero-length respectively in the given JID. The username/room
- * and server/service are lower-cased because the Jabber protocol treats them
+ * not present or zero-length respectively in the given JID. The node and
+ * domain are lower-cased because the Jabber protocol treats them
* case-insensitively.
*/
void
gabble_decode_jid (const gchar *jid,
- gchar **username_room,
- gchar **server_service,
- gchar **resource_nick)
+ gchar **node,
+ gchar **domain,
+ gchar **resource)
{
- char *tmp_jid, *tmp_username, *tmp_server, *tmp_resource;
+ char *tmp_jid, *tmp_node, *tmp_domain, *tmp_resource;
g_assert (jid != NULL);
- if (username_room != NULL)
- *username_room = NULL;
+ if (node != NULL)
+ *node = NULL;
- if (server_service != NULL)
- *server_service = NULL;
+ if (domain != NULL)
+ *domain = NULL;
- if (resource_nick != NULL)
- *resource_nick = NULL;
+ if (resource != NULL)
+ *resource = NULL;
/* take a local copy so we don't modify the caller's string */
tmp_jid = g_strdup (jid);
/* find an @ in username, truncate username to that length, and point
* 'server' to the byte afterwards */
- tmp_server = strchr (tmp_jid, '@');
- if (tmp_server)
+ tmp_domain = strchr (tmp_jid, '@');
+ if (tmp_domain)
{
- tmp_username = tmp_jid;
+ tmp_node = tmp_jid;
- *tmp_server = '\0';
- tmp_server++;
+ *tmp_domain = '\0';
+ tmp_domain++;
/* store the username if the user provided a pointer */
- if (username_room != NULL)
- *username_room = g_utf8_strdown (tmp_username, -1);
+ if (node != NULL)
+ *node = g_utf8_strdown (tmp_node, -1);
}
else
{
- tmp_username = NULL;
- tmp_server = tmp_jid;
+ tmp_node = NULL;
+ tmp_domain = tmp_jid;
}
/* if we have a server, find a / in it, truncate it to that length, and point
* 'resource' to the byte afterwards. otherwise, do the same to username to
* find any resource there. */
- tmp_resource = strchr (tmp_server, '/');
+ tmp_resource = strchr (tmp_domain, '/');
if (tmp_resource)
{
*tmp_resource = '\0';
tmp_resource++;
/* store the resource if the user provided a pointer */
- if (resource_nick != NULL)
- *resource_nick = g_strdup (tmp_resource);
+ if (resource != NULL)
+ *resource = g_strdup (tmp_resource);
}
/* the server must be stored after the resource, in case we truncated a
* resource from it */
- if (server_service != NULL)
- *server_service = g_utf8_strdown (tmp_server, -1);
+ if (domain != NULL)
+ *domain = g_utf8_strdown (tmp_domain, -1);
/* free our working copy */
g_free (tmp_jid);
--
1.5.6.5
More information about the telepathy-commits
mailing list