42 static gboolean
usage(
int status);
90 static gboolean
usage(
int status)
94 fprintf (stderr, Q_(
"Try `heraia --help' for more information.\n"));
101 fprintf(stdout, Q_(
"\nheraia is a simple hexadecimal file editor and file analyser"));
102 fprintf(stdout, Q_(
"\nUsage :\n heraia [options] filename(s)\n"));
103 fprintf(stdout, Q_(
"\nOptions :\n"));
104 fprintf(stdout, Q_(
" -h, --help\tThis help.\n"));
105 fprintf(stdout, Q_(
" -v, --version\tProgram version information.\n"));
106 fprintf(stdout, Q_(
" -t, --tests=TESTS\tRuns some tests.\n"));
107 fprintf(stdout, Q_(
" TESTS might be :\n"));
109 fprintf(stdout, Q_(
" %d for loading files tests\n"),
LOADING_TESTS);
135 window_p->
height = height;
136 window_p->
width = width;
215 if (main_struct == NULL)
217 fprintf(stderr, Q_(
"Main structure could not be initialiazed !"));
218 fprintf(stderr, Q_(
"Do you have a memory problem ?\n"));
223 main_struct->
prefs =
init_preference_struct(g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(),
"heraia", NULL),
"main_preferences");
239 main_struct->
xmls = xmls;
250 main_struct->
documents = g_ptr_array_new();
256 main_struct->
results = g_ptr_array_new();
257 main_struct->
fdft = NULL;
260 libheraia_main_struct = main_struct;
280 log_message(main_struct, G_LOG_LEVEL_INFO, Q_(
"Enabling plugins"));
284 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"Inits the plugin list window"));
291 log_message(main_struct, G_LOG_LEVEL_WARNING, Q_(
"Plugins will be disabled"));
307 gchar *abs_path = NULL;
308 const gchar*
const *system_dirs;
310 GList *location_list = NULL;
313 path = g_get_current_dir();
314 location_list = g_list_prepend(location_list, path);
317 system_dirs = g_get_system_data_dirs();
319 while(system_dirs[i] != NULL)
321 path = g_build_path(G_DIR_SEPARATOR_S, system_dirs[i],
"heraia", NULL);
322 location_list = g_list_prepend(location_list, path);
327 system_dirs = g_get_system_config_dirs();
329 while(system_dirs[i] != NULL)
331 path = g_build_path(G_DIR_SEPARATOR_S, system_dirs[i],
"heraia", NULL);
332 location_list = g_list_prepend(location_list, path);
337 path = g_build_path(G_DIR_SEPARATOR_S, g_get_home_dir(),
"heraia", NULL);
338 location_list = g_list_prepend(location_list, path);
341 path = g_build_path(G_DIR_SEPARATOR_S, g_get_user_data_dir(),
"heraia", NULL);
342 location_list = g_list_prepend(location_list, path);
345 path = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(),
"heraia", NULL);
346 location_list = g_list_prepend(location_list, path);
349 path = g_build_path(G_DIR_SEPARATOR_S, heraia_path,
"..",
"share",
"heraia", NULL);
350 location_list = g_list_prepend(location_list, path);
353 abs_path = g_find_program_in_path(
"heraia");
354 if (abs_path != NULL)
356 path = g_build_path(G_DIR_SEPARATOR_S, g_path_get_dirname(abs_path),
"..",
"share",
"heraia", NULL);
357 location_list = g_list_prepend(location_list, path);
361 return location_list;
370 gchar *result = NULL;
371 gchar *codeset = NULL;
372 gchar *text_domain = NULL;
382 fprintf(stdout, Q_(
"Locale dir : %s\n"), LOCALEDIR);
383 fprintf(stdout, Q_(
"Bindtextdomain : %s\n"), result);
384 fprintf(stdout, Q_(
"Code set : %s\n"), codeset);
385 fprintf(stdout, Q_(
"Text domain : %s\n"), text_domain);
402 gboolean exit_value = FALSE;
405 exit_value =
usage(0);
406 exit_value =
usage(1);
409 if (tmp_struct != main_struct)
411 fprintf(stderr, Q_(
"WARNING : tmp_struct is not equal to main_struct!\n"));
415 if (exit_value != TRUE)
417 fprintf(stderr, Q_(
"WARNING : Error while testing decode functions\n"));
445 int exit_value = TRUE;
447 gchar *filename = NULL;
450 while ((c = getopt_long(argc, argv,
"vht",
long_options, NULL)) != -1)
463 exit_value =
usage(1);
470 if (sscanf(optarg,
"%d", &tests) < 1)
488 exit_value =
usage(0);
493 while (optind < argc)
495 filename = (
char *) malloc (
sizeof(
char) * strlen(argv[optind]) + 1);
496 strcpy(filename, argv[optind]);
532 fprintf(stdout, Q_(
"GTK version : %d.%d.%d\n"), GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
533 fprintf(stdout, Q_(
"GLIB version : %d.%d.%d\n"), glib_major_version, glib_minor_version, glib_micro_version);
544 int main(
int argc,
char **argv)
547 gboolean exit_value = TRUE;
550 gchar *heraia_path = NULL;
552 if (argv != NULL && argv[0] != NULL)
554 heraia_path = g_path_get_dirname(argv[0]);
564 exit_value = gtk_init_check(&argc, &argv);
572 if (main_struct->
debug == TRUE)
575 fprintf(stdout, Q_(
"Main struct initialized !\n"));
581 if (opt->
usage != TRUE)
583 if (main_struct->
debug == TRUE)
585 fprintf(stderr, Q_(
"Beginning things\n"));
594 log_message(main_struct, G_LOG_LEVEL_INFO, Q_(
"Main interface loaded"));
606 list = g_list_next(list);
610 log_message(main_struct, G_LOG_LEVEL_DEBUG, Q_(
"main_struct : %p"), main_struct);
633 fprintf(stderr, Q_(
"File heraia.gtkbuilder not found !\n"));
634 if (main_struct->
debug == TRUE)
640 heraia_path = (gchar *) list->data;
641 fprintf(stdout,
"\t%s\n", heraia_path);
642 list = g_list_next(list);
window_prop_t * find_window
find window
GPtrArray * results
An array of pointers (doc_t *) for each tab in the result window.
This is the main structure.
window_prop_t * data_interpretor
data interpretor window
doc_t * fr_find_doc
find and replace window, find document and hexwidget
static void print_lirairies_versions(void)
Prints on stdout the librairies versions.
void init_heraia_interface(heraia_struct_t *main_struct)
Here we might init some call backs and menu options and display the interface (main && sub-windows) This ...
static gboolean version(void)
prints program name, version, author, date and licence to the standard output
gint x
x position (upper left corner)
window_prop_t * result_window
result window properties
gint tab_displayed
keeps the last displayed tab's number before closing
int main(int argc, char **argv)
main program options :
void plugin_list_window_init_interface(heraia_struct_t *main_struct)
the function to init the plugin_list_window interface
prefs_t * init_preference_struct(gchar *pathname, gchar *filename)
Look out if the preference structure exists or not.
window_prop_t * fr_window
find and replace window
void log_message(heraia_struct_t *main_struct, GLogLevelFlags log_level, const char *format,...)
A function that helps logging a message a the specified level.
#define WPT_DEFAULT_HEIGHT
Defines the default height for a window (set in window_prop_t)
static gboolean do_heraia_loading_tests(heraia_struct_t *main_struct)
Does some loading tests in heraia.
window_prop_t * main_dialog
heraia's main window
gboolean displayed
TRUE if displayed, FALSE otherwise.
gboolean plugin_capable(void)
Says whether the system can handle plugins (or not)
gchar * filename
user preference file file name
window_prop_t * plugin_list
plugin description window
gboolean usage
to know if we displayed the usage message
static void init_international_languages(void)
Inits internationalisation (don't know wether it works or not!)
all_window_prop_t * win_prop
Keeps window properties.
static window_prop_t * init_window_properties(gint x, gint y, guint height, guint width, gboolean displayed)
Inits the properties of a window with defined values.
window_prop_t * main_pref_window
main preference window
window_prop_t * fdft_window
find data from type window
#define WPT_DEFAULT_WIDTH
Defines the default width for a window (set in window_prop_t)
Data interpretor window structure.
fdft_t * fdft
Keeps comboboxes created for the fdft window.
#define COVERAGE_TESTS
In order to do some coverage tests.
xml_t * xmls
All the xmls used in the program, loaded at running time.
#define HERAIA_LICENSE
defines heraia's license (at least GPL v2)
static GList * init_heraia_location_list(gchar *heraia_path)
Here we want to init the location list where we might look for in the future.
static heraia_struct_t * init_window_property_struct(heraia_struct_t *main_struct)
Inits the window property structure.
void load_plugins(heraia_struct_t *main_struct)
looks at the plugins dir(s) and loads the needed plugins (all ;-) (one at a time !!) ...
static struct option const long_options[]
static Options * init_options_struct(void)
Inits the Options struct that contains all stuff needed to managed command line options within heraia...
gboolean debug
Used to tell the program wether we want to display debug messages or not.
window_prop_t * ldt
list data types window
int libheraia_test(void)
A simple test function.
window_prop_t * about_box
prefs_t * prefs
All datas related to main preferences.
void libheraia_finalize(void)
static gboolean do_heraia_coverage_tests(heraia_struct_t *main_struct)
Does some self tests for code coverage in heraia.
gint y
y position (upper left corner)
void libheraia_initialize(void)
Python specific.
GtkBuilder * main
the main interface xml description
Structure to keep window properties for each window.
#define NO_TESTS
defines that no tests should be done (this is the default behaviour)
static gboolean manage_command_line_options(Options *opt, int argc, char **argv)
Manages all the command line options and populates the Options *opt structure accordingly.
#define HERAIA_NOERR
No error occured, everything is fine.
gint HERAIA_ERROR
Defines heraia error type (this should be used !)
GList * plugins_list
A list of plugins.
data_window_t * current_DW
data_interpretor pointer
window_prop_t * log_box
log window
static heraia_struct_t * heraia_init_main_struct(gchar *heraia_path)
Initialize the main structure (main_struct)
gboolean test_decode_functions(void)
test decode functions No parameters
guint height
y+height (bottom right corner)
Structure that contains all the xml definitions loaded at running time using GtkBuilder.
GtkWidget * diw
data interpretor window
doc_t * current_doc
This is a pointer to the current edited document.
heraia_struct_t * get_main_struct(void)
This is intended to be called by the library or any program that will use the library in order to get...
window_prop_t * goto_window
goto dialog window
#define HERAIA_VERSION
defines heraia's current version and release date of this version (00.00.20XX means a development ver...
#define HERAIA_DATE
defines heraia's creation date
doc_t * find_doc
find document and hexwidget for find window
guint width
x+width (bottom right corner)
GPtrArray * documents
An array of doc_t in order to be able to open more than one doc.
static gboolean usage(int status)
Function that informs the user about the command line options available with heraia.
#define HERAIA_NO_PLUGINS
When no plugin are found.
As there seems to be huge differences between the linux and the windows developpement platform such a...
static HERAIA_ERROR init_heraia_plugin_system(heraia_struct_t *main_struct)
Function that initializes the plugin system if any :
void verify_preference_file(prefs_t *prefs)
Verify preference file presence and creates it if it does not already exists.
Structure Options gives a way to store program options passed from the command line.
GList * location_list
this is the location list where we store some paths
gint8 tests
to know if the users wants to do self tests
doc_t * fr_replace_doc
find and replace window, replace document and hexwidget
static heraia_struct_t * libheraia_main_struct
libheraia_main_struct is a global variable that points to the main structure and is intended for the ...
GList * filenames
the filename to open
#define HERAIA_AUTHORS
defines heraia's main authors
gboolean load_file_to_analyse(heraia_struct_t *main_struct, gchar *filename)
Loads the file 'filename' to analyse and populates the corresponfing structure 'main_struct' as neede...
int load_heraia_ui(heraia_struct_t *main_struct)
Loads, if possible, the gtkbuilder xml file and then connects the signals and inits the following win...