Heraia  0.1.8
ghex_heraia_interface.h
Go to the documentation of this file.
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /*
3  ghex_heraia_interface.h
4  heraia - an hexadecimal file editor and analyser based on ghex
5 
6  (C) Copyright 2005 - 2011 Olivier Delhomme
7  e-mail : heraia@delhomme.org
8  URL : http://heraia.tuxfamily.org
9 
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2, or (at your option)
13  any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
23 /**
24  * @file ghex_heraia_interface.h
25  * Header file providing an interface to Heraia_Hex
26  */
27 #ifndef _GHEX_HERAIA_INTERFACE_H_
28 #define _GHEX_HERAIA_INTERFACE_H_
29 
30 extern gboolean ghex_memcpy(Heraia_Hex *gh, guint64 pos, guint len, guint endianness, guchar *result);
31 extern gboolean ghex_get_data(GtkWidget *hex_widget, guint length, guint endianness, guchar *c);
32 extern void ghex_set_data(doc_t *doc, guint64 position, guint rep_len, guint len, guchar *data);
33 
34 extern gboolean ghex_get_data_position(GtkWidget *hex_widget, guint64 pos, guint length, guint endianness, guchar *c);
35 
36 extern guchar *ghex_get_data_to_ascii(GtkWidget *hex_widget, guint64 pos, guint length, guint endianness);
37 extern guchar *ghex_get_data_to_hex(GtkWidget *hex_widget, guint64 pos, guint length, guint endianness);
38 
39 extern gint ghex_compare_data(doc_t *doc, guchar *string, guint buffer_size, guint64 position);
40 
41 extern doc_t *heraia_hex_document_new(heraia_struct_t *main_struct, char *filename);
42 extern HERAIA_ERROR heraia_hex_document_save(doc_t *current_doc);
43 extern HERAIA_ERROR heraia_hex_document_save_as(doc_t *current_doc, gchar *filename);
44 
46 extern gchar *doc_t_document_get_filename(doc_t *doc);
47 
48 extern guint64 ghex_file_size(Heraia_Hex *gh);
49 
50 extern guint64 ghex_get_cursor_position(GtkWidget *hex_widget);
51 extern void ghex_set_cursor_position(GtkWidget *hex_widget, guint64 position);
52 
53 extern gboolean ghex_find_forward(doc_t *doc, guchar *search_buffer, guint buffer_size, guint64 *position);
54 extern gboolean ghex_find_backward(doc_t *doc, guchar *search_buffer, guint buffer_size, guint64 *position);
55 
56 extern selection_t *ghex_get_selection(GtkWidget *hex_widget);
57 
58 extern doc_t *new_doc_t(Heraia_Document *hex_doc, GtkWidget *hex_widget);
59 extern void close_doc_t(doc_t *current_doc);
60 
61 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);
62 
63 
64 /* From libgtkhex */
65 #define is_displayable(c) (((c) >= 0x20) && ((c) < 0x7f))
66 
67 #endif /* _GHEX_HERAIA_INTERFACE_H_ */
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.
This is the main structure.
Definition: libheraia.h:332
gchar * heraia_hex_document_get_filename(Heraia_Document *hex_doc)
Retrieves the filename of a document which ever it is !
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 v...
HERAIA_ERROR heraia_hex_document_save_as(doc_t *current_doc, gchar *filename)
Saves an opened and edited document to a new file.
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.
void ghex_set_cursor_position(GtkWidget *hex_widget, guint64 position)
Sets the cursor at the defined position in the hexwidget.
Proposal for a structure that will group all informations about a single document.
Definition: libheraia.h:293
GtkHex Heraia_Hex
Abstract layer this may be usefull if we decide to leave Heraia_Hex and use something else ! ...
Definition: libheraia.h:77
A structure to manage a single selection.
Definition: libheraia.h:307
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.
void close_doc_t(doc_t *current_doc)
Closes a previously malloced doc_t structure.
doc_t * new_doc_t(Heraia_Document *hex_doc, GtkWidget *hex_widget)
Inits a doc_t structure.
HERAIA_ERROR heraia_hex_document_save(doc_t *current_doc)
gchar * doc_t_document_get_filename(doc_t *doc)
Retrieves from a doc_t * document it's filename, which ever it is.
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 d...
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.
gchar *(* DecodeFunc)(guchar *, gpointer)
Templates for the decoding functions.
Definition: libheraia.h:139
gint HERAIA_ERROR
Defines heraia error type (this should be used !)
Definition: libheraia.h:78
selection_t * ghex_get_selection(GtkWidget *hex_widget)
Retrieves the selection made (if any) in the hex widget.
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.
HexDocument Heraia_Document
Abstract layer this may be usefull if we decide to leave Heraia_Hex and use something else ! ...
Definition: libheraia.h:76
void ghex_set_data(doc_t *doc, guint64 position, guint rep_len, guint len, guchar *data)
Wrapper to the hex_document_set_data function.
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_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'.
guint64 ghex_file_size(Heraia_Hex *gh)
Returns the file size of an opened Heraia_Hex document.
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)...
guint64 ghex_get_cursor_position(GtkWidget *hex_widget)
Retrieves the cursor's position from the current hexwidget.
Used to pass decoding options to the functions.
Definition: libheraia.h:147