comparison libpurple/protocols/qq/utils.c @ 23051:190bc4ecf6c3

patch-03-add-qq_hex_dump
author SHiNE CsyFeK <csyfek@gmail.com>
date Tue, 24 Jun 2008 12:09:16 +0000
parents 44b4e8bd759b
children 51dbe83ebbd3
comparison
equal deleted inserted replaced
23050:9a5d140400f1 23051:190bc4ecf6c3
292 return g_memdup(bytes, *out_len); 292 return g_memdup(bytes, *out_len);
293 } 293 }
294 294
295 /* Dumps a chunk of raw data into an ASCII hex string. 295 /* Dumps a chunk of raw data into an ASCII hex string.
296 * The return should be freed later. */ 296 * The return should be freed later. */
297 gchar *hex_dump_to_str(const guint8 *const buffer, gint bytes) 297 static gchar *hex_dump_to_str(const guint8 *const buffer, gint bytes)
298 { 298 {
299 GString *str; 299 GString *str;
300 gchar *ret; 300 gchar *ret;
301 gint i, j, ch; 301 gint i, j, ch;
302 302
329 g_string_free(str, FALSE); 329 g_string_free(str, FALSE);
330 330
331 return ret; 331 return ret;
332 } 332 }
333 333
334 void qq_hex_dump(PurpleDebugLevel level, const char *category,
335 const guint8 *pdata, gint bytes,
336 const char *format, ...)
337 {
338 va_list args;
339 char *arg_s = NULL;
340 gchar *phex = NULL;
341
342 g_return_if_fail(level != PURPLE_DEBUG_ALL);
343 g_return_if_fail(format != NULL);
344
345 va_start(args, format);
346 arg_s = g_strdup_vprintf(format, args);
347 va_end(args);
348
349 if (bytes <= 0) {
350 purple_debug(level, category, arg_s);
351 return;
352 }
353
354 phex = hex_dump_to_str(pdata, bytes);
355 purple_debug(level, category, "%s - (len %d)\n%s", arg_s, bytes, phex);
356 g_free(phex);
357 }
358
334 /* convert face num from packet (0-299) to local face (1-100) */ 359 /* convert face num from packet (0-299) to local face (1-100) */
335 gchar *face_to_icon_str(gint face) 360 gchar *face_to_icon_str(gint face)
336 { 361 {
337 gchar *icon_num_str; 362 gchar *icon_num_str;
338 gint icon_num = face / 3 + 1; 363 gint icon_num = face / 3 + 1;