Mercurial > pidgin
diff src/protocols/yahoo/yahoo_packet.c @ 10394:45a0a07e8b25
[gaim-migrate @ 11623]
Renamed yahoo_packet_hash to yahoo_packet_hash_str, added
yahoo_packet_hash_int, and a new variable arg yahoo_packet_hash that calls
either of them.
I was going to add some more format chars to yahoo_packet_hash, and may
yet. Stuff like automaticly converting strings' character sets or html
to yahoo codes, etc. But first I want to look at how yahoo 6 handles
character sets and see if it's any different.
Feel free to give opinions on if these changes are actually better,
assuming you actually look at them, as opposed to running away like a girly
man when you see yahoo protocol code.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Fri, 17 Dec 2004 00:05:32 +0000 |
parents | a8f9e5ce4f92 |
children | 2e71eddc828b |
line wrap: on
line diff
--- a/src/protocols/yahoo/yahoo_packet.c Thu Dec 16 21:57:58 2004 +0000 +++ b/src/protocols/yahoo/yahoo_packet.c Fri Dec 17 00:05:32 2004 +0000 @@ -38,7 +38,7 @@ return pkt; } -void yahoo_packet_hash(struct yahoo_packet *pkt, int key, const char *value) +void yahoo_packet_hash_str(struct yahoo_packet *pkt, int key, const char *value) { struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); pair->key = key; @@ -46,6 +46,42 @@ pkt->hash = g_slist_append(pkt->hash, pair); } +void yahoo_packet_hash_int(struct yahoo_packet *pkt, int key, int value) +{ + struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); + + pair->key = key; + pair->value = g_strdup_printf("%d", value); + pkt->hash = g_slist_append(pkt->hash, pair); +} + +void yahoo_packet_hash(struct yahoo_packet *pkt, const char *fmt, ...) +{ + char *strval; + int key, intval; + const char *cur; + va_list ap; + + va_start(ap, fmt); + for (cur = fmt; *cur; cur++) { + key = va_arg(ap, int); + switch (*cur) { + case 'i': + intval = va_arg(ap, int); + yahoo_packet_hash_int(pkt, key, intval); + break; + case 's': + strval = va_arg(ap, char *); + yahoo_packet_hash_str(pkt, key, strval); + break; + default: + gaim_debug_error("yahoo", "Invalid format character '%c'\n", *cur); + break; + } + } + va_end(ap); +} + int yahoo_packet_length(struct yahoo_packet *pkt) { GSList *l;