00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ 00002 /* 00003 libheraia.h 00004 Heraia's library header 00005 00006 (C) Copyright 2008 - 2010 Sébastien Tricaud, Olivier Delhomme 00007 e-mail : heraia@delhomme.org 00008 URL : http://heraia.tuxfamily.org 00009 00010 This program is free software; you can redistribute it and/or modify 00011 it under the terms of the GNU General Public License as published by 00012 the Free Software Foundation; either version 2, or (at your option) 00013 any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 00023 /** 00024 * @file libheraia.h 00025 * 00026 * This file contains all the definitions and includes all other .h 00027 * files. This is not very friendly, but ease compilation on exotic 00028 * systems. 00029 */ 00030 #ifndef _LIBHERAIA_H_ 00031 #define _LIBHERAIA_H_ 00032 00033 /* I have some problems under windows if #ifdef statement is activated */ 00034 00035 /* #ifdef HAVE_CONFIG_H */ 00036 #include "config.h" 00037 /* #endif */ /* HAVE_CONFIG_H */ 00038 00039 00040 #include <stdio.h> 00041 #include <stdlib.h> 00042 #include <string.h> 00043 #include <time.h> 00044 #include <unistd.h> 00045 #include <sys/types.h> 00046 #include <sys/stat.h> 00047 #include <getopt.h> 00048 00049 #include <glib.h> 00050 #include <glib/gstdio.h> 00051 #include <glib/gi18n-lib.h> 00052 #include <gmodule.h> 00053 00054 #include <gtkhex/gtkhex.h> 00055 00056 /** 00057 * @typedef HexDocument Heraia_Document 00058 * Abstract layer this may be usefull if we decide to leave Heraia_Hex 00059 * and use something else ! 00060 * 00061 * @typedef Heraia_Hex Heraia_Hex 00062 * Abstract layer this may be usefull if we decide to leave Heraia_Hex 00063 * and use something else ! 00064 */ 00065 /** 00066 * @typedef gint HERAIA_ERROR 00067 * Defines heraia error type (this should be used !) 00068 */ 00069 typedef HexDocument Heraia_Document; 00070 typedef GtkHex Heraia_Hex; 00071 typedef gint HERAIA_ERROR; 00072 00073 /** 00074 * @typedef gint RefreshType 00075 * Refresh type (may be used to decide what to do 00076 * in a particular case) 00077 * @warning This is not thread safe !! 00078 */ 00079 /** 00080 * @def HERAIA_REFRESH_NOTHING 00081 * When nothing is refreshed 00082 * 00083 * @def HERAIA_REFRESH_NEW_FILE 00084 * When a new file has been loaded 00085 * 00086 * @def HERAIA_REFRESH_CURSOR_MOVE 00087 * When the cursor is moving 00088 * 00089 * @def HERAIA_REFRESH_TAB_CHANGED 00090 * When user selects another tab in main notebook 00091 */ 00092 typedef gint RefreshType; 00093 #define HERAIA_REFRESH_NOTHING 0 00094 #define HERAIA_REFRESH_NEW_FILE 1 00095 #define HERAIA_REFRESH_CURSOR_MOVE 2 00096 #define HERAIA_REFRESH_TAB_CHANGED 3 00097 00098 00099 /** 00100 * @struct date_and_time_t 00101 * A human struct to store a date with a time. 00102 * @todo add an UTC info field 00103 */ 00104 typedef struct 00105 { 00106 guint32 year; 00107 guint32 month; 00108 guint32 day; 00109 00110 guint32 hour; 00111 guint32 minutes; 00112 guint32 seconds; 00113 } date_and_time_t; 00114 00115 00116 /** Templates for the decoding functions */ 00117 typedef gchar *(* DecodeFunc) (guchar *, gpointer); /**< Decode function template */ 00118 00119 00120 /** 00121 * @struct decode_parameters_t 00122 * Used to pass decoding options to the functions. Those options are evaluated 00123 * from data_interpretor's window 00124 */ 00125 typedef struct 00126 { 00127 guint endianness; /**< endianness */ 00128 guint stream_size; /**< stream_size */ 00129 } decode_parameters_t; 00130 00131 00132 /** 00133 * @struct decode_t 00134 * Basic way to associate a decode function and an entry that will receive the 00135 * result 00136 * @warning this structure is subject to changes 00137 */ 00138 typedef struct 00139 { 00140 DecodeFunc func; /**< a function to decode into something */ 00141 GtkWidget *entry; /**< the widget that will receive the result */ 00142 gchar *err_msg; /**< error message if something went wrong when decoding 00143 expects a %d somewhere in the message to represents 00144 the stream lenght to be decoded */ 00145 } decode_t; 00146 00147 00148 /** 00149 * @struct decode_generic_t 00150 * Basic way to have as many as we want decoding functions corresponding to one 00151 * label. This structure is basicaly one row in the data intrepretor window 00152 * @warning this structure is subject to changes 00153 */ 00154 typedef struct 00155 { 00156 GPtrArray *decode_array; /**< Pointer Array of decode_t functions and corresponding entries */ 00157 GtkWidget *label; /**< label for these decoding functions */ 00158 guint data_size; /**< size of what we may decode */ 00159 gboolean fixed_size; /**< says whether we can modify data_size or not */ 00160 } decode_generic_t; 00161 00162 00163 /** 00164 * @struct tab_t 00165 * Tabulation structure to be used in the GtkNoteBook of 00166 * data_interpretor's window 00167 */ 00168 typedef struct 00169 { 00170 guint index; /**< number for this tab */ 00171 guint nb_cols; /**< number of columns in this tab - this MUST NOT change in any way */ 00172 guint nb_rows; /**< number of rows in this tab - this is automatically updated */ 00173 GtkWidget *label; /**< label for this tab */ 00174 GPtrArray *col_labels; /**< array of GtkWidgets of columns labels */ 00175 GPtrArray *vboxes; /**< array of vboxes where we will pack label and entry widgets */ 00176 GPtrArray *rows; /**< array of pointers to decode_generic_t variables. */ 00177 } tab_t; 00178 00179 00180 /** 00181 * @struct data_window_t 00182 * Data interpretor window structure 00183 */ 00184 typedef struct 00185 { 00186 GtkWidget *diw; /**< data interpretor window */ 00187 gint tab_displayed; /**< keeps the last displayed tab's number before closing */ 00188 guint nb_tabs; /**< keeps Number of tabs in the GPtrArray */ 00189 GPtrArray *tabs; /**< an array of tabs displayed in data interpretor's notebook */ 00190 } data_window_t; 00191 00192 00193 /** 00194 * @struct xml_t 00195 * Structure that contains all the xml definitions loaded at 00196 * running time using GtkBuilder 00197 */ 00198 typedef struct 00199 { 00200 GtkBuilder *main; /**< the main interface xml description */ 00201 } xml_t; 00202 00203 00204 /** 00205 * @def WPT_DEFAULT_HEIGHT 00206 * Defines the default height for a window (set in window_prop_t) 00207 * 00208 * @def WPT_DEFAULT_WIDTH 00209 * Defines the default width for a window (set in window_prop_t) 00210 */ 00211 #define WPT_DEFAULT_HEIGHT 200 00212 #define WPT_DEFAULT_WIDTH 200 00213 00214 00215 /** 00216 * @struct window_prop_t 00217 * Window properties 00218 * - position (x,y) record window's position 00219 * - displayed (boolean) say whether the window is displayed or not 00220 */ 00221 typedef struct 00222 { 00223 gint x; /**< x position (upper left corner) */ 00224 gint y; /**< y position (upper left corner) */ 00225 guint height; /**< y+height (bottom right corner) */ 00226 guint width; /**< x+width (bottom right corner) */ 00227 gboolean displayed; /**< TRUE if displayed, FALSE otherwise */ 00228 } window_prop_t; 00229 00230 00231 /** 00232 * @struct all_window_prop_t 00233 * Structure to keep window properties for each window 00234 */ 00235 typedef struct 00236 { 00237 window_prop_t *about_box; 00238 window_prop_t *data_interpretor; /**< data interpretor window */ 00239 window_prop_t *log_box; /**< log window */ 00240 window_prop_t *main_dialog; /**< heraia's main window */ 00241 window_prop_t *plugin_list; /**< plugin description window */ 00242 window_prop_t *ldt; /**< list data types window */ 00243 window_prop_t *main_pref_window; /**< main preference window */ 00244 } all_window_prop_t; 00245 00246 00247 /** 00248 * @struct prefs_t 00249 * Data type related to preferences 00250 */ 00251 typedef struct 00252 { 00253 gchar *filename; /**< user preference file file name */ 00254 gchar *pathname; /**< user preference file path name */ 00255 GKeyFile *file; /**< preference file contents */ 00256 } prefs_t; 00257 00258 00259 /** 00260 * @struct doc_t 00261 * Proposal for a structure that will group all informations about 00262 * a single document. This structure is managed in heraia_io.c 00263 */ 00264 typedef struct 00265 { 00266 Heraia_Document *hex_doc; /**< Document definition related to libHeraia_Hex */ 00267 GtkWidget *hex_widget; /**< hexwidget corresponding to the document */ 00268 gboolean modified; /**< If hex_doc->changed <> modified then the 00269 document has something changed that may need 00270 an upate */ 00271 } doc_t; 00272 00273 00274 /** 00275 * @struct selection_t 00276 * A structure to manage a single selection 00277 */ 00278 typedef struct 00279 { 00280 guint64 start; /**< Starting position of the selection */ 00281 guint64 end; /**< Ending position of the selection */ 00282 } selection_t; 00283 00284 00285 /** 00286 * @struct heraia_struct_t 00287 * This is the main structure. It contains all things that the program needs 00288 */ 00289 typedef struct 00290 { 00291 gboolean debug; /**< Used to tell the program wether we want to display debug messages or not */ 00292 doc_t *current_doc; /**< This is a pointer to the current edited document */ 00293 GPtrArray *documents; /**< An array of doc_t in order to be able to open more than one doc */ 00294 xml_t *xmls; /**< All the xmls used in the program, loaded at running time */ 00295 data_window_t *current_DW; /**< data_interpretor pointer */ 00296 GList *location_list; /**< this is the location list where we store some paths */ 00297 GList *plugins_list; /**< A list of plugins */ 00298 RefreshType event; /**< Tells what is happening */ 00299 all_window_prop_t *win_prop; /**< Keeps window properties */ 00300 prefs_t *prefs; /**< All datas related to main preferences */ 00301 } heraia_struct_t; 00302 00303 00304 #include "data_interpretor.h" 00305 #include "decode.h" 00306 #include "ghex_heraia_interface.h" 00307 #include "heraia_errors.h" 00308 #include "heraia_io.h" 00309 #include "heraia_ui.h" 00310 #include "log.h" 00311 #include "main_pref_window.h" 00312 #include "plugin.h" 00313 #include "plugin_list.h" 00314 #include "user_prefs.h" 00315 #include "tests.h" 00316 00317 00318 extern int libheraia_test(void); 00319 00320 /** 00321 * Python specific 00322 */ 00323 extern void libheraia_initialize(void); 00324 extern void libheraia_finalize(void); 00325 00326 #endif /* _LIBHERAIA_H_ */