diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2010-04-10 11:56:11 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-04-10 11:56:11 +0200 |
commit | a9c204effa724ff31937e526f1050eadca6a9beb (patch) | |
tree | 8cae6a4f8823f7d8bcb9a83bb9e6f16b9a435502 /gatchat/gatutil.c | |
parent | 4c76be6c0dd6c96d64a2b26f1e959320456e6113 (diff) | |
download | ofono-a9c204effa724ff31937e526f1050eadca6a9beb.tar.bz2 |
Add utility helper for debugging binary blobs
Diffstat (limited to 'gatchat/gatutil.c')
-rw-r--r-- | gatchat/gatutil.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gatchat/gatutil.c b/gatchat/gatutil.c index 575019d6..1306c616 100644 --- a/gatchat/gatutil.c +++ b/gatchat/gatutil.c @@ -109,6 +109,29 @@ void g_at_util_debug_chat(gboolean in, const char *str, gsize len, g_free(escaped_str); } +void g_at_util_debug_dump(gboolean in, const unsigned char *buf, gsize len, + GAtDebugFunc debugf, gpointer user_data) +{ + char type = in ? '<' : '>'; + GString *str; + gsize i; + + if (!debugf || !len) + return; + + str = g_string_sized_new(1 + (len * 2)); + if (!str) + return; + + g_string_append_c(str, type); + + for (i = 0; i < len; i++) + g_string_append_printf(str, " %02x", buf[i]); + + debugf(str->str, user_data); + g_string_free(str, TRUE); +} + gboolean g_at_util_setup_io(GIOChannel *io, GIOFlags flags) { GIOFlags io_flags; |