diff options
Diffstat (limited to 'src/qmicli/qmicli-helpers.c')
-rw-r--r-- | src/qmicli/qmicli-helpers.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/qmicli/qmicli-helpers.c b/src/qmicli/qmicli-helpers.c index c6911c6..32d5f49 100644 --- a/src/qmicli/qmicli-helpers.c +++ b/src/qmicli/qmicli-helpers.c @@ -389,3 +389,28 @@ qmicli_read_uint_from_string (const gchar *str, } return FALSE; } + +gchar * +qmicli_get_supported_messages_list (const guint8 *data, + gsize len) +{ + GString *str = NULL; + + if (len > 0 && data) { + guint bytearray_i; + + for (bytearray_i = 0; bytearray_i < len; bytearray_i++) { + guint bit_i; + + for (bit_i = 0; bit_i < 8; bit_i++) { + if (data[bytearray_i] & (1 << bit_i)) { + if (!str) + str = g_string_new (""); + g_string_append_printf (str, "\t0x%04X\n", (guint16) (bit_i + (8 * bytearray_i))); + } + } + } + } + + return (str ? g_string_free (str, FALSE) : g_strdup ("\tnone\n")); +} |