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 - 2009 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 * file. This is not very friendly, but ease compilation on exotic 00028 * systems. 00029 */ 00030 #ifndef _LIBHERAIA_H_ 00031 #define _LIBHERAIA_H_ 00032 00033 #include <stdio.h> 00034 #include <stdlib.h> 00035 #include <string.h> 00036 #include <time.h> 00037 #include <unistd.h> 00038 #include <sys/types.h> 00039 #include <sys/stat.h> 00040 #include <getopt.h> 00041 00042 #include <glib.h> 00043 #include <glib/gstdio.h> 00044 #include <glade/glade.h> 00045 #include <gmodule.h> 00046 00047 #include <gtkhex/gtkhex.h> 00048 00049 /** 00050 * @typedef HexDocument Heraia_Document 00051 * Abstract layer this may be usefull if we decide to leave GtkHex 00052 * and use something else ! 00053 * 00054 * @typedef GtkHex Heraia_Hex 00055 * Abstract layer this may be usefull if we decide to leave GtkHex 00056 * and use something else ! 00057 */ 00058 /** 00059 * @typedef gint HERAIA_ERROR 00060 * Defines heraia error type (this should be used !) 00061 */ 00062 typedef HexDocument Heraia_Document; 00063 typedef GtkHex Heraia_Hex; 00064 typedef gint HERAIA_ERROR; 00065 00066 /** 00067 * @typedef gint RefreshType 00068 * Refresh type (may be used to decide what to do 00069 * in a particular case) 00070 * @warning This is not thread safe !! 00071 */ 00072 /** 00073 * @def HERAIA_REFRESH_NOTHING 00074 * When nothing is refreshed 00075 * 00076 * @def HERAIA_REFRESH_NEW_FILE 00077 * When a new file has been loaded 00078 * 00079 * @def HERAIA_REFRESH_CURSOR_MOVE 00080 * When the cursor is moving 00081 */ 00082 typedef gint RefreshType; 00083 #define HERAIA_REFRESH_NOTHING 0 00084 #define HERAIA_REFRESH_NEW_FILE 1 00085 #define HERAIA_REFRESH_CURSOR_MOVE 2 00086 00087 /** 00088 * @struct date_and_time_t 00089 * A human struct to store a date with a time. 00090 * @todo add an UTC info field 00091 */ 00092 typedef struct 00093 { 00094 guint32 year; 00095 guint32 month; 00096 guint32 day; 00097 00098 guint32 hour; 00099 guint32 minutes; 00100 guint32 seconds; 00101 } date_and_time_t; 00102 00103 00104 /** Templates for the decoding functions */ 00105 typedef gchar *(* DecodeFunc) (guchar *, gpointer); /**< Decode function template */ 00106 00107 /** 00108 * @struct decode_parameters_t 00109 * Used to pass decoding options to the functions. Those options are evaluated 00110 * from data_interpretor's window 00111 */ 00112 typedef struct 00113 { 00114 guint endianness; /**< endianness */ 00115 guint stream_size; /**< stream_size */ 00116 } decode_parameters_t; 00117 00118 /** 00119 * @struct decode_t 00120 * Basic way to associate a decode function and an entry that will receive the 00121 * result 00122 * @warning this structure is subject to changes 00123 */ 00124 typedef struct 00125 { 00126 DecodeFunc func; /**< a function to decode into something */ 00127 GtkWidget *entry; /**< the widget that will receive the result */ 00128 } decode_t; 00129 00130 00131 /** 00132 * @struct decode_generic_t 00133 * Basic way to have as many as we want decoding functions corresponding to one 00134 * label. This Structure is basicaly one row in the data intrepretor window 00135 * @warning this structure is subject to changes 00136 */ 00137 typedef struct 00138 { 00139 GPtrArray *decode_array; /**< Pointer Array of decode_t functions and corresponding entries */ 00140 GtkWidget *label; /**< label for these decoding functions */ 00141 guint data_size; /**< size of what we may decode */ 00142 gboolean fixed_size; /**< says whether we can modify data_size or not */ 00143 } decode_generic_t; 00144 00145 00146 /** 00147 * @struct tab_t 00148 * Tabulation structure to be used in the GtkNoteBook of 00149 * data_interpretor's window 00150 */ 00151 typedef struct 00152 { 00153 guint index; /**< number for this tab */ 00154 guint nb_cols; /**< number of columns in this tab - this MUST NOT change in any way */ 00155 guint nb_rows; /**< number of rows in this tab - this is automatically updated */ 00156 GtkWidget *label; /**< label for this tab */ 00157 GPtrArray *col_labels; /**< array of GtkWidgets of columns labels */ 00158 GPtrArray *vboxes; /**< array of vboxes where we will pack label and entry widgets */ 00159 GPtrArray *rows; /**< array of pointers to decode_generic_t variables. */ 00160 } tab_t; 00161 00162 /** 00163 * @struct data_window_t 00164 * Data interpretor window structure 00165 */ 00166 typedef struct 00167 { 00168 /** Current Hexwidget that we want data to be interpreted */ 00169 GtkWidget *current_hexwidget; /** @todo we may want to move this from here to heraia_window_t structure */ 00170 GtkWidget *diw; /**< data interpretor window */ 00171 gint tab_displayed; /**< keeps the last displayed tab's number before closing */ 00172 guint nb_tabs; /**< keeps Number of tabs in the GPtrArray */ 00173 GPtrArray *tabs; /**< an array of tabs displayed in data interpretor's notebook */ 00174 } data_window_t; 00175 00176 /* Treatment Stuff (if one wants to add new data types) */ 00177 typedef GList *(* TreatmentDoFunc) (GList *); /**< Treatment function called while operating the treatment */ 00178 typedef void (* TreatmentInitFunc) (gpointer); /**< Treatment init function */ 00179 typedef void (* TreatmentDelFunc) (gpointer); /**< Treatment delete function */ 00180 typedef gpointer (*TreatmentCopyFunc) (gpointer); /**< Treatment copy function that have to copy internal 00181 structures (widgets and all stuff in it) */ 00182 /** 00183 * @struct treatment_t 00184 * Treatment structure 00185 * @warning I'm not happy with this struct and all data_type.c file. I plan 00186 * to replace thoses ugly things with an embedded scripting language 00187 * such as python. 00188 */ 00189 typedef struct 00190 { 00191 gchar *name; /**< Treatment name */ 00192 TreatmentDoFunc do_it; /**< Treatment function that manages the whole treatment (interface + treatment itself) */ 00193 TreatmentInitFunc init; /**< inits the interface */ 00194 TreatmentDelFunc kill; /**< kills the treatment itself */ 00195 TreatmentCopyFunc copy; /**< Copy the gpointer data sub structure of the treatment itself */ 00196 gpointer data; /**< Generic treatment data. Each instantiated treatment may have it's own */ 00197 } treatment_t; 00198 00199 /** 00200 * @struct treatment_container_t 00201 * Structure in order to contain one treatment 00202 * @warning I'm not happy with this struct and all data_type.c file. I plan 00203 * to replace thoses ugly things with an embedded scripting language 00204 * such as python. 00205 */ 00206 typedef struct 00207 { 00208 GtkWidget *container_box; /**< Upper box containing the whole stuff */ 00209 GtkWidget *button_box; /**< Right part of the hbox. Contains "-", GtkEntry, "+" */ 00210 GtkWidget *combo_box; /**< Left box where we have the combobox */ 00211 GtkWidget *tment_list; /**< Combobox containning the treatment list */ 00212 GtkWidget *result; /**< The GtkEntry in the vbox */ 00213 GtkWidget *moins; /**< "-" button */ 00214 GtkWidget *plus; /**< "+" button */ 00215 treatment_t *treatment; /**< Selected treatment */ 00216 } treatment_container_t; 00217 00218 /** 00219 * @struct data_type_t 00220 * Data type structure entry that contains user defined data types 00221 * This is integrated within a GList. 00222 * !! Do not forget to update the functions related to this such as 00223 * - new_data_type 00224 * - free_data_type 00225 * - copy_data_type 00226 * See data_type.c for thoses functions 00227 * @warning I'm not happy with this struct and all data_type.c file. I plan 00228 * to replace thoses ugly things with an embedded scripting language 00229 * such as python. 00230 */ 00231 typedef struct 00232 { 00233 gchar *name; /**< Name of the data type */ 00234 guint size; /**< size of the data type (here we may limit size entry, eg <= 16 for example) */ 00235 GList *treatment_c_list; /**< Treatments containers to be applied (in the list order) to the data 00236 (treatment_container_t *) */ 00237 GtkWidget *di_label; /**< label for the data_interpretor window */ 00238 GtkWidget *di_entry; /**< entry for the data interpretor window */ 00239 } data_type_t; 00240 00241 00242 /** 00243 * @struct xml_t 00244 * Structure that contains all the xml definitions loaded at 00245 * running time using libglade 00246 */ 00247 typedef struct 00248 { 00249 GladeXML *main; /**< the main interface xml description */ 00250 } xml_t; 00251 00252 00253 /** 00254 * @def WPT_DEFAULT_HEIGHT 00255 * Defines the default height for a window (set in window_prop_t) 00256 * 00257 * @def WPT_DEFAULT_WIDTH 00258 * Defines the default width for a window (set in window_prop_t) 00259 */ 00260 #define WPT_DEFAULT_HEIGHT 200 00261 #define WPT_DEFAULT_WIDTH 200 00262 00263 /** 00264 * @struct window_prop_t 00265 * Window properties 00266 * - position (x,y) record window's position 00267 * - displayed (boolean) say whether the window is displayed or not 00268 */ 00269 typedef struct 00270 { 00271 gint x; /**< x position (upper left corner) */ 00272 gint y; /**< y position (upper left corner) */ 00273 guint height; /**< y+height (bottom right corner) */ 00274 guint width; /**< x+width (bottom right corner) */ 00275 gboolean displayed; /**< TRUE if displayed, FALSE otherwise */ 00276 } window_prop_t; 00277 00278 /** 00279 * @struct all_window_prop_t 00280 * Structure to keep window properties for each window 00281 */ 00282 typedef struct 00283 { 00284 window_prop_t *about_box; 00285 window_prop_t *data_interpretor; /**< data interpretor window */ 00286 window_prop_t *log_box; /**< log window */ 00287 window_prop_t *main_dialog; /**< heraia's main window */ 00288 window_prop_t *plugin_list; /**< plugin description window */ 00289 window_prop_t *ldt; /**< list data types window */ 00290 window_prop_t *main_pref_window; /**< main preference window */ 00291 } all_window_prop_t; 00292 00293 /** 00294 * @struct prefs_t 00295 * Data type related to preferences 00296 */ 00297 typedef struct 00298 { 00299 gchar *filename; /**< user preference file file name */ 00300 gchar *pathname; /**< user preference file path name */ 00301 GKeyFile *file; /**< preference file contents */ 00302 } prefs_t; 00303 00304 /** 00305 * @struct heraia_window_t 00306 * This is the main structure (mainly named main_window due to historycal reasons) 00307 * It contains all things that the program needs 00308 */ 00309 typedef struct 00310 { 00311 gboolean debug; /**< Used to tell the program wether we want to display debug messages or not */ 00312 gchar *filename; /**< this could (should) be a list of filenames !!! */ 00313 Heraia_Document *current_doc; /**< We may want to group this with current_hexwidget in a specific struct */ 00314 xml_t *xmls; /**< All the xmls used in the program, loaded at running time */ 00315 data_window_t *current_DW; /**< data_interpretor pointer */ 00316 GList *location_list; /**< this is the location list where we store some paths */ 00317 GList *plugins_list; /**< A list of plugins */ 00318 GList *data_type_list; /**< A list of data types */ 00319 data_type_t *current_data_type; /**< data type that is being edited */ 00320 GList *available_treatment_list;/**< Available treatments that can be used by the user in the data type window */ 00321 RefreshType event; /**< Tells what is happening */ 00322 all_window_prop_t *win_prop; /**< Keeps window properties */ 00323 prefs_t *prefs; /**< All datas related to main preferences */ 00324 } heraia_window_t; 00325 00326 #include "config.h" 00327 #include "data_interpretor.h" 00328 #include "data_type.h" 00329 #include "decode.h" 00330 #include "ghex_heraia_interface.h" 00331 #include "heraia_errors.h" 00332 #include "heraia_io.h" 00333 #include "heraia_ui.h" 00334 #include "list_data_types.h" 00335 #include "log.h" 00336 #include "main_pref_window.h" 00337 #include "plugin.h" 00338 #include "plugin_list.h" 00339 #include "treatments.h" 00340 #include "user_prefs.h" 00341 00342 extern int libheraia_test(void); 00343 00344 /** 00345 * Python specific 00346 */ 00347 extern void libheraia_initialize(void); 00348 extern void libheraia_finalize(void); 00349 00350 #endif /* _LIBHERAIA_H_ */