ghex_heraia_interface.c File Reference

An interface to the ghex library -> this adds an abstract layer. More...

#include <libheraia.h>
Include dependency graph for ghex_heraia_interface.c:

Go to the source code of this file.

Functions

doc_theraia_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'.
gchar * heraia_hex_document_get_filename (Heraia_Document *hex_doc)
 Retrieves the filename of a document which ever it is !
gchar * doc_t_document_get_filename (doc_t *doc)
 Retrieves from a doc_t * document it's filename, which ever it is.
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.
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.
gboolean ghex_memcpy (Heraia_Hex *gh, guint 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.
gboolean ghex_get_data (GtkWidget *hex_widget, guint length, guint endianness, guchar *c)
 Gets the data from the hexwidget, a wrapper to the ghex_memcpy function.
guint64 ghex_file_size (Heraia_Hex *gh)
 Returns the file size of an opened Heraia_Hex document.
guint64 ghex_get_cursor_position (GtkWidget *hex_widget)
 Retrieves the cursor's position from the current hexwidget.
selection_tghex_get_selection (GtkWidget *hex_widget)
 Retrieves the selection made (if any) in the hex widget.
doc_tnew_doc_t (Heraia_Document *hex_doc, GtkWidget *hex_widget)
 Inits a doc_t structure.

Detailed Description

An interface to the ghex library -> this adds an abstract layer.

Definition in file ghex_heraia_interface.c.


Function Documentation

static void change_endianness ( guint  len,
guint  endianness,
guchar *  result 
) [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.

Warning:
Assumption is made that the default order is LITTLE_ENDIAN (which may not be true on some systems !)
We do assume that 'result' really contains 'len' bytes of data previously gmalloc'ed
Parameters:
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 202 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().

Here is the call graph for this function:

Here is the caller graph for this function:

gchar* doc_t_document_get_filename ( doc_t doc  ) 

Retrieves from a doc_t * document it's filename, which ever it is.

Parameters:
doc : an existing doc_t
Returns:
returns the filename of that document.

Definition at line 94 of file ghex_heraia_interface.c.

References heraia_hex_document_get_filename(), and doc_t::hex_doc.

Referenced by on_save_activate(), on_save_as_activate(), realize_some_numerical_stat(), select_a_file_to_save(), select_file_to_load(), set_notebook_tab_name(), and update_main_struct_name().

Here is the call graph for this function:

Here is the caller graph for this function:

guint64 ghex_file_size ( Heraia_Hex gh  ) 

Returns the file size of an opened Heraia_Hex document.

Parameters:
gh : the widget of a an opened Heraia_Hex document
Returns:
returns the file size of that document

Definition at line 302 of file ghex_heraia_interface.c.

Referenced by ghex_memcpy(), populate_stats_histos(), and refresh_file_labels().

Here is the caller graph for this function:

guint64 ghex_get_cursor_position ( GtkWidget *  hex_widget  ) 

Retrieves the cursor's position from the current hexwidget.

Parameters:
hex_widget : the widget that displays the hex document
Returns:
returns the cursor's position

Definition at line 320 of file ghex_heraia_interface.c.

Referenced by refresh_file_labels().

Here is the caller graph for this function:

gboolean ghex_get_data ( GtkWidget *  hex_widget,
guint  length,
guint  endianness,
guchar *  c 
)

Gets the data from the hexwidget, a wrapper to the ghex_memcpy function.

Warning:
guchar *c MUST have been pre allocated BEFORE the call.
Parameters:
data_window : data interpretor window structure
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 279 of file ghex_heraia_interface.c.

References ghex_memcpy().

Referenced by interpret().

Here is the call graph for this function:

Here is the caller graph for this function:

selection_t* ghex_get_selection ( GtkWidget *  hex_widget  ) 

Retrieves the selection made (if any) in the hex widget.

Parameters:
hex_widget : the widget that displays the hex document
Returns:
returns a filed selection_t structure

Definition at line 340 of file ghex_heraia_interface.c.

References selection_t::end, and selection_t::start.

Referenced by refresh_file_labels().

Here is the caller graph for this function:

gboolean ghex_memcpy ( Heraia_Hex gh,
guint  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.

Warning:
We assume that a previous g_malloc has been done in order to use the function. Here we need the "swap_bytes" function defined in the decode.h header in order to take the endianness into account
Parameters:
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.
Returns:
TRUE if everything went ok, FALSE otherwise

Definition at line 239 of file ghex_heraia_interface.c.

References change_endianness(), and ghex_file_size().

Referenced by ghex_get_data().

Here is the call graph for this function:

Here is the caller graph for this function:

gchar* heraia_hex_document_get_filename ( Heraia_Document hex_doc  ) 

Retrieves the filename of a document which ever it is !

Parameters:
doc : an Heraia_Document
Returns:
returns the filename of that document.

Definition at line 76 of file ghex_heraia_interface.c.

Referenced by doc_t_document_get_filename().

Here is the caller graph for this function:

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'.

Parameters:
main_struct : main structure
filename : a char * representing an existing file named "filename"
Returns:
Always returns HERAIA_NOERR;
Todo:
: do something to take errors into account

Definition at line 39 of file ghex_heraia_interface.c.

References connect_cursor_moved_signal(), heraia_struct_t::documents, and new_doc_t().

Referenced by load_file_to_analyse().

Here is the call graph for this function:

Here is the caller graph for this function:

HERAIA_ERROR heraia_hex_document_save ( doc_t current_doc  ) 

Definition at line 113 of file ghex_heraia_interface.c.

References HERAIA_FILE_ERROR, HERAIA_NOERR, and doc_t::hex_doc.

Referenced by on_save_activate().

Here is the caller graph for this function:

HERAIA_ERROR heraia_hex_document_save_as ( doc_t current_doc,
gchar *  filename 
)

Saves an opened and edited document to a new file.

Parameters:
current_doc : current edited document (doc_t * structure)
filename : the new filename where to save the file
Returns:
returns HERAIA_NOERR if everything went ok or HERAIA_FILE_ERROR in case of an error

< to make libghex happy !

Definition at line 142 of file ghex_heraia_interface.c.

References HERAIA_FILE_ERROR, HERAIA_NOERR, and doc_t::hex_doc.

Referenced by on_save_as_activate().

Here is the caller graph for this function:

doc_t* new_doc_t ( Heraia_Document hex_doc,
GtkWidget *  hex_widget 
)

Inits a doc_t structure.

Parameters:
doc : hex_document but encapsulated in Heraia_Document structure
hexwidget : Widget to display an hexadecimal view of the file
Returns:
returns a newly allocated doc_t structure

Todo:
do a function to access this value

Definition at line 376 of file ghex_heraia_interface.c.

References doc_t::hex_doc, doc_t::hex_widget, and doc_t::modified.

Referenced by heraia_hex_document_new().

Here is the caller graph for this function:

Generated on Tue May 11 18:46:20 2010 for Heraia by  doxygen 1.6.3