diff --git a/common/utils/itti_analyzer/libbuffers/buffers.c b/common/utils/itti_analyzer/libbuffers/buffers.c index 60af2b54450e416f7b825f9f5f15ca2da85ac5f6..6656c2fa43b5f184f02fe7cffbb0438d6ad6f51d 100644 --- a/common/utils/itti_analyzer/libbuffers/buffers.c +++ b/common/utils/itti_analyzer/libbuffers/buffers.c @@ -10,13 +10,6 @@ extern int debug_buffers; -buffer_list_t list = { - .head = NULL, - .tail = NULL, - .count = 0, -}; -pthread_mutex_t buffer_list_mutex = PTHREAD_MUTEX_INITIALIZER; - static int buffer_fetch(buffer_t *buffer, uint32_t offset, int size, void *value); @@ -121,8 +114,6 @@ int buffer_new_from_data(buffer_t **buffer, uint8_t *data, const uint32_t length new->buffer_current = NULL; } - new->next = NULL; - *buffer = new; return 0; @@ -196,49 +187,3 @@ int buffer_has_enouch_data(buffer_t *buffer, uint32_t offset, uint32_t to_get) offset, to_get, buffer->size_bytes); return underflow; } - -int buffer_get_from_mn(const uint32_t message_number, buffer_t **buffer) -{ - buffer_t *temp_buf; - - if (!buffer) - return RC_BAD_PARAM; - - for (temp_buf = list.head; temp_buf; temp_buf = temp_buf->next) { - if (temp_buf->message_number == message_number) { - break; - } - } - - *buffer = temp_buf; - - return RC_OK; -} - -int buffer_add_to_list(buffer_t *new_buf) -{ - if (!new_buf) - return RC_BAD_PARAM; - - pthread_mutex_lock(&buffer_list_mutex); - - /* No element at tail */ - if (list.tail == NULL) { - if (list.head == NULL) { - list.head = new_buf; - list.tail = list.head; - } else { - return RC_FAIL; - } - } else { - list.tail->next = new_buf; - new_buf->previous = list.tail; - list.tail = new_buf; - } - - list.count++; - - pthread_mutex_unlock(&buffer_list_mutex); - - return RC_OK; -} diff --git a/common/utils/itti_analyzer/libbuffers/buffers.h b/common/utils/itti_analyzer/libbuffers/buffers.h index 4bffc1543ce6c4b4acf4cc408c51c239e3ee7463..72adb546a7095782325f7ae8efa71cb032f06b4a 100644 --- a/common/utils/itti_analyzer/libbuffers/buffers.h +++ b/common/utils/itti_analyzer/libbuffers/buffers.h @@ -17,18 +17,8 @@ typedef struct buffer_s { uint32_t message_number; uint32_t message_id; - - struct buffer_s *previous; - struct buffer_s *next; } buffer_t; -typedef struct { - buffer_t *head; - buffer_t *tail; - - uint32_t count; -} buffer_list_t; - uint8_t buffer_get_uint8_t(buffer_t *buffer, uint32_t offset); uint16_t buffer_get_uint16_t(buffer_t *buffer, uint32_t offset); @@ -46,8 +36,4 @@ int buffer_new_from_data(buffer_t **buffer, uint8_t *data, const uint32_t length int buffer_has_enouch_data(buffer_t *buffer, uint32_t offset, uint32_t to_get); -int buffer_add_to_list(buffer_t *new_buf); - -int buffer_get_from_mn(const uint32_t message_number, buffer_t **buffer); - #endif /* BUFFERS_H_ */ diff --git a/common/utils/itti_analyzer/libparser/array_type.c b/common/utils/itti_analyzer/libparser/array_type.c index 139e5889df44027cd737d1baa6d6ee07e3eb717a..9d46a522dd92c190ee6ffa31e7fdf350448cfaf3 100644 --- a/common/utils/itti_analyzer/libparser/array_type.c +++ b/common/utils/itti_analyzer/libparser/array_type.c @@ -7,8 +7,10 @@ #include "fundamental_type.h" #include "ui_interface.h" -int array_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset, - int indent) { +int array_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent) +{ struct types_s *type_child; DISPLAY_PARSE_INFO("array", type->name, offset, parent_offset); @@ -47,24 +49,23 @@ int array_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t o } } for (i = 0; i < (items - zero_counter); i++) - type->child->type_dissect_from_buffer (type->child, buffer, parent_offset, offset + i * type_child->size, - type->name == NULL ? indent : indent + 4); + type->child->type_dissect_from_buffer ( + type->child, ui_set_signal_text_cb, user_data, buffer, parent_offset, + offset + i * type_child->size, type->name == NULL ? indent : indent + 4); if (zero_counter > 0) { - int length = 0; - char cbuf[50]; - char *cpy = NULL; + int length = 0; + char cbuf[50]; - INDENTED_STRING(cbuf, type->name == NULL ? indent : indent + 4,); + INDENTED_STRING(cbuf, type->name == NULL ? indent : indent + 4,); - length = sprintf(cbuf, "[%d .. %d] ", i, items -1); - cpy = malloc(sizeof(char) * length); - memcpy(cpy, cbuf, length); - ui_interface.ui_signal_set_text(cpy, length); - if (cpy) - free(cpy); + length = sprintf(cbuf, "[%d .. %d] ", i, items -1); - type->child->type_dissect_from_buffer (type->child, buffer, parent_offset, offset + i * type_child->size, 0); +// ui_interface.ui_signal_set_text(cpy, length); + ui_set_signal_text_cb(user_data, cbuf, length); + type->child->type_dissect_from_buffer ( + type->child, ui_set_signal_text_cb, user_data, + buffer, parent_offset, offset + i * type_child->size, 0); } } if (type->name) { diff --git a/common/utils/itti_analyzer/libparser/array_type.h b/common/utils/itti_analyzer/libparser/array_type.h index e21f279b32877a969358aace4912e8070f0428ea..3dd9571af600bd19c81228c0faad8ab8a21b0b13 100644 --- a/common/utils/itti_analyzer/libparser/array_type.h +++ b/common/utils/itti_analyzer/libparser/array_type.h @@ -3,8 +3,9 @@ #ifndef ARRAY_TYPE_H_ #define ARRAY_TYPE_H_ -int array_dissect_from_buffer(struct types_s *type, buffer_t *buffer, - uint32_t offset, uint32_t parent_offset, int indent); +int array_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent); int array_type_hr_display(struct types_s *type, int indent); diff --git a/common/utils/itti_analyzer/libparser/enum_type.c b/common/utils/itti_analyzer/libparser/enum_type.c index dbaca92f18adfe8e939b5a89c32c9c2baaba8660..5cc91c0ae0a825fb3cb37a679dfa0f76ddb40d17 100644 --- a/common/utils/itti_analyzer/libparser/enum_type.c +++ b/common/utils/itti_analyzer/libparser/enum_type.c @@ -22,8 +22,8 @@ char *enum_type_get_name_from_value(struct types_s *type, uint32_t value) } int enum_type_dissect_from_buffer( - struct types_s *type, buffer_t *buffer, uint32_t offset, - uint32_t parent_offset, int indent) + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent) { uint32_t value = 0; types_t *values; @@ -32,33 +32,22 @@ int enum_type_dissect_from_buffer( value = buffer_get_uint32_t(buffer, parent_offset + offset); -// if (type->name) { -// INDENTED(stdout, indent, fprintf(stdout, "<%s>\n", type->name)); -// } for (values = type->child; values; values = values->next) { if (value == values->init_value) { values->type_dissect_from_buffer( - values, buffer, offset, parent_offset, + values, ui_set_signal_text_cb, user_data, buffer, offset, parent_offset, type->name == NULL ? indent: indent+4); break; } } if (values == NULL) { -// INDENTED(stdout, indent+4, fprintf(stdout, "<UNKNOWN/>\n")); int length = 0; char cbuf[50]; - char *cpy = NULL; length = sprintf(cbuf, "(0x%08x) UNKNOWN;\n", value); - cpy = malloc(sizeof(char) * length); - memcpy(cpy, cbuf, length); - ui_interface.ui_signal_set_text(cpy, length); - if (cpy) - free(cpy); + + ui_set_signal_text_cb(user_data, cbuf, length); } -// if (type->name) { -// INDENTED(stdout, indent, fprintf(stdout, "</%s>\n", type->name)); -// } return 0; } diff --git a/common/utils/itti_analyzer/libparser/enum_type.h b/common/utils/itti_analyzer/libparser/enum_type.h index 1c153a0ccb99c7674a16668f9521ecc6daa83d11..27501ffa45c75306baf9170404c18827386bac80 100644 --- a/common/utils/itti_analyzer/libparser/enum_type.h +++ b/common/utils/itti_analyzer/libparser/enum_type.h @@ -6,8 +6,8 @@ char *enum_type_get_name_from_value(struct types_s *type, uint32_t value); int enum_type_dissect_from_buffer( - struct types_s *type, buffer_t *buffer, uint32_t offset, - uint32_t parent_offset, int indent); + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent); int enum_type_file_print(struct types_s *type, int indent, FILE *file); diff --git a/common/utils/itti_analyzer/libparser/enum_value_type.c b/common/utils/itti_analyzer/libparser/enum_value_type.c index e4f0a38f643f0e8f792212b22d9ded7531e84173..752d9654dc1c06379d5d888799d52d6f9ca25037 100644 --- a/common/utils/itti_analyzer/libparser/enum_value_type.c +++ b/common/utils/itti_analyzer/libparser/enum_value_type.c @@ -7,8 +7,8 @@ #include "ui_interface.h" int enum_value_dissect_from_buffer( - struct types_s *type, buffer_t *buffer, uint32_t offset, - uint32_t parent_offset, int indent) + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent) { uint32_t value = 0; @@ -18,15 +18,11 @@ int enum_value_dissect_from_buffer( if (type->name) { int length = 0; char cbuf[50 + strlen(type->name)]; - char *cpy = NULL; sprintf(cbuf, "(0x%08x) %s;\n", value, type->name); length = strlen(cbuf); - cpy = malloc(sizeof(char) * length); - memcpy(cpy, cbuf, length); - ui_interface.ui_signal_set_text(cpy, length); - if (cpy) - free(cpy); + + ui_set_signal_text_cb(user_data, cbuf, length); } return 0; diff --git a/common/utils/itti_analyzer/libparser/enum_value_type.h b/common/utils/itti_analyzer/libparser/enum_value_type.h index 3aad409edb8a7bff4f2c4cba1f48cac143f4bef8..0bfb7d821baddb9a1ecae07aea54ed6e2fe3b572 100644 --- a/common/utils/itti_analyzer/libparser/enum_value_type.h +++ b/common/utils/itti_analyzer/libparser/enum_value_type.h @@ -4,8 +4,8 @@ #define ENUM_VALUE_TYPE_H_ int enum_value_dissect_from_buffer( - struct types_s *type, buffer_t *buffer, uint32_t offset, - uint32_t parent_offset, int indent); + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent); int enum_value_file_print(struct types_s *type, int indent, FILE *file); diff --git a/common/utils/itti_analyzer/libparser/field_type.c b/common/utils/itti_analyzer/libparser/field_type.c index a8cc5a0ebb9ac5b166328366444ca90391b83fc5..348c26a5fecf3a4f230963060d6f3ec76ad37a1b 100644 --- a/common/utils/itti_analyzer/libparser/field_type.c +++ b/common/utils/itti_analyzer/libparser/field_type.c @@ -9,11 +9,12 @@ #include "buffers.h" #include "ui_interface.h" -int field_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset, - int indent) { +int field_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent) +{ int length = 0; char cbuf[50]; - char *cpy = NULL; struct types_s *type_child; char array_info[50]; int indent_child; @@ -47,34 +48,30 @@ int field_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t o DISPLAY_TYPE("Fld"); INDENTED_STRING(cbuf, indent, sprintf(cbuf, ".%s%s = ", type->name ? type->name : "Field", array_info)); length = strlen (cbuf); - cpy = malloc (sizeof(char) * length); - memcpy (cpy, cbuf, length); - ui_interface.ui_signal_set_text (cpy, length); - if (cpy) - free (cpy); + + ui_set_signal_text_cb(user_data, cbuf, length); indent_child = indent; if (type_child->type == TYPE_ARRAY || type_child->type == TYPE_STRUCT || type_child->type == TYPE_UNION) { - DISPLAY_BRACE(ui_interface.ui_signal_set_text ("{", 1);) - ui_interface.ui_signal_set_text ("\n", 1); + DISPLAY_BRACE(ui_set_signal_text_cb(user_data, "{", 1);) + ui_set_signal_text_cb(user_data, "\n", 1); indent_child += 4; } if (type_child->type == TYPE_FUNDAMENTAL || type_child->type == TYPE_POINTER) { indent_child = 0; } - CHECK_FCT( - type->child->type_dissect_from_buffer( type->child, buffer, parent_offset, offset + type->offset, indent_child)); + CHECK_FCT(type->child->type_dissect_from_buffer( + type->child, ui_set_signal_text_cb, user_data, buffer, + parent_offset, offset + type->offset, indent_child)); DISPLAY_BRACE( if (type_child->type == TYPE_ARRAY || type_child->type == TYPE_STRUCT || type_child->type == TYPE_UNION) { DISPLAY_TYPE("Fld"); INDENTED_STRING(cbuf, indent, sprintf(cbuf, "};\n")); length = strlen (cbuf); - cpy = malloc (sizeof(char) * length); memcpy (cpy, cbuf, length); - ui_interface.ui_signal_set_text (cpy, length); - if (cpy) - free (cpy); + + ui_set_signal_text_cb(user_data, cbuf, length); }); } } @@ -90,11 +87,8 @@ int field_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t o indent, sprintf(cbuf, ".%s:%d = (0x%0*x) %d;\n", type->name ? type->name : "Field", type->bits, (type->bits + 3) / 4, value, value)); length = strlen (cbuf); - cpy = malloc (sizeof(char) * length); - memcpy (cpy, cbuf, length); - ui_interface.ui_signal_set_text (cpy, length); - if (cpy) - free (cpy); + + ui_set_signal_text_cb(user_data, cbuf, length); } return 0; diff --git a/common/utils/itti_analyzer/libparser/field_type.h b/common/utils/itti_analyzer/libparser/field_type.h index dcbbc8c2060b83786036009cc6ef886a640d1375..bf23cb8dc257bc12ea5f7372a3c1db8c557e1b55 100644 --- a/common/utils/itti_analyzer/libparser/field_type.h +++ b/common/utils/itti_analyzer/libparser/field_type.h @@ -3,8 +3,9 @@ #ifndef FIELD_TYPE_H_ #define FIELD_TYPE_H_ -int field_dissect_from_buffer(struct types_s *type, buffer_t *buffer, - uint32_t offset, uint32_t parent_offset, int indent); +int field_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent); int field_type_file_print(struct types_s *type, int indent, FILE *file); diff --git a/common/utils/itti_analyzer/libparser/fundamental_type.c b/common/utils/itti_analyzer/libparser/fundamental_type.c index 8442fa0eaa4c9d0940a4634ffeac407a7b1c1e25..3a4388ccdce6b7d5846f068328cda2bfb504a368 100644 --- a/common/utils/itti_analyzer/libparser/fundamental_type.c +++ b/common/utils/itti_analyzer/libparser/fundamental_type.c @@ -30,13 +30,14 @@ uint32_t fundamental_read_from_buffer(struct types_s *type, buffer_t *buffer, ui return value; } -int fundamental_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset, - int indent) { - int length = 0; - char cbuf[200]; - char *cpy = NULL; - int type_unsigned; - uint32_t value; +int fundamental_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent) +{ + int length = 0; + char cbuf[200]; + int type_unsigned; + uint32_t value; DISPLAY_PARSE_INFO("fundamental", type->name, offset, parent_offset); @@ -72,12 +73,8 @@ int fundamental_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint } length = strlen (cbuf); - cpy = malloc (length * sizeof(char)); - memcpy (cpy, cbuf, length); - ui_interface.ui_signal_set_text (cpy, length); - if (cpy) - free (cpy); + ui_set_signal_text_cb(user_data, cbuf, length); return 0; } diff --git a/common/utils/itti_analyzer/libparser/fundamental_type.h b/common/utils/itti_analyzer/libparser/fundamental_type.h index 710ce6dad8686876618519b4ac3851ae711d89fe..956788a8d2eb87937fe6501de2f111bca668be31 100644 --- a/common/utils/itti_analyzer/libparser/fundamental_type.h +++ b/common/utils/itti_analyzer/libparser/fundamental_type.h @@ -5,8 +5,9 @@ uint32_t fundamental_read_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset); -int fundamental_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset, - int indent); +int fundamental_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent); int fundamental_type_file_print(struct types_s *type, int indent, FILE *file); diff --git a/common/utils/itti_analyzer/libparser/pointer_type.c b/common/utils/itti_analyzer/libparser/pointer_type.c index 27b695b7f43fb49f8ddc0dbe9abd7e7495f3ce98..eaeff5b4c06916ca6b0a5cc7aa0b3548079f1a63 100644 --- a/common/utils/itti_analyzer/libparser/pointer_type.c +++ b/common/utils/itti_analyzer/libparser/pointer_type.c @@ -6,20 +6,18 @@ #include "pointer_type.h" #include "ui_interface.h" -int pointer_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset, - int indent) { - int length = 0; - char cbuf[200]; - char *cpy = NULL; +int pointer_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent) +{ + int length = 0; + char cbuf[200]; + uint32_t value; DISPLAY_PARSE_INFO("pointer", type->name, offset, parent_offset); memset (cbuf, 0, 200); -// int i; -// CHECK_FCT(buffer_has_enouch_data(buffer, offset, type->size / 8)); - uint32_t value; - value = buffer_get_uint32_t (buffer, parent_offset + offset); DISPLAY_TYPE("Ptr"); @@ -39,12 +37,8 @@ int pointer_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t } length = strlen (cbuf); - cpy = malloc (length * sizeof(char)); - memcpy (cpy, cbuf, length); - ui_interface.ui_signal_set_text (cpy, length); - if (cpy) - free (cpy); + ui_set_signal_text_cb(user_data, cbuf, length); return 0; } diff --git a/common/utils/itti_analyzer/libparser/pointer_type.h b/common/utils/itti_analyzer/libparser/pointer_type.h index b0d76f981f7c425214f34f9e87d6b6489cbaaa94..6f82f42c6b9e03df2d507ea1c789e5195f8a4f8a 100644 --- a/common/utils/itti_analyzer/libparser/pointer_type.h +++ b/common/utils/itti_analyzer/libparser/pointer_type.h @@ -3,8 +3,9 @@ #ifndef POINTER_TYPE_H_ #define POINTER_TYPE_H_ -int pointer_dissect_from_buffer(struct types_s *type, buffer_t *buffer, - uint32_t offset, uint32_t parent_offset, int indent); +int pointer_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent); int pointer_type_file_print(struct types_s *type, int indent, FILE *file); diff --git a/common/utils/itti_analyzer/libparser/reference_type.c b/common/utils/itti_analyzer/libparser/reference_type.c index 82e32572273a68a81afa8c8c7f6123eb54dec065..dc485b1c9ffed0378726769751f0b4eddc57d31b 100644 --- a/common/utils/itti_analyzer/libparser/reference_type.c +++ b/common/utils/itti_analyzer/libparser/reference_type.c @@ -6,8 +6,9 @@ #include "reference_type.h" #include "ui_interface.h" -int reference_dissect_from_buffer(struct types_s *type, buffer_t *buffer, - uint32_t offset, uint32_t parent_offset, int indent) +int reference_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent) { DISPLAY_PARSE_INFO("reference", type->name, offset, parent_offset); @@ -15,7 +16,8 @@ int reference_dissect_from_buffer(struct types_s *type, buffer_t *buffer, INDENTED(stdout, indent, fprintf(stdout, "<%s>\n", type->name)); } if (type->child != NULL) - type->child->type_dissect_from_buffer(type->child, buffer, offset, parent_offset, + type->child->type_dissect_from_buffer(type->child, ui_set_signal_text_cb, + user_data, buffer, offset, parent_offset, type->name == NULL ? indent: indent+4); if (type->name) { INDENTED(stdout, indent, fprintf(stdout, "</%s>\n", type->name)); diff --git a/common/utils/itti_analyzer/libparser/reference_type.h b/common/utils/itti_analyzer/libparser/reference_type.h index 245bd024f60b4c2aaace9e9f7df24e17b12d7e7a..3c52088d8f798b6ee7d81f10ecbc45eaff03bdc3 100644 --- a/common/utils/itti_analyzer/libparser/reference_type.h +++ b/common/utils/itti_analyzer/libparser/reference_type.h @@ -3,8 +3,9 @@ #ifndef REFERENCE_TYPE_H_ #define REFERENCE_TYPE_H_ -int reference_dissect_from_buffer(struct types_s *type, buffer_t *buffer, - uint32_t offset, uint32_t parent_offset, int indent); +int reference_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent); int reference_type_file_print(struct types_s *type, int indent, FILE *file); diff --git a/common/utils/itti_analyzer/libparser/struct_type.c b/common/utils/itti_analyzer/libparser/struct_type.c index 03d436ce1e675f3155b1708ccfd28e6a65ac7602..5ded6d914ca5a18c10f598279dc2e75ea4523e71 100644 --- a/common/utils/itti_analyzer/libparser/struct_type.c +++ b/common/utils/itti_analyzer/libparser/struct_type.c @@ -9,12 +9,13 @@ #include "buffers.h" #include "ui_interface.h" -int struct_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset, - int indent) { +int struct_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent) +{ int i; int length = 0; char cbuf[200]; - char *cpy = NULL; DISPLAY_PARSE_INFO("structure", type->name, offset, parent_offset); @@ -26,17 +27,15 @@ int struct_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t } length = strlen (cbuf); - cpy = malloc (length * sizeof(char)); - memcpy (cpy, cbuf, length); - ui_interface.ui_signal_set_text (cpy, length); - if (cpy) - free (cpy); + ui_set_signal_text_cb(user_data, cbuf, length); for (i = 0; i < type->nb_members; i++) { if (type->members_child[i] != NULL) - type->members_child[i]->type_dissect_from_buffer (type->members_child[i], buffer, offset, parent_offset, - type->name == NULL ? indent : indent + 4); + type->members_child[i]->type_dissect_from_buffer ( + type->members_child[i], ui_set_signal_text_cb, user_data, + buffer, offset, parent_offset, + type->name == NULL ? indent : indent + 4); } DISPLAY_BRACE( @@ -45,11 +44,8 @@ int struct_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t INDENTED_STRING(cbuf, indent, sprintf(cbuf, "};\n")); } length = strlen (cbuf); - cpy = malloc (length * sizeof(char)); - memcpy (cpy, cbuf, length); - ui_interface.ui_signal_set_text (cpy, length); - if (cpy) - free (cpy);) + + ui_set_signal_text_cb(user_data, cbuf, length);) return 0; } diff --git a/common/utils/itti_analyzer/libparser/struct_type.h b/common/utils/itti_analyzer/libparser/struct_type.h index c808ef29d07c224f79459c7ae45877b588484905..d785141e903da3b77123989d18b4016bef9c5d1f 100644 --- a/common/utils/itti_analyzer/libparser/struct_type.h +++ b/common/utils/itti_analyzer/libparser/struct_type.h @@ -3,8 +3,9 @@ #ifndef STRUCT_TYPE_H_ #define STRUCT_TYPE_H_ -int struct_dissect_from_buffer(struct types_s *type, buffer_t *buffer, - uint32_t offset, uint32_t parent_offset, int indent); +int struct_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent); int struct_type_hr_display(struct types_s *type, int indent); diff --git a/common/utils/itti_analyzer/libparser/typedef_type.c b/common/utils/itti_analyzer/libparser/typedef_type.c index 7cccda453ce09f73938ed0c9db22d19298ba0e9e..ce5f0f9313475df6d4e03a147eb623dfb29ec24b 100644 --- a/common/utils/itti_analyzer/libparser/typedef_type.c +++ b/common/utils/itti_analyzer/libparser/typedef_type.c @@ -6,15 +6,16 @@ #include "typedef_type.h" #include "ui_interface.h" -int typedef_dissect_from_buffer(struct types_s *type, buffer_t *buffer, - uint32_t offset, uint32_t parent_offset, int indent) +int typedef_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent) { DISPLAY_PARSE_INFO("typedef", type->name, offset, parent_offset); /* Simply call next_type */ if (type->child != NULL) { type->child->type_dissect_from_buffer( - type->child, buffer, offset, parent_offset, indent); + type->child, ui_set_signal_text_cb, user_data, buffer, offset, parent_offset, indent); } return 0; diff --git a/common/utils/itti_analyzer/libparser/typedef_type.h b/common/utils/itti_analyzer/libparser/typedef_type.h index f9f384cce56c8534b7800f6aa69a431a3f2a274a..e0f96f501b246777a7dfe8bbc354614fb3315192 100644 --- a/common/utils/itti_analyzer/libparser/typedef_type.h +++ b/common/utils/itti_analyzer/libparser/typedef_type.h @@ -7,7 +7,8 @@ int typedef_type_file_print(struct types_s *type, int indent, FILE *file); int typedef_type_hr_display(struct types_s *type, int indent); -int typedef_dissect_from_buffer(struct types_s *type, buffer_t *buffer, - uint32_t offset, uint32_t parent_offset, int indent); +int typedef_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent); #endif /* TYPEDEF_TYPE_H_ */ diff --git a/common/utils/itti_analyzer/libparser/types.h b/common/utils/itti_analyzer/libparser/types.h index 1f8333222bcf57f19c9ff3835e76b69098e6a436..adb32fc9c4ee9abb99f84fcc9f26dd39f639e9f0 100644 --- a/common/utils/itti_analyzer/libparser/types.h +++ b/common/utils/itti_analyzer/libparser/types.h @@ -1,6 +1,7 @@ #include <stdio.h> #include "buffers.h" +#include "ui_interface.h" #ifndef TYPES_H_ #define TYPES_H_ @@ -15,17 +16,17 @@ #define ENABLE_DISPLAY_BRACE 0 #if (ENABLE_DISPLAY_TYPE != 0) -# define DISPLAY_TYPE(tYPE) ui_interface.ui_signal_set_text(tYPE, strlen(tYPE)); +# define DISPLAY_TYPE(tYPE) ui_set_signal_text_cb(user_data, tYPE, strlen(tYPE)); #else # define DISPLAY_TYPE(tYPE) #endif #if (ENABLE_DISPLAY_PARSE_INFO != 0) -# define DISPLAY_PARSE_INFO(tYPE, nAME, oFFSET, pARENToFFSET) \ - { \ - char buf[200]; \ +# define DISPLAY_PARSE_INFO(tYPE, nAME, oFFSET, pARENToFFSET) \ + { \ + char buf[200]; \ sprintf(buf, "/* %s \"%s\" %d %d */\n", tYPE, nAME, oFFSET, pARENToFFSET); \ - ui_interface.ui_signal_set_text(buf, strlen(buf)); \ + ui_set_signal_text_cb(user_data, buf, strlen(buf)); \ } #else # define DISPLAY_PARSE_INFO(tYPE, nAME, oFFSET, pARENToFFSET) @@ -63,12 +64,15 @@ typedef int (*type_file_print_t)(struct types_s *type, int indent, FILE *file); /** * type_dissect_from_buffer_t * @param type The current type + * @param ui_set_signal_text_cb GUI display function + * @param user_data Transparent data to pass to the GUI display function * @param buffer The buffer containing data to dissect * @param offset offset of field from the beginning of the parent * @param parent_offset offset of the parent from begining **/ -typedef int (*type_dissect_from_buffer_t)(struct types_s *type, buffer_t *buffer, - uint32_t offset, uint32_t parent_offset, int indent); +typedef int (*type_dissect_from_buffer_t)( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent); typedef struct types_s { /* The type of the current description */ @@ -152,7 +156,7 @@ do { \ #define INDENTED_STRING(sTR, x, y) \ do { \ int indentation = x; \ - while(indentation--) ui_interface.ui_signal_set_text(" ", 1); \ + while(indentation--) ui_set_signal_text_cb(user_data, " ", 1); \ y; \ } while(0) diff --git a/common/utils/itti_analyzer/libparser/union_type.c b/common/utils/itti_analyzer/libparser/union_type.c index d62a438f42d3c91b7539aefee7465bc8b07ff119..6976bf1bedf465e9cb5c5606adf34b1f802dd60b 100644 --- a/common/utils/itti_analyzer/libparser/union_type.c +++ b/common/utils/itti_analyzer/libparser/union_type.c @@ -10,8 +10,10 @@ #include "ui_interface.h" /* There is only one special case of union which is associated to an index: the message id */ -int union_msg_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset, - int indent) { +int union_msg_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent) +{ uint32_t message_id; DISPLAY_PARSE_INFO("union_msg", type->name, offset, parent_offset); @@ -19,17 +21,19 @@ int union_msg_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32 CHECK_FCT(get_message_id(type->head, buffer, &message_id)); if (type->members_child[message_id] != NULL) - type->members_child[message_id]->type_dissect_from_buffer (type->members_child[message_id], buffer, offset, - parent_offset, indent); + type->members_child[message_id]->type_dissect_from_buffer( + type->members_child[message_id], ui_set_signal_text_cb, user_data, + buffer, offset, parent_offset, indent); return RC_OK; } -int union_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset, - int indent) { +int union_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent) +{ int length = 0; char cbuf[200]; - char *cpy = NULL; DISPLAY_PARSE_INFO("union", type->name, offset, parent_offset); @@ -44,31 +48,23 @@ int union_dissect_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t o } length = strlen (cbuf); - cpy = malloc (length * sizeof(char)); - memcpy (cpy, cbuf, length); - ui_interface.ui_signal_set_text (cpy, length); - if (cpy) - free (cpy); + ui_set_signal_text_cb(user_data, cbuf, length); /* Only dissect the first field present in unions */ if (type->members_child[0] != NULL) - type->members_child[0]->type_dissect_from_buffer (type->members_child[0], buffer, offset, parent_offset, - type->name == NULL ? indent : indent + 4); + type->members_child[0]->type_dissect_from_buffer( + type->members_child[0], ui_set_signal_text_cb, user_data, buffer, + offset, parent_offset, type->name == NULL ? indent : indent + 4); if (type->name) { -// INDENTED(stdout, indent, fprintf(stdout, "</%s>\n", type->name)); DISPLAY_TYPE("Uni"); INDENTED_STRING(cbuf, indent, sprintf(cbuf, "};\n")); } length = strlen (cbuf); - cpy = malloc (length * sizeof(char)); - memcpy (cpy, cbuf, length); - ui_interface.ui_signal_set_text (cpy, length); - if (cpy) - free (cpy); + ui_set_signal_text_cb(user_data, cbuf, length); return 0; } diff --git a/common/utils/itti_analyzer/libparser/union_type.h b/common/utils/itti_analyzer/libparser/union_type.h index f29a2098c6a1c5d2cc533d164d771b18033f3372..0df3fba3c0d128aab54fb431876671dc51c514fc 100644 --- a/common/utils/itti_analyzer/libparser/union_type.h +++ b/common/utils/itti_analyzer/libparser/union_type.h @@ -3,11 +3,13 @@ #ifndef UNION_TYPE_H_ #define UNION_TYPE_H_ -int union_msg_dissect_from_buffer(struct types_s *type, buffer_t *buffer, - uint32_t offset, uint32_t parent_offset, int indent); +int union_msg_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent); -int union_dissect_from_buffer(struct types_s *type, buffer_t *buffer, - uint32_t offset, uint32_t parent_offset, int indent); +int union_dissect_from_buffer( + struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, + buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent); int union_type_file_print(struct types_s *type, int indent, FILE *file); diff --git a/common/utils/itti_analyzer/libparser/xml_parse.c b/common/utils/itti_analyzer/libparser/xml_parse.c index 2ec4b8ece74dc918f9b2bfa237474cc332d9f1cf..b048d10bc357db0215178de5d53320a04a0a71cf 100644 --- a/common/utils/itti_analyzer/libparser/xml_parse.c +++ b/common/utils/itti_analyzer/libparser/xml_parse.c @@ -729,22 +729,21 @@ static int xml_parse_doc(xmlDocPtr doc) { return ret; } -int dissect_signal(buffer_t *buffer) { -// buffer_t *buffer; - +int dissect_signal(buffer_t *buffer, ui_set_signal_text_cb_t ui_set_signal_text_cb, + gpointer user_data) +{ if (root == NULL) { // ui_notification_dialog(DIALOG_ERROR, "No message XML file provided"); return RC_FAIL; } -// CHECK_FCT(buffer_get_from_mn(message_number, &buffer)); - if (buffer == NULL) { g_error("Failed buffer is NULL\n"); return RC_FAIL; } - root->type_dissect_from_buffer(root, buffer, 0, 0, INDENT_START); + root->type_dissect_from_buffer(root, ui_set_signal_text_cb, user_data, + buffer, 0, 0, INDENT_START); return RC_OK; } diff --git a/common/utils/itti_analyzer/libparser/xml_parse.h b/common/utils/itti_analyzer/libparser/xml_parse.h index 5bc56dd9aaf933d9a6a0d8200828764857f5172d..6ae00c55f90f06eec93b5a2a0b625c5fd8a02c29 100644 --- a/common/utils/itti_analyzer/libparser/xml_parse.h +++ b/common/utils/itti_analyzer/libparser/xml_parse.h @@ -10,6 +10,7 @@ int xml_parse_file(const char *filename); int xml_parse_buffer(const char *xml_buffer, const int size); -int dissect_signal(buffer_t *buffer); +int dissect_signal(buffer_t *buffer, ui_set_signal_text_cb_t ui_set_signal_text_cb, + gpointer user_data); #endif /* XML_PARSE_H_ */ diff --git a/common/utils/itti_analyzer/libresolver/Makefile.am b/common/utils/itti_analyzer/libresolver/Makefile.am index 5911c3c4df57059a4cf8245c5175b718e8fe3200..875fc819166b1cc4e3fac4bf8ce359eb4139aaf1 100644 --- a/common/utils/itti_analyzer/libresolver/Makefile.am +++ b/common/utils/itti_analyzer/libresolver/Makefile.am @@ -2,6 +2,7 @@ AM_CFLAGS = \ @ADD_CFLAGS@ \ -I$(top_srcdir)/common \ -I$(top_srcdir)/libparser \ + -I$(top_srcdir)/libui \ -I$(top_srcdir)/libbuffers noinst_LTLIBRARIES = libresolver.la diff --git a/common/utils/itti_analyzer/libui/ui_callbacks.c b/common/utils/itti_analyzer/libui/ui_callbacks.c index 902ee8903b13febe4010570ae11d2746a7bd1d8a..4b1fc42505dc3a354c08978215557be9a54ded0a 100644 --- a/common/utils/itti_analyzer/libui/ui_callbacks.c +++ b/common/utils/itti_analyzer/libui/ui_callbacks.c @@ -43,13 +43,18 @@ ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, - gpointer userdata) + gpointer user_data) { + ui_text_view_t *text_view; GtkTreeIter iter; + text_view = (ui_text_view_t *)user_data; + + g_assert(text_view != NULL); + if (gtk_tree_model_get_iter(model, &iter, path)) { - gchar *name; +// gchar *name; GValue buffer_store = G_VALUE_INIT; gpointer buffer; @@ -64,15 +69,17 @@ ui_callback_on_select_signal(GtkTreeSelection *selection, if (!path_currently_selected) { /* Clear the view */ - CHECK_FCT_DO(ui_signal_dissect_clear_view(), return FALSE); - CHECK_FCT_DO(dissect_signal((buffer_t*)buffer), return FALSE); - } - else - { - g_debug("%s is going to be unselected", name); - } + CHECK_FCT_DO(ui_signal_dissect_clear_view(text_view), return FALSE); - g_free(name); + /* Dissect the signal */ + CHECK_FCT_DO(dissect_signal((buffer_t*)buffer, ui_signal_set_text, text_view), return FALSE); + } +// else +// { +// g_debug("%s is going to be unselected", name); +// } +// +// g_free(name); } return TRUE; } @@ -92,7 +99,7 @@ void ui_signal_add_to_list(gpointer data, gpointer user_data) data); } -static gboolean ui_handle_update_signal_list(gint fd, const void *data, +static gboolean ui_handle_update_signal_list(gint fd, void *data, size_t data_length) { pipe_new_signals_list_message_t *signal_list_message; @@ -145,7 +152,7 @@ static gboolean ui_handle_socket_connection_lost(gint fd) return TRUE; } -static gboolean ui_handle_socket_xml_definition(gint fd, const void *data, +static gboolean ui_handle_socket_xml_definition(gint fd, void *data, size_t data_length) { pipe_xml_definition_message_t *xml_definition_message; diff --git a/common/utils/itti_analyzer/libui/ui_interface.c b/common/utils/itti_analyzer/libui/ui_interface.c index 78b73d8fd3dceb8df1e8111f2767fb4a68e31138..56a0e92c57b033b4a98a9a03a2f2fe2c511cfac4 100644 --- a/common/utils/itti_analyzer/libui/ui_interface.c +++ b/common/utils/itti_analyzer/libui/ui_interface.c @@ -13,11 +13,6 @@ #include "socket.h" #include "xml_parse.h" -ui_interface_t ui_interface = { - - .ui_signal_set_text = ui_signal_set_text, -}; - static gboolean ui_callback_on_pipe_notification( GIOChannel *source, GIOCondition condition, gpointer user_data) diff --git a/common/utils/itti_analyzer/libui/ui_interface.h b/common/utils/itti_analyzer/libui/ui_interface.h index bed9c63c50d3dd4a2bb8bfa97fbac2c5eca3a212..922bd89554cc06e8607750a5663739ba72b7941c 100644 --- a/common/utils/itti_analyzer/libui/ui_interface.h +++ b/common/utils/itti_analyzer/libui/ui_interface.h @@ -3,15 +3,11 @@ #ifndef UI_INTERFACE_H_ #define UI_INTERFACE_H_ -typedef int (*ui_signal_set_text_t)(char *text, int length); - -typedef struct { - - /** core program -> UI */ - ui_signal_set_text_t ui_signal_set_text; -} ui_interface_t; +/******************************************************************************* + * Functions used between dissectors and GUI to update signal dissection + ******************************************************************************/ -extern ui_interface_t ui_interface; +typedef gboolean (*ui_set_signal_text_cb_t) (gpointer user_data, gchar *text, gint length); /******************************************************************************* * Pipe interface between GUI thread and other thread diff --git a/common/utils/itti_analyzer/libui/ui_main_screen.h b/common/utils/itti_analyzer/libui/ui_main_screen.h index ff99dda0f75df31ca5358bec1b8863bb624e7b95..370326f39dfb34c5162503b2715fbba2aae4caf9 100644 --- a/common/utils/itti_analyzer/libui/ui_main_screen.h +++ b/common/utils/itti_analyzer/libui/ui_main_screen.h @@ -1,3 +1,5 @@ +#include "ui_signal_dissect_view.h" + #ifndef UI_MAIN_SCREEN_H_ #define UI_MAIN_SCREEN_H_ @@ -6,9 +8,9 @@ typedef struct { GtkWidget *ipentry; GtkWidget *portentry; - GtkWidget *progressbar; - GtkWidget *signalslist; - GtkWidget *textview; + GtkWidget *progressbar; + GtkWidget *signalslist; + ui_text_view_t *text_view; /* Buttons */ GtkToolItem *connect; diff --git a/common/utils/itti_analyzer/libui/ui_signal_dissect_view.c b/common/utils/itti_analyzer/libui/ui_signal_dissect_view.c index 54bc91a5d59ab0d66699f5691a6dc7b1f8e7a207..c182e42b46ef2213338160a2639eb60868b4046f 100644 --- a/common/utils/itti_analyzer/libui/ui_signal_dissect_view.c +++ b/common/utils/itti_analyzer/libui/ui_signal_dissect_view.c @@ -8,67 +8,74 @@ #include "ui_menu_bar.h" #include "ui_signal_dissect_view.h" -int ui_signal_dissect_new(GtkWidget *hbox) +ui_text_view_t *ui_signal_dissect_new(GtkWidget *hbox) { GtkWidget *scrolled_window; + ui_text_view_t *new_text_view; - ui_main_data.textview = gtk_text_view_new(); + new_text_view = malloc(sizeof(ui_text_view_t)); + + new_text_view->text_view = gtk_text_view_new(); scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); - CHECK_BUFFER(ui_main_data.textview); - /* Disable editable attribute */ - gtk_text_view_set_editable(GTK_TEXT_VIEW(ui_main_data.textview), FALSE); + gtk_text_view_set_editable(GTK_TEXT_VIEW(new_text_view->text_view), FALSE); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), - ui_main_data.textview); + new_text_view->text_view); gtk_box_pack_start(GTK_BOX(hbox), scrolled_window, TRUE, TRUE, 5); - return 0; + return new_text_view; } -int ui_signal_dissect_clear_view(void) +int ui_signal_dissect_clear_view(ui_text_view_t *text_view) { - GtkTextBuffer *textbuffer; + GtkTextBuffer *text_buffer; - textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(ui_main_data.textview)); + g_assert(text_view != NULL); - CHECK_BUFFER(textbuffer); + text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view->text_view)); /* If a text buffer is present for the textview remove it */ - if (textbuffer) { - gtk_text_view_set_buffer(GTK_TEXT_VIEW(ui_main_data.textview), NULL); -// g_object_unref(textbuffer); + if (text_buffer != NULL) { + gtk_text_view_set_buffer(GTK_TEXT_VIEW(text_view->text_view), NULL); } + return RC_OK; } -int ui_signal_set_text(char *text, int length) +gboolean ui_signal_set_text(gpointer user_data, gchar *text, gint length) { - GtkTextBuffer *textbuffer; + GtkTextBuffer *text_buffer; + ui_text_view_t *text_view; if (length < 0) - return RC_BAD_PARAM; + return FALSE; - CHECK_BUFFER(text); + text_view = (ui_text_view_t *)user_data; - // fprintf (stdout, "%*s", length, text); + g_assert(text != NULL); + g_assert(text_view != NULL); + g_assert(text_view->text_view != NULL); - textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(ui_main_data.textview)); + g_assert(GTK_IS_TEXT_VIEW(GTK_TEXT_VIEW(text_view->text_view))); - if (textbuffer) { + text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view->text_view)); + + if (text_buffer) { /* We already have a text buffer, use it */ - gtk_text_buffer_insert_at_cursor(textbuffer, text, length); + gtk_text_buffer_insert_at_cursor(text_buffer, text, length); } else { /* No buffer currently in use, create a new one */ - textbuffer = gtk_text_buffer_new(NULL); - gtk_text_buffer_set_text(textbuffer, text, length); - gtk_text_view_set_buffer(GTK_TEXT_VIEW(ui_main_data.textview), textbuffer); + text_buffer = gtk_text_buffer_new(NULL); + gtk_text_buffer_set_text(text_buffer, text, length); + gtk_text_view_set_buffer(GTK_TEXT_VIEW(text_view->text_view), + text_buffer); } - return RC_OK; + return TRUE; } diff --git a/common/utils/itti_analyzer/libui/ui_signal_dissect_view.h b/common/utils/itti_analyzer/libui/ui_signal_dissect_view.h index b1082a20b5bacab786fbfc820cf87dee70c0cac3..36112a9fad1627b85c057c7397ee724557654fe0 100644 --- a/common/utils/itti_analyzer/libui/ui_signal_dissect_view.h +++ b/common/utils/itti_analyzer/libui/ui_signal_dissect_view.h @@ -1,10 +1,14 @@ #ifndef UI_SIGNAL_DISSECT_VIEW_H_ #define UI_SIGNAL_DISSECT_VIEW_H_ -int ui_signal_dissect_new(GtkWidget *hbox); +typedef struct { + GtkWidget *text_view; +} ui_text_view_t; -int ui_signal_set_text(char *text, int length); +ui_text_view_t *ui_signal_dissect_new(GtkWidget *hbox); -int ui_signal_dissect_clear_view(void); +int ui_signal_dissect_clear_view(ui_text_view_t *text_view); + +gboolean ui_signal_set_text(gpointer user_data, gchar *text, gint length); #endif /*UI_SIGNAL_DISSECT_VIEW_H_ */ diff --git a/common/utils/itti_analyzer/libui/ui_tree_view.c b/common/utils/itti_analyzer/libui/ui_tree_view.c index 1d7098021292584237fc4ead38c1a65a994087ad..8a738fcc6dfc785b4d0ff1c68758ad64eb509417 100644 --- a/common/utils/itti_analyzer/libui/ui_tree_view.c +++ b/common/utils/itti_analyzer/libui/ui_tree_view.c @@ -50,6 +50,8 @@ ui_tree_view_init_list(GtkWidget *list) gtk_tree_view_set_model(GTK_TREE_VIEW(list), GTK_TREE_MODEL(store)); + gtk_tree_view_columns_autosize(GTK_TREE_VIEW(list)); + g_object_unref(store); } @@ -117,7 +119,7 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox) // gtk_widget_get_size_request(GTK_WIDGET(ui_main_data.signalslist), &width, NULL); gtk_widget_set_size_request(GTK_WIDGET(scrolled_window), 350, -1); gtk_box_pack_start(GTK_BOX(hbox), scrolled_window, FALSE, FALSE, 0); - CHECK_FCT(ui_signal_dissect_new(hbox)); + ui_main_data.text_view = ui_signal_dissect_new(hbox); gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5); @@ -125,7 +127,8 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox) // G_CALLBACK(ui_callback_on_select_signal), NULL); /* Connect callback on row selection */ - gtk_tree_selection_set_select_function(selection, ui_callback_on_select_signal, NULL, NULL); + gtk_tree_selection_set_select_function(selection, ui_callback_on_select_signal, + ui_main_data.text_view, NULL); return 0; }