diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-09-24 16:15:09 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-09-26 09:25:05 +0200 |
commit | 27ce79a38bfd9e28a262769ced8e970bfb631b1f (patch) | |
tree | 2a3eda9aded5a1e6bcb5bb8bed0dd259f58174dd | |
parent | f88c6029d0f9504e2d88b95d25f1bae7bccbdf9f (diff) | |
download | external_libqmi-27ce79a38bfd9e28a262769ced8e970bfb631b1f.zip external_libqmi-27ce79a38bfd9e28a262769ced8e970bfb631b1f.tar.gz external_libqmi-27ce79a38bfd9e28a262769ced8e970bfb631b1f.tar.bz2 |
message: swapped buffer/length variables in `qmi_message_get_tlv_printable()'
-rw-r--r-- | build-aux/qmi-codegen/Message.py | 4 | ||||
-rw-r--r-- | libqmi-glib/qmi-message.c | 31 | ||||
-rw-r--r-- | libqmi-glib/qmi-message.h | 4 |
3 files changed, 29 insertions, 10 deletions
diff --git a/build-aux/qmi-codegen/Message.py b/build-aux/qmi-codegen/Message.py index 5e23f08..d90b13c 100644 --- a/build-aux/qmi-codegen/Message.py +++ b/build-aux/qmi-codegen/Message.py @@ -342,8 +342,8 @@ class Message: ' value_str = qmi_message_get_tlv_printable (ctx->self,\n' ' ctx->line_prefix,\n' ' type,\n' - ' length,\n' - ' value);\n' + ' value,\n' + ' length);\n' ' g_string_append (ctx->printable, value_str);\n' ' g_free (value_str);\n' ' } else {\n' diff --git a/libqmi-glib/qmi-message.c b/libqmi-glib/qmi-message.c index 378eccf..76cddf5 100644 --- a/libqmi-glib/qmi-message.c +++ b/libqmi-glib/qmi-message.c @@ -614,24 +614,43 @@ qmi_message_new_from_raw (const guint8 *raw, return self; } +/** + * qmi_message_get_tlv_printable: + * @self: a #QmiMessage. + * @line_prefix: prefix string to use in each new generated line. + * @type: type of the TLV. + * @raw: raw data buffer with the value of the TLV. + * @raw_length: length of the raw data buffer. + * + * Gets a printable string with the contents of the TLV. + * + * This method is the most generic one and doesn't try to translate the TLV contents. + * + * Returns: (transfer full): a newly allocated string, which should be freed with g_free(). + */ gchar * qmi_message_get_tlv_printable (QmiMessage *self, const gchar *line_prefix, guint8 type, - gsize length, - gconstpointer value) + const guint8 *raw, + gsize raw_length) { gchar *printable; gchar *value_hex; - value_hex = qmi_utils_str_hex (value, length, ':'); + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (line_prefix != NULL, NULL); + g_return_val_if_fail (raw != NULL, NULL); + g_return_val_if_fail (raw_length > 0, NULL); + + value_hex = qmi_utils_str_hex (raw, raw_length, ':'); printable = g_strdup_printf ("%sTLV:\n" "%s type = 0x%02x\n" "%s length = %" G_GSIZE_FORMAT "\n" "%s value = %s\n", line_prefix, line_prefix, type, - line_prefix, length, + line_prefix, raw_length, line_prefix, value_hex); g_free (value_hex); return printable; @@ -656,8 +675,8 @@ get_generic_printable (QmiMessage *self, printable_tlv = qmi_message_get_tlv_printable (self, line_prefix, tlv->type, - tlv->length, - tlv->value); + tlv->value, + tlv->length); g_string_append (printable, printable_tlv); g_free (printable_tlv); } diff --git a/libqmi-glib/qmi-message.h b/libqmi-glib/qmi-message.h index b60b0fd..c15ea18 100644 --- a/libqmi-glib/qmi-message.h +++ b/libqmi-glib/qmi-message.h @@ -80,8 +80,8 @@ gchar *qmi_message_get_printable (QmiMessage *self, gchar *qmi_message_get_tlv_printable (QmiMessage *self, const gchar *line_prefix, guint8 type, - gsize length, - gconstpointer value); + const guint8 *raw, + gsize raw_length); gboolean qmi_message_check (QmiMessage *self, GError **error); |