aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhwspeedy <ns@bigbear.dk>2024-03-06 08:39:27 +0100
committerhwspeedy <ns@bigbear.dk>2024-03-06 08:40:25 +0100
commit1ea9d8e74a2b6131cddd1d56d0fb8f16250e613f (patch)
treefac870364c9b9cbf833712c4466b3b030567fc8e
parentfd6d6d3d489d9299b6b3e045e71f74e307f00ac3 (diff)
FIX hardinfo lib-loading cleanup, params clean up
-rw-r--r--hardinfo2/hardinfo.c29
-rw-r--r--hardinfo2/util.c164
-rw-r--r--hardinfo2/vendor.c2
-rw-r--r--includes/hardinfo.h21
-rw-r--r--includes/shell.h6
-rw-r--r--modules/benchmark.c7
-rw-r--r--shell/callbacks.c57
-rw-r--r--shell/report.c2
-rw-r--r--shell/shell.c59
9 files changed, 34 insertions, 313 deletions
diff --git a/hardinfo2/hardinfo.c b/hardinfo2/hardinfo.c
index 5d4655c3..e2f11cdf 100644
--- a/hardinfo2/hardinfo.c
+++ b/hardinfo2/hardinfo.c
@@ -68,8 +68,6 @@ int main(int argc, char **argv)
DEBUG(" Debugging is enabled.");
- /* show also available modules */
- params.list_modules = TRUE;
}
/* initialize the binreloc library, so we can load program data */
@@ -79,25 +77,6 @@ int main(int argc, char **argv)
"\342\200\242 See if %s and %s exists and you have read permission."),
PREFIX, LIBPREFIX);
- /* list all module names */
- if (params.list_modules) {
- g_print(_("Modules:\n"
- "%-20s %-15s %-12s\n"), _("File Name"), _("Name"), _("Version"));
-
- for (modules = modules_load_all(); modules;
- modules = modules->next) {
- ShellModule *module = (ShellModule *) modules->data;
- const ModuleAbout *ma = module_get_about(module);
- gchar *name = g_path_get_basename(g_module_name(module->dll));
-
- g_print("%-20s %-15s %-12s\n", name, module->name, ma->version);
-
- g_free(name);
- }
-
- return 0;
- }
-
if (!params.create_report && !params.run_benchmark) {
/* we only try to open the UI if the user didn't ask for a report. */
params.gui_running = ui_init(&argc, &argv);
@@ -112,15 +91,9 @@ int main(int argc, char **argv)
}
}
- if (params.use_modules) {
- /* load only selected modules */
- DEBUG("loading user-selected modules");
- modules = modules_load_selected();
- } else {
/* load all modules */
DEBUG("loading all modules");
modules = modules_load_all();
- }
/* initialize vendor database */
vendor_init();
@@ -133,7 +106,7 @@ int main(int argc, char **argv)
result = module_call_method_param("benchmark::runBenchmark", params.run_benchmark);
if (!result) {
- fprintf(stderr, _("Unknown benchmark ``%s'' or benchmark.so not loaded"), params.run_benchmark);
+ fprintf(stderr, _("Unknown benchmark ``%s''"), params.run_benchmark);
exit_code = 1;
} else {
fprintf(stderr, "\n");
diff --git a/hardinfo2/util.c b/hardinfo2/util.c
index c3b138c9..cbabcc53 100644
--- a/hardinfo2/util.c
+++ b/hardinfo2/util.c
@@ -47,8 +47,6 @@
#define TiB 1099511627776
#define PiB 1125899906842624
-static GSList *modules_list = NULL;
-
void sync_manager_clear_entries(void);
gchar *find_program(gchar *program_name)
@@ -383,18 +381,15 @@ log_handler(const gchar * log_domain,
void parameters_init(int *argc, char ***argv, ProgramParameters * param)
{
- static gboolean create_report = FALSE;
- static gboolean force_all_details = FALSE;
- static gboolean show_version = FALSE;
- static gboolean list_modules = FALSE;
- static gboolean autoload_deps = FALSE;
- static gboolean skip_benchmarks = FALSE;
- static gboolean quiet = FALSE;
+ static gint create_report = FALSE;
+ static gint force_all_details = FALSE;
+ static gint show_version = FALSE;
+ static gint skip_benchmarks = FALSE;
+ static gint quiet = FALSE;
static gchar *report_format = NULL;
static gchar *run_benchmark = NULL;
static gchar *result_format = NULL;
static gchar *bench_user_note = NULL;
- static gchar **use_modules = NULL;
static gint max_bench_results = 50;
static GOptionEntry options[] = {
@@ -421,7 +416,7 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param)
.short_name = 'b',
.arg = G_OPTION_ARG_STRING,
.arg_data = &run_benchmark,
- .description = N_("run benchmark; requires benchmark.so to be loaded")},
+ .description = N_("run benchmark eg. -b 'FPU FFT'")},
{
.long_name = "user-note",
.short_name = 'u',
@@ -440,26 +435,6 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param)
.arg = G_OPTION_ARG_INT,
.arg_data = &max_bench_results,
.description = N_("maximum number of benchmark results to include (-1 for no limit, default is 50)")},
-//#if NOT_DEFINED
- {
- .long_name = "list-modules",
- .short_name = 'l',
- .arg = G_OPTION_ARG_NONE,
- .arg_data = &list_modules,
- .description = N_("lists modules")},
- {
- .long_name = "load-module",
- .short_name = 'm',
- .arg = G_OPTION_ARG_STRING_ARRAY,
- .arg_data = &use_modules,
- .description = N_("specify module to load")},
- {
- .long_name = "autoload-deps",
- .short_name = 'a',
- .arg = G_OPTION_ARG_NONE,
- .arg_data = &autoload_deps,
- .description = N_("automatically load module dependencies")},
-//#endif
{
.long_name = "version",
.short_name = 'v',
@@ -482,7 +457,7 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param)
};
GOptionContext *ctx;
- ctx = g_option_context_new(_("- System Profiler and Benchmark tool"));
+ ctx = g_option_context_new(_("- System Information and Benchmark"));
g_option_context_set_ignore_unknown_options(ctx, FALSE);
g_option_context_set_help_enabled(ctx, TRUE);
@@ -500,12 +475,9 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param)
param->create_report = create_report;
param->report_format = REPORT_FORMAT_TEXT;
param->show_version = show_version;
- param->list_modules = list_modules;
- param->use_modules = use_modules;
param->run_benchmark = run_benchmark;
param->result_format = result_format;
param->max_bench_results = max_bench_results;
- param->autoload_deps = autoload_deps;
param->skip_benchmarks = skip_benchmarks;
param->force_all_details = force_all_details;
param->quiet = quiet;
@@ -545,7 +517,7 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param)
g_free(confdir);
}
-gboolean ui_init(int *argc, char ***argv)
+gint ui_init(int *argc, char ***argv)
{
DEBUG("initializing gtk+ UI");
@@ -835,29 +807,6 @@ static gint module_cmp(gconstpointer m1, gconstpointer m2)
return a->weight - b->weight;
}
-#if 0
-static void module_entry_free(gpointer data, gpointer user_data)
-{
- ShellModuleEntry *entry = (ShellModuleEntry *) data;
-
- if (entry) {
- g_free(entry->name);
- g_object_unref(entry->icon);
-
- g_free(entry);
- }
-}
-#endif
-
-const ModuleAbout *module_get_about(ShellModule * module)
-{
- if (module->aboutfunc) {
- return module->aboutfunc();
- }
-
- return NULL;
-}
-
static GSList *modules_check_deps(GSList * modules)
{
GSList *mm;
@@ -886,7 +835,7 @@ static GSList *modules_check_deps(GSList * modules)
}
if (!found) {
- if (params.autoload_deps) {
+ if (0){//params.autoload_deps) {
ShellModule *mod = module_load(deps[i]);
if (mod)
@@ -937,94 +886,23 @@ static GSList *modules_check_deps(GSList * modules)
return modules;
}
-
-GSList *modules_get_list()
-{
- return modules_list;
-}
-
-//Compatibility
-#if GLIB_CHECK_VERSION(2,44,0)
-#else
-static inline gpointer
-g2_steal_pointer (gpointer pp)
-{
- gpointer *ptr = (gpointer *) pp;
- gpointer ref;
-
- ref = *ptr;
- *ptr = NULL;
-
- return ref;
-}
-#endif
-
-static GSList *modules_load(gchar ** module_list)
+GSList *modules_load_all(void)
{
- GDir *dir;
GSList *modules = NULL;
ShellModule *module;
- gchar *filename;
-
- filename = g_build_filename(params.path_lib, "modules", NULL);
- dir = g_dir_open(filename, 0, NULL);
- g_free(filename);
-
- if (dir) {
- GList *filenames = NULL;
- while ((filename = (gchar *)g_dir_read_name(dir))) {
- if (g_strrstr(filename, "." G_MODULE_SUFFIX) &&
- module_in_module_list(filename, module_list)) {
- if (g_strrstr(filename, "devices." G_MODULE_SUFFIX)) {
- filenames = g_list_prepend(filenames, filename);
- }
- else {
- filenames = g_list_append(filenames, filename);
- }
- }
- }
- GList* item = NULL;
- while (item = g_list_first(filenames)) {
- if (module = module_load((gchar *)item->data)) {
- modules = g_slist_prepend(modules, module);
- }
- filenames = g_list_delete_link(filenames, item);
- }
-#if GLIB_CHECK_VERSION(2,44,0)
- g_list_free_full (g_steal_pointer (&filenames), g_object_unref);
-#else
- g_list_free_full (g2_steal_pointer (&filenames), g_object_unref);
-#endif
- g_dir_close(dir);
- }
-
- modules = modules_check_deps(modules);
-
- if (g_slist_length(modules) == 0) {
- if (params.use_modules == NULL) {
- g_error
- (_("No module could be loaded. Check permissions on \"%s\" and try again."),
- params.path_lib);
- } else {
- g_error
- (_("No module could be loaded. Please use hardinfo2 -l to list all avai"
- "lable modules and try again with a valid module list."));
-
- }
+ gchar *filenames[]={"devices.so","computer.so","benchmark.so","network.so"};
+ int i=0;
+
+ while(i<4) {
+ if (module = module_load(filenames[i])) {
+ modules = g_slist_prepend(modules, module);
+ }
+ i++;
}
- modules_list = g_slist_sort(modules, module_cmp);
- return modules_list;
-}
-
-GSList *modules_load_selected(void)
-{
- return modules_load(params.use_modules);
-}
-
-GSList *modules_load_all(void)
-{
- return modules_load(NULL);
+ //modules = modules_check_deps(modules);
+ modules = g_slist_sort(modules, module_cmp);
+ return modules;
}
gint tree_view_get_visible_height(GtkTreeView * tv)
diff --git a/hardinfo2/vendor.c b/hardinfo2/vendor.c
index 2031ac44..3d7092cc 100644
--- a/hardinfo2/vendor.c
+++ b/hardinfo2/vendor.c
@@ -206,7 +206,7 @@ static int read_from_vendor_ids(const char *path) {
void vendor_init(void)
{
- gchar *path;
+ gchar *path=NULL;
static SyncEntry se1;
static SyncEntry se2 = {
.name = N_("Update vendor list"),
diff --git a/includes/hardinfo.h b/includes/hardinfo.h
index 872a29fc..9c229289 100644
--- a/includes/hardinfo.h
+++ b/includes/hardinfo.h
@@ -50,14 +50,12 @@ typedef struct _FileTypes FileTypes;
typedef struct _ProgramParameters ProgramParameters;
struct _ProgramParameters {
- gboolean create_report;
- gboolean force_all_details; /* for create_report, include any "moreinfo" that exists for any item */
- gboolean show_version;
- gboolean gui_running;
- gboolean list_modules;
- gboolean autoload_deps;
- gboolean skip_benchmarks;
- gboolean quiet;
+ gint create_report;
+ gint force_all_details; /* for create_report, include any "moreinfo" that exists for any item */
+ gint show_version;
+ gint gui_running;
+ gint skip_benchmarks;
+ gint quiet;
/*
* OK to use the common parts of HTML(4.0) and Pango Markup
@@ -65,13 +63,11 @@ struct _ProgramParameters {
* Including the (b,big,i,s,sub,sup,small,tt,u) tags.
* https://developer.gnome.org/pango/stable/PangoMarkupFormat.html
*/
- gboolean markup_ok;
+ gint markup_ok;
int fmt_opts;
gint report_format;
gint max_bench_results;
-
- gchar **use_modules;
gchar *run_benchmark;
gchar *bench_user_note;
gchar *result_format;
@@ -134,7 +130,6 @@ GSList *modules_get_list(void);
GSList *modules_load_selected(void);
GSList *modules_load_all(void);
void module_unload_all(void);
-const ModuleAbout *module_get_about(ShellModule *module);
gchar *seconds_to_string(unsigned int seconds);
gchar *h_strdup_cprintf(const gchar *format, gchar *source, ...)
@@ -155,7 +150,7 @@ gchar *module_entry_get_moreinfo(ShellModuleEntry * module_entry, gchar *
gboolean binreloc_init(gboolean try_hardcoded);
/* GTK UI stuff */
-gboolean ui_init(int *argc, char ***argv);
+gint ui_init(int *argc, char ***argv);
void parameters_init(int *argc, char ***argv, ProgramParameters *params);
extern ProgramParameters params;
diff --git a/includes/shell.h b/includes/shell.h
index ab39106c..223326fb 100644
--- a/includes/shell.h
+++ b/includes/shell.h
@@ -79,7 +79,6 @@ typedef enum {
struct _Shell {
GtkWidget *window, *vbox;
GtkWidget *status, *progress;
- GtkWidget *remote_label;
GtkWidget *notebook;
GtkWidget *hbox, *vpaned;
@@ -217,11 +216,6 @@ void shell_set_title(Shell *shell, char *subtitle);
void shell_add_modules_to_gui(gpointer _shell_module, gpointer _shell_tree);
-void shell_save_hosts_file(void);
-void shell_update_remote_menu(void);
-
-void shell_set_remote_label(Shell *shell, gchar *label);
-
/* decode special information in keys
*
* key syntax:
diff --git a/modules/benchmark.c b/modules/benchmark.c
index 18156e01..511c984e 100644
--- a/modules/benchmark.c
+++ b/modules/benchmark.c
@@ -253,7 +253,7 @@ bench_value benchmark_parallel_for(gint n_threads,
{
gchar *temp;
int cpu_procs, cpu_cores, cpu_threads, cpu_nodes;
- guint iter_per_thread, iter, thread_number = 0;
+ guint iter_per_thread=1, iter, thread_number = 0;
GSList *threads = NULL, *t;
GTimer *timer;
@@ -603,7 +603,6 @@ do_benchmark_handler(GIOChannel *source, GIOCondition condition, gpointer data)
GIOStatus status;
gchar *result;
bench_value r = EMPTY_BENCH_VALUE;
-
status = g_io_channel_read_line(source, &result, NULL, NULL, NULL);
if (status != G_IO_STATUS_NORMAL) {
DEBUG("error while reading benchmark result");
@@ -633,9 +632,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)
return;
if (params.gui_running) {
- gchar *argv[] = {params.argv0, "-b", entries[entry].name,
- "-m", "benchmark.so", "-a",
- NULL};
+ gchar *argv[] = {params.argv0, "-b",entries[entry].name,NULL};
GPid bench_pid;
gint bench_stdout;
GtkWidget *bench_dialog;
diff --git a/shell/callbacks.c b/shell/callbacks.c
index e7808471..c60487d9 100644
--- a/shell/callbacks.c
+++ b/shell/callbacks.c
@@ -138,63 +138,6 @@ void cb_toolbar()
shell_ui_manager_set_visible("/MainMenuBarAction", visible);
}
-void cb_about_module(GtkAction * action)
-{
- Shell *shell = shell_get_main_shell();
- GSList *modules = shell->tree->modules;
- const ModuleAbout *ma;
- gchar *name;
-
- g_object_get(G_OBJECT(action), "tooltip", &name, NULL);
-
- for (; modules; modules = modules->next) {
- ShellModule *sm = (ShellModule *) modules->data;
-
- if (!g_str_equal(sm->name, name))
- continue;
-
- if ((ma = module_get_about(sm))) {
- GtkWidget *about;
- gchar *text;
-
- about = gtk_about_dialog_new();
-
- gtk_window_set_transient_for(GTK_WINDOW(about), GTK_WINDOW(shell->window));
-
- text = g_strdup(sm->name);
-#if GTK_CHECK_VERSION(2, 12, 0)
- gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(about), text);
-#else
- gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(about), text);
-#endif
- g_free(text);
-
- gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about),
- ma->version);
-
- text = g_strdup_printf(_("Written by %s\nLicensed under %s"),
- ma->author, ma->license);
- gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about), text);
- g_free(text);
-
- if (ma->description)
- gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about),
- _(ma->description));
-
- gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(about), sm->icon);
- gtk_dialog_run(GTK_DIALOG(about));
- gtk_widget_destroy(about);
- } else {
- g_warning
- (_("No about information is associated with the %s module."),
- name);
- }
-
- break;
- }
-
- g_free(name);
-}
void cb_about()
{
diff --git a/shell/report.c b/shell/report.c
index 25b73beb..d264128e 100644
--- a/shell/report.c
+++ b/shell/report.c
@@ -289,7 +289,7 @@ void report_details(ReportContext *ctx, gchar *key, gchar *value, gchar *details
static void report_table_shell_dump(ReportContext *ctx, gchar *key_file_str, int level)
{
- gchar *text, *p, *next_nl, *eq, *indent;
+ gchar *text=NULL, *p, *next_nl, *eq, *indent;
gchar *key, *value;
indent = g_strnfill(level * 4, ' ');
diff --git a/shell/shell.c b/shell/shell.c
index e74486f2..e3f64891 100644
--- a/shell/shell.c
+++ b/shell/shell.c
@@ -523,63 +523,6 @@ static void menu_item_set_icon_always_visible(Shell *shell,
g_free(path);
}
-static void add_module_to_menu(gchar * name, GdkPixbuf * pixbuf)
-{
- GtkAction *action;
- GtkWidget *menuitem;
- gchar *about_module = g_strdup_printf("AboutModule%s", name);
- gchar *path;
- gint merge_id;
-
- GtkActionEntry entries[] = {
- {
- name, /* name */
- name, /* stockid */
- name, /* label */
- NULL, /* accelerator */
- NULL, /* tooltip */
- NULL, /* callback */
- },
- {
- about_module,
- name,
- name,
- NULL,
- name,
- (GCallback) cb_about_module,
- },
- };
-
- stock_icon_register_pixbuf(pixbuf, name);
-
- if ((action = gtk_action_group_get_action(shell->action_group, name))) {
- gtk_action_group_remove_action(shell->action_group, action);
- }
-
- if ((action = gtk_action_group_get_action(shell->action_group, about_module))) {
- gtk_action_group_remove_action(shell->action_group, action);
- }
-
- gtk_action_group_add_actions(shell->action_group, entries, 2, NULL);
-
- merge_id = gtk_ui_manager_new_merge_id(shell->ui_manager);
- gtk_ui_manager_add_ui(shell->ui_manager,
- merge_id,
- "/menubar/ViewMenu/LastSep",
- name, name, GTK_UI_MANAGER_MENU, TRUE);
- shell->merge_ids = g_slist_prepend(shell->merge_ids, GINT_TO_POINTER(merge_id));
-
- merge_id = gtk_ui_manager_new_merge_id(shell->ui_manager);
- gtk_ui_manager_add_ui(shell->ui_manager,
- merge_id,
- // "/menubar/HelpMenu/HelpMenuModules/LastSep",
- "/menubar/HelpMenu/LastSep",
- about_module, about_module, GTK_UI_MANAGER_AUTO,
- TRUE);
- shell->merge_ids = g_slist_prepend(shell->merge_ids, GINT_TO_POINTER(merge_id));
-
- menu_item_set_icon_always_visible(shell, "/menubar/ViewMenu", name);
-}
static void
add_module_entry_to_view_menu(gchar * module, gchar * name,
@@ -643,8 +586,6 @@ void shell_add_modules_to_gui(gpointer _shell_module, gpointer _shell_tree)
-1);
}
- //add_module_to_menu(module->name, module->icon);
-
if (module->entries) {
ShellModuleEntry *entry;
GSList *p;