diff options
author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2006-11-26 15:38:03 +0000 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2006-11-26 15:38:03 +0000 |
commit | 2f4ae3a5d3404daff96fa70022f9e45d623fa720 (patch) | |
tree | 3c779c28ba90a1658997b9c7ccb33c47f010dfe5 /hardinfo2/hardinfo.c | |
parent | e39038e95cbcc52fe95039e8229e0dd98d86ade9 (diff) |
Cleanups.
Add ability to choose which modules will be loaded.
Diffstat (limited to 'hardinfo2/hardinfo.c')
-rw-r--r-- | hardinfo2/hardinfo.c | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/hardinfo2/hardinfo.c b/hardinfo2/hardinfo.c index 6619afa1..e2a4a91c 100644 --- a/hardinfo2/hardinfo.c +++ b/hardinfo2/hardinfo.c @@ -33,34 +33,59 @@ main(int argc, char **argv) { GSList *modules; + /* parse all command line parameters */ parameters_init(&argc, &argv, ¶ms); + /* show version information and quit */ if (params.show_version) { g_print("HardInfo version " VERSION "\n"); g_print("Copyright (C) 2003-2006 Leandro A. F. Pereira. See COPYING for details.\n"); + return 0; } + /* initialize the binreloc library, so we can load program data */ + if (!binreloc_init(FALSE)) + g_error("Failed to find runtime data.\n\n" + "\342\200\242 Is HardInfo correctly installed?\n" + "\342\200\242 See if %s and %s exists and you have read permision.", + PREFIX, LIBPREFIX); + + /* list all module names */ + if (params.list_modules) { + GSList *modules = modules_load_all(); + + g_print("Module Name\t\tDynamic Loadable Module\n"); + for (; modules; modules = modules->next) { + ShellModule *module = (ShellModule *) modules->data; + + g_print("%s\t\t%s\n", module->name, g_module_name(module->dll)); + } + + return 0; + } + if (!params.create_report) { /* we only try to open the UI if the user didn't asked for a report. */ params.gui_running = ui_init(&argc, &argv); - /* if GTK+ initialization failed, assume the user wants a - report. */ + /* as a fallback, if GTK+ initialization failed, run in report + generation mode. */ if (!params.gui_running) params.create_report = TRUE; } - if (!binreloc_init(FALSE)) - g_error("Failed to find runtime data.\n\n" - "\342\200\242 Is HardInfo correctly installed?\n" - "\342\200\242 See if %s and %s exists and you have read permision.", - PREFIX, LIBPREFIX); - - modules = modules_load(); - + if (params.use_modules) { + /* load only selected modules */ + modules = modules_load_selected(); + } else { + /* load all modules */ + modules = modules_load_all(); + } + if (params.gui_running) { + /* initialize gui and start gtk+ main loop */ icon_cache_init(); stock_icons_init(); @@ -68,6 +93,7 @@ main(int argc, char **argv) gtk_main(); } else if (params.create_report) { + /* generate report */ gchar *report; report = report_create_from_module_list_format(modules, |