Heraia
0.1.8
|
An interface to the ghex library -> this adds an abstract layer. More...
#include <libheraia.h>
Go to the source code of this file.
Functions | |
doc_t * | heraia_hex_document_new (heraia_struct_t *main_struct, char *filename) |
Removes the old document if it exists and adds a new one from the filename 'filename'. More... | |
gchar * | heraia_hex_document_get_filename (Heraia_Document *hex_doc) |
Retrieves the filename of a document which ever it is ! More... | |
gchar * | doc_t_document_get_filename (doc_t *doc) |
Retrieves from a doc_t * document it's filename, which ever it is. More... | |
HERAIA_ERROR | heraia_hex_document_save (doc_t *current_doc) |
HERAIA_ERROR | heraia_hex_document_save_as (doc_t *current_doc, gchar *filename) |
Saves an opened and edited document to a new file. More... | |
static void | change_endianness (guint len, guint endianness, guchar *result) |
Deals with the endianness of 'len' bytes located in 'result' for BIG_ENDIAN we only swap bytes if we have two or more of them if we have only one byte, we reverse its order if endianness is MIDDLE_ENDIAN we swap only four or more bytes Here we might have funny things with len corresponding to 24 or 56 bits for example. More... | |
gboolean | ghex_memcpy (Heraia_Hex *gh, guint64 pos, guint len, guint endianness, guchar *result) |
Returns 'len' number of bytes located at 'pos' in the Heraia_Hex document and puts it in the result variable. More... | |
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. More... | |
void | ghex_set_data (doc_t *doc, guint64 position, guint rep_len, guint len, guchar *data) |
Wrapper to the hex_document_set_data function. More... | |
gboolean | ghex_get_data_position (GtkWidget *hex_widget, guint64 pos, guint length, guint endianness, guchar *c) |
Gets the data from the hexwidget, a wrapper to the ghex_memcpy function. More... | |
guchar * | ghex_get_data_to_ascii (GtkWidget *hex_widget, guint64 pos, guint length, guint endianness) |
Gets data from a defined position and formats it in an ascii displayable form. More... | |
guchar * | ghex_get_data_to_hex (GtkWidget *hex_widget, guint64 pos, guint length, guint endianness) |
Gets data from a defined position and formats it in an hex displayable form. More... | |
guint64 | ghex_file_size (Heraia_Hex *gh) |
Returns the file size of an opened Heraia_Hex document. More... | |
guint64 | ghex_get_cursor_position (GtkWidget *hex_widget) |
Retrieves the cursor's position from the current hexwidget. More... | |
void | ghex_set_cursor_position (GtkWidget *hex_widget, guint64 position) |
Sets the cursor at the defined position in the hexwidget. More... | |
gboolean | ghex_find_forward (doc_t *doc, guchar *search_buffer, guint buffer_size, guint64 *position) |
Wrapper to the hex_document_find_forward function Tries to find search_buffer in doc. More... | |
static gboolean | hex_document_find_decode (gint direction, doc_t *doc, DecodeFunc decode_it, guint data_size, decode_parameters_t *decode_parameters, guint64 start, gchar *search_buffer, guint64 *found) |
Finds, in all directions the desired searched string. More... | |
gboolean | ghex_find_decode (gint direction, doc_t *doc, DecodeFunc decode_it, decode_parameters_t *decode_parameters, guint data_size, gchar *search_buffer, guint64 *position) |
Wrappers to the functions that will do the search (here it has nothing to do with ghex in fact). More... | |
gint | ghex_compare_data (doc_t *doc, guchar *string, guint buffer_size, guint64 position) |
Wrapper to the hex_document_compare_data function Compares data from string to the one contained in doc at position position and with len buffer_size. More... | |
gboolean | ghex_find_backward (doc_t *doc, guchar *search_buffer, guint buffer_size, guint64 *position) |
Wrapper to the hex_document_find_backward function Tries to find search_buffer in doc. More... | |
selection_t * | ghex_get_selection (GtkWidget *hex_widget) |
Retrieves the selection made (if any) in the hex widget. More... | |
doc_t * | new_doc_t (Heraia_Document *hex_doc, GtkWidget *hex_widget) |
Inits a doc_t structure. More... | |
void | close_doc_t (doc_t *current_doc) |
Closes a previously malloced doc_t structure. More... | |
An interface to the ghex library -> this adds an abstract layer.
Definition in file ghex_heraia_interface.c.
|
static |
Deals with the endianness of 'len' bytes located in 'result' for BIG_ENDIAN we only swap bytes if we have two or more of them if we have only one byte, we reverse its order if endianness is MIDDLE_ENDIAN we swap only four or more bytes Here we might have funny things with len corresponding to 24 or 56 bits for example.
len | : len bytes to change endianness | |
endianness | : H_DI_BIG_ENDIAN or H_DI_MIDDLE_ENDIAN we consider that there is nothing to do with H_DI_LITTLE_ENDIAN | |
[in,out] | result | : contains the bytes to be swaped and at the end, contains the result. |
Definition at line 205 of file ghex_heraia_interface.c.
References H_DI_BIG_ENDIAN, H_DI_MIDDLE_ENDIAN, reverse_byte_order(), and swap_bytes().
Referenced by ghex_memcpy().
void close_doc_t | ( | doc_t * | current_doc | ) |
Closes a previously malloced doc_t structure.
current_doc |
Definition at line 827 of file ghex_heraia_interface.c.
References doc_t::hex_widget.
Referenced by close_one_document().
gchar* doc_t_document_get_filename | ( | doc_t * | doc | ) |
Retrieves from a doc_t * document it's filename, which ever it is.
doc | : an existing doc_t |
Definition at line 97 of file ghex_heraia_interface.c.
References heraia_hex_document_get_filename(), and doc_t::hex_doc.
Referenced by add_gtk_tree_view_to_result_notebook(), add_new_tab_in_main_window(), on_close_activate(), on_save_activate(), on_save_as_activate(), realize_some_numerical_stat(), save_mp_files_filenames(), select_a_file_to_save(), select_file_to_load(), set_notebook_tab_name(), and update_main_window_name().
gint ghex_compare_data | ( | doc_t * | doc, |
guchar * | string, | ||
guint | buffer_size, | ||
guint64 | position | ||
) |
Wrapper to the hex_document_compare_data function Compares data from string to the one contained in doc at position position and with len buffer_size.
doc | : the document where we want to compare data |
string | : the string we want to compare |
buffer_size | : size of the buffer string |
position | the localisation in the document where we want to compare thing |
Definition at line 715 of file ghex_heraia_interface.c.
References doc_t::hex_doc.
Referenced by fr_replace_data().
guint64 ghex_file_size | ( | Heraia_Hex * | gh | ) |
Returns the file size of an opened Heraia_Hex document.
gh | : the widget of a an opened Heraia_Hex document |
Definition at line 459 of file ghex_heraia_interface.c.
Referenced by fr_get_search_string(), ghex_memcpy(), goto_dialog_ok(), populate_stats_histos(), refresh_file_labels(), and rw_add_one_tab_from_find_all_bt().
gboolean ghex_find_backward | ( | doc_t * | doc, |
guchar * | search_buffer, | ||
guint | buffer_size, | ||
guint64 * | position | ||
) |
Wrapper to the hex_document_find_backward function Tries to find search_buffer in doc.
doc | : the document searched | |
search_buffer | : the string searched for | |
buffer_size | : size of the buffer | |
[out] | position (if any) of the found string |
Definition at line 738 of file ghex_heraia_interface.c.
References doc_t::hex_doc, and doc_t::hex_widget.
Referenced by find_prev_bt_clicked().
gboolean ghex_find_decode | ( | gint | direction, |
doc_t * | doc, | ||
DecodeFunc | decode_it, | ||
decode_parameters_t * | decode_parameters, | ||
guint | data_size, | ||
gchar * | search_buffer, | ||
guint64 * | position | ||
) |
Wrappers to the functions that will do the search (here it has nothing to do with ghex in fact).
Tries to find search_buffer in doc, data being passed to a decoding function
direction | : the direction to look for (HERAIA_FIND_FORWARD or HERAIA_FIND_BACKWARD and only those directions) | |
doc | : the document searched in | |
decode_it | the function that will be used to decode the text | |
decode_parameters | : this structure contains the selected endiannes and the selected stream size | |
data_size | : size of the data to be read in order to use the decoding function | |
search_buffer | : the string searched for (this is a simple guchar *null terminated entered by the user | |
[out] | position | (if any) of the found string |
Definition at line 660 of file ghex_heraia_interface.c.
References HERAIA_FIND_ALL, HERAIA_FIND_BACKWARD, HERAIA_FIND_FORWARD, doc_t::hex_doc, hex_document_find_decode(), and doc_t::hex_widget.
Referenced by fdft_search_direction().
gboolean ghex_find_forward | ( | doc_t * | doc, |
guchar * | search_buffer, | ||
guint | buffer_size, | ||
guint64 * | position | ||
) |
Wrapper to the hex_document_find_forward function Tries to find search_buffer in doc.
doc | : the document searched | |
search_buffer | : the string searched for | |
buffer_size | : size of the buffer | |
[out] | position | (if any) of the found string |
Definition at line 520 of file ghex_heraia_interface.c.
References doc_t::hex_doc, and doc_t::hex_widget.
Referenced by find_all_bt_clicked(), and fr_search_forward().
guint64 ghex_get_cursor_position | ( | GtkWidget * | hex_widget | ) |
Retrieves the cursor's position from the current hexwidget.
hex_widget | : the widget that displays the hex document |
Definition at line 477 of file ghex_heraia_interface.c.
Referenced by fdft_search_direction(), find_prev_bt_clicked(), fr_replace_data(), fr_search_forward(), goto_dialog_ok(), refresh_file_labels(), and save_mp_files_filenames().
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.
hex_widget | : MUST be a Heraia_Hex widget |
length | : can be anything but MUST be strictly less than the size allocated to *c |
endianness | : H_DI_BIG_ENDIAN, H_DI_MIDDLE_ENDIAN or H_DI_LITTLE_ENDIAN |
c | : a previously g_malloc'ed gchar * string that will contain copied bytes. |
Definition at line 282 of file ghex_heraia_interface.c.
References ghex_get_data_position().
Referenced by interpret().
gboolean ghex_get_data_position | ( | GtkWidget * | hex_widget, |
guint64 | pos, | ||
guint | length, | ||
guint | endianness, | ||
guchar * | c | ||
) |
Gets the data from the hexwidget, a wrapper to the ghex_memcpy function.
hex_widget | : MUST be a Heraia_Hex widget |
pos | : position in the file where we want to get the data |
length | : can be anything but MUST be strictly less than the size allocated to *c |
endianness | : H_DI_BIG_ENDIAN, H_DI_MIDDLE_ENDIAN or H_DI_LITTLE_ENDIAN |
c | : a previously g_malloc'ed gchar * string that will contain copied bytes. |
Definition at line 327 of file ghex_heraia_interface.c.
References ghex_memcpy().
Referenced by fr_get_search_string(), ghex_get_data(), and hex_document_find_decode().
guchar* ghex_get_data_to_ascii | ( | GtkWidget * | hex_widget, |
guint64 | pos, | ||
guint | length, | ||
guint | endianness | ||
) |
Gets data from a defined position and formats it in an ascii displayable form.
hex_widget | : MUST be a Heraia_Hex widget |
pos | : position in the file where we want to get the data |
length | : length of the data to get |
endianness | : H_DI_BIG_ENDIAN, H_DI_MIDDLE_ENDIAN or H_DI_LITTLE_ENDIAN |
Definition at line 354 of file ghex_heraia_interface.c.
References ghex_memcpy(), and is_displayable.
Referenced by rw_add_one_tab_from_find_all_bt().
guchar* ghex_get_data_to_hex | ( | GtkWidget * | hex_widget, |
guint64 | pos, | ||
guint | length, | ||
guint | endianness | ||
) |
Gets data from a defined position and formats it in an hex displayable form.
hex_widget | : MUST be a Heraia_Hex widget |
pos | : position in the file where we want to get the data |
length | : length of the data to get |
endianness | : H_DI_BIG_ENDIAN, H_DI_MIDDLE_ENDIAN or H_DI_LITTLE_ENDIAN |
Definition at line 404 of file ghex_heraia_interface.c.
References ghex_memcpy().
Referenced by rw_add_one_tab_from_find_all_bt().
selection_t* ghex_get_selection | ( | GtkWidget * | hex_widget | ) |
Retrieves the selection made (if any) in the hex widget.
hex_widget | : the widget that displays the hex document |
Definition at line 773 of file ghex_heraia_interface.c.
References selection_t::end, and selection_t::start.
Referenced by refresh_file_labels().
gboolean ghex_memcpy | ( | Heraia_Hex * | gh, |
guint64 | pos, | ||
guint | len, | ||
guint | endianness, | ||
guchar * | result | ||
) |
Returns 'len' number of bytes located at 'pos' in the Heraia_Hex document and puts it in the result variable.
gh | : A Heraia_Hex document. | |
pos | : position where we want to begin to copy bytes | |
len | : number of bytes we want to copy | |
endianness | : endianness we want to apply to the bytes we want to copy | |
[out] | result | : a previously g_malloc'ed gchar * string that will contain copied bytes. |
Definition at line 242 of file ghex_heraia_interface.c.
References change_endianness(), and ghex_file_size().
Referenced by ghex_get_data_position(), ghex_get_data_to_ascii(), and ghex_get_data_to_hex().
void ghex_set_cursor_position | ( | GtkWidget * | hex_widget, |
guint64 | position | ||
) |
Sets the cursor at the defined position in the hexwidget.
hex_widget | : the widget that displays the hex document |
position | : the position where we want to go |
Definition at line 499 of file ghex_heraia_interface.c.
Referenced by fdft_search_direction(), find_prev_bt_clicked(), fr_search_forward(), goto_dialog_ok(), load_mp_files_filenames(), and tree_selection_changed().
void ghex_set_data | ( | doc_t * | doc, |
guint64 | position, | ||
guint | rep_len, | ||
guint | len, | ||
guchar * | data | ||
) |
Wrapper to the hex_document_set_data function.
doc | : the document searched |
position | : the position where to set the data |
rep_len | : the len of the data to be replaced in the document doc |
len | : the len of the data |
data | : the data that will replace the one in the document |
Definition at line 305 of file ghex_heraia_interface.c.
References doc_t::hex_doc.
Referenced by fr_replace_data().
gchar* heraia_hex_document_get_filename | ( | Heraia_Document * | hex_doc | ) |
Retrieves the filename of a document which ever it is !
doc | : an Heraia_Document |
Definition at line 79 of file ghex_heraia_interface.c.
Referenced by doc_t_document_get_filename().
HERAIA_ERROR heraia_hex_document_new | ( | heraia_struct_t * | main_struct, |
char * | filename | ||
) |
Removes the old document if it exists and adds a new one from the filename 'filename'.
main_struct | : main structure |
filename | : a char * representing an existing file named "filename" |
Definition at line 39 of file ghex_heraia_interface.c.
References connect_cursor_moved_signal(), heraia_struct_t::documents, is_toggle_button_activated(), xml_t::main, new_doc_t(), and heraia_struct_t::xmls.
Referenced by load_file_to_analyse().
HERAIA_ERROR heraia_hex_document_save | ( | doc_t * | current_doc | ) |
Definition at line 116 of file ghex_heraia_interface.c.
References HERAIA_FILE_ERROR, HERAIA_NOERR, and doc_t::hex_doc.
Referenced by on_save_activate().
HERAIA_ERROR heraia_hex_document_save_as | ( | doc_t * | current_doc, |
gchar * | filename | ||
) |
Saves an opened and edited document to a new file.
current_doc | : current edited document (doc_t * structure) |
filename | : the new filename where to save the file |
< to make libghex happy !
Definition at line 145 of file ghex_heraia_interface.c.
References HERAIA_FILE_ERROR, HERAIA_NOERR, and doc_t::hex_doc.
Referenced by on_save_as_activate().
|
static |
Finds, in all directions the desired searched string.
direction | : the direction to look for (HERAIA_FIND_FORWARD or HERAIA_FIND_BACKWARD) | |
doc | : the document searched in | |
decode_it | the function that will be used to decode the text | |
data_size | : size of the data to be read in order to use the decoding function | |
decode_parameters | : this structure contains the selected endiannes and the selected stream size | |
start | : the start position where to begin the search | |
search_buffer | : the string searched for (this is a simple guchar *null terminated entered by the user | |
[out] | found | : the position of the found string (or start +1 if not found) |
used to test different results of function calls
the character under the cursor
decoded text
to stop the search when something is found or something is wrong
TRUE if something has been found, FALSE otherwise
Definition at line 566 of file ghex_heraia_interface.c.
References decode_parameters_t::endianness, ghex_get_data_position(), HERAIA_FIND_ALL, HERAIA_FIND_BACKWARD, HERAIA_FIND_FORWARD, and doc_t::hex_widget.
Referenced by ghex_find_decode().
doc_t* new_doc_t | ( | Heraia_Document * | hex_doc, |
GtkWidget * | hex_widget | ||
) |
Inits a doc_t structure.
hex_doc | : hex_document but encapsulated in Heraia_Document structure |
hex_widget | : Widget to display an hexadecimal view of the file |
Definition at line 809 of file ghex_heraia_interface.c.
References doc_t::hex_doc, doc_t::hex_widget, and doc_t::modified.
Referenced by create_find_or_replace_doc_t(), heraia_hex_document_new(), and on_new_activate().