libheraia.h

Go to the documentation of this file.
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  *  @todo Transform this to a list of properties and add values to distinguish
00235  *        between windows ?
00236  */
00237 typedef struct
00238 {
00239     window_prop_t *about_box;
00240     window_prop_t *data_interpretor;  /**< data interpretor window   */
00241     window_prop_t *log_box;           /**< log window                */
00242     window_prop_t *main_dialog;       /**< heraia's main window      */
00243     window_prop_t *plugin_list;       /**< plugin description window */
00244     window_prop_t *ldt;               /**< list data types window    */
00245     window_prop_t *main_pref_window;  /**< main preference window    */
00246     window_prop_t *goto_window;       /**< goto dialog window        */
00247     window_prop_t *result_window;     /**< result window properties  */
00248     window_prop_t *find_window;       /**< find window               */
00249     window_prop_t *fr_window;         /**< find and replace window   */
00250 } all_window_prop_t;
00251 
00252 
00253 /**
00254  * @struct prefs_t
00255  *  Data type related to preferences
00256  */
00257 typedef struct
00258 {
00259    gchar *filename;    /**< user preference file file name   */
00260    gchar *pathname;    /**< user preference file path name   */
00261    GKeyFile *file;     /**< preference file contents         */
00262 } prefs_t;
00263 
00264 
00265 /**
00266  * @struct doc_t
00267  * Proposal for a structure that will group all informations about
00268  * a single document. This structure is managed in heraia_io.c
00269  */
00270 typedef struct
00271 {
00272     Heraia_Document *hex_doc;  /**< Document definition related to libHeraia_Hex */
00273     GtkWidget *hex_widget;     /**< hexwidget corresponding to the document      */
00274     gboolean modified;         /**< If hex_doc->changed <> modified then the
00275                                     document has something changed that may need
00276                                     an upate                                     */
00277 } doc_t;
00278 
00279 
00280 /**
00281  * @struct selection_t
00282  * A structure to manage a single selection
00283  */
00284 typedef struct
00285 {
00286     guint64 start;  /**< Starting position of the selection */
00287     guint64 end;    /**< Ending position of the selection   */
00288 } selection_t;
00289 
00290 
00291 /**
00292  * @struct heraia_struct_t
00293  *  This is the main structure. It contains all things that the program needs
00294  *  results GPtrArray stores the pointer of the corresponding document from
00295  *  which the search took place.
00296  */
00297 typedef struct
00298 {
00299     gboolean  debug;                /**< Used to tell the program wether we want to display debug messages or not  */
00300     doc_t *current_doc;             /**< This is a pointer to the current edited document                          */
00301     GPtrArray *documents;           /**< An array of doc_t in order to be able to open more than one doc           */
00302     xml_t *xmls;                    /**< All the xmls used in the program, loaded at running time                  */
00303     data_window_t *current_DW;      /**< data_interpretor pointer                                                  */
00304     GList *location_list;           /**< this is the location list where we store some paths                       */
00305     GList *plugins_list;            /**< A list of plugins                                                         */
00306     RefreshType event;              /**< Tells what is happening                                                   */
00307     all_window_prop_t *win_prop;    /**< Keeps window properties                                                   */
00308     prefs_t *prefs;                 /**< All datas related to main preferences                                     */
00309     doc_t *find_doc;                /**< find document and hexwidget for find window                               */
00310     doc_t *fr_find_doc;             /**< find and replace window, find document and hexwidget                      */
00311     doc_t *fr_replace_doc;          /**< find and replace window, replace document and hexwidget                   */
00312     GPtrArray *results;             /**< An array of pointers for each tab in the result window.                   */
00313 } heraia_struct_t;
00314 
00315 
00316 #include "data_interpretor.h"
00317 #include "decode.h"
00318 #include "ghex_heraia_interface.h"
00319 #include "heraia_errors.h"
00320 #include "heraia_io.h"
00321 #include "heraia_ui.h"
00322 #include "log.h"
00323 #include "main_pref_window.h"
00324 #include "plugin.h"
00325 #include "plugin_list.h"
00326 #include "user_prefs.h"
00327 #include "tests.h"
00328 #include "goto_dialog.h"
00329 #include "result_window.h"
00330 #include "find_replace_window.h"
00331 
00332 
00333 extern int libheraia_test(void);
00334 
00335 /**
00336  * Python specific
00337  */
00338 extern void libheraia_initialize(void);
00339 extern void libheraia_finalize(void);
00340 
00341 #endif /* _LIBHERAIA_H_ */
Generated on Sat Oct 30 18:31:55 2010 for Heraia by  doxygen 1.6.3