Commit ef9d164d authored by Cedric Roux's avatar Cedric Roux
Browse files

- Removed UI interface structure

- Update calls to signal_set_text

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4265 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 497527fa
......@@ -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;
}
......@@ -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_ */
......@@ -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) {
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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));
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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,