71 guint stream_size = 1;
104 c = (guchar *) g_malloc0(
sizeof(guchar) * length);
110 decode_it = decode_struct->
func;
112 text = decode_it(c, (gpointer) decode_parameters);
116 gtk_entry_set_text(GTK_ENTRY(decode_struct->
entry), text);
120 text = g_strdup_printf(Q_(
"Something's wrong!"));
121 gtk_entry_set_text(GTK_ENTRY(decode_struct->
entry), text);
126 if (decode_struct->
err_msg != NULL)
128 text = g_strdup_printf(decode_struct->
err_msg, length);
132 text = g_strdup_printf(Q_(
"Cannot interpret as a %d byte(s)"), length);
135 gtk_entry_set_text(GTK_ENTRY(decode_struct->
entry), text);
184 while (i < tab->nb_rows)
186 row = g_ptr_array_index(tab->
rows, i);
204 while (i < dw->nb_tabs)
206 tab = g_ptr_array_index(dw->
tabs, i);
227 guint endianness = 0;
228 guint stream_size = 0;
230 if (main_struct != NULL &&
242 g_free(decode_parameters);
289 if (main_struct != NULL)
323 gchar *va_label = NULL;
324 GPtrArray *col_labels = NULL;
325 GPtrArray *vboxes = NULL;
326 GtkWidget *child = NULL;
327 GtkWidget *hpaned = NULL;
328 GtkWidget *hpaned2 = NULL;
329 GtkWidget *vbox = NULL;
330 GtkWidget *vbox_label = NULL;
332 col_labels = g_ptr_array_new();
333 vboxes = g_ptr_array_new();
335 va_start(args, nb_cols);
336 for (i = 0 ; i < nb_cols ; i++)
338 va_label = va_arg(args, gchar *);
339 if (va_label != NULL)
341 vbox_label = gtk_label_new(va_label);
342 gtk_misc_set_padding(GTK_MISC(vbox_label), 3, 3);
343 gtk_misc_set_alignment(GTK_MISC(vbox_label), 0.5, 0.5);
344 g_ptr_array_add(col_labels, (gpointer) vbox_label);
353 #if GTK_MAJOR_VERSION < 3
355 hpaned = gtk_hpaned_new();
357 #if GTK_MAJOR_VERSION >= 3
358 #if GTK_MINOR_VERSION <= 1
360 hpaned = gtk_hpaned_new();
362 #if GTK_MINOR_VERSION >= 2
364 hpaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
368 gtk_container_set_border_width(GTK_CONTAINER(hpaned), 2);
371 #if GTK_MAJOR_VERSION < 3
373 vbox = gtk_vbox_new(FALSE, 2);
375 #if GTK_MAJOR_VERSION >= 3
376 #if GTK_MINOR_VERSION <= 1
378 vbox = gtk_vbox_new(FALSE, 2);
380 #if GTK_MINOR_VERSION >= 2
382 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
386 gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE);
387 g_ptr_array_add(vboxes, vbox);
388 gtk_paned_add1(GTK_PANED(hpaned), (gpointer) vbox);
389 vbox_label = g_ptr_array_index(col_labels, i);
390 gtk_box_pack_start(GTK_BOX(vbox), vbox_label, FALSE, FALSE, 3);
393 while (i < nb_cols-1)
395 #if GTK_MAJOR_VERSION < 3
397 hpaned2 = gtk_hpaned_new();
399 #if GTK_MAJOR_VERSION >= 3
400 #if GTK_MINOR_VERSION <= 1
402 hpaned2 = gtk_hpaned_new();
404 #if GTK_MINOR_VERSION >= 2
406 hpaned2 = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
410 gtk_container_set_border_width(GTK_CONTAINER(hpaned2), 2);
411 gtk_paned_add2(GTK_PANED(hpaned), hpaned2);
414 #if GTK_MAJOR_VERSION < 3
416 vbox = gtk_vbox_new(FALSE, 2);
418 #if GTK_MAJOR_VERSION >= 3
419 #if GTK_MINOR_VERSION <= 1
421 vbox = gtk_vbox_new(FALSE, 2);
423 #if GTK_MINOR_VERSION >= 2
425 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
429 gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE);
430 g_ptr_array_add(vboxes, (gpointer) vbox);
431 gtk_paned_add1(GTK_PANED(hpaned), vbox);
432 vbox_label = g_ptr_array_index(col_labels, i);
433 gtk_box_pack_start(GTK_BOX(vbox), vbox_label, FALSE, FALSE, 3);
437 #if GTK_MAJOR_VERSION < 3
439 vbox = gtk_vbox_new(FALSE, 2);
441 #if GTK_MAJOR_VERSION >= 3
442 #if GTK_MINOR_VERSION <= 1
444 vbox = gtk_vbox_new(FALSE, 2);
446 #if GTK_MINOR_VERSION >= 2
448 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
452 g_ptr_array_add(vboxes, (gpointer) vbox);
453 gtk_paned_add2(GTK_PANED(hpaned), vbox);
454 gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE);
455 vbox_label = g_ptr_array_index(col_labels, i);
456 gtk_box_pack_start(GTK_BOX(vbox), vbox_label, FALSE, FALSE, 3);
461 tab->
label = gtk_label_new(label);
462 gtk_misc_set_padding(GTK_MISC(tab->
label), 2, 2);
463 gtk_misc_set_alignment(GTK_MISC(tab->
label), 0.5, 0.5);
468 gtk_widget_show_all(child);
469 gtk_notebook_append_page(notebook, child, tab->
label);
482 GtkWidget *vbox = NULL;
487 if (tab != NULL && row != NULL)
490 if (tab->
rows == NULL)
492 tab->
rows = g_ptr_array_new();
495 g_ptr_array_add(tab->
rows, (gpointer) row);
499 vbox = g_ptr_array_index(tab->
vboxes, 0);
500 gtk_box_pack_start(GTK_BOX(vbox), row->label, FALSE, FALSE, 3);
505 while (i < tab->nb_cols)
507 vbox = g_ptr_array_index(tab->
vboxes, i);
508 couple = g_ptr_array_index(row->decode_array, j);
509 gtk_box_pack_start(GTK_BOX(vbox), couple->
entry, FALSE, FALSE, 1);
510 gtk_widget_show(couple->
entry);
525 GtkWidget *notebook = NULL;
533 dw->
tabs = g_ptr_array_new();
540 g_ptr_array_add(dw->
tabs, (gpointer) tab);
557 g_ptr_array_add(dw->
tabs, (gpointer) tab);
570 g_ptr_array_add(dw->
tabs, (gpointer) tab);
587 g_ptr_array_add(dw->
tabs, (gpointer) tab);
604 GtkNotebook *notebook = NULL;
605 gint selected_tab = -1;
609 if (notebook != NULL)
611 selected_tab = gtk_notebook_get_current_page(notebook);
625 GtkNotebook *notebook = NULL;
627 if (selected_tab >= 0)
631 if (notebook != NULL)
633 gtk_notebook_set_current_page(notebook, selected_tab);
647 GtkSpinButton *spin_button = NULL;
648 gint stream_size = -1;
652 if (spin_button != NULL)
654 stream_size = gtk_spin_button_get_value_as_int(spin_button);
668 GtkSpinButton *spin_button = NULL;
670 if (stream_size >= 0)
674 if (spin_button != NULL)
676 gtk_spin_button_set_value(spin_button, (gdouble) stream_size);
690 GtkWidget *rb = NULL;
691 GtkWidget *activated = NULL;
692 const gchar *widget_name = NULL;
700 if (activated != NULL)
702 widget_name = gtk_buildable_get_name(GTK_BUILDABLE(activated));
706 if (widget_name != NULL)
708 if (g_ascii_strcasecmp(widget_name,
"diw_rb_little_endian") == 0)
712 else if (g_ascii_strcasecmp(widget_name,
"diw_rb_big_endian") == 0)
716 else if (g_ascii_strcasecmp(widget_name,
"diw_rb_middle_endian") == 0)
740 GtkWidget *rb = NULL;
This is the main structure.
gchar * decode_16bits_unsigned(guchar *data, gpointer data_struct)
general purpose of this function is to take a 2 byte data stream and convert it as if it is a 16 bits...
static void interpret(doc_t *doc, decode_t *decode_struct, decode_parameters_t *decode_parameters, guint length)
Here we do interpret a something according to the decode_it function and we write down the result in ...
gboolean fixed_size
says whether we can modify data_size or not
gchar * err_msg
error message if something went wrong when decoding expects a d somewhere in the message to represent...
#define H_DI_MIDDLE_ENDIAN
Stands for middle endian representation (http://en.wikipedia.org/wiki/Endianness#Middle-endian) ...
Tabulation structure to be used in the GtkNoteBook of data_interpretor's window.
gint tab_displayed
keeps the last displayed tab's number before closing
static void add_default_tabs(heraia_struct_t *main_struct)
Inits data interpretor with default tabs Must be called only once at bootime.
gchar * decode_double_scientific(guchar *data, gpointer data_struct)
general purpose of this function is to take a 8 byte data stream and convert it as if it is a float n...
void gtk_radio_button_set_active(GtkRadioButton *radio_button)
Sets the radio button active.
window_prop_t * main_dialog
heraia's main window
gboolean displayed
TRUE if displayed, FALSE otherwise.
gchar * decode_32bits_unsigned(guchar *data, gpointer data_struct)
general purpose of this function is to take a 4 byte data stream and convert it as if it is a 32 bits...
guint data_size
size of what we may decode
gboolean delete_dt_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
call back function for the data interpretor window destruction
DecodeFunc func
a function to decode into something
guint nb_rows
number of rows in this tab - this is automatically updated
all_window_prop_t * win_prop
Keeps window properties.
gint di_get_stream_size(heraia_struct_t *main_struct)
Gets the stream_size (if any) from data interpretor's window.
gchar * decode_float_scientific(guchar *data, gpointer data_struct)
general purpose of this function is to take a 4 byte data stream and convert it as if it is a float n...
GtkWidget * label
label for this tab
Data interpretor window structure.
#define H_DI_BIG_ENDIAN
Stands for big endian representation.
gchar * decode_dos_date(guchar *data, gpointer data_struct)
general purpose of this function is to take a 4 byte data stream and convert it as if it is a dos dat...
Proposal for a structure that will group all informations about a single document.
gchar * decode_filetime_date(guchar *data, gpointer data_struct)
general purpose of this function is to take a 8 byte data stream and convert it as if it is a filetim...
#define H_DI_LITTLE_ENDIAN
Stands for little endian representation (this is the default)
gchar * decode_8bits_unsigned(guchar *data, gpointer data_struct)
general purpose of this function is to take a 1 byte data stream and convert it as if it is an 8 bits...
xml_t * xmls
All the xmls used in the program, loaded at running time.
gchar * decode_32bits_signed(guchar *data, gpointer data_struct)
general purpose of this function is to take a 4 byte data stream and convert it as if it is a 32 bits...
gchar * decode_to_bits(guchar *data, gpointer data_struct)
decodes the stream represented by *data (one byte) to a string containing eight 0 or 1 (Little Endian...
guint which_stream_size(heraia_struct_t *main_struct)
returns stream size as selected in the spin button
gchar * decode_8bits_signed(guchar *data, gpointer data_struct)
General purpose of this function is to take a 1 byte data stream and convert it as if it is an 8 bits...
void di_set_selected_tab(heraia_struct_t *main_struct, gint selected_tab)
Sets the selected tab (if possible) to data interpretor's notebook.
void refresh_data_interpretor_window(GtkWidget *widget, gpointer data)
Refreshes the data interpretor window with the new values.
GPtrArray * vboxes
array of vboxes where we will pack label and entry widgets
Basic way to associate a decode function and an entry that will receive the result.
GtkWidget * hex_widget
hexwidget corresponding to the document
decode_parameters_t * new_decode_parameters_t(guint endianness, guint stream_size)
Make an new decode_parameters_t in order to pass to the functions.
GtkBuilder * main
the main interface xml description
gchar * decode_double_normal(guchar *data, gpointer data_struct)
general purpose of this function is to take a 8 byte data stream and convert it as if it is a float n...
tab_t * add_new_tab_in_data_interpretor(GtkNotebook *notebook, guint index, const gchar *label, guint nb_cols,...)
Adds a new tab in the data interpretor window.
gchar *(* DecodeFunc)(guchar *, gpointer)
Templates for the decoding functions.
void di_set_stream_size(heraia_struct_t *main_struct, gint stream_size)
Sets the stream size (if possible) to data interpretor's notebook.
GPtrArray * decode_array
Pointer Array of decode_t functions and corresponding entries.
gchar * decode_64bits_signed(guchar *data, gpointer data_struct)
general purpose of this function is to take a 8 byte data stream and convert it as if it is a 64 bits...
gchar * decode_HFS_date(guchar *data, gpointer data_struct)
general purpose of this function is to take a 4 byte data stream and convert it as if it is a HFS dat...
data_window_t * current_DW
data_interpretor pointer
gchar * decode_float_normal(guchar *data, gpointer data_struct)
general purpose of this function is to take a 4 byte data stream and convert it as if it is a float n...
void di_set_endianness(heraia_struct_t *main_struct, gint endianness)
Sets the endianness as stated by the second parameter.
GPtrArray * tabs
an array of tabs displayed in data interpretor's notebook (tab_t)
GPtrArray * col_labels
array of GtkWidgets of columns labels
This file contains all the definitions and includes all other .h files.
gchar * decode_packed_BCD(guchar *data, gpointer data_struct)
Decode one byte as a Packed BCD (Binary Coded Decimal) and return a gchar* that may be freed when no ...
static void refresh_one_tab(doc_t *doc, data_window_t *dw, tab_t *tab, decode_parameters_t *decode_parameters)
This function refreshes one entire tab (row by row)
GtkWidget * diw
data interpretor window
guint nb_tabs
keeps Number of tabs in the GPtrArray
doc_t * current_doc
This is a pointer to the current edited document.
GtkWidget * heraia_get_widget(GtkBuilder *xml, gchar *widget_name)
This is a wrapper to the GtkBuilder xml get widget.
void data_interpretor_init_interface(heraia_struct_t *main_struct)
Inits the data interpretor structure and window with default values.
gint di_get_endianness(heraia_struct_t *main_struct)
Gets the endianness as selected in the radio group button.
gboolean ghex_get_data(GtkWidget *hex_widget, guint length, guint endianness, guchar *c)
Gets the data from the hexwidget under the cursor, a wrapper to the ghex_memcpy function.
GtkWidget * entry
the widget that will receive the result
gchar * decode_64bits_unsigned(guchar *data, gpointer data_struct)
general purpose of this function is to take a 8 byte data stream and convert it as if it is a 64 bits...
guint index
number for this tab
guint stream_size
stream_size
gchar * decode_C_date(guchar *data, gpointer data_struct)
general purpose of this function is to take a 4 byte data stream and convert it as if it is a C date...
gint di_get_selected_tab(heraia_struct_t *main_struct)
Gets the selected tab (if any) from data interpretor's notebook.
guint endianness
endianness
decode_generic_t * new_decode_generic_t(const gchar *label, guint data_size, gboolean fixed_size, const gchar *err_msg, guint nb_cols,...)
Make a new decode_generic_t structure and creates the associated widgets.
static void refresh_all_tabs(doc_t *doc, data_window_t *dw, decode_parameters_t *decode_parameters)
Refreshes all tabs.
Basic way to have as many as we want decoding functions corresponding to one label.
GtkWidget * gtk_radio_button_get_active_from_widget(GtkRadioButton *radio_button)
gets the active radio button from a radio group
void add_new_row_to_tab(tab_t *tab, decode_generic_t *row)
Adds a row to a particular tab.
static void connect_data_interpretor_signals(heraia_struct_t *main_struct)
Connects data interpretor window's signals to the right functions.
static void refresh_one_row(doc_t *doc, decode_generic_t *row, guint nb_cols, decode_parameters_t *decode_parameters)
This function refreshes one row of the tab.
void destroy_dt_window(GtkWidget *widget, GdkEvent *event, gpointer data)
call back function for the data interpretor window destruction
Used to pass decoding options to the functions.
guint which_endianness(heraia_struct_t *main_struct)
Determines which endianness is selected that is to say which radio button is active in the window...
GPtrArray * rows
array of pointers to decode_generic_t variables.
guint nb_cols
number of columns in this tab - this MUST NOT change in any way
gchar * decode_16bits_signed(guchar *data, gpointer data_struct)
general purpose of this function is to take a 2 byte data stream and convert it as if it is a 16 bits...