Mercurial > pidgin
annotate src/protocols/yahoo/yahoo_packet.c @ 14120:d812efcea547
[gaim-migrate @ 16754]
Warning fixes for now. Someone (probably me, sigh) will have
to change this to use gaim_proxy_connect_cancel() later in
the week
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 14 Aug 2006 08:27:53 +0000 |
parents | c070fdec12a3 |
children | 89d043d547cc |
rev | line source |
---|---|
10392 | 1 /* |
2 * gaim | |
3 * | |
4 * Gaim is the legal property of its developers, whose names are too numerous | |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6 * source distribution. | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 * | |
22 */ | |
23 | |
24 #include "internal.h" | |
25 #include "debug.h" | |
26 | |
27 #include "yahoo.h" | |
28 #include "yahoo_packet.h" | |
29 | |
30 struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id) | |
31 { | |
32 struct yahoo_packet *pkt = g_new0(struct yahoo_packet, 1); | |
33 | |
34 pkt->service = service; | |
35 pkt->status = status; | |
36 pkt->id = id; | |
37 | |
38 return pkt; | |
39 } | |
40 | |
10394 | 41 void yahoo_packet_hash_str(struct yahoo_packet *pkt, int key, const char *value) |
10392 | 42 { |
43 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
44 pair->key = key; | |
45 pair->value = g_strdup(value); | |
14033 | 46 pkt->hash = g_slist_prepend(pkt->hash, pair); |
10392 | 47 } |
48 | |
10394 | 49 void yahoo_packet_hash_int(struct yahoo_packet *pkt, int key, int value) |
50 { | |
51 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
52 | |
53 pair->key = key; | |
54 pair->value = g_strdup_printf("%d", value); | |
14033 | 55 pkt->hash = g_slist_prepend(pkt->hash, pair); |
10394 | 56 } |
57 | |
58 void yahoo_packet_hash(struct yahoo_packet *pkt, const char *fmt, ...) | |
59 { | |
60 char *strval; | |
61 int key, intval; | |
62 const char *cur; | |
63 va_list ap; | |
64 | |
65 va_start(ap, fmt); | |
66 for (cur = fmt; *cur; cur++) { | |
67 key = va_arg(ap, int); | |
68 switch (*cur) { | |
69 case 'i': | |
70 intval = va_arg(ap, int); | |
71 yahoo_packet_hash_int(pkt, key, intval); | |
72 break; | |
73 case 's': | |
74 strval = va_arg(ap, char *); | |
75 yahoo_packet_hash_str(pkt, key, strval); | |
76 break; | |
77 default: | |
78 gaim_debug_error("yahoo", "Invalid format character '%c'\n", *cur); | |
79 break; | |
80 } | |
81 } | |
82 va_end(ap); | |
83 } | |
84 | |
13276
d6a799421657
[gaim-migrate @ 15642]
Richard Laager <rlaager@wiktel.com>
parents:
13275
diff
changeset
|
85 size_t yahoo_packet_length(struct yahoo_packet *pkt) |
10392 | 86 { |
87 GSList *l; | |
88 | |
13276
d6a799421657
[gaim-migrate @ 15642]
Richard Laager <rlaager@wiktel.com>
parents:
13275
diff
changeset
|
89 size_t len = 0; |
10392 | 90 |
91 l = pkt->hash; | |
92 while (l) { | |
93 struct yahoo_pair *pair = l->data; | |
94 int tmp = pair->key; | |
95 do { | |
96 tmp /= 10; | |
97 len++; | |
98 } while (tmp); | |
99 len += 2; | |
100 len += strlen(pair->value); | |
101 len += 2; | |
102 l = l->next; | |
103 } | |
104 | |
105 return len; | |
106 } | |
107 | |
14033 | 108 void yahoo_packet_read(struct yahoo_packet *pkt, const guchar *data, int len) |
10392 | 109 { |
110 int pos = 0; | |
14033 | 111 char key[64], *delimiter, *esc; |
112 gboolean accept; | |
113 int x; | |
114 struct yahoo_pair *pair; | |
10392 | 115 |
14033 | 116 while (pos + 1 < len) |
117 { | |
13827 | 118 /* this is weird, and in one of the chat packets, and causes us to |
10392 | 119 * think all the values are keys and all the keys are values after |
120 * this point if we don't handle it */ | |
121 if (data[pos] == '\0') { | |
122 while (pos + 1 < len) { | |
123 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) | |
124 break; | |
125 pos++; | |
126 } | |
127 pos += 2; | |
128 continue; | |
129 } | |
130 | |
14033 | 131 pair = g_new0(struct yahoo_pair, 1); |
132 | |
10392 | 133 x = 0; |
134 while (pos + 1 < len) { | |
135 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) | |
136 break; | |
137 if (x >= sizeof(key)-1) { | |
138 x++; | |
139 pos++; | |
140 continue; | |
141 } | |
142 key[x++] = data[pos++]; | |
143 } | |
144 if (x >= sizeof(key)-1) { | |
145 x = 0; | |
146 } | |
147 key[x] = 0; | |
148 pos += 2; | |
149 pair->key = strtol(key, NULL, 10); | |
150 accept = x; /* if x is 0 there was no key, so don't accept it */ | |
151 | |
152 if (len - pos + 1 <= 0) { | |
153 /* Truncated. Garbage or something. */ | |
14033 | 154 accept = FALSE; |
10392 | 155 } |
156 | |
157 if (accept) { | |
14033 | 158 delimiter = strstr((char *)&data[pos], "\xc0\x80"); |
159 if (delimiter == NULL) | |
160 { | |
161 /* Malformed packet! (it doesn't end in 0xc0 0x80) */ | |
162 g_free(pair); | |
163 pos = len; | |
164 continue; | |
10392 | 165 } |
14033 | 166 x = (guint64)delimiter - (guint64)data; |
167 pair->value = g_strndup((const gchar *)&data[pos], x - pos); | |
168 pos = x; | |
169 pkt->hash = g_slist_prepend(pkt->hash, pair); | |
170 | |
171 #ifdef DEBUG | |
10392 | 172 esc = g_strescape(pair->value, NULL); |
173 gaim_debug(GAIM_DEBUG_MISC, "yahoo", | |
174 "Key: %d \tValue: %s\n", pair->key, esc); | |
175 g_free(esc); | |
14033 | 176 #endif |
10392 | 177 } else { |
178 g_free(pair); | |
179 } | |
180 pos += 2; | |
181 | |
182 /* Skip over garbage we've noticed in the mail notifications */ | |
183 if (data[0] == '9' && data[pos] == 0x01) | |
184 pos++; | |
185 } | |
14033 | 186 |
187 /* | |
188 * Originally this function used g_slist_append(). I changed | |
189 * it to use g_slist_prepend() for improved performance. | |
190 * Ideally the Yahoo! PRPL code would be indifferent to the | |
191 * order of the key/value pairs, but I don't know if this is | |
192 * the case for all incoming messages. To be on the safe side | |
193 * we reverse the list. | |
194 */ | |
195 pkt->hash = g_slist_reverse(pkt->hash); | |
10392 | 196 } |
197 | |
198 void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data) | |
199 { | |
200 GSList *l = pkt->hash; | |
201 int pos = 0; | |
202 | |
203 while (l) { | |
204 struct yahoo_pair *pair = l->data; | |
11161 | 205 gchar buf[100]; |
10392 | 206 |
207 g_snprintf(buf, sizeof(buf), "%d", pair->key); | |
11161 | 208 strcpy((char *)&data[pos], buf); |
10392 | 209 pos += strlen(buf); |
210 data[pos++] = 0xc0; | |
211 data[pos++] = 0x80; | |
212 | |
11161 | 213 strcpy((char *)&data[pos], pair->value); |
10392 | 214 pos += strlen(pair->value); |
215 data[pos++] = 0xc0; | |
216 data[pos++] = 0x80; | |
217 | |
218 l = l->next; | |
219 } | |
220 } | |
221 | |
222 void yahoo_packet_dump(guchar *data, int len) | |
223 { | |
224 #ifdef YAHOO_DEBUG | |
225 int i; | |
226 | |
227 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); | |
228 | |
229 for (i = 0; i + 1 < len; i += 2) { | |
230 if ((i % 16 == 0) && i) { | |
231 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); | |
232 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); | |
233 } | |
234 | |
235 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x%02x ", data[i], data[i + 1]); | |
236 } | |
237 if (i < len) | |
238 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x", data[i]); | |
239 | |
240 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); | |
241 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); | |
242 | |
243 for (i = 0; i < len; i++) { | |
244 if ((i % 16 == 0) && i) { | |
245 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); | |
246 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); | |
247 } | |
248 | |
249 if (g_ascii_isprint(data[i])) | |
250 gaim_debug(GAIM_DEBUG_MISC, NULL, "%c ", data[i]); | |
251 else | |
252 gaim_debug(GAIM_DEBUG_MISC, NULL, ". "); | |
253 } | |
254 | |
255 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); | |
256 #endif | |
257 } | |
258 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
259 static void |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
260 yahoo_packet_send_can_write(gpointer data, gint source, GaimInputCondition cond) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
261 { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
262 struct yahoo_data *yd = data; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
263 int ret, writelen; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
264 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
265 writelen = gaim_circ_buffer_get_max_read(yd->txbuf); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
266 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
267 if (writelen == 0) { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
268 gaim_input_remove(yd->txhandler); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
269 yd->txhandler = -1; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
270 return; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
271 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
272 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
273 ret = write(yd->fd, yd->txbuf->outptr, writelen); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
274 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
275 if (ret < 0 && errno == EAGAIN) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
276 return; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
277 else if (ret < 0) { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
278 /* TODO: what to do here - do we really have to disconnect? */ |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
279 gaim_connection_error(yd->gc, _("Write Error")); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
280 return; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
281 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
282 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
283 gaim_circ_buffer_mark_read(yd->txbuf, ret); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
284 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
285 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
286 |
13276
d6a799421657
[gaim-migrate @ 15642]
Richard Laager <rlaager@wiktel.com>
parents:
13275
diff
changeset
|
287 size_t yahoo_packet_build(struct yahoo_packet *pkt, int pad, gboolean wm, |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
288 guchar **buf) |
10392 | 289 { |
13276
d6a799421657
[gaim-migrate @ 15642]
Richard Laager <rlaager@wiktel.com>
parents:
13275
diff
changeset
|
290 size_t pktlen = yahoo_packet_length(pkt); |
d6a799421657
[gaim-migrate @ 15642]
Richard Laager <rlaager@wiktel.com>
parents:
13275
diff
changeset
|
291 size_t len = YAHOO_PACKET_HDRLEN + pktlen; |
10392 | 292 guchar *data; |
293 int pos = 0; | |
294 | |
295 data = g_malloc0(len + 1); | |
296 | |
297 memcpy(data + pos, "YMSG", 4); pos += 4; | |
298 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
299 if (wm) |
10392 | 300 pos += yahoo_put16(data + pos, YAHOO_WEBMESSENGER_PROTO_VER); |
301 else | |
302 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER); | |
303 pos += yahoo_put16(data + pos, 0x0000); | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
304 pos += yahoo_put16(data + pos, pktlen + pad); |
10392 | 305 pos += yahoo_put16(data + pos, pkt->service); |
306 pos += yahoo_put32(data + pos, pkt->status); | |
307 pos += yahoo_put32(data + pos, pkt->id); | |
308 | |
309 yahoo_packet_write(pkt, data + pos); | |
310 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
311 *buf = data; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
312 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
313 return len; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
314 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
315 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
316 int yahoo_packet_send(struct yahoo_packet *pkt, struct yahoo_data *yd) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
317 { |
13276
d6a799421657
[gaim-migrate @ 15642]
Richard Laager <rlaager@wiktel.com>
parents:
13275
diff
changeset
|
318 size_t len; |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
319 int ret; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
320 guchar *data; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
321 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
322 if (yd->fd < 0) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
323 return -1; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
324 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
325 len = yahoo_packet_build(pkt, 0, yd->wm, &data); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
326 |
10392 | 327 yahoo_packet_dump(data, len); |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
328 if (yd->txhandler == -1) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
329 ret = write(yd->fd, data, len); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
330 else { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
331 ret = -1; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
332 errno = EAGAIN; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
333 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
334 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
335 if (ret < 0 && errno == EAGAIN) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
336 ret = 0; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
337 else if (ret <= 0) { |
10392 | 338 gaim_debug_warning("yahoo", "Only wrote %d of %d bytes!", ret, len); |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
339 g_free(data); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
340 return ret; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
341 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
342 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
343 if (ret < len) { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
344 if (yd->txhandler == -1) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
345 yd->txhandler = gaim_input_add(yd->fd, GAIM_INPUT_WRITE, |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
346 yahoo_packet_send_can_write, yd); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
347 gaim_circ_buffer_append(yd->txbuf, data + ret, len - ret); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
348 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11644
diff
changeset
|
349 |
10392 | 350 g_free(data); |
351 | |
352 return ret; | |
353 } | |
354 | |
355 int yahoo_packet_send_and_free(struct yahoo_packet *pkt, struct yahoo_data *yd) | |
356 { | |
357 int ret; | |
11644 | 358 |
10392 | 359 ret = yahoo_packet_send(pkt, yd); |
360 yahoo_packet_free(pkt); | |
361 return ret; | |
362 } | |
363 | |
364 void yahoo_packet_free(struct yahoo_packet *pkt) | |
365 { | |
366 while (pkt->hash) { | |
367 struct yahoo_pair *pair = pkt->hash->data; | |
368 g_free(pair->value); | |
369 g_free(pair); | |
370 pkt->hash = g_slist_remove(pkt->hash, pair); | |
371 } | |
372 g_free(pkt); | |
373 } |