libpurple/protocols/yahoo/yahoo_packet.c

changeset 15884
4de1981757fc
parent 15435
4b933b06d75e
child 15982
31ae61be5792
equal deleted inserted replaced
15883:969b74a3e27a 15884:4de1981757fc
1 /* 1 /*
2 * gaim 2 * purple
3 * 3 *
4 * Gaim is the legal property of its developers, whose names are too numerous 4 * Purple 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 5 * to list here. Please refer to the COPYRIGHT file distributed with this
6 * source distribution. 6 * source distribution.
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 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 9 * it under the terms of the GNU General Public License as published by
78 case 's': 78 case 's':
79 strval = va_arg(ap, char *); 79 strval = va_arg(ap, char *);
80 yahoo_packet_hash_str(pkt, key, strval); 80 yahoo_packet_hash_str(pkt, key, strval);
81 break; 81 break;
82 default: 82 default:
83 gaim_debug_error("yahoo", "Invalid format character '%c'\n", *cur); 83 purple_debug_error("yahoo", "Invalid format character '%c'\n", *cur);
84 break; 84 break;
85 } 85 }
86 } 86 }
87 va_end(ap); 87 va_end(ap);
88 } 88 }
176 176
177 #ifdef DEBUG 177 #ifdef DEBUG
178 { 178 {
179 char *esc; 179 char *esc;
180 esc = g_strescape(pair->value, NULL); 180 esc = g_strescape(pair->value, NULL);
181 gaim_debug(GAIM_DEBUG_MISC, "yahoo", 181 purple_debug(PURPLE_DEBUG_MISC, "yahoo",
182 "Key: %d \tValue: %s\n", pair->key, esc); 182 "Key: %d \tValue: %s\n", pair->key, esc);
183 g_free(esc); 183 g_free(esc);
184 } 184 }
185 #endif 185 #endif
186 } else { 186 } else {
231 void yahoo_packet_dump(guchar *data, int len) 231 void yahoo_packet_dump(guchar *data, int len)
232 { 232 {
233 #ifdef YAHOO_DEBUG 233 #ifdef YAHOO_DEBUG
234 int i; 234 int i;
235 235
236 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); 236 purple_debug(PURPLE_DEBUG_MISC, "yahoo", "");
237 237
238 for (i = 0; i + 1 < len; i += 2) { 238 for (i = 0; i + 1 < len; i += 2) {
239 if ((i % 16 == 0) && i) { 239 if ((i % 16 == 0) && i) {
240 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); 240 purple_debug(PURPLE_DEBUG_MISC, NULL, "\n");
241 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); 241 purple_debug(PURPLE_DEBUG_MISC, "yahoo", "");
242 } 242 }
243 243
244 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x%02x ", data[i], data[i + 1]); 244 purple_debug(PURPLE_DEBUG_MISC, NULL, "%02x%02x ", data[i], data[i + 1]);
245 } 245 }
246 if (i < len) 246 if (i < len)
247 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x", data[i]); 247 purple_debug(PURPLE_DEBUG_MISC, NULL, "%02x", data[i]);
248 248
249 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); 249 purple_debug(PURPLE_DEBUG_MISC, NULL, "\n");
250 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); 250 purple_debug(PURPLE_DEBUG_MISC, "yahoo", "");
251 251
252 for (i = 0; i < len; i++) { 252 for (i = 0; i < len; i++) {
253 if ((i % 16 == 0) && i) { 253 if ((i % 16 == 0) && i) {
254 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); 254 purple_debug(PURPLE_DEBUG_MISC, NULL, "\n");
255 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); 255 purple_debug(PURPLE_DEBUG_MISC, "yahoo", "");
256 } 256 }
257 257
258 if (g_ascii_isprint(data[i])) 258 if (g_ascii_isprint(data[i]))
259 gaim_debug(GAIM_DEBUG_MISC, NULL, "%c ", data[i]); 259 purple_debug(PURPLE_DEBUG_MISC, NULL, "%c ", data[i]);
260 else 260 else
261 gaim_debug(GAIM_DEBUG_MISC, NULL, ". "); 261 purple_debug(PURPLE_DEBUG_MISC, NULL, ". ");
262 } 262 }
263 263
264 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); 264 purple_debug(PURPLE_DEBUG_MISC, NULL, "\n");
265 #endif 265 #endif
266 } 266 }
267 267
268 static void 268 static void
269 yahoo_packet_send_can_write(gpointer data, gint source, GaimInputCondition cond) 269 yahoo_packet_send_can_write(gpointer data, gint source, PurpleInputCondition cond)
270 { 270 {
271 struct yahoo_data *yd = data; 271 struct yahoo_data *yd = data;
272 int ret, writelen; 272 int ret, writelen;
273 273
274 writelen = gaim_circ_buffer_get_max_read(yd->txbuf); 274 writelen = purple_circ_buffer_get_max_read(yd->txbuf);
275 275
276 if (writelen == 0) { 276 if (writelen == 0) {
277 gaim_input_remove(yd->txhandler); 277 purple_input_remove(yd->txhandler);
278 yd->txhandler = -1; 278 yd->txhandler = -1;
279 return; 279 return;
280 } 280 }
281 281
282 ret = write(yd->fd, yd->txbuf->outptr, writelen); 282 ret = write(yd->fd, yd->txbuf->outptr, writelen);
283 283
284 if (ret < 0 && errno == EAGAIN) 284 if (ret < 0 && errno == EAGAIN)
285 return; 285 return;
286 else if (ret < 0) { 286 else if (ret < 0) {
287 /* TODO: what to do here - do we really have to disconnect? */ 287 /* TODO: what to do here - do we really have to disconnect? */
288 gaim_connection_error(yd->gc, _("Write Error")); 288 purple_connection_error(yd->gc, _("Write Error"));
289 return; 289 return;
290 } 290 }
291 291
292 gaim_circ_buffer_mark_read(yd->txbuf, ret); 292 purple_circ_buffer_mark_read(yd->txbuf, ret);
293 } 293 }
294 294
295 295
296 size_t yahoo_packet_build(struct yahoo_packet *pkt, int pad, gboolean wm, 296 size_t yahoo_packet_build(struct yahoo_packet *pkt, int pad, gboolean wm,
297 gboolean jp, guchar **buf) 297 gboolean jp, guchar **buf)
344 } 344 }
345 345
346 if (ret < 0 && errno == EAGAIN) 346 if (ret < 0 && errno == EAGAIN)
347 ret = 0; 347 ret = 0;
348 else if (ret <= 0) { 348 else if (ret <= 0) {
349 gaim_debug_warning("yahoo", "Only wrote %d of %d bytes!", ret, len); 349 purple_debug_warning("yahoo", "Only wrote %d of %d bytes!", ret, len);
350 g_free(data); 350 g_free(data);
351 return ret; 351 return ret;
352 } 352 }
353 353
354 if (ret < len) { 354 if (ret < len) {
355 if (yd->txhandler == -1) 355 if (yd->txhandler == -1)
356 yd->txhandler = gaim_input_add(yd->fd, GAIM_INPUT_WRITE, 356 yd->txhandler = purple_input_add(yd->fd, PURPLE_INPUT_WRITE,
357 yahoo_packet_send_can_write, yd); 357 yahoo_packet_send_can_write, yd);
358 gaim_circ_buffer_append(yd->txbuf, data + ret, len - ret); 358 purple_circ_buffer_append(yd->txbuf, data + ret, len - ret);
359 } 359 }
360 360
361 g_free(data); 361 g_free(data);
362 362
363 return ret; 363 return ret;

mercurial