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 data_window_t 00089 * Data interpretor window structure 00090 */ 00091 typedef struct 00092 { 00093 /** Current Hexwidget that we want data to be interpreted */ 00094 GtkWidget *current_hexwidget; /** @todo we may want to move this from here to heraia_window_t structure */ 00095 GtkWidget *diw; /**< data interpretor window */ 00096 00097 /* gboolean window_displayed; says whether the window is displayed or not */ 00098 gint tab_displayed; /**< keeps the last displayed tab's number before closing */ 00099 00100 } data_window_t; 00101 00102 /* Treatment Stuff (if one wants to add new data types) */ 00103 typedef GList *(* TreatmentDoFunc) (GList *); /**< Treatment function called while operating the treatment */ 00104 typedef void (* TreatmentInitFunc) (gpointer); /**< Treatment init function */ 00105 typedef void (* TreatmentDelFunc) (gpointer); /**< Treatment delete function */ 00106 typedef gpointer (*TreatmentCopyFunc) (gpointer); /**< Treatment copy function that have to copy internal 00107 structures (widgets and all stuff in it) */ 00108 /** 00109 * @struct treatment_t 00110 * Treatment structure 00111 * @warning I'm not happy with this struct and all data_type.c file. I plan 00112 * to replace thoses ugly things with an embedded scripting language 00113 * such as python. 00114 */ 00115 typedef struct 00116 { 00117 gchar *name; /**< Treatment name */ 00118 TreatmentDoFunc do_it; /**< Treatment function that manages the whole treatment (interface + treatment itself) */ 00119 TreatmentInitFunc init; /**< inits the interface */ 00120 TreatmentDelFunc kill; /**< kills the treatment itself */ 00121 TreatmentCopyFunc copy; /**< Copy the gpointer data sub structure of the treatment itself */ 00122 gpointer data; /**< Generic treatment data. Each instantiated treatment may have it's own */ 00123 } treatment_t; 00124 00125 /** 00126 * @struct treatment_container_t 00127 * Structure in order to contain one treatment 00128 * @warning I'm not happy with this struct and all data_type.c file. I plan 00129 * to replace thoses ugly things with an embedded scripting language 00130 * such as python. 00131 */ 00132 typedef struct 00133 { 00134 GtkWidget *container_box; /**< Upper box containing the whole stuff */ 00135 GtkWidget *button_box; /**< Right part of the hbox. Contains "-", GtkEntry, "+" */ 00136 GtkWidget *combo_box; /**< Left box where we have the combobox */ 00137 GtkWidget *tment_list; /**< Combobox containning the treatment list */ 00138 GtkWidget *result; /**< The GtkEntry in the vbox */ 00139 GtkWidget *moins; /**< "-" button */ 00140 GtkWidget *plus; /**< "+" button */ 00141 treatment_t *treatment; /**< Selected treatment */ 00142 } treatment_container_t; 00143 00144 /** 00145 * @struct data_type_t 00146 * Data type structure entry that contains user defined data types 00147 * This is integrated within a GList. 00148 * !! Do not forget to update the functions related to this such as 00149 * - new_data_type 00150 * - free_data_type 00151 * - copy_data_type 00152 * See data_type.c for thoses functions 00153 * @warning I'm not happy with this struct and all data_type.c file. I plan 00154 * to replace thoses ugly things with an embedded scripting language 00155 * such as python. 00156 */ 00157 typedef struct 00158 { 00159 gchar *name; /**< Name of the data type */ 00160 guint size; /**< size of the data type (here we may limit size entry, eg <= 16 for example) */ 00161 GList *treatment_c_list; /**< Treatments containers to be applied (in the list order) to the data 00162 (treatment_container_t *) */ 00163 GtkWidget *di_label; /**< label for the data_interpretor window */ 00164 GtkWidget *di_entry; /**< entry for the data interpretor window */ 00165 } data_type_t; 00166 00167 00168 /** 00169 * @struct xml_t 00170 * Structure that contains all the xml definitions loaded at 00171 * running time using libglade 00172 */ 00173 typedef struct 00174 { 00175 GladeXML *main; /**< the main interface xml description */ 00176 } xml_t; 00177 00178 /** 00179 * @struct window_prop_t 00180 * Window properties 00181 * - position (x,y) record window's position 00182 * - displayed (boolean) say whether the window is displayed or not 00183 */ 00184 typedef struct 00185 { 00186 gint x; /**< x position (upper left corner) */ 00187 gint y; /**< y position (upper left croner) */ 00188 gboolean displayed; /**< TRUE if displayed, FALSE otherwise */ 00189 } window_prop_t; 00190 00191 /** 00192 * @struct all_window_prop_t 00193 * Structure to keep window properties for each window 00194 */ 00195 typedef struct 00196 { 00197 window_prop_t *about_box; 00198 window_prop_t *data_interpretor; /**< data interpretor window */ 00199 window_prop_t *log_box; /**< log window */ 00200 window_prop_t *main_dialog; /**< heraia's main window */ 00201 window_prop_t *plugin_list; /**< plugin description window */ 00202 window_prop_t *ldt; /**< list data types window */ 00203 window_prop_t *main_pref_window; /**< main preference window */ 00204 } all_window_prop_t; 00205 00206 /** 00207 * @struct prefs_t 00208 * Data type related to preferences 00209 */ 00210 typedef struct 00211 { 00212 gchar *filename; /**< user preference file file name */ 00213 gchar *pathname; /**< user preference file path name */ 00214 GKeyFile *file; /**< preference file contents */ 00215 } prefs_t; 00216 00217 /** 00218 * @struct heraia_window_t 00219 * This is the main structure (mainly named main_window due to historycal reasons) 00220 * It contains all things that the program needs 00221 */ 00222 typedef struct 00223 { 00224 gboolean debug; /**< Used to tell the program wether we want to display debug messages or not */ 00225 gchar *filename; /**< this could (should) be a list of filenames !!! */ 00226 Heraia_Document *current_doc; /**< We may want to group this with current_hexwidget in a specific struct */ 00227 xml_t *xmls; /**< All the xmls used in the program, loaded at running time */ 00228 data_window_t *current_DW; /**< data_interpretor pointer */ 00229 GList *location_list; /**< this is the location list where we store some paths */ 00230 GList *plugins_list; /**< A list of plugins */ 00231 GList *data_type_list; /**< A list of data types */ 00232 data_type_t *current_data_type; /**< data type that is being edited */ 00233 GList *available_treatment_list;/**< Available treatments that can be used by the user in the data type window */ 00234 RefreshType event; /**< Tells what is happening */ 00235 all_window_prop_t *win_prop; /**< Keeps window properties */ 00236 prefs_t *prefs; /**< All datas related to main preferences */ 00237 } heraia_window_t; 00238 00239 #include "config.h" 00240 #include "data_interpretor.h" 00241 #include "data_type.h" 00242 #include "decode.h" 00243 #include "ghex_heraia_interface.h" 00244 #include "heraia_errors.h" 00245 #include "heraia_io.h" 00246 #include "heraia_ui.h" 00247 #include "list_data_types.h" 00248 #include "log.h" 00249 #include "main_pref_window.h" 00250 #include "plugin.h" 00251 #include "plugin_list.h" 00252 #include "treatments.h" 00253 #include "user_prefs.h" 00254 00255 extern int libheraia_test(void); 00256 00257 /** 00258 * Python specific 00259 */ 00260 extern void libheraia_initialize(void); 00261 extern void libheraia_finalize(void); 00262 00263 #endif /* _LIBHERAIA_H_ */