mirror of git://git.sysmocom.de/ofono
Add utility helper for debugging binary blobs
This commit is contained in:
parent
4c76be6c0d
commit
a9c204effa
|
@ -109,6 +109,29 @@ void g_at_util_debug_chat(gboolean in, const char *str, gsize len,
|
||||||
g_free(escaped_str);
|
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)
|
gboolean g_at_util_setup_io(GIOChannel *io, GIOFlags flags)
|
||||||
{
|
{
|
||||||
GIOFlags io_flags;
|
GIOFlags io_flags;
|
||||||
|
|
|
@ -22,15 +22,18 @@
|
||||||
#ifndef __GATUTIL_H
|
#ifndef __GATUTIL_H
|
||||||
#define __GATUTIL_H
|
#define __GATUTIL_H
|
||||||
|
|
||||||
|
#include "gat.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gat.h"
|
|
||||||
|
|
||||||
void g_at_util_debug_chat(gboolean in, const char *str, gsize len,
|
void g_at_util_debug_chat(gboolean in, const char *str, gsize len,
|
||||||
GAtDebugFunc debugf, gpointer user_data);
|
GAtDebugFunc debugf, gpointer user_data);
|
||||||
|
|
||||||
|
void g_at_util_debug_dump(gboolean in, const unsigned char *buf, gsize len,
|
||||||
|
GAtDebugFunc debugf, gpointer user_data);
|
||||||
|
|
||||||
gboolean g_at_util_setup_io(GIOChannel *io, GIOFlags flags);
|
gboolean g_at_util_setup_io(GIOChannel *io, GIOFlags flags);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
Loading…
Reference in New Issue