Modified display of strings.
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4446 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "array_type.h"
|
#include "array_type.h"
|
||||||
#include "fundamental_type.h"
|
#include "fundamental_type.h"
|
||||||
@@ -29,6 +30,8 @@ int array_dissect_from_buffer(
|
|||||||
int items = type->size / type_child->size;
|
int items = type->size / type_child->size;
|
||||||
int i;
|
int i;
|
||||||
int zero_counter = 0;
|
int zero_counter = 0;
|
||||||
|
gboolean is_string = FALSE;
|
||||||
|
char *string;
|
||||||
|
|
||||||
/* Factorizes trailing 0 */
|
/* Factorizes trailing 0 */
|
||||||
if ((items > 1) && (type_child->type == TYPE_FUNDAMENTAL))
|
if ((items > 1) && (type_child->type == TYPE_FUNDAMENTAL))
|
||||||
@@ -44,30 +47,60 @@ int array_dissect_from_buffer(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Do not factorize if there is only one item */
|
|
||||||
|
/* Check if this is an array of 8 bits items and if at least the firsts ones are not null */
|
||||||
|
if ((type_child->size == 8) && ((items - zero_counter) >= 2))
|
||||||
|
{
|
||||||
|
/* check if this is a printable string */
|
||||||
|
is_string = TRUE;
|
||||||
|
string = calloc(items + 1, 1);
|
||||||
|
|
||||||
|
for (i = 0; i < (items - zero_counter); i++)
|
||||||
|
{
|
||||||
|
string[i] = fundamental_read_from_buffer(type_child, buffer, parent_offset, offset + i * type_child->size);
|
||||||
|
if (isprint(string[i]) == 0)
|
||||||
|
{
|
||||||
|
/* This is not a printable string */
|
||||||
|
is_string = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_string)
|
||||||
|
{
|
||||||
|
INDENTED_STRING(cbuf, indent, length = sprintf(cbuf, "[%d .. %d] \"%s\"\n", 0, (items - zero_counter - 1), string));
|
||||||
|
ui_set_signal_text_cb(user_data, cbuf, length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do not factorize if there is only one null item */
|
||||||
if (zero_counter <= 1)
|
if (zero_counter <= 1)
|
||||||
{
|
{
|
||||||
zero_counter = 0;
|
zero_counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < (items - zero_counter); i++)
|
|
||||||
{
|
|
||||||
INDENTED_STRING(cbuf, indent, length = sprintf(cbuf, "[%d] ", i));
|
|
||||||
ui_set_signal_text_cb(user_data, cbuf, length);
|
|
||||||
|
|
||||||
type->child->type_dissect_from_buffer (
|
if (is_string == FALSE)
|
||||||
type->child, ui_set_signal_text_cb, user_data, buffer, parent_offset,
|
|
||||||
offset + i * type_child->size, indent,
|
|
||||||
FALSE);
|
|
||||||
}
|
|
||||||
if (zero_counter > 0)
|
|
||||||
{
|
{
|
||||||
INDENTED_STRING(cbuf, indent, length = sprintf(cbuf, "[%d .. %d] ", i, items -1));
|
for (i = 0; i < (items - zero_counter); i++)
|
||||||
ui_set_signal_text_cb(user_data, cbuf, length);
|
{
|
||||||
|
INDENTED_STRING(cbuf, indent, length = sprintf(cbuf, "[%d] ", i));
|
||||||
|
ui_set_signal_text_cb(user_data, cbuf, length);
|
||||||
|
|
||||||
type->child->type_dissect_from_buffer (
|
type->child->type_dissect_from_buffer (
|
||||||
type->child, ui_set_signal_text_cb, user_data,
|
type->child, ui_set_signal_text_cb, user_data, buffer, parent_offset,
|
||||||
buffer, parent_offset, offset + i * type_child->size, indent, FALSE);
|
offset + i * type_child->size, indent,
|
||||||
|
FALSE);
|
||||||
|
}
|
||||||
|
if (zero_counter > 0)
|
||||||
|
{
|
||||||
|
INDENTED_STRING(cbuf, indent, length = sprintf(cbuf, "[%d .. %d] ", i, items -1));
|
||||||
|
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, indent, FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type->name) {
|
if (type->name) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "fundamental_type.h"
|
#include "fundamental_type.h"
|
||||||
@@ -64,7 +63,7 @@ int fundamental_dissect_from_buffer(
|
|||||||
case 8:
|
case 8:
|
||||||
value8 = (uint8_t) value64;
|
value8 = (uint8_t) value64;
|
||||||
INDENTED_STRING(cbuf, indent,
|
INDENTED_STRING(cbuf, indent,
|
||||||
length = sprintf(cbuf, type_unsigned ? "(0x%02" PRIx8 ") %3" PRIu8 " '%c';\n" : "(0x%02" PRIx8 ") %4" PRId8 " '%c';\n", value8, value8, isprint(value8) ? value8 : '.'));
|
length = sprintf(cbuf, type_unsigned ? "(0x%02" PRIx8 ") %3" PRIu8 ";\n" : "(0x%02" PRIx8 ") %4" PRId8 ";\n", value8, value8));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
|
|||||||
Reference in New Issue
Block a user