Mercurial > pidgin.yaz
diff libpurple/protocols/myspace/message.c @ 18897:d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
the first argument, instead of a boolean value indicating that variadic
arguments follow. So now, you don't need to pass TRUE as the first argument
all the time. NULL can still be passed in the first argument (well, instead
of FALSE) to create a new empty message.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Sat, 11 Aug 2007 17:57:19 +0000 |
parents | f732d072b118 |
children | 3f95e691bad2 |
line wrap: on
line diff
--- a/libpurple/protocols/myspace/message.c Sat Aug 11 06:22:21 2007 +0000 +++ b/libpurple/protocols/myspace/message.c Sat Aug 11 17:57:19 2007 +0000 @@ -27,7 +27,7 @@ static void msim_msg_debug_string_element(gpointer data, gpointer user_data); static gchar *msim_msg_pack_using(MsimMessage *msg, GFunc gf, const gchar *sep, const gchar *begin, const gchar *end); static GList *msim_msg_get_node(MsimMessage *msg, const gchar *name); -static MsimMessage *msim_msg_new_v(va_list argp); +static MsimMessage *msim_msg_new_v(gchar *first_key, va_list argp); /* Escape codes and associated replacement text, used for protocol message * escaping and unescaping. */ @@ -101,20 +101,19 @@ /** Create a new MsimMessage. * - * @param not_empty FALSE if message is empty, TRUE if variadic arguments follow. + * @param first_key The first key in the sequence, or NULL for an empty message. * @param ... A sequence of gchar* key/type/value triplets, terminated with NULL. * * See msim_msg_append() documentation for details on types. */ MsimMessage * -msim_msg_new(gboolean not_empty, ...) +msim_msg_new(gchar *first_key, ...) { va_list argp; - va_start(argp, not_empty); - - if (not_empty) { - return msim_msg_new_v(argp); + if (first_key) { + va_start(argp, first_key); + return msim_msg_new_v(first_key, argp); } else { return NULL; } @@ -122,32 +121,43 @@ /** Create a new message from va_list and its first argument. * + * @param first_key The first argument (a key), or NULL to take all arguments + * from argp. * @param argp A va_list of variadic arguments, already started with va_start(). Will be va_end()'d. * @return New MsimMessage *, must be freed with msim_msg_free(). * * For internal use - users probably want msim_msg_new() or msim_send(). */ static MsimMessage * -msim_msg_new_v(va_list argp) +msim_msg_new_v(gchar *first_key, va_list argp) { gchar *key, *value; MsimMessageType type; MsimMessage *msg; + gboolean first; GString *gs; GList *gl; MsimMessage *dict; - /* Begin with an empty message. */ msg = NULL; + + /* First parameter can be given explicitly. */ + first = first_key != NULL; /* Read key, type, value triplets until NULL. */ do { - key = va_arg(argp, gchar *); - if (!key) { - break; - } + if (first) + { + key = first_key; + first = FALSE; + } else { + key = va_arg(argp, gchar *); + if (!key) { + break; + } + } type = va_arg(argp, int); @@ -440,7 +450,7 @@ va_list argp; va_start(argp, session); - msg = msim_msg_new_v(argp); + msg = msim_msg_new_v(NULL, argp); /* Actually send the message. */ success = msim_msg_send(session, msg);