sharkd: export uat records.
Move gtk's fld_tostr() to epan API as uat_fld_tostr. Change-Id: I01e3b66ca9ea3cd1e2e06e2122190ee42b9ad44b Reviewed-on: https://code.wireshark.org/review/21664 Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
bb6e31d8cc
commit
400bff055f
|
@ -1683,6 +1683,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
||||||
uat_fld_chk_str_isdigit@Base 1.9.1
|
uat_fld_chk_str_isdigit@Base 1.9.1
|
||||||
uat_fld_chk_str_isprint@Base 1.9.1
|
uat_fld_chk_str_isprint@Base 1.9.1
|
||||||
uat_fld_chk_str_isxdigit@Base 1.9.1
|
uat_fld_chk_str_isxdigit@Base 1.9.1
|
||||||
|
uat_fld_tostr@Base 2.3.0
|
||||||
uat_foreach_table@Base 1.9.1
|
uat_foreach_table@Base 1.9.1
|
||||||
uat_get_actual_filename@Base 1.12.0~rc1
|
uat_get_actual_filename@Base 1.12.0~rc1
|
||||||
uat_get_table_by_name@Base 1.9.1
|
uat_get_table_by_name@Base 1.9.1
|
||||||
|
|
|
@ -130,6 +130,12 @@ gboolean uat_save(uat_t *uat, char **error);
|
||||||
*/
|
*/
|
||||||
void uat_load_all(void);
|
void uat_load_all(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dump given UAT record to string in form, which can be later loaded with uat_load_str().
|
||||||
|
*/
|
||||||
|
WS_DLL_PUBLIC
|
||||||
|
char *uat_fld_tostr(void *rec, uat_field_t *f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exposes the array of valid records to the UAT consumer (dissectors), updating
|
* Exposes the array of valid records to the UAT consumer (dissectors), updating
|
||||||
* the contents of 'data_ptr' and 'num_items_ptr' (see 'uat_new').
|
* the contents of 'data_ptr' and 'num_items_ptr' (see 'uat_new').
|
||||||
|
|
36
epan/uat.c
36
epan/uat.c
|
@ -262,6 +262,42 @@ uat_t* uat_get_table_by_name(const char* name) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *uat_fld_tostr(void *rec, uat_field_t *f) {
|
||||||
|
guint len;
|
||||||
|
char *ptr;
|
||||||
|
char *out;
|
||||||
|
|
||||||
|
f->cb.tostr(rec, &ptr, &len, f->cbdata.tostr, f->fld_data);
|
||||||
|
|
||||||
|
switch(f->mode) {
|
||||||
|
case PT_TXTMOD_NONE:
|
||||||
|
case PT_TXTMOD_STRING:
|
||||||
|
case PT_TXTMOD_ENUM:
|
||||||
|
case PT_TXTMOD_FILENAME:
|
||||||
|
case PT_TXTMOD_DIRECTORYNAME:
|
||||||
|
out = g_strndup(ptr, len);
|
||||||
|
break;
|
||||||
|
case PT_TXTMOD_HEXBYTES: {
|
||||||
|
GString *s = g_string_sized_new( len*2 + 1 );
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
for (i=0; i<len;i++) g_string_append_printf(s, "%.2X", ((const guint8*)ptr)[i]);
|
||||||
|
|
||||||
|
out = g_strdup(s->str);
|
||||||
|
|
||||||
|
g_string_free(s, TRUE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
g_assert_not_reached();
|
||||||
|
out = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(ptr);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
static void putfld(FILE* fp, void* rec, uat_field_t* f) {
|
static void putfld(FILE* fp, void* rec, uat_field_t* f) {
|
||||||
guint fld_len;
|
guint fld_len;
|
||||||
char* fld_ptr;
|
char* fld_ptr;
|
||||||
|
|
|
@ -3128,6 +3128,38 @@ sharkd_session_process_dumpconf_cb(pref_t *pref, gpointer d)
|
||||||
}
|
}
|
||||||
|
|
||||||
case PREF_UAT:
|
case PREF_UAT:
|
||||||
|
{
|
||||||
|
uat_t *uat = prefs_get_uat_value(pref);
|
||||||
|
guint idx;
|
||||||
|
|
||||||
|
printf("\"t\":[");
|
||||||
|
for (idx = 0; idx < uat->raw_data->len; idx++)
|
||||||
|
{
|
||||||
|
void *rec = UAT_INDEX_PTR(uat, idx);
|
||||||
|
guint colnum;
|
||||||
|
|
||||||
|
if (idx)
|
||||||
|
printf(",");
|
||||||
|
|
||||||
|
printf("[");
|
||||||
|
for (colnum = 0; colnum < uat->ncols; colnum++)
|
||||||
|
{
|
||||||
|
char *str = uat_fld_tostr(rec, &(uat->fields[colnum]));
|
||||||
|
|
||||||
|
if (colnum)
|
||||||
|
printf(",");
|
||||||
|
|
||||||
|
json_puts_string(str);
|
||||||
|
g_free(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("]");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("]");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case PREF_COLOR:
|
case PREF_COLOR:
|
||||||
case PREF_CUSTOM:
|
case PREF_CUSTOM:
|
||||||
case PREF_STATIC_TEXT:
|
case PREF_STATIC_TEXT:
|
||||||
|
|
|
@ -167,44 +167,6 @@ static void limit_buttons(uat_t *uat) {
|
||||||
gtk_widget_set_sensitive (uat->rep->bt_clear, FALSE);
|
gtk_widget_set_sensitive (uat->rep->bt_clear, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *fld_tostr(void *rec, uat_field_t *f) {
|
|
||||||
guint len;
|
|
||||||
char *ptr;
|
|
||||||
char *out;
|
|
||||||
|
|
||||||
f->cb.tostr(rec, &ptr, &len, f->cbdata.tostr, f->fld_data);
|
|
||||||
|
|
||||||
switch(f->mode) {
|
|
||||||
case PT_TXTMOD_NONE:
|
|
||||||
case PT_TXTMOD_STRING:
|
|
||||||
case PT_TXTMOD_ENUM:
|
|
||||||
case PT_TXTMOD_FILENAME:
|
|
||||||
case PT_TXTMOD_DIRECTORYNAME:
|
|
||||||
out = g_strndup(ptr, len);
|
|
||||||
break;
|
|
||||||
case PT_TXTMOD_HEXBYTES: {
|
|
||||||
GString *s = g_string_sized_new( len*2 + 1 );
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
for (i=0; i<len;i++) g_string_append_printf(s, "%.2X", ((const guint8*)ptr)[i]);
|
|
||||||
|
|
||||||
out = g_strdup(s->str);
|
|
||||||
|
|
||||||
g_string_free(s, TRUE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
g_assert_not_reached();
|
|
||||||
out = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free(ptr);
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void append_row(uat_t *uat, guint idx) {
|
static void append_row(uat_t *uat, guint idx) {
|
||||||
void *rec = UAT_INDEX_PTR(uat, idx);
|
void *rec = UAT_INDEX_PTR(uat, idx);
|
||||||
uat_field_t *f = uat->fields;
|
uat_field_t *f = uat->fields;
|
||||||
|
@ -216,7 +178,7 @@ static void append_row(uat_t *uat, guint idx) {
|
||||||
|
|
||||||
gtk_list_store_insert_before(uat->rep->list_store, &iter, NULL);
|
gtk_list_store_insert_before(uat->rep->list_store, &iter, NULL);
|
||||||
for ( colnum = 0; colnum < uat->ncols; colnum++ ) {
|
for ( colnum = 0; colnum < uat->ncols; colnum++ ) {
|
||||||
tmp_str = fld_tostr(rec, &(f[colnum]));
|
tmp_str = uat_fld_tostr(rec, &(f[colnum]));
|
||||||
gtk_list_store_set(uat->rep->list_store, &iter, colnum, tmp_str, -1);
|
gtk_list_store_set(uat->rep->list_store, &iter, colnum, tmp_str, -1);
|
||||||
g_free(tmp_str);
|
g_free(tmp_str);
|
||||||
}
|
}
|
||||||
|
@ -238,7 +200,7 @@ static void reset_row(uat_t *uat, guint idx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( colnum = 0; colnum < uat->ncols; colnum++ ) {
|
for ( colnum = 0; colnum < uat->ncols; colnum++ ) {
|
||||||
tmp_str = fld_tostr(rec, &(f[colnum]));
|
tmp_str = uat_fld_tostr(rec, &(f[colnum]));
|
||||||
gtk_list_store_set(uat->rep->list_store, &iter, colnum, tmp_str, -1);
|
gtk_list_store_set(uat->rep->list_store, &iter, colnum, tmp_str, -1);
|
||||||
g_free(tmp_str);
|
g_free(tmp_str);
|
||||||
}
|
}
|
||||||
|
@ -511,7 +473,7 @@ static void uat_edit_dialog(uat_t *uat, gint row, gboolean copy) {
|
||||||
|
|
||||||
for ( colnum = 0; colnum < uat->ncols; colnum++ ) {
|
for ( colnum = 0; colnum < uat->ncols; colnum++ ) {
|
||||||
GtkWidget *entry, *label, *event_box;
|
GtkWidget *entry, *label, *event_box;
|
||||||
char *text = fld_tostr(dd->rec, &(f[colnum]));
|
char *text = uat_fld_tostr(dd->rec, &(f[colnum]));
|
||||||
char *label_text;
|
char *label_text;
|
||||||
gchar *fc_filename;
|
gchar *fc_filename;
|
||||||
|
|
||||||
|
@ -681,7 +643,7 @@ static void uat_del_dlg(uat_t *uat, int idx) {
|
||||||
|
|
||||||
for ( colnum = 0; colnum < uat->ncols; colnum++ ) {
|
for ( colnum = 0; colnum < uat->ncols; colnum++ ) {
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
char *text = fld_tostr(rec, &(f[colnum]));
|
char *text = uat_fld_tostr(rec, &(f[colnum]));
|
||||||
|
|
||||||
tmp_str = g_strdup_printf("%s:", f[colnum].title);
|
tmp_str = g_strdup_printf("%s:", f[colnum].title);
|
||||||
label = gtk_label_new(tmp_str);
|
label = gtk_label_new(tmp_str);
|
||||||
|
|
Loading…
Reference in New Issue