diff options
author | Simon Quigley <tsimonq2@ubuntu.com> | 2017-06-19 14:38:33 -0500 |
---|---|---|
committer | Simon Quigley <tsimonq2@ubuntu.com> | 2017-06-19 14:38:33 -0500 |
commit | 854292407779593a401a1d5ce71add51880fa84f (patch) | |
tree | 42b5f1896eda603c04a30db1effb133f10f71ca8 | |
parent | a08438bda21b3e0d7db2db2360d040841970104d (diff) |
Import Upstream version 0.4
267 files changed, 8313 insertions, 5615 deletions
diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index bb1d7140..00000000 --- a/ChangeLog +++ /dev/null @@ -1,149 +0,0 @@ -06/01/2003 12:05 BRST <leandro@linuxmag.com.br> 0.3.7-pre1 - - * details.[ch] - Use a window to show details instead of showing them inside the - main window - * computer.c, hardinfo.[ch] - Show more processor information (currently x86 only) - * modules.[ch], hardinfo.[ch] - Loaded kernel modules information - -05/01/2003 12:05 BRST <leandro@linuxmag.com.br> 0.3.6 - - * 0.3.6 released - -17/12/2003 10:50 BRST <leandro@linuxmag.com.br> 0.3.6-pre4 - - * hardinfo.desktop, Makefile.in - - Added GNOME/KDE menu entry - (Thanks to Gustavo Noronha <kov@debian.org>) - * net.[ch] - - Preliminary network information support (disabled in GUI). - -03/07/2003 13:25 BRST <leandro@linuxmag.com.br> 0.3.6-pre3 - - * v4l.[ch], hardinfo.[ch], pixmaps/v4l.png - - Added Video 4 Linux support - -02/07/2003 20:51 BRST <leandro@linuxmag.com.br> 0.3.6-pre2 - - * pixmaps/cnc.png - - Added pixmap for Conectiva Linux. - - * pci.c - - Fixed memory detection bug in lspci parser. - -24/06/2003 20:10 BRST <leandro@linuxmag.com.br> 0.3.6-pre1 - - * intl.c - - Search for locale information in LANG, LC_MESSAGES and LC_ALL. - - * about.[ch], hardinfo.[ch], pixmaps/logo.png - - Included about box. - - * configure - - Added --with-gtk1 and --with-gtk2. - - * lang/es_*.lang - - Added Spanish translation - (Thanks to Erica Andrews <phrozensmoke@yahoo.com>) - - * pixmaps/usb.png - - Changed USB icon a little bit. - -23/06/2003 15:50 BRST <leandro@linuxmag.com.br> 0.3.5 - - * intl.c - - Improved error checking. - - Fixed segfault. - (Patch from Sameh Attia <sameh.attia@tedata.net>) - - * configure - - Added option to disable i18n (--disable-nls). - -22/06/2003 21:52 BRST <leandro@linuxmag.com.br> 0.3.4 - - * 0.3.4 released! - -19/06/2003 21:42 BRST <leandro@linuxmag.com.br> 0.3.4-pre2 - - * intl.c, intl.h, genintl.pl, lang/* - - Added i18n support. - - * configure, computer.c - - Finished PowerPC processor information support. - -19/06/2003 10:52 BRST <leandro@linuxmag.com.br> 0.3.4-pre1 - - * hardinfo.h - - Fixed segfault on startup. - (Patch from Thomas Zajic <zlatko@gmx.at>) - - * x11.c, x11.h, hardinfo.c - - Added X-Window system information. - - * pixmaps/x11.png - - Added pixmap for X-Window information. - - * configure, computer.c - - Preliminary PowerPC processor information support. - -18/06/2003 22:14 BRST <leandro@linuxmag.com.br> 0.3.3 - - * pci.c - - Fixed a bug in lspci parser. - - * computer.c, computer.h, hardinfo.c, hardinfo.h - - Added operating system, processor and memory information - - * hardinfo.c, hardinfo.h - - Added "Refresh" and "Close" buttons - -16/06/2003 17:50 BRST <leandro@linuxmag.com.br> 0.3.2 - - * configure, Makefile.in, hardinfo.c, pci.c - - Some cleanups. - -16/06/2003 17:41 BRST <leandro@linuxmag.com.br> 0.3.2-pre2 - - * configure, Makefile.in - - Using automatic configuration utility: - o If GTK2 isn't available, the GTK1.2 version will be built. - o Search for lspci in various paths. If not found, fall back - to the old /proc/pci parser. - - * hardinfo.c - - Parallel Port support added. - - * ide.c, isapnp.c, parport.c, pci.c, scsi.c, serial.c, usb.c - - Separate parsers from GUI. - - * *.xpm - - Moved *.xpm to pixmaps/. - -16/06/2003 10:46 BRST <leandro@linuxmag.com.br> 0.3.2-pre1 - - * hardinfo.c - - SCSI support added. - (Patch from Pascal F.Martin <pascalmartin@earthlink.net>) - - Fixed lspci path (it's now fixed in "/sbin/lspci", which seems - to be the default, as Google says). - - * *.png - - Moved all PNG files to pixmaps/. - - -15/06/2003 21:17 BRST <leandro@linuxmag.com.br> 0.3.1 - - * hardinfo.c - - Application is now exits when the window is closed. - - Parse `lspci -v' output instead of `/proc/pci', which - is deprecated. This should work with 2.5 kernels too! - - Images are not loaded from current directory anymore. - - * debian/ - - HardInfo is now Debianized. :) - - * Makefile - - Added `install' target. - - Images are now installed in `/usr/share/hardinfo/pixmaps'. diff --git a/Makefile.in b/Makefile.in index 29014b89..c4ac1fa1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,41 +1,40 @@ -# ---------------------------------------------------------------------------- -CC = gcc -CFLAGS = -Wall -g $(GTK_CFLAGS) -O6 +CC = gcc -fPIC -pipe -O3 $(ARCHOPTS) +CCSLOW = gcc -fPIC -pipe -O0 +CFLAGS = -Wall -g $(GTK_CFLAGS) $(GLADE_CFLAGS) -I. # ---------------------------------------------------------------------------- -OBJECTS = hardinfo.o scsi.o ide.o pci.o usb.o isapnp.o serial.o parport.o \ - computer.o x11.o intl.o about.o v4l.o status.o net.o stock.o \ - details.o modules.o +OBJECTS = hardinfo.o shell.o util.o iconcache.o loadgraph.o sha1.o md5.o \ + menu.o stock.o callbacks.o expr.o report.o blowfish.o +MODULES = computer.so devices.so benchmark.so -all: $(OBJECTS) - $(CC) $(CFLAGS) -o hardinfo $(OBJECTS) $(GTK_LIBS) $(GTK_FLAGS) +all: $(OBJECTS) $(MODULES) + $(CC) $(CFLAGS) -o hardinfo -Wl,-export-dynamic $(OBJECTS) $(GTK_LIBS) $(GTK_FLAGS) \ + $(GLADE_LIBS) $(GLADE_FLAGS) -clean: - rm -rf *~ .xvpics pixmaps/.xvpics *.o hardinfo +md5.o: + $(CCSLOW) $(CFLAGS) -c md5.c -o $@ -install: all - mkdir -p ${DESTDIR}/usr/bin/ - cp hardinfo ${DESTDIR}/usr/bin/hardinfo - mkdir -p ${DESTDIR}/usr/share/hardinfo/pixmaps - cp -rv pixmaps/*.png ${DESTDIR}/usr/share/hardinfo/pixmaps - cp -rv pixmaps/logo.xpm ${DESTDIR}/usr/share/hardinfo/pixmaps - mkdir -p ${DESTDIR}/usr/share/hardinfo/pixmaps/distro - cp -rv pixmaps/distro/*.png ${DESTDIR}/usr/share/hardinfo/pixmaps/distro - mkdir -p ${DESTDIR}/usr/share/hardinfo/lang - cp -rv lang/* ${DESTDIR}/usr/share/hardinfo/lang - chmod -R 755 ${DESTDIR}/usr/share/hardinfo - chmod -R -x ${DESTDIR}/usr/share/hardinfo - chmod 755 ${DESTDIR}/usr/share/hardinfo - chmod 755 ${DESTDIR}/usr/share/hardinfo/pixmaps - chmod 755 ${DESTDIR}/usr/share/hardinfo/lang - chmod 755 ${DESTDIR}/usr/share/hardinfo/pixmaps/distro - mkdir -p ${DESTDIR}/usr/share/applications - cp hardinfo.desktop ${DESTDIR}/usr/share/applications +blowfish.o: + $(CCSLOW) $(CFLAGS) -c blowfish.c -o $@ + +sha1.o: + $(CCSLOW) $(CFLAGS) -c sha1.c -o $@ + +%.so: %.c + @echo "[01;34m--- Module: $< ($@)[00m" + $(CC) $(CFLAGS) -o $@ -shared $< $(GTK_FLAGS) $(GTK_LIBS) \ + $(GLADE_LIBS) $(GLADE_FLAGS) + mv $@ modules + +clean: + rm -rf .xvpics pixmaps/.xvpics *.o *.so hardinfo modules/*.so report + find . -name \*~ -exec rm -v {} \; + find . -name x86 -type l -exec rm -v {} \; dist-clean: clean - rm -rf Makefile debian/hardinfo/ config.h + rm -rf Makefile debian/hardinfo/ config.h arch/this package: dist-clean @echo "Creating tar.gz..." @@ -47,3 +46,17 @@ deb: dist-clean @echo "Creating deb..." dpkg-buildpackage -rfakeroot -k${USER} +install: all + mkdir -p ${DESTDIR}/usr/bin + cp hardinfo ${DESTDIR}/usr/bin/hardinfo + mkdir -p ${DESTDIR}/usr/share/hardinfo/modules + cp -rv modules/*.so ${DESTDIR}/usr/share/hardinfo/modules + mkdir -p ${DESTDIR}/usr/share/hardinfo/pixmaps + cp -rv pixmaps/* ${DESTDIR}/usr/share/hardinfo/pixmaps + cp uidefs.xml ${DESTDIR}/usr/share/hardinfo + cp modules.conf ${DESTDIR}/usr/share/hardinfo + cp benchmark.conf ${DESTDIR}/usr/share/hardinfo + cp benchmark.data ${DESTDIR}/usr/share/hardinfo + chmod -R 755 ${DESTDIR}/usr/share/hardinfo + chmod 755 ${DESTDIR}/usr/bin/hardinfo + diff --git a/README b/README deleted file mode 100644 index 4e2f765e..00000000 --- a/README +++ /dev/null @@ -1,8 +0,0 @@ - - -Some sites that mentions HardInfo: ----------------------------------- - -- http://www.smlug.org/meetings/2003/06.php -- http://www.linuxzone.cz/modules/tisk_clanku-nw.phtml?ids=7&idc=742 -- http://vico.kleinplanet.de/crux.html diff --git a/about.c b/about.c deleted file mode 100644 index 982c9753..00000000 --- a/about.c +++ /dev/null @@ -1,90 +0,0 @@ -#include "hardinfo.h" -#include "about.h" - -static void about_close(GtkWidget *widget, gpointer data) -{ - GtkAbout *about = (GtkAbout*) data; - - gtk_widget_destroy(about->window); -} - -GtkAbout * -gtk_about_new(const gchar * name, const gchar * version, - const gchar * description, const gchar * authors[], const gchar * logo_img) -{ - GtkWidget *img; - gchar *buf; - const gchar *auth; - GtkWidget *window, *vbox, *label, *btn, *hr, *hbox; - GtkAbout *about; - gint i; - - about = g_new0(GtkAbout, 1); - - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(window), "About"); - gtk_container_set_border_width(GTK_CONTAINER(window), 8); - - about->window = window; - - gtk_window_set_resizable(GTK_WINDOW(window), FALSE); - - vbox = gtk_vbox_new(FALSE, 5); - gtk_box_set_spacing(GTK_BOX(vbox), 3); - gtk_container_add(GTK_CONTAINER(window), vbox); - - img = gtk_image_new_from_file(logo_img); - gtk_widget_show(img); - gtk_box_pack_start(GTK_BOX(vbox), img, FALSE, FALSE, 0); - gtk_widget_set_usize(GTK_WIDGET(img), 64, 64); - -#define ADD_LABEL(x,y) label = gtk_label_new(x); \ - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); \ - gtk_widget_show(label); \ - gtk_box_pack_start(GTK_BOX(y), label, TRUE, TRUE, 0); - - buf = - g_strdup_printf - ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>", name, - version); - ADD_LABEL(buf, vbox); - g_free(buf); - - ADD_LABEL(description, vbox); - - for (i = 0; authors[i] != NULL; i++) { - auth = authors[i]; - - if (*auth == '>') { - auth++; - - buf = g_strdup_printf("<b>%s</b>", auth); - ADD_LABEL(buf, vbox); - g_free(buf); - } else { - buf = g_strdup_printf("<span size=\"small\">%s</span>", auth); - ADD_LABEL(buf, vbox); - g_free(buf); - } - } - - hr = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(vbox), hr, FALSE, FALSE, 0); - - hbox = gtk_hbutton_box_new(); - gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); - gtk_widget_show(hbox); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbox), 6); - gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END); - - btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE); - g_signal_connect(G_OBJECT(btn), "clicked", (GCallback)about_close, about); - gtk_widget_show(btn); - gtk_box_pack_start(GTK_BOX(hbox), btn, FALSE, FALSE, 0); - - gtk_widget_show_all(window); - - return about; - -} diff --git a/about.h b/about.h deleted file mode 100644 index a131b0d9..00000000 --- a/about.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __GTK_ABOUT_H__ -#define __GTK_ABOUT_H__ - -typedef struct _GtkAbout GtkAbout; - -struct _GtkAbout { - GtkWidget *window; -}; - -GtkAbout *gtk_about_new(const gchar * name, - const gchar * version, - const gchar * comments, - const gchar * authors[], - const gchar * logo_img); - -#endif /* __GTK_ABOUT_H__ */ diff --git a/arch/common/blowfish.h b/arch/common/blowfish.h new file mode 100644 index 00000000..7333d069 --- /dev/null +++ b/arch/common/blowfish.h @@ -0,0 +1,64 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <blowfish.h> + +gchar * +benchmark_fish(void) +{ + BLOWFISH_CTX ctx; + GTimer *timer = g_timer_new(); + gdouble elapsed = 0; + gchar src[65536], *tmpsrc; + glong srclen = 65536; + unsigned long L, R; + int i; + + tmpsrc = src; + + L = 0xBEBACAFE; + R = 0xDEADBEEF; + + if (!g_file_get_contents(PREFIX "benchmark.data", + &tmpsrc, NULL, NULL)) { + return g_strdup("[Error]\n" + PREFIX "benchmark.data not found=\n"); + } + + shell_view_set_enabled(FALSE); + shell_status_update("Benchmarking..."); + + for (i = 0; i <= 50000; i++) { + g_timer_start(timer); + + Blowfish_Init(&ctx, (unsigned char*)tmpsrc, srclen); + Blowfish_Encrypt(&ctx, &L, &R); + Blowfish_Decrypt(&ctx, &L, &R); + + g_timer_stop(timer); + elapsed += g_timer_elapsed(timer, NULL); + + shell_status_set_percentage(i/500); + } + + g_timer_destroy(timer); + + gchar *retval = g_strdup_printf("[Results <i>(in seconds; lower is better)</i>]\n" + "<b>This Machine</b>=<b>%.2f</b>\n", elapsed); + return benchmark_include_results(retval, "Blowfish"); +} diff --git a/arch/common/display.h b/arch/common/display.h new file mode 100644 index 00000000..6731e3e3 --- /dev/null +++ b/arch/common/display.h @@ -0,0 +1,137 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static void +get_glx_info(DisplayInfo *di) +{ + gchar *output; + if (g_spawn_command_line_sync("glxinfo", &output, NULL, NULL, NULL)) { + gchar **output_lines, **old; + + output_lines = g_strsplit(output, "\n", 0); + g_free(output); + + old = output_lines; + while (*(++output_lines)) { + if (strstr(*output_lines, "OpenGL")) { + gchar **tmp = g_strsplit(*output_lines, ":", 0); + + tmp[1] = g_strchug(tmp[1]); + + get_str("OpenGL vendor str", di->ogl_vendor); + get_str("OpenGL renderer str", di->ogl_renderer); + get_str("OpenGL version str", di->ogl_version); + + g_strfreev(tmp); + } + } + + g_strfreev(old); + + if (!di->ogl_vendor) + di->ogl_vendor = "Unknown"; + if (!di->ogl_renderer) + di->ogl_renderer = "Unknown"; + if (!di->ogl_version) + di->ogl_version = "Unknown"; + } else { + di->ogl_vendor = di->ogl_renderer = di->ogl_version = "Unknown"; + } + +} + +static void +get_x11_info(DisplayInfo *di) +{ + gchar *output; + + if (g_spawn_command_line_sync("xdpyinfo", &output, NULL, NULL, NULL)) { + gchar **output_lines, **old; + + output_lines = g_strsplit(output, "\n", 0); + g_free(output); + + old = output_lines; + while (*(output_lines++)) { + gchar **tmp = g_strsplit(*output_lines, ":", 0); + + if (tmp[1] && tmp[0]) { + tmp[1] = g_strchug(tmp[1]); + + get_str("vendor string", di->vendor); + get_str("X.Org version", di->version); + get_str("XFree86 version", di->version); + + if (g_str_has_prefix(tmp[0], "number of extensions")) { + int n; + + di->extensions = ""; + + for (n = atoi(tmp[1]); n; n--) { + di->extensions = g_strconcat(di->extensions, + g_strstrip(*(++output_lines)), + "=\n", + NULL); + } + g_strfreev(tmp); + + break; + } + } + + g_strfreev(tmp); + } + + g_strfreev(old); + } + + GdkScreen *screen = gdk_screen_get_default(); + + if (screen && GDK_IS_SCREEN(screen)) { + gint n_monitors = gdk_screen_get_n_monitors(screen); + gint i; + + di->monitors = ""; + for (i = 0; i < n_monitors; i++) { + GdkRectangle rect; + + gdk_screen_get_monitor_geometry(screen, i, &rect); + + di->monitors = g_strdup_printf("%sMonitor %d=%dx%d pixels\n", + di->monitors, i, rect.width, rect.height); + } + } else { + di->monitors = ""; + } +} + +static DisplayInfo * +computer_get_display(void) +{ + DisplayInfo *di = g_new0(DisplayInfo, 1); + + GdkScreen *screen = gdk_screen_get_default(); + + di->width = gdk_screen_get_width(screen); + di->height = gdk_screen_get_height(screen); + + get_glx_info(di); + get_x11_info(di); + + return di; +} diff --git a/arch/common/fib.h b/arch/common/fib.h new file mode 100644 index 00000000..493cfd0f --- /dev/null +++ b/arch/common/fib.h @@ -0,0 +1,50 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static unsigned long long +fib(unsigned long long n) +{ + if (n == 0) + return 0; + else if (n == 1 || n == 2) + return 1; + return fib(n - 1) + fib(n - 2); +} + +static gchar * +benchmark_fib(void) +{ + GTimer *timer = g_timer_new(); + gdouble elapsed = 0; + + shell_view_set_enabled(FALSE); + shell_status_update("Calculating the 42<sup>th</sup> Fibonacci number..."); + + g_timer_start(timer); + fib(42); /* the answer? :) */ + g_timer_stop(timer); + + elapsed = g_timer_elapsed(timer, NULL); + + g_timer_destroy(timer); + + gchar *retval = g_strdup_printf("[Results <i>(in seconds; lower is better)</i>]\n" + "<b>This Machine</b>=<b>%.2f</b>\n", elapsed); + return benchmark_include_results(retval, "Fibonacci"); +} + diff --git a/arch/common/languages.h b/arch/common/languages.h new file mode 100644 index 00000000..3a31ef7f --- /dev/null +++ b/arch/common/languages.h @@ -0,0 +1,102 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +void +scan_languages(OperatingSystem * os) +{ + FILE *locale; + gchar buf[128], *retval = ""; + + locale = popen("locale -va", "r"); + if (!locale) + return; + + gchar name[32]; + gchar *title = NULL, + *source = NULL, + *address = NULL, + *email = NULL, + *language = NULL, + *territory = NULL, + *revision = NULL, + *date = NULL, + *codeset = NULL; + + while (fgets(buf, 128, locale)) { + if (!strncmp(buf, "locale:", 7)) { + sscanf(buf, "locale: %s", name); + fgets(buf, 128, locale); + } else if (strchr(buf, '|')) { + gchar **tmp = g_strsplit(buf, "|", 2); + + tmp[0] = g_strstrip(tmp[0]); + + if (tmp[1]) { + tmp[1] = g_strstrip(tmp[1]); + + get_str("title", title); + get_str("source", source); + get_str("address", address); + get_str("email", email); + get_str("language", language); + get_str("territory", territory); + get_str("revision", revision); + get_str("date", date); + get_str("codeset", codeset); + } + + g_strfreev(tmp); + } else { + gchar *currlocale; + + retval = g_strdup_printf("%s$%s$%s=%s\n", retval, name, name, title); + + currlocale = g_strdup_printf("[Locale Information]\n" + "Name=%s (%s)\n" + "Source=%s\n" + "Address=%s\n" + "Email=%s\n" + "Language=%s\n" + "Territory=%s\n" + "Revision=%s\n" + "Date=%s\n" + "Codeset=%s\n", name, title, + source, address, email, language, + territory, revision, date, + codeset); + + g_hash_table_insert(moreinfo, g_strdup(name), currlocale); + + g_free(title); + g_free(source); + g_free(address); + g_free(email); + g_free(language); + g_free(territory); + g_free(revision); + g_free(date); + g_free(codeset); + + title = source = address = email = language = territory = \ + revision = date = codeset = NULL; + } + } + + fclose(locale); + + os->languages = retval; +} diff --git a/arch/common/md5.h b/arch/common/md5.h new file mode 100644 index 00000000..f61aef0f --- /dev/null +++ b/arch/common/md5.h @@ -0,0 +1,62 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <md5.h> + +gchar * +benchmark_md5(void) +{ + struct MD5Context ctx; + guchar checksum[16]; + int i; + GTimer *timer = g_timer_new(); + gdouble elapsed = 0; + gchar src[65536], *tmpsrc; + glong srclen = 65536; + + tmpsrc = src; + + if (!g_file_get_contents(PREFIX "benchmark.data", + &tmpsrc, NULL, NULL)) { + return g_strdup("[Error]\n" + PREFIX "benchmark.data not found=\n"); + } + + shell_view_set_enabled(FALSE); + shell_status_update("Generating MD5 sum for 312MiB of data..."); + + for (i = 0; i <= 5000; i++) { + g_timer_start(timer); + + MD5Init(&ctx); + MD5Update(&ctx, (guchar*)tmpsrc, srclen); + MD5Final(checksum, &ctx); + + g_timer_stop(timer); + elapsed += g_timer_elapsed(timer, NULL); + + shell_status_set_percentage(i/50); + } + + g_timer_destroy(timer); + + gchar *retval = g_strdup_printf("[Results <i>(in seconds; lower is better)</i>]\n" + "<b>This Machine</b>=<b>%.2f</b>\n", elapsed); + return benchmark_include_results(retval, "MD5"); +} + diff --git a/arch/common/printers.h b/arch/common/printers.h new file mode 100644 index 00000000..8632ea18 --- /dev/null +++ b/arch/common/printers.h @@ -0,0 +1,67 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +void +scan_printers(void) +{ + GModule *cups; + static int (*cupsGetPrinters) (char ***printers) = NULL; + static char *(*cupsGetDefault) (void) = NULL; + + if (printer_list) + g_free(printer_list); + + if (!(cupsGetPrinters && cupsGetDefault)) { + cups = g_module_open("libcups", G_MODULE_BIND_LAZY); + if (!cups) { + printer_list = g_strdup("[Printers]\n" + "CUPS libraries cannot be found="); + return; + } + + if (!g_module_symbol(cups, "cupsGetPrinters", (gpointer) & cupsGetPrinters) + || !g_module_symbol(cups, "cupsGetDefault", + (gpointer) & cupsGetDefault)) { + printer_list = + g_strdup("[Printers]\n" "No suitable CUPS library found="); + g_module_close(cups); + return; + } + } + + gchar **printers; + int noprinters, i; + const char *default_printer; + + noprinters = cupsGetPrinters(&printers); + default_printer = cupsGetDefault(); + + if (noprinters > 0) { + printer_list = g_strdup_printf("[Printers (CUPS)]\n"); + for (i = 0; i < noprinters; i++) { + printer_list = g_strconcat(printer_list, printers[i], + !strcmp(default_printer, + printers[i]) ? + "=<i>(Default)</i>\n" : "=\n", + NULL); + g_free(printers[i]); + } + } else { + printer_list = g_strdup("[Printers]\n" "No printers found"); + } +} diff --git a/arch/common/sha1.h b/arch/common/sha1.h new file mode 100644 index 00000000..521cbcae --- /dev/null +++ b/arch/common/sha1.h @@ -0,0 +1,61 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include <sha1.h> + +gchar * +benchmark_sha1(void) +{ + SHA1_CTX ctx; + guchar checksum[20]; + int i; + GTimer *timer = g_timer_new(); + gdouble elapsed = 0; + gchar src[65536], *tmpsrc; + glong srclen = 65536; + + tmpsrc = src; + + if (!g_file_get_contents(PREFIX "benchmark.data", + &tmpsrc, NULL, NULL)) { + return g_strdup("[Error]\n" + PREFIX "benchmark.data not found=\n"); + } + + shell_view_set_enabled(FALSE); + shell_status_update("Generating SHA1 sum for 312MiB of data..."); + + for (i = 0; i <= 5000; i++) { + g_timer_start(timer); + + SHA1Init(&ctx); + SHA1Update(&ctx, (guchar*)tmpsrc, srclen); + SHA1Final(checksum, &ctx); + + g_timer_stop(timer); + elapsed += g_timer_elapsed(timer, NULL); + + shell_status_set_percentage(i/50); + } + + g_timer_destroy(timer); + + gchar *retval = g_strdup_printf("[Results <i>(in seconds; lower is better)</i>]\n" + "<b>This Machine</b>=<b>%.2f</b>\n", elapsed); + return benchmark_include_results(retval, "SHA1"); +} + diff --git a/arch/common/zlib.h b/arch/common/zlib.h new file mode 100644 index 00000000..f68d60f4 --- /dev/null +++ b/arch/common/zlib.h @@ -0,0 +1,85 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static gchar * +benchmark_zlib(void) +{ + GModule *libz; + static gulong (*compressBound) (glong srclen) = NULL; + static gint (*compress) (gchar *dst, glong *dstlen, + const gchar *src, glong srclen) = NULL; + + if (!(compress && compressBound)) { + libz = g_module_open("libz", G_MODULE_BIND_LAZY); + if (!libz) { + libz = g_module_open("/lib/libz.so", G_MODULE_BIND_LAZY); + if (!libz) { + g_print("%s\n", g_module_error()); + return g_strdup("[Error]\n" + "ZLib not found="); + } + } + + if (!g_module_symbol(libz, "compress", (gpointer) & compress) + || !g_module_symbol(libz, "compressBound", (gpointer) & compressBound)) { + + g_module_close(libz); + return g_strdup("[Error]\n" + "Invalid Z-Lib found="); + } + } + + shell_view_set_enabled(FALSE); + + int i; + GTimer *timer = g_timer_new(); + gdouble elapsed = 0; + gchar src[65536], *tmpsrc; + glong srclen = 65536; + + if (!g_file_get_contents(PREFIX "benchmark.data", + &tmpsrc, NULL, NULL)) { + return g_strdup("[Error]\n" + PREFIX "benchmark.data not found=\n"); + } + + shell_status_update("Compressing 64MB with default options..."); + + for (i = 0; i <= 1000; i++) { + g_timer_start(timer); + + gchar *dst; + glong dstlen = compressBound(srclen); + + dst = g_new0(gchar, dstlen); + compress(dst, &dstlen, src, srclen); + + g_timer_stop(timer); + elapsed += g_timer_elapsed(timer, NULL); + g_free(dst); + + shell_status_set_percentage(i/10); + } + + g_timer_destroy(timer); + + gchar *retval = g_strdup_printf("[Results <i>(in seconds; lower is better)</i>]\n" + "<b>This Machine</b>=<b>%.2f</b>\n", elapsed); + return benchmark_include_results(retval, "ZLib"); +} + diff --git a/arch/linux/common/alsa.h b/arch/linux/common/alsa.h new file mode 100644 index 00000000..0c0744ae --- /dev/null +++ b/arch/linux/common/alsa.h @@ -0,0 +1,69 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +gchar * +computer_get_alsacards(Computer * computer) +{ + GSList *p; + gchar *tmp = ""; + gint n = 0; + + if (computer->alsa) { + for (p = computer->alsa->cards; p; p = p->next) { + AlsaCard *ac = (AlsaCard *) p->data; + + tmp = + g_strdup_printf("Audio Adapter#%d=%s\n%s", ++n, + ac->friendly_name, tmp); + } + } + + return tmp; +} + +static AlsaInfo * +computer_get_alsainfo(void) +{ + AlsaInfo *ai; + AlsaCard *ac; + FILE *cards; + gchar buffer[128]; + + cards = fopen("/proc/asound/cards", "r"); + if (!cards) + return NULL; + + ai = g_new0(AlsaInfo, 1); + + while (fgets(buffer, 128, cards)) { + gchar **tmp; + + ac = g_new0(AlsaCard, 1); + + tmp = g_strsplit(buffer, ":", 0); + + ac->friendly_name = g_strdup(tmp[1]); + ai->cards = g_slist_append(ai->cards, ac); + + g_strfreev(tmp); + fgets(buffer, 128, cards); /* skip next line */ + } + fclose(cards); + + return ai; +} diff --git a/arch/linux/common/filesystem.h b/arch/linux/common/filesystem.h new file mode 100644 index 00000000..37e5a730 --- /dev/null +++ b/arch/linux/common/filesystem.h @@ -0,0 +1,103 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Some code from xfce4-mount-plugin, version 0.4.3 + * Copyright (C) 2005 Jean-Baptiste jb_dul@yahoo.com + * Distributed under the terms of GNU GPL 2. + */ +#include <sys/vfs.h> +#define KB 1024 +#define MB 1048576 +#define GB 1073741824 + +static gchar *fs_list = NULL; + +static gchar * +fs_human_readable(gfloat size) +{ + if (size < KB) + return g_strdup_printf("%.1f B", size); + if (size < MB) + return g_strdup_printf("%.1f KiB", size / KB); + if (size < GB) + return g_strdup_printf("%.1f MiB", size / MB); + + return g_strdup_printf("%.1f GiB", size / GB); +} + +static void +scan_filesystems(void) +{ + FILE *mtab; + gchar buf[128]; + struct statfs sfs; + + g_free(fs_list); + fs_list = g_strdup(""); + + mtab = fopen("/etc/mtab", "r"); + if (!mtab) + return; + + while (fgets(buf, 128, mtab)) { + gfloat size, used, avail; + gchar **tmp; + + tmp = g_strsplit(buf, " ", 0); + statfs(tmp[1], &sfs); + + size = (float) sfs.f_bsize * (float) sfs.f_blocks; + avail = (float) sfs.f_bsize * (float) sfs.f_bavail; + used = size - avail; + + gchar *strsize = fs_human_readable(size), + *stravail = fs_human_readable(avail), + *strused = fs_human_readable(used); + + gchar *strhash; + if ((strhash = g_hash_table_lookup(moreinfo, tmp[0]))) { + g_hash_table_remove(moreinfo, tmp[0]); + g_free(strhash); + } + + strhash = g_strdup_printf("[%s]\n" + "Filesystem=%s\n" + "Mounted As=%s\n" + "Mount Point=%s\n" + "Size=%s\n" + "Used=%s\n" + "Available=%s\n", + tmp[0], + tmp[2], + strstr(tmp[3], + "rw") ? "Read-Write" : + "Read-Only", tmp[1], strsize, strused, + stravail); + g_hash_table_insert(moreinfo, g_strdup(tmp[0]), strhash); + + fs_list = g_strdup_printf("%s$%s$%s=%s total, %s free\n", + fs_list, + tmp[0], tmp[0], strsize, stravail); + + g_free(strsize); + g_free(stravail); + g_free(strused); + g_strfreev(tmp); + } + + fclose(mtab); +} diff --git a/arch/linux/common/inputdevices.h b/arch/linux/common/inputdevices.h new file mode 100644 index 00000000..c32015a2 --- /dev/null +++ b/arch/linux/common/inputdevices.h @@ -0,0 +1,117 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static gchar *input_icons = NULL; + +static gboolean +remove_input_devices(gpointer key, gpointer value, gpointer data) +{ + if (!strncmp((gchar *) key, "INP", 3)) { + g_free((gchar *) key); + g_free((GtkTreeIter *) value); + return TRUE; + } + + return FALSE; +} + +static struct { + char *name; + char *icon; +} input_devices[] = { + { "Keyboard", "keyboard.png" }, + { "Joystick", "joystick.png" }, + { "Mouse", "mouse.png" }, + { "Unknown", "module.png" }, +}; + +void +scan_inputdevices(void) +{ + FILE *dev; + gchar buffer[128]; + gchar *tmp, *name = NULL, *phys = NULL; + gint bus, vendor, product, version; + int d = 0, n = 0; + + dev = fopen("/proc/bus/input/devices", "r"); + if (!dev) + return; + + if (input_list) { + g_hash_table_foreach_remove(devices, remove_input_devices, NULL); + g_free(input_list); + g_free(input_icons); + } + input_list = g_strdup(""); + input_icons = g_strdup(""); + + while (fgets(buffer, 128, dev)) { + tmp = buffer; + + switch (*tmp) { + case 'N': + name = g_strdup(tmp + strlen("N: Name=")); + remove_quotes(name); + break; + case 'P': + phys = g_strdup(tmp + strlen("P: Phys=")); + break; + case 'I': + sscanf(tmp, "I: Bus=%x Vendor=%x Product=%x Version=%x", + &bus, &vendor, &product, &version); + break; + case 'H': + if (strstr(tmp, "kbd")) + d = 0; //INPUT_KEYBOARD; + else if (strstr(tmp, "js")) + d = 1; //INPUT_JOYSTICK; + else if (strstr(tmp, "mouse")) + d = 2; //INPUT_MOUSE; + else + d = 3; //INPUT_UNKNOWN; + break; + case '\n': + tmp = g_strdup_printf("INP%d", ++n); + input_list = g_strdup_printf("%s$%s$%s=\n", + input_list, + tmp, name); + input_icons = g_strdup_printf("%sIcon$%s$%s=%s\n", + input_icons, + tmp, name, + input_devices[d].icon); + gchar *strhash = g_strdup_printf("[Device Information]\n" + "Name=%s\n" + "Type=%s\n" + "Bus=0x%x\n" + "Vendor=0x%x\n" + "Product=0x%x\n" + "Version=0x%x\n" + "Connected to=%s\n", + name, input_devices[d].name, + bus, vendor, product, + version, phys); + g_hash_table_insert(devices, tmp, strhash); + + g_free(phys); + g_free(name); + } + } + + fclose(dev); +} diff --git a/arch/linux/common/loadavg.h b/arch/linux/common/loadavg.h new file mode 100644 index 00000000..28132b5f --- /dev/null +++ b/arch/linux/common/loadavg.h @@ -0,0 +1,47 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static LoadInfo * +computer_get_loadinfo(void) +{ + LoadInfo *li = g_new0(LoadInfo, 1); + FILE *procloadavg; + + procloadavg = fopen("/proc/loadavg", "r"); + fscanf(procloadavg, "%f %f %f", &(li->load1), &(li->load5), + &(li->load15)); + fclose(procloadavg); + + return li; +} + +static gchar * +computer_get_formatted_loadavg() +{ + LoadInfo *li; + gchar *tmp; + + li = computer_get_loadinfo(); + + tmp = + g_strdup_printf("%.2f, %.2f, %.2f", li->load1, li->load5, + li->load15); + + g_free(li); + return tmp; +} diff --git a/arch/linux/common/memory.h b/arch/linux/common/memory.h new file mode 100644 index 00000000..def4cc1d --- /dev/null +++ b/arch/linux/common/memory.h @@ -0,0 +1,56 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static MemoryInfo * +computer_get_memory(void) +{ + MemoryInfo *mi; + FILE *procmem; + gchar buffer[128]; + + procmem = fopen("/proc/meminfo", "r"); + if (!procmem) + return NULL; + mi = g_new0(MemoryInfo, 1); + + while (fgets(buffer, 128, procmem)) { + gchar **tmp = g_strsplit(buffer, ":", 2); + + tmp[0] = g_strstrip(tmp[0]); + tmp[1] = g_strstrip(tmp[1]); + + get_int("MemTotal", mi->total); + get_int("MemFree", mi->free); + get_int("Cached", mi->cached); + + g_strfreev(tmp); + } + fclose(procmem); + + mi->used = mi->total - mi->free; + + mi->total /= 1000; + mi->cached /= 1000; + mi->used /= 1000; + mi->free /= 1000; + + mi->used -= mi->cached; + mi->ratio = 1 - (gdouble) mi->used / mi->total; + + return mi; +} diff --git a/arch/linux/common/modules.h b/arch/linux/common/modules.h new file mode 100644 index 00000000..69f7ebd6 --- /dev/null +++ b/arch/linux/common/modules.h @@ -0,0 +1,129 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +void +scan_modules(void) +{ + FILE *lsmod; + gchar buffer[1024]; + + lsmod = popen("/sbin/lsmod", "r"); + if (!lsmod) + return; + + fgets(buffer, 1024, lsmod); /* Discards the first line */ + + while (fgets(buffer, 1024, lsmod)) { + gchar *buf, *strmodule, *hashkey; + gchar *author = NULL, + *description = NULL, + *license = NULL, + *deps = NULL, *vermagic = NULL, *filename = NULL, modname[64]; + FILE *modi; + glong memory; + + shell_status_pulse(); + + buf = buffer; + + sscanf(buf, "%s %ld", modname, &memory); + + hashkey = g_strdup_printf("MOD%s", modname); + buf = g_strdup_printf("/sbin/modinfo %s", modname); + + modi = popen(buf, "r"); + while (fgets(buffer, 1024, modi)) { + gchar **tmp = g_strsplit(buffer, ":", 2); + + GET_STR("author", author); + GET_STR("description", description); + GET_STR("license", license); + GET_STR("depends", deps); + GET_STR("vermagic", vermagic); + GET_STR("filename", filename); + + g_strfreev(tmp); + } + pclose(modi); + g_free(buf); + + /* old modutils includes quotes in some strings; strip them */ + /*remove_quotes(modname); + remove_quotes(description); + remove_quotes(vermagic); + remove_quotes(author); + remove_quotes(license); */ + + /* old modutils displays <none> when there's no value for a + given field; this is not desirable in the module name + display, so change it to an empty string */ + if (description && !strcmp(description, "<none>")) { + g_free(description); + description = g_strdup(""); + } + + /* append this module to the list of modules */ + module_list = g_strdup_printf("%s$%s$%s=%s\n", + module_list, + hashkey, + modname, + description ? description : ""); + +#define NONE_IF_NULL(var) (var) ? (var) : "N/A" + + /* create the module information string */ + strmodule = g_strdup_printf("[Module Information]\n" + "Path=%s\n" + "Used Memory=%.2fKiB\n" + "[Description]\n" + "Name=%s\n" + "Description=%s\n" + "Version Magic=%s\n" + "[Copyright]\n" + "Author=%s\n" + "License=%s\n", + NONE_IF_NULL(filename), + memory / 1024.0, + NONE_IF_NULL(modname), + NONE_IF_NULL(description), + NONE_IF_NULL(vermagic), + NONE_IF_NULL(author), + NONE_IF_NULL(license)); + + /* if there are dependencies, append them to that string */ + if (deps && strlen(deps)) { + gchar **tmp = g_strsplit(deps, ",", 0); + + strmodule = g_strconcat(strmodule, + "\n[Dependencies]\n", + g_strjoinv("=\n", tmp), + "=\n", NULL); + g_strfreev(tmp); + g_free(deps); + } + + g_hash_table_insert(devices, hashkey, strmodule); + + g_free(license); + g_free(description); + g_free(author); + g_free(vermagic); + g_free(filename); + } + pclose(lsmod); +} diff --git a/arch/linux/common/net.h b/arch/linux/common/net.h new file mode 100644 index 00000000..87e7e59b --- /dev/null +++ b/arch/linux/common/net.h @@ -0,0 +1,203 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static gchar *network_interfaces = NULL; + +#include <sys/ioctl.h> +#include <net/if.h> +#include <netinet/in.h> +#include <linux/sockios.h> +#include <sys/socket.h> + +typedef struct _NetInfo NetInfo; +struct _NetInfo { + char name[16]; + int mtu; + unsigned char mac[8]; +}; + + +void get_net_info(char *if_name, NetInfo *netinfo) +{ + struct ifreq ifr; + int fd; + + fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); + + strcpy(ifr.ifr_name, if_name); + strcpy(netinfo->name, if_name); + + if (ioctl(fd, SIOCGIFMTU, &ifr) < 0) { + netinfo->mtu = 0; + } else { + netinfo->mtu = ifr.ifr_mtu; + } + + strcpy(ifr.ifr_name, if_name); + if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { + memset(netinfo->mac, 0, 8); + } else { + memcpy(netinfo->mac, ifr.ifr_ifru.ifru_hwaddr.sa_data, 8); + } + + shutdown(fd, 0); +} + +static struct { + char *type; + char *label; +} netdev2type[] = { + { "eth", "Ethernet" }, + { "lo", "Loopback" }, + { "ppp", "Point-to-Point" }, + { "ath", "Wireless" }, + { "wlan", "Wireless" }, + { "tun", "Virtual Point-to-Point (TUN)" }, + { "tap", "Ethernet (TAP)" }, + { "plip", "Parallel Line Internet Protocol" }, + { "irlan", "Infrared" }, + { "slip", "Serial Line Internet Protocol" }, + { "isdn", "Integrated Services Digital Network" }, + { "sit", "IPv6-over-IPv4 Tunnel" }, + { "vmnet8", "VMWare Virtual Network Interface (NAT)" }, + { "vmnet", "VMWare Virtual Network Interface" }, + { NULL, "Unknown" }, +}; + +static const gchar * +net_get_iface_type(gchar *name) +{ + int i; + + for (i = 0; netdev2type[i].type; i++) { + if (g_str_has_prefix(name, netdev2type[i].type)) + break; + } + + return netdev2type[i].label; +} + +static gboolean +remove_net_devices(gpointer key, gpointer value, gpointer data) +{ + if (!strncmp((gchar *) key, "NET", 4)) { + g_free((gchar *) key); + g_free((GtkTreeIter *) value); + return TRUE; + } + return FALSE; +} + +static void +scan_net_interfaces_24(void) +{ + FILE *proc_net; + NetInfo ni; + gchar buffer[256]; + gchar *devid, *detailed; + gulong recv_bytes; + gulong recv_errors; + gulong recv_packets; + + gulong trans_bytes; + gulong trans_errors; + gulong trans_packets; + + if (!g_file_test("/proc/net/dev", G_FILE_TEST_EXISTS)) { + if (network_interfaces) { + g_free(network_interfaces); + network_interfaces = g_strdup("[Network Interfaces]\n" + "None found=\n"); + } + + return; + } + + if (network_interfaces) { + g_free(network_interfaces); + } + + network_interfaces = g_strdup("[Network Interfaces]\n"); + + proc_net = fopen("/proc/net/dev", "r"); + while (fgets(buffer, 256, proc_net)) { + if (strchr(buffer, ':')) { + gint trash; + gchar ifacename[16]; + gchar *buf = buffer; + gint i; + + buf = g_strstrip(buf); + + memset(ifacename, 0, 16); + + for (i = 0; buffer[i] != ':' && i < 16; i++) { + ifacename[i] = buffer[i]; + } + + buf = strchr(buf, ':') + 1; + + /* iface: bytes packets errs drop fifo frame compressed multicast */ + sscanf(buf, "%ld %ld %ld %d %d %d %d %d %ld %ld %ld", + &recv_bytes, &recv_packets, + &recv_errors, &trash, &trash, &trash, &trash, + &trash, &trans_bytes, &trans_packets, + &trans_errors); + + gfloat recv_mb = recv_bytes / 1048576.0; + gfloat trans_mb = trans_bytes / 1048576.0; + + devid = g_strdup_printf("NET%s", ifacename); + network_interfaces = g_strdup_printf("%s$%s$%s=Sent %.2fMiB, received %.2fMiB\n", + network_interfaces, + devid, + ifacename, + trans_mb, + recv_mb); + + get_net_info(ifacename, &ni); + detailed = g_strdup_printf("[Network Adapter Properties]\n" + "Interface Type=%s\n" + "Hardware Address=%02x:%02x:%02x:%02x:%02x:%02x\n" + "MTU=%d\n" + "Bytes Sent=%ld (%.2fMiB)\n" + "Bytes Received=%ld (%.2fMiB)\n", + net_get_iface_type(ifacename), + ni.mac[0], ni.mac[1], + ni.mac[2], ni.mac[3], + ni.mac[4], ni.mac[5], + ni.mtu, + recv_bytes, recv_mb, + trans_bytes, trans_mb); + g_hash_table_insert(moreinfo, devid, detailed); + } + } + fclose(proc_net); +} + +static void +scan_net_interfaces(void) +{ + /* FIXME: See if we're running Linux 2.6 and if /sys is mounted, then use + that instead of /proc/net/dev */ + + /* remove old devices from global device table */ + g_hash_table_foreach_remove(moreinfo, remove_net_devices, NULL); + + scan_net_interfaces_24(); +} diff --git a/arch/linux/common/os.h b/arch/linux/common/os.h new file mode 100644 index 00000000..0f7b59e3 --- /dev/null +++ b/arch/linux/common/os.h @@ -0,0 +1,203 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static gchar * +get_libc_version(void) +{ + FILE *libc; + gchar buf[256], *tmp, *p; + + libc = popen("/lib/libc.so.6", "r"); + if (!libc) goto err; + + fgets(buf, 256, libc); + if (pclose(libc)) goto err; + + tmp = strstr(buf, "version "); + if (!tmp) goto err; + + p = strchr(tmp, ','); + if (p) *p = '\0'; + else goto err; + + return g_strdup_printf("GNU C Library version %s (%sstable)", + strchr(tmp, ' ') + 1, + strstr(buf, " stable ") ? "" : "un"); + err: + return g_strdup("Unknown"); +} + +static gchar * +get_os_compiled_date(void) +{ + FILE *procversion; + gchar buf[512]; + + procversion = fopen("/proc/sys/kernel/version", "r"); + if (!procversion) + return g_strdup("Unknown"); + + fgets(buf, 512, procversion); + fclose(procversion); + + return g_strdup(buf); +} + + +#include <gdk/gdkx.h> + +void +detect_desktop_environment(OperatingSystem * os) +{ + const gchar *tmp = g_getenv("GNOME_DESKTOP_SESSION_ID"); + FILE *version; + int maj, min; + + if (tmp) { + /* FIXME: this might not be true, as the gnome-panel in path + may not be the one that's running. + see where the user's running panel is and run *that* to + obtain the version. */ + version = popen("gnome-panel --version", "r"); + if (version) { + fscanf(version, "Gnome gnome-panel %d.%d", &maj, &min); + if (pclose(version)) + goto unknown; + } else { + goto unknown; + } + + os->desktop = + g_strdup_printf("GNOME %d.%d (session name: %s)", maj, min, + tmp); + } else if (g_getenv("KDE_FULL_SESSION")) { + version = popen("kcontrol --version", "r"); + if (version) { + char buf[32]; + + fgets(buf, 32, version); + + fscanf(version, "KDE: %d.%d", &maj, &min); + if (pclose(version)) + goto unknown; + } else { + goto unknown; + } + + os->desktop = g_strdup_printf("KDE %d.%d", maj, min); + } else { + unknown: + if (!g_getenv("DISPLAY")) { + os->desktop = g_strdup("Terminal"); + } else { + const gchar *windowman; + GdkScreen *screen = gdk_screen_get_default(); + + windowman = gdk_x11_screen_get_window_manager_name(screen); + + if (g_str_equal(windowman, "Xfwm4")) { + /* FIXME: check if xprop -root | grep XFCE_DESKTOP_WINDOW + is defined */ + os->desktop = g_strdup("XFCE 4"); + } else { + os->desktop = g_strdup_printf("Unknown (Window Manager: %s)", + windowman); + } + } + } +} + +static OperatingSystem * +computer_get_os(void) +{ + struct utsname utsbuf; + OperatingSystem *os; + int i; + + os = g_new0(OperatingSystem, 1); + + os->compiled_date = get_os_compiled_date(); + + /* Attempt to get the Distribution name; try using /etc/lsb-release first, + then doing the legacy method (checking for /etc/$DISTRO-release files) */ + if (g_file_test("/etc/lsb-release", G_FILE_TEST_EXISTS)) { + FILE *release; + gchar buffer[128]; + + release = popen("lsb_release -d", "r"); + fgets(buffer, 128, release); + pclose(release); + + os->distro = buffer; + os->distro = g_strdup(os->distro + strlen("Description:\t")); + } + + for (i = 0;; i++) { + if (distro_db[i].file == NULL) { + os->distrocode = g_strdup("unk"); + os->distro = g_strdup("Unknown distribution"); + break; + } + + if (g_file_test(distro_db[i].file, G_FILE_TEST_EXISTS)) { + + + FILE *distro_ver; + char buf[128]; + + distro_ver = fopen(distro_db[i].file, "r"); + fgets(buf, 128, distro_ver); + fclose(distro_ver); + + buf[strlen(buf) - 1] = 0; + + if (!os->distro) { + /* + * HACK: Some Debian systems doesn't include + * the distribuition name in /etc/debian_release, + * so add them here. + */ + if (!strncmp(distro_db[i].codename, "deb", 3) && + ((buf[0] >= '0' && buf[0] <= '9') || buf[0] != 'D')) { + os->distro = g_strdup_printf + ("Debian GNU/Linux %s", buf); + } else { + os->distro = g_strdup(buf); + } + } + os->distrocode = g_strdup(distro_db[i].codename); + + break; + } + } + + /* Kernel and hostname info */ + uname(&utsbuf); + os->kernel = g_strdup_printf("%s %s (%s)", utsbuf.sysname, + utsbuf.release, utsbuf.machine); + os->hostname = g_strdup(utsbuf.nodename); + os->language = g_strdup(g_getenv("LC_MESSAGES")); + os->homedir = g_strdup(g_get_home_dir()); + os->username = g_strdup_printf("%s (%s)", + g_get_user_name(), g_get_real_name()); + os->libc = get_libc_version(); + scan_languages(os); + detect_desktop_environment(os); + + return os; +} diff --git a/arch/linux/common/pci.h b/arch/linux/common/pci.h new file mode 100644 index 00000000..f8c9d319 --- /dev/null +++ b/arch/linux/common/pci.h @@ -0,0 +1,190 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +void +scan_pci(void) +{ + FILE *lspci; + gchar buffer[256], *buf, *strhash = NULL, *strdevice = NULL; + gchar *category = NULL, *name = NULL; + gint n = 0; + + //if (g_file_test("/usr/bin/gksudo", G_FILE_TEST_EXISTS)) { + // lspci = popen("gksudo '/bin/lspci -v'", "r"); + //} else { + lspci = popen(LSPCI, "r"); + //} + + if (!lspci) { + return; + } + + gchar *icon; + + int x = 0; /* unique Memory, Capability and I/O port */ + while (fgets(buffer, 256, lspci)) { + buf = g_strstrip(buffer); + + if (!strncmp(buf, "Flags", 5)) { + gint irq = 0, freq = 0, latency = 0, i; + gchar **list; + gboolean bus_master; + + buf += 7; + + bus_master = FALSE; + + list = g_strsplit(buf, ", ", 10); + for (i = 0; i <= 10; i++) { + if (!list[i]) + break; + + if (!strncmp(list[i], "IRQ", 3)) + sscanf(list[i], "IRQ %d", &irq); + else if (strstr(list[i], "Mhz")) + sscanf(list[i], "%dMhz", &freq); + else if (!strncmp(list[i], "bus master", 10)) + bus_master = TRUE; + else if (!strncmp(list[i], "latency", 7)) + sscanf(list[i], "latency %d", &latency); + } + g_strfreev(list); + + if (irq) + strdevice = g_strdup_printf("%sIRQ=%d\n", strdevice, irq); + if (freq) + strdevice = + g_strdup_printf("%sFrequency=%dMHz\n", strdevice, + freq); + if (latency) + strdevice = + g_strdup_printf("%sLatency=%d\n", strdevice, latency); + + strdevice = + g_strdup_printf("%sBus Master=%s\n", strdevice, + bus_master ? "Yes" : "No"); + } else if (!strncmp(buf, "Subsystem", 9)) { + WALK_UNTIL(' '); + buf++; + strdevice = + g_strdup_printf("%sOEM Vendor=%s\n", strdevice, buf); + } else if (!strncmp(buf, "Capabilities", 12) + && !strstr(buf, "only to root") && + !strstr(buf, "access denied")) { + WALK_UNTIL(' '); + WALK_UNTIL(']'); + buf++; + strdevice = + g_strdup_printf("%sCapability#%d=%s\n", strdevice, ++x, + buf); + } else if (!strncmp(buf, "Memory at", 9) && strstr(buf, "[size=")) { + gint mem; + gchar unit; + gboolean prefetch; + gboolean _32bit; + + prefetch = strstr(buf, "non-prefetchable") ? FALSE : TRUE; + _32bit = strstr(buf, "32-bit") ? TRUE : FALSE; + + WALK_UNTIL('['); + sscanf(buf, "[size=%d%c", &mem, &unit); + + strdevice = g_strdup_printf("%sMemory#%d=%d%cB (%s%s)\n", + strdevice, ++x, + mem, + (unit == ']') ? ' ' : unit, + _32bit ? "32-bit, " : "", + prefetch ? "prefetchable" : + "non-prefetchable"); + + } else if (!strncmp(buf, "I/O", 3)) { + guint io_addr, io_size; + + sscanf(buf, "I/O ports at %x [size=%d]", &io_addr, &io_size); + + strdevice = + g_strdup_printf("%sI/O ports at#%d=0x%x - 0x%x\n", + strdevice, ++x, io_addr, + io_addr + io_size); + } else if ((buf[0] >= '0' && buf[0] <= '9') && (buf[4] == ':' || buf[2] == ':')) { + gint bus, device, function, domain; + gpointer start, end; + + if (strdevice != NULL && strhash != NULL) { + g_hash_table_insert(devices, strhash, strdevice); + g_free(category); + g_free(name); + } + + if (buf[4] == ':') { + sscanf(buf, "%x:%x:%x.%d", &domain, &bus, &device, &function); + } else { + /* lspci without domain field */ + sscanf(buf, "%x:%x.%x", &bus, &device, &function); + domain = 0; + } + + WALK_UNTIL(' '); + + start = buf; + + WALK_UNTIL(':'); + end = buf + 1; + *buf = 0; + + buf = start + 1; + category = g_strdup(buf); + + buf = end; + start = buf; + WALK_UNTIL('('); + *buf = 0; + buf = start + 1; + + if (strstr(category, "RAM memory")) icon = "mem"; + else if (strstr(category, "Multimedia")) icon = "media"; + else if (strstr(category, "USB")) icon = "usb"; + else icon = "pci"; + + name = g_strdup(buf); + + strhash = g_strdup_printf("PCI%d", n); + strdevice = g_strdup_printf("[Device Information]\n" + "Name=%s\n" + "Class=%s\n" + "Domain=%d\n" + "Bus, device, function=%d, %d, %d\n", + name, category, domain, bus, + device, function); + pci_list = g_strdup_printf("%s$PCI%d$%s=%s\n", pci_list, n, category, + name); + + n++; + } + } + + if (pclose(lspci)) { + /* error (no pci, perhaps?) */ + pci_list = g_strconcat(pci_list, "No PCI devices found=\n", NULL); + } else if (strhash) { + /* insert the last device */ + g_hash_table_insert(devices, strhash, strdevice); + g_free(category); + g_free(name); + } +} diff --git a/arch/linux/common/samba.h b/arch/linux/common/samba.h new file mode 100644 index 00000000..538659a6 --- /dev/null +++ b/arch/linux/common/samba.h @@ -0,0 +1,80 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static gchar *shares_list = NULL; +void +scan_shared_directories(void) +{ + GKeyFile *keyfile; + GError *error = NULL; + gchar **groups; + gchar *smbconf; + gsize length; + + if (shares_list) { + g_free(shares_list); + } + + keyfile = g_key_file_new(); + + if (!g_file_get_contents("/etc/samba/smb.conf", &smbconf, &length, &error)) { + shares_list = g_strdup("Cannot open /etc/samba/smb.conf=\n"); + g_error_free(error); + goto cleanup; + } + + gchar *_smbconf = smbconf; + for (; *_smbconf; _smbconf++) + if (*_smbconf == ';') *_smbconf = '\0'; + + if (!g_key_file_load_from_data(keyfile, smbconf, length, 0, &error)) { + shares_list = g_strdup("Cannot parse smb.conf=\n"); + g_error_free(error); + goto cleanup; + } + + shares_list = g_strdup(""); + + groups = g_key_file_get_groups(keyfile, NULL); + gchar **_groups = groups; + while (*groups) { + if (g_key_file_has_key(keyfile, *groups, "path", NULL) && + g_key_file_has_key(keyfile, *groups, "available", NULL)) { + + gchar *available = g_key_file_get_string(keyfile, *groups, "available", NULL); + + if (g_str_equal(available, "yes")) { + gchar *path = g_key_file_get_string(keyfile, *groups, "path", NULL); + shares_list = g_strconcat(shares_list, *groups, "=", + path, "\n", NULL); + g_free(path); + } + + g_free(available); + } + + *groups++; + } + + g_strfreev(_groups); + + cleanup: + g_key_file_free(keyfile); + g_free(smbconf); +} + diff --git a/arch/linux/common/sensors.h b/arch/linux/common/sensors.h new file mode 100644 index 00000000..ef834de2 --- /dev/null +++ b/arch/linux/common/sensors.h @@ -0,0 +1,237 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static gchar *sensors = NULL; +static GHashTable *sensor_labels = NULL; +static GHashTable *sensor_compute = NULL; + +static void +read_sensor_labels(gchar *driver) +{ + FILE *conf; + gchar buf[256], *line, *p; + gboolean lock = FALSE; + gint i; + + sensor_labels = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, g_free); + sensor_compute = g_hash_table_new(g_str_hash, g_str_equal); + + conf = fopen("/etc/sensors.conf", "r"); + if (!conf) + return; + + while (fgets(buf, 256, conf)) { + line = buf; + + remove_linefeed(line); + strend(line, '#'); + + if (*line == '\0') { + continue; + } else if (lock && strstr(line, "label")) { /* label lines */ + gchar **names = g_strsplit(strstr(line, "label") + 5, " ", 0); + gchar *name = NULL, *value = NULL; + + for (i = 0; names[i]; i++) { + if (names[i][0] == '\0') + continue; + + if (!name) name = g_strdup(names[i]); + else if (!value) value = g_strdup(names[i]); + else value = g_strconcat(value, " ", names[i], NULL); + } + + remove_quotes(value); + g_hash_table_insert(sensor_labels, name, value); + + g_strfreev(names); + } else if (lock && strstr(line, "ignore")) { /* ignore lines */ + p = strstr(line, "ignore") + 6; + if (!strchr(p, ' ')) + continue; + + while (*p == ' ') p++; + g_hash_table_insert(sensor_labels, g_strdup(p), "ignore"); + } else if (lock && strstr(line, "compute")) { /* compute lines */ + gchar **formulas = g_strsplit(strstr(line, "compute") + 7, " ", 0); + gchar *name = NULL, *formula = NULL; + + for (i = 0; formulas[i]; i++) { + if (formulas[i][0] == '\0') + continue; + if (formulas[i][0] == ',') + break; + + if (!name) name = g_strdup(formulas[i]); + else if (!formula) formula = g_strdup(formulas[i]); + else formula = g_strconcat(formula, formulas[i], NULL); + } + + g_strfreev(formulas); + g_hash_table_insert(sensor_compute, name, math_string_to_postfix(formula)); + } else if (g_str_has_prefix(line, "chip")) { /* chip lines (delimiter) */ + if (lock == FALSE) { + gchar **chips = g_strsplit(line, " ", 0); + + for (i = 1; chips[i]; i++) { + strend(chips[i], '*'); + + if (g_str_has_prefix(driver, chips[i] + 1)) { + lock = TRUE; + break; + } + } + + g_strfreev(chips); + } else { + break; + } + } + } + + fclose(conf); +} + +static gchar * +get_sensor_label(gchar *sensor) +{ + gchar *ret; + + ret = g_hash_table_lookup(sensor_labels, sensor); + if (!ret) ret = g_strdup(sensor); + else ret = g_strdup(ret); + + return ret; +} + +static float +adjust_sensor(gchar *name, float value) +{ + GSList *postfix; + + postfix = g_hash_table_lookup(sensor_compute, name); + if (!postfix) return value; + + return math_postfix_eval(postfix, value); +} + +static void +read_sensors(void) +{ + gchar *path_hwmon, *path_sensor, *tmp, *driver, *name, *mon; + int hwmon, count; + + if (sensors) + g_free(sensors); + + hwmon = 0; + sensors = g_strdup(""); + + path_hwmon = g_strdup_printf("/sys/class/hwmon/hwmon%d/device/", hwmon); + while (g_file_test(path_hwmon, G_FILE_TEST_EXISTS)) { + tmp = g_strdup_printf("%sdriver", path_hwmon); + driver = g_file_read_link(tmp, NULL); + g_free(tmp); + + tmp = g_path_get_basename(driver); + g_free(driver); + driver = tmp; + + if (!sensor_labels) { + read_sensor_labels(driver); + } + + sensors = g_strdup_printf("%s[Driver Info]\n" + "Name=%s\n", sensors, driver); + + sensors = g_strconcat(sensors, "[Cooling Fans]\n", NULL); + for (count = 1; ; count++) { + path_sensor = g_strdup_printf("%sfan%d_input", path_hwmon, count); + if (!g_file_get_contents(path_sensor, &tmp, NULL, NULL)) { + g_free(path_sensor); + break; + } + + mon = g_strdup_printf("fan%d", count); + name = get_sensor_label(mon); + if (!g_str_equal(name, "ignore")) { + sensors = g_strdup_printf("%s%s=%.0fRPM\n", + sensors, name, + adjust_sensor(mon, atof(tmp))); + } + + g_free(name); + g_free(mon); + g_free(tmp); + g_free(path_sensor); + } + + sensors = g_strconcat(sensors, "[Temperatures]\n", NULL); + for (count = 1; ; count++) { + path_sensor = g_strdup_printf("%stemp%d_input", path_hwmon, count); + if (!g_file_get_contents(path_sensor, &tmp, NULL, NULL)) { + g_free(path_sensor); + break; + } + + mon = g_strdup_printf("temp%d", count); + name = get_sensor_label(mon); + if (!g_str_equal(name, "ignore")) { + sensors = g_strdup_printf("%s%s=%.2f\302\260C\n", + sensors, name, + adjust_sensor(mon, atof(tmp) / 1000.0)); + } + + g_free(tmp); + g_free(name); + g_free(path_sensor); + g_free(mon); + } + + sensors = g_strconcat(sensors, "[Voltage Values]\n", NULL); + for (count = 0; ; count++) { + path_sensor = g_strdup_printf("%sin%d_input", path_hwmon, count); + if (!g_file_get_contents(path_sensor, &tmp, NULL, NULL)) { + g_free(path_sensor); + break; + } + + + mon = g_strdup_printf("in%d", count); + name = get_sensor_label(mon); + if (!g_str_equal(name, "ignore")) { + sensors = g_strdup_printf("%s%s=%.3fV\n", + sensors, name, + adjust_sensor(mon, atof(tmp) / 1000.0)); + } + + g_free(tmp); + g_free(mon); + g_free(name); + g_free(path_sensor); + } + + g_free(path_hwmon); + g_free(driver); + path_hwmon = g_strdup_printf("/sys/class/hwmon/hwmon%d/device/", ++hwmon); + } + + g_free(path_hwmon); +} + diff --git a/arch/linux/common/storage.h b/arch/linux/common/storage.h new file mode 100644 index 00000000..4fb682a9 --- /dev/null +++ b/arch/linux/common/storage.h @@ -0,0 +1,268 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static gchar *storage_icons = ""; + +static gboolean +remove_scsi_devices(gpointer key, gpointer value, gpointer data) +{ + if (!strncmp((gchar *) key, "SCSI", 4)) { + g_free((gchar *) key); + g_free((GtkTreeIter *) value); + return TRUE; + } + return FALSE; +} + +/* SCSI support by Pascal F.Martin <pascalmartin@earthlink.net> */ +void +scan_scsi(void) +{ + FILE *proc_scsi; + gchar buffer[256], *buf; + gint n = 0; + gint scsi_controller; + gint scsi_channel; + gint scsi_id; + gint scsi_lun; + gchar *vendor = NULL, *revision = NULL, *model = NULL; + + /* remove old devices from global device table */ + g_hash_table_foreach_remove(devices, remove_scsi_devices, NULL); + + if (!g_file_test("/proc/scsi/scsi", G_FILE_TEST_EXISTS)) + return; + + storage_list = g_strconcat(storage_list, "\n[SCSI Disks]\n", NULL); + + proc_scsi = fopen("/proc/scsi/scsi", "r"); + while (fgets(buffer, 256, proc_scsi)) { + buf = g_strstrip(buffer); + if (!strncmp(buf, "Host: scsi", 10)) { + sscanf(buf, + "Host: scsi%d Channel: %d Id: %d Lun: %d", + &scsi_controller, &scsi_channel, &scsi_id, &scsi_lun); + + n++; + } else if (!strncmp(buf, "Vendor: ", 8)) { + char *p; + char *rev = strstr(buf, "Rev: "); + + model = strstr(buf, "Model: "); + + if (model == NULL) { + model = buf + strlen(buf); + } + p = model; + while (*(--p) == ' '); + *(++p) = 0; + vendor = g_strdup(buf + 8); + + if (rev != NULL) { + revision = g_strdup(rev + 5); + } else { + rev = model + strlen(model); + } + p = rev; + while (*(--p) == ' '); + *(++p) = 0; + model = g_strdup_printf("%s %s", vendor, model + 7); + + } else if (!strncmp(buf, "Type: ", 8)) { + char *p = strstr(buf, "ANSI SCSI revi"); + gchar *type = NULL, *icon = NULL; + + if (p != NULL) { + while (*(--p) == ' '); + *(++p) = 0; + + static struct { + char *type; + char *label; + char *icon; + } type2icon[] = { + { "Direct-Access", "Disk", "hdd"}, + { "Sequential-Access", "Tape", "tape"}, + { "Printer", "Printer", "lpr"}, + { "WORM", "CD-ROM", "cd"}, + { "CD-ROM", "CD-ROM", "cd"}, + { "Scanner", "Scanner", "scanner"}, + { NULL, "Generic", "scsi"} + }; + int i; + + for (i = 0; type2icon[i].type != NULL; i++) + if (!strcmp(buf + 8, type2icon[i].type)) + break; + + type = type2icon[i].label; + icon = type2icon[i].icon; + } + + gchar *devid = g_strdup_printf("SCSI%d", n); + storage_list = g_strdup_printf("%s$%s$%s=\n", storage_list, devid, model); + storage_icons = g_strdup_printf("%sIcon$%s$%s=%s.png\n", storage_icons, devid, model, icon); + + gchar *strhash = g_strdup_printf("[Device Information]\n" + "Model=%s\n" + "Type=%s\n" + "Revision=%s\n" + "[SCSI Controller]\n" + "Controller=scsi%d\n" + "Channel=%d\n" + "ID=%d\n" "LUN=%d\n", + model, + type, + revision, + scsi_controller, + scsi_channel, + scsi_id, + scsi_lun); + g_hash_table_insert(devices, devid, strhash); + + g_free(model); + g_free(revision); + g_free(vendor); + } + } + fclose(proc_scsi); +} + +static gboolean +remove_ide_devices(gpointer key, gpointer value, gpointer data) +{ + if (!strncmp((gchar *) key, "IDE", 3)) { + g_free((gchar *) key); + g_free((gchar *) value); + + return TRUE; + } + return FALSE; +} + + +void +scan_ide(void) +{ + FILE *proc_ide; + gchar *device, iface, *model, *media, *pgeometry = NULL, *lgeometry = + NULL; + gint n = 0, i = 0, cache; + + /* remove old devices from global device table */ + g_hash_table_foreach_remove(devices, remove_ide_devices, NULL); + + storage_list = g_strdup_printf("%s\n[IDE Disks]\n", storage_list); + + iface = 'a'; + for (i = 0; i <= 16; i++) { + device = g_strdup_printf("/proc/ide/hd%c/model", iface); + if (g_file_test(device, G_FILE_TEST_EXISTS)) { + gchar buf[64]; + + cache = 0; + + proc_ide = fopen(device, "r"); + fgets(buf, 64, proc_ide); + fclose(proc_ide); + + buf[strlen(buf) - 1] = 0; + + model = g_strdup(buf); + + g_free(device); + + device = g_strdup_printf("/proc/ide/hd%c/media", iface); + proc_ide = fopen(device, "r"); + fgets(buf, 64, proc_ide); + fclose(proc_ide); + buf[strlen(buf) - 1] = 0; + + media = g_strdup(buf); + + g_free(device); + + device = g_strdup_printf("/proc/ide/hd%c/cache", iface); + if (g_file_test(device, G_FILE_TEST_EXISTS)) { + proc_ide = fopen(device, "r"); + fscanf(proc_ide, "%d", &cache); + fclose(proc_ide); + } + g_free(device); + + device = g_strdup_printf("/proc/ide/hd%c/geometry", iface); + if (g_file_test(device, G_FILE_TEST_EXISTS)) { + gchar *tmp; + + proc_ide = fopen(device, "r"); + + fgets(buf, 64, proc_ide); + for (tmp = buf; *tmp; tmp++) { + if (*tmp >= '0' && *tmp <= '9') + break; + } + + pgeometry = g_strdup(g_strstrip(tmp)); + + fgets(buf, 64, proc_ide); + for (tmp = buf; *tmp; tmp++) { + if (*tmp >= '0' && *tmp <= '9') + break; + } + lgeometry = g_strdup(g_strstrip(tmp)); + + fclose(proc_ide); + } + g_free(device); + + n++; + + gchar *devid = g_strdup_printf("IDE%d", n); + + storage_list = g_strdup_printf("%s$%s$%s=\n", storage_list, + devid, model); + storage_icons = g_strdup_printf("%sIcon$%s$%s=%s.png\n", storage_icons, devid, + model, g_str_equal(media, "cdrom") ? \ + "cdrom" : "hdd"); + + gchar *strhash = g_strdup_printf("[Device Information]\n" + "Model=%s\n" + "Device Name=hd%c\n" + "Media=%s\n" "Cache=%dkb\n", + model, iface, media, cache); + if (pgeometry && lgeometry) + strhash = g_strdup_printf("%s[Geometry]\n" + "Physical=%s\n" + "Logical=%s\n", + strhash, pgeometry, lgeometry); + + g_hash_table_insert(devices, devid, strhash); + + g_free(model); + model = ""; + + g_free(pgeometry); + pgeometry = NULL; + g_free(lgeometry); + lgeometry = NULL; + } else + g_free(device); + + iface++; + } +} diff --git a/arch/linux/common/uptime.h b/arch/linux/common/uptime.h new file mode 100644 index 00000000..cf339bf3 --- /dev/null +++ b/arch/linux/common/uptime.h @@ -0,0 +1,75 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static UptimeInfo * +computer_get_uptime(void) +{ + UptimeInfo *ui = g_new0(UptimeInfo, 1); + FILE *procuptime; + gulong minutes; + + if ((procuptime = fopen("/proc/uptime", "r")) != NULL) { + fscanf(procuptime, "%lu", &minutes); + ui->minutes = minutes / 60; + fclose(procuptime); + } else { + return NULL; + } + + ui->hours = ui->minutes / 60; + ui->minutes %= 60; + ui->days = ui->hours / 24; + ui->hours %= 24; + + return ui; +} + +static gchar * +computer_get_formatted_uptime() +{ + UptimeInfo *ui; + gchar *tmp; + + ui = computer_get_uptime(); + + /* FIXME: Use ngettext */ +#define plural(x) ((x > 1) ? "s" : "") + + + if (ui->days < 1) { + if (ui->hours < 1) { + tmp = + g_strdup_printf("%d minute%s", ui->minutes, + plural(ui->minutes)); + } else { + tmp = + g_strdup_printf("%d hour%s, %d minute%s", ui->hours, + plural(ui->hours), ui->minutes, + plural(ui->minutes)); + } + } else { + tmp = + g_strdup_printf("%d day%s, %d hour%s and %d minute%s", + ui->days, plural(ui->days), ui->hours, + plural(ui->hours), ui->minutes, + plural(ui->minutes)); + } + + g_free(ui); + return tmp; +} diff --git a/arch/linux/common/usb.h b/arch/linux/common/usb.h new file mode 100644 index 00000000..a52be2cb --- /dev/null +++ b/arch/linux/common/usb.h @@ -0,0 +1,132 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static gboolean +remove_usb_devices(gpointer key, gpointer value, gpointer data) +{ + if (!strncmp((gchar *) key, "USB", 3)) { + GtkTreeIter *iter = (GtkTreeIter *) data; + + g_free((gchar *) value); + g_free(iter); + + return TRUE; + } + return FALSE; +} + +static gchar *usb_list = NULL; +void +scan_usb(void) +{ + FILE *dev; + gchar buffer[128]; + gchar *tmp, *manuf = NULL, *product = NULL, *mxpwr; + gint bus, level, port, classid, trash; + gint vendor, prodid; + gfloat ver, rev, speed; + int n = 0; + + dev = fopen("/proc/bus/usb/devices", "r"); + if (!dev) + return; + + if (usb_list) { + g_hash_table_foreach_remove(devices, remove_usb_devices, NULL); + g_free(usb_list); + } + usb_list = g_strdup(""); + + while (fgets(buffer, 128, dev)) { + tmp = buffer; + + switch (*tmp) { + case 'T': + sscanf(tmp, + "T: Bus=%d Lev=%d Prnt=%d Port=%d Cnt=%d Dev#=%d Spd=%f", + &bus, &level, &trash, &port, &trash, &trash, &speed); + break; + case 'D': + sscanf(tmp, "D: Ver=%f Cls=%x", &ver, &classid); + break; + case 'P': + sscanf(tmp, "P: Vendor=%x ProdID=%x Rev=%f", + &vendor, &prodid, &rev); + break; + case 'S': + if (strstr(tmp, "Manufacturer=")) { + manuf = g_strdup(strchr(tmp, '=') + 1); + remove_linefeed(manuf); + } else if (strstr(tmp, "Product=")) { + product = g_strdup(strchr(tmp, '=') + 1); + remove_linefeed(product); + } + break; + case 'C': + mxpwr = strstr(buffer, "MxPwr=") + 6; + + tmp = g_strdup_printf("USB%d", ++n); + + if (*product == '\0') { + g_free(product); + if (classid == 9) { + product = g_strdup_printf("USB %.2f Hub", ver); + } else { + product = g_strdup_printf("Unknown USB %.2f Device (class %d)", + ver, classid); + } + } + + + if (classid == 9) { /* hub */ + usb_list = g_strdup_printf("%s[%s#%d]\n", + usb_list, product, n); + } else { /* everything else */ + usb_list = g_strdup_printf("%s$%s$%s=\n", + usb_list, tmp, product); + + gchar *strhash = g_strdup_printf("[Device Information]\n" + "Product=%s\n" + "Manufacturer=%s\n" + "[Port #%d]\n" + "Speed=%.2fMbit/s\n" + "Max Current=%s\n" + "[Misc]\n" + "USB Version=%.2f\n" + "Revision=%.2f\n" + "Class=0x%x\n" + "Vendor=0x%x\n" + "Product ID=0x%x\n" + "Bus=%d\n" "Level=%d\n", + product, manuf, + port, speed, mxpwr, + ver, rev, classid, + vendor, prodid, bus, level); + + g_hash_table_insert(devices, tmp, strhash); + } + + g_free(manuf); + g_free(product); + manuf = g_strdup(""); + product = g_strdup(""); + } + } + + fclose(dev); +} diff --git a/arch/linux/m68k/alsa.h b/arch/linux/m68k/alsa.h new file mode 120000 index 00000000..0216845a --- /dev/null +++ b/arch/linux/m68k/alsa.h @@ -0,0 +1 @@ +../../linux/common/alsa.h
\ No newline at end of file diff --git a/arch/linux/m68k/filesystem.h b/arch/linux/m68k/filesystem.h new file mode 120000 index 00000000..6b325b40 --- /dev/null +++ b/arch/linux/m68k/filesystem.h @@ -0,0 +1 @@ +../../linux/common/filesystem.h
\ No newline at end of file diff --git a/arch/linux/m68k/inputdevices.h b/arch/linux/m68k/inputdevices.h new file mode 120000 index 00000000..b9226a29 --- /dev/null +++ b/arch/linux/m68k/inputdevices.h @@ -0,0 +1 @@ +../../linux/common/inputdevices.h
\ No newline at end of file diff --git a/arch/linux/m68k/loadavg.h b/arch/linux/m68k/loadavg.h new file mode 120000 index 00000000..daaed6d5 --- /dev/null +++ b/arch/linux/m68k/loadavg.h @@ -0,0 +1 @@ +../../linux/common/loadavg.h
\ No newline at end of file diff --git a/arch/linux/m68k/memory.h b/arch/linux/m68k/memory.h new file mode 120000 index 00000000..5ffc013e --- /dev/null +++ b/arch/linux/m68k/memory.h @@ -0,0 +1 @@ +../../linux/common/memory.h
\ No newline at end of file diff --git a/arch/linux/m68k/modules.h b/arch/linux/m68k/modules.h new file mode 120000 index 00000000..8ce5a808 --- /dev/null +++ b/arch/linux/m68k/modules.h @@ -0,0 +1 @@ +../../linux/common/modules.h
\ No newline at end of file diff --git a/arch/linux/m68k/net.h b/arch/linux/m68k/net.h new file mode 120000 index 00000000..72d77b26 --- /dev/null +++ b/arch/linux/m68k/net.h @@ -0,0 +1 @@ +../../linux/common/net.h
\ No newline at end of file diff --git a/arch/linux/m68k/os.h b/arch/linux/m68k/os.h new file mode 120000 index 00000000..ef547be5 --- /dev/null +++ b/arch/linux/m68k/os.h @@ -0,0 +1 @@ +../../linux/common/os.h
\ No newline at end of file diff --git a/arch/linux/m68k/pci.h b/arch/linux/m68k/pci.h new file mode 120000 index 00000000..63760048 --- /dev/null +++ b/arch/linux/m68k/pci.h @@ -0,0 +1 @@ +../../linux/common/pci.h
\ No newline at end of file diff --git a/arch/linux/m68k/processor.h b/arch/linux/m68k/processor.h new file mode 100644 index 00000000..0a1bab62 --- /dev/null +++ b/arch/linux/m68k/processor.h @@ -0,0 +1,74 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static Processor * +computer_get_processor(void) +{ + Processor *processor; + FILE *cpuinfo; + gchar buffer[128]; + + cpuinfo = fopen("/proc/cpuinfo", "r"); + if (!cpuinfo) + return NULL; + + processor = g_new0(Processor, 1); + while (fgets(buffer, 128, cpuinfo)) { + gchar **tmp = g_strsplit(buffer, ":", 2); + + if (tmp[0] && tmp[1]) { + tmp[0] = g_strstrip(tmp[0]); + tmp[1] = g_strstrip(tmp[1]); + + get_str("CPU", processor->model_name); + get_float("Clocking", processor->cpu_mhz); + get_float("bogomips", processor->bogomips); + + get_str("FPU", processor->has_fpu); + } + g_strfreev(tmp); + } + + gchar *tmp; + tmp = g_strconcat("Motorola ", processor->model_name, NULL); + g_free(processor->model_name); + processor->model_name = tmp; + + fclose(cpuinfo); + + return processor; +} + +static gchar * +processor_get_info(Processor *processor) +{ + return g_strdup_printf("[Processor]\n" + "Name=%s\n" + "Frequency=%.2fMHz\n" + "BogoMips=%.2f\n" + "Byte Order=%s\n", + processor->model_name, + processor->cpu_mhz, + processor->bogomips, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + "Little Endian" +#else + "Big Endian" +#endif + ); +} diff --git a/arch/linux/m68k/samba.h b/arch/linux/m68k/samba.h new file mode 120000 index 00000000..9227f722 --- /dev/null +++ b/arch/linux/m68k/samba.h @@ -0,0 +1 @@ +../../linux/common/samba.h
\ No newline at end of file diff --git a/arch/linux/m68k/sensors.h b/arch/linux/m68k/sensors.h new file mode 120000 index 00000000..35e5f37a --- /dev/null +++ b/arch/linux/m68k/sensors.h @@ -0,0 +1 @@ +../../linux/common/sensors.h
\ No newline at end of file diff --git a/arch/linux/m68k/storage.h b/arch/linux/m68k/storage.h new file mode 120000 index 00000000..55b68de3 --- /dev/null +++ b/arch/linux/m68k/storage.h @@ -0,0 +1 @@ +../../linux/common/storage.h
\ No newline at end of file diff --git a/arch/linux/m68k/uptime.h b/arch/linux/m68k/uptime.h new file mode 120000 index 00000000..78c026ff --- /dev/null +++ b/arch/linux/m68k/uptime.h @@ -0,0 +1 @@ +../../linux/common/uptime.h
\ No newline at end of file diff --git a/arch/linux/m68k/usb.h b/arch/linux/m68k/usb.h new file mode 120000 index 00000000..8b8fbb5d --- /dev/null +++ b/arch/linux/m68k/usb.h @@ -0,0 +1 @@ +../../linux/common/usb.h
\ No newline at end of file diff --git a/arch/linux/mips/alsa.h b/arch/linux/mips/alsa.h new file mode 120000 index 00000000..0216845a --- /dev/null +++ b/arch/linux/mips/alsa.h @@ -0,0 +1 @@ +../../linux/common/alsa.h
\ No newline at end of file diff --git a/arch/linux/mips/filesystem.h b/arch/linux/mips/filesystem.h new file mode 120000 index 00000000..6b325b40 --- /dev/null +++ b/arch/linux/mips/filesystem.h @@ -0,0 +1 @@ +../../linux/common/filesystem.h
\ No newline at end of file diff --git a/arch/linux/mips/inputdevices.h b/arch/linux/mips/inputdevices.h new file mode 120000 index 00000000..b9226a29 --- /dev/null +++ b/arch/linux/mips/inputdevices.h @@ -0,0 +1 @@ +../../linux/common/inputdevices.h
\ No newline at end of file diff --git a/arch/linux/mips/loadavg.h b/arch/linux/mips/loadavg.h new file mode 120000 index 00000000..daaed6d5 --- /dev/null +++ b/arch/linux/mips/loadavg.h @@ -0,0 +1 @@ +../../linux/common/loadavg.h
\ No newline at end of file diff --git a/arch/linux/mips/memory.h b/arch/linux/mips/memory.h new file mode 120000 index 00000000..5ffc013e --- /dev/null +++ b/arch/linux/mips/memory.h @@ -0,0 +1 @@ +../../linux/common/memory.h
\ No newline at end of file diff --git a/arch/linux/mips/modules.h b/arch/linux/mips/modules.h new file mode 120000 index 00000000..8ce5a808 --- /dev/null +++ b/arch/linux/mips/modules.h @@ -0,0 +1 @@ +../../linux/common/modules.h
\ No newline at end of file diff --git a/arch/linux/mips/net.h b/arch/linux/mips/net.h new file mode 120000 index 00000000..72d77b26 --- /dev/null +++ b/arch/linux/mips/net.h @@ -0,0 +1 @@ +../../linux/common/net.h
\ No newline at end of file diff --git a/arch/linux/mips/os.h b/arch/linux/mips/os.h new file mode 120000 index 00000000..ef547be5 --- /dev/null +++ b/arch/linux/mips/os.h @@ -0,0 +1 @@ +../../linux/common/os.h
\ No newline at end of file diff --git a/arch/linux/mips/pci.h b/arch/linux/mips/pci.h new file mode 120000 index 00000000..63760048 --- /dev/null +++ b/arch/linux/mips/pci.h @@ -0,0 +1 @@ +../../linux/common/pci.h
\ No newline at end of file diff --git a/arch/linux/mips/processor.h b/arch/linux/mips/processor.h new file mode 100644 index 00000000..8be922f9 --- /dev/null +++ b/arch/linux/mips/processor.h @@ -0,0 +1,70 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static Processor * +computer_get_processor(void) +{ + Processor *processor; + FILE *cpuinfo; + gchar buffer[128]; + + cpuinfo = fopen("/proc/cpuinfo", "r"); + if (!cpuinfo) + return NULL; + + processor = g_new0(Processor, 1); + while (fgets(buffer, 128, cpuinfo)) { + gchar **tmp = g_strsplit(buffer, ":", 2); + + if (tmp[0] && tmp[1]) { + tmp[0] = g_strstrip(tmp[0]); + tmp[1] = g_strstrip(tmp[1]); + + get_str("system type", processor->model_name); + get_str("cpu model", processor->vendor_id); + get_float("cpu MHz", processor->cpu_mhz); + get_float("BogoMIPS", processor->bogomips); + } + g_strfreev(tmp); + } + + fclose(cpuinfo); + + return processor; +} + +static gchar * +processor_get_info(Processor *processor) +{ + return g_strdup_printf("[Processor]\n" + "System Type=%s\n" + "CPU Model=%s\n" + "Frequency=%.2fMHz\n" + "BogoMIPS=%.2f\n" + "Byte Order=%s\n", + processor->model_name, + processor->vendor_id, + processor->cpu_mhz, + processor->bogomips, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + "Little Endian" +#else + "Big Endian" +#endif + ); +} diff --git a/arch/linux/mips/samba.h b/arch/linux/mips/samba.h new file mode 120000 index 00000000..9227f722 --- /dev/null +++ b/arch/linux/mips/samba.h @@ -0,0 +1 @@ +../../linux/common/samba.h
\ No newline at end of file diff --git a/arch/linux/mips/sensors.h b/arch/linux/mips/sensors.h new file mode 120000 index 00000000..35e5f37a --- /dev/null +++ b/arch/linux/mips/sensors.h @@ -0,0 +1 @@ +../../linux/common/sensors.h
\ No newline at end of file diff --git a/arch/linux/mips/storage.h b/arch/linux/mips/storage.h new file mode 120000 index 00000000..55b68de3 --- /dev/null +++ b/arch/linux/mips/storage.h @@ -0,0 +1 @@ +../../linux/common/storage.h
\ No newline at end of file diff --git a/arch/linux/mips/uptime.h b/arch/linux/mips/uptime.h new file mode 120000 index 00000000..78c026ff --- /dev/null +++ b/arch/linux/mips/uptime.h @@ -0,0 +1 @@ +../../linux/common/uptime.h
\ No newline at end of file diff --git a/arch/linux/mips/usb.h b/arch/linux/mips/usb.h new file mode 120000 index 00000000..8b8fbb5d --- /dev/null +++ b/arch/linux/mips/usb.h @@ -0,0 +1 @@ +../../linux/common/usb.h
\ No newline at end of file diff --git a/arch/linux/parisc/alsa.h b/arch/linux/parisc/alsa.h new file mode 120000 index 00000000..0216845a --- /dev/null +++ b/arch/linux/parisc/alsa.h @@ -0,0 +1 @@ +../../linux/common/alsa.h
\ No newline at end of file diff --git a/arch/linux/parisc/filesystem.h b/arch/linux/parisc/filesystem.h new file mode 120000 index 00000000..6b325b40 --- /dev/null +++ b/arch/linux/parisc/filesystem.h @@ -0,0 +1 @@ +../../linux/common/filesystem.h
\ No newline at end of file diff --git a/arch/linux/parisc/inputdevices.h b/arch/linux/parisc/inputdevices.h new file mode 120000 index 00000000..b9226a29 --- /dev/null +++ b/arch/linux/parisc/inputdevices.h @@ -0,0 +1 @@ +../../linux/common/inputdevices.h
\ No newline at end of file diff --git a/arch/linux/parisc/loadavg.h b/arch/linux/parisc/loadavg.h new file mode 120000 index 00000000..daaed6d5 --- /dev/null +++ b/arch/linux/parisc/loadavg.h @@ -0,0 +1 @@ +../../linux/common/loadavg.h
\ No newline at end of file diff --git a/arch/linux/parisc/memory.h b/arch/linux/parisc/memory.h new file mode 120000 index 00000000..5ffc013e --- /dev/null +++ b/arch/linux/parisc/memory.h @@ -0,0 +1 @@ +../../linux/common/memory.h
\ No newline at end of file diff --git a/arch/linux/parisc/modules.h b/arch/linux/parisc/modules.h new file mode 120000 index 00000000..8ce5a808 --- /dev/null +++ b/arch/linux/parisc/modules.h @@ -0,0 +1 @@ +../../linux/common/modules.h
\ No newline at end of file diff --git a/arch/linux/parisc/net.h b/arch/linux/parisc/net.h new file mode 120000 index 00000000..72d77b26 --- /dev/null +++ b/arch/linux/parisc/net.h @@ -0,0 +1 @@ +../../linux/common/net.h
\ No newline at end of file diff --git a/arch/linux/parisc/os.h b/arch/linux/parisc/os.h new file mode 120000 index 00000000..ef547be5 --- /dev/null +++ b/arch/linux/parisc/os.h @@ -0,0 +1 @@ +../../linux/common/os.h
\ No newline at end of file diff --git a/arch/linux/parisc/pci.h b/arch/linux/parisc/pci.h new file mode 120000 index 00000000..63760048 --- /dev/null +++ b/arch/linux/parisc/pci.h @@ -0,0 +1 @@ +../../linux/common/pci.h
\ No newline at end of file diff --git a/arch/linux/parisc/processor.h b/arch/linux/parisc/processor.h new file mode 100644 index 00000000..41b628f4 --- /dev/null +++ b/arch/linux/parisc/processor.h @@ -0,0 +1,82 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static Processor * +computer_get_processor(void) +{ + Processor *processor; + FILE *cpuinfo; + gchar buffer[128]; + + cpuinfo = fopen("/proc/cpuinfo", "r"); + if (!cpuinfo) + return NULL; + + processor = g_new0(Processor, 1); + while (fgets(buffer, 128, cpuinfo)) { + gchar **tmp = g_strsplit(buffer, ":", 2); + + if (tmp[0] && tmp[1]) { + tmp[0] = g_strstrip(tmp[0]); + tmp[1] = g_strstrip(tmp[1]); + + get_str("cpu family", processor->model_name); + get_str("cpu", processor->vendor_id); + get_float("cpu MHz", processor->cpu_mhz); + get_float("bogomips", processor->bogomips); + + get_str("model name", processor->strmodel); + + get_int("I-cache", processor->has_fpu); + get_int("D-cache", processor->flags); + + } + g_strfreev(tmp); + } + + fclose(cpuinfo); + + return processor; +} + +static gchar * +processor_get_info(Processor *processor) +{ + return g_strdup_printf("[Processor]\n" + "CPU Family=%s\n" + "CPU=%s\n" + "Frequency=%.2fMHz\n" + "Bogomips=%.2f\n" + "Model Name=%s\n" + "Byte Order=%s\n" + "[Cache]\n" + "I-Cache=%s\n" + "D-Cache=%s\n", + processor->model_name, + processor->vendor_id, + processor->cpu_mhz, + processor->bogomips, + processor->strmodel, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + "Little Endian", +#else + "Big Endian", +#endif + processor->has_fpu, + processor->flags); +} diff --git a/arch/linux/parisc/samba.h b/arch/linux/parisc/samba.h new file mode 120000 index 00000000..9227f722 --- /dev/null +++ b/arch/linux/parisc/samba.h @@ -0,0 +1 @@ +../../linux/common/samba.h
\ No newline at end of file diff --git a/arch/linux/parisc/sensors.h b/arch/linux/parisc/sensors.h new file mode 120000 index 00000000..35e5f37a --- /dev/null +++ b/arch/linux/parisc/sensors.h @@ -0,0 +1 @@ +../../linux/common/sensors.h
\ No newline at end of file diff --git a/arch/linux/parisc/storage.h b/arch/linux/parisc/storage.h new file mode 120000 index 00000000..55b68de3 --- /dev/null +++ b/arch/linux/parisc/storage.h @@ -0,0 +1 @@ +../../linux/common/storage.h
\ No newline at end of file diff --git a/arch/linux/parisc/uptime.h b/arch/linux/parisc/uptime.h new file mode 120000 index 00000000..78c026ff --- /dev/null +++ b/arch/linux/parisc/uptime.h @@ -0,0 +1 @@ +../../linux/common/uptime.h
\ No newline at end of file diff --git a/arch/linux/parisc/usb.h b/arch/linux/parisc/usb.h new file mode 120000 index 00000000..8b8fbb5d --- /dev/null +++ b/arch/linux/parisc/usb.h @@ -0,0 +1 @@ +../../linux/common/usb.h
\ No newline at end of file diff --git a/arch/linux/ppc/alsa.h b/arch/linux/ppc/alsa.h new file mode 120000 index 00000000..0216845a --- /dev/null +++ b/arch/linux/ppc/alsa.h @@ -0,0 +1 @@ +../../linux/common/alsa.h
\ No newline at end of file diff --git a/arch/linux/ppc/filesystem.h b/arch/linux/ppc/filesystem.h new file mode 120000 index 00000000..6b325b40 --- /dev/null +++ b/arch/linux/ppc/filesystem.h @@ -0,0 +1 @@ +../../linux/common/filesystem.h
\ No newline at end of file diff --git a/arch/linux/ppc/inputdevices.h b/arch/linux/ppc/inputdevices.h new file mode 120000 index 00000000..b9226a29 --- /dev/null +++ b/arch/linux/ppc/inputdevices.h @@ -0,0 +1 @@ +../../linux/common/inputdevices.h
\ No newline at end of file diff --git a/arch/linux/ppc/loadavg.h b/arch/linux/ppc/loadavg.h new file mode 120000 index 00000000..daaed6d5 --- /dev/null +++ b/arch/linux/ppc/loadavg.h @@ -0,0 +1 @@ +../../linux/common/loadavg.h
\ No newline at end of file diff --git a/arch/linux/ppc/memory.h b/arch/linux/ppc/memory.h new file mode 120000 index 00000000..5ffc013e --- /dev/null +++ b/arch/linux/ppc/memory.h @@ -0,0 +1 @@ +../../linux/common/memory.h
\ No newline at end of file diff --git a/arch/linux/ppc/modules.h b/arch/linux/ppc/modules.h new file mode 120000 index 00000000..8ce5a808 --- /dev/null +++ b/arch/linux/ppc/modules.h @@ -0,0 +1 @@ +../../linux/common/modules.h
\ No newline at end of file diff --git a/arch/linux/ppc/net.h b/arch/linux/ppc/net.h new file mode 120000 index 00000000..72d77b26 --- /dev/null +++ b/arch/linux/ppc/net.h @@ -0,0 +1 @@ +../../linux/common/net.h
\ No newline at end of file diff --git a/arch/linux/ppc/os.h b/arch/linux/ppc/os.h new file mode 120000 index 00000000..ef547be5 --- /dev/null +++ b/arch/linux/ppc/os.h @@ -0,0 +1 @@ +../../linux/common/os.h
\ No newline at end of file diff --git a/arch/linux/ppc/pci.h b/arch/linux/ppc/pci.h new file mode 120000 index 00000000..63760048 --- /dev/null +++ b/arch/linux/ppc/pci.h @@ -0,0 +1 @@ +../../linux/common/pci.h
\ No newline at end of file diff --git a/arch/linux/ppc/processor.h b/arch/linux/ppc/processor.h new file mode 100644 index 00000000..f4ff5b0e --- /dev/null +++ b/arch/linux/ppc/processor.h @@ -0,0 +1,78 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static Processor * +computer_get_processor(void) +{ + Processor *processor; + FILE *cpuinfo; + gchar buffer[128]; + + cpuinfo = fopen("/proc/cpuinfo", "r"); + if (!cpuinfo) + return NULL; + + processor = g_new0(Processor, 1); + while (fgets(buffer, 128, cpuinfo)) { + gchar **tmp = g_strsplit(buffer, ":", 2); + + if (tmp[0] && tmp[1]) { + tmp[0] = g_strstrip(tmp[0]); + tmp[1] = g_strstrip(tmp[1]); + + get_str("cpu", processor->model_name); + get_str("machine", processor->vendor_id); + get_int("L2 cache", processor->cache_size); + get_float("clock", processor->cpu_mhz); + get_float("bogomips", processor->bogomips); + + } + g_strfreev(tmp); + } + + gchar *tmp = g_strconcat("PowerPC ", processor->model_name, NULL); + g_free(processor->model_name); + processor->model_name = tmp; + + fclose(cpuinfo); + + return processor; +} + +static gchar * +processor_get_info(Processor *processor) +{ + return g_strdup_printf("[Processor]\n" + "Machine=%s\n" + "CPU=%s\n" + "L2 Cache=%.2f\n" + "Frequency=%.2fMHz\n" + "BogoMips=%.2f" + "Byte Order=%s\n", + processor->vendor_id, + processor->model_name, + processor->cache_size, + processor->cpu_mhz, + processor->bogomips, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + "Little Endian" +#else + "Big Endian" +#endif + ); +} diff --git a/arch/linux/ppc/samba.h b/arch/linux/ppc/samba.h new file mode 120000 index 00000000..9227f722 --- /dev/null +++ b/arch/linux/ppc/samba.h @@ -0,0 +1 @@ +../../linux/common/samba.h
\ No newline at end of file diff --git a/arch/linux/ppc/sensors.h b/arch/linux/ppc/sensors.h new file mode 120000 index 00000000..35e5f37a --- /dev/null +++ b/arch/linux/ppc/sensors.h @@ -0,0 +1 @@ +../../linux/common/sensors.h
\ No newline at end of file diff --git a/arch/linux/ppc/storage.h b/arch/linux/ppc/storage.h new file mode 120000 index 00000000..55b68de3 --- /dev/null +++ b/arch/linux/ppc/storage.h @@ -0,0 +1 @@ +../../linux/common/storage.h
\ No newline at end of file diff --git a/arch/linux/ppc/uptime.h b/arch/linux/ppc/uptime.h new file mode 120000 index 00000000..78c026ff --- /dev/null +++ b/arch/linux/ppc/uptime.h @@ -0,0 +1 @@ +../../linux/common/uptime.h
\ No newline at end of file diff --git a/arch/linux/ppc/usb.h b/arch/linux/ppc/usb.h new file mode 120000 index 00000000..8b8fbb5d --- /dev/null +++ b/arch/linux/ppc/usb.h @@ -0,0 +1 @@ +../../linux/common/usb.h
\ No newline at end of file diff --git a/arch/linux/sparc/alsa.h b/arch/linux/sparc/alsa.h new file mode 120000 index 00000000..0216845a --- /dev/null +++ b/arch/linux/sparc/alsa.h @@ -0,0 +1 @@ +../../linux/common/alsa.h
\ No newline at end of file diff --git a/arch/linux/sparc/filesystem.h b/arch/linux/sparc/filesystem.h new file mode 120000 index 00000000..6b325b40 --- /dev/null +++ b/arch/linux/sparc/filesystem.h @@ -0,0 +1 @@ +../../linux/common/filesystem.h
\ No newline at end of file diff --git a/arch/linux/sparc/inputdevices.h b/arch/linux/sparc/inputdevices.h new file mode 120000 index 00000000..b9226a29 --- /dev/null +++ b/arch/linux/sparc/inputdevices.h @@ -0,0 +1 @@ +../../linux/common/inputdevices.h
\ No newline at end of file diff --git a/arch/linux/sparc/loadavg.h b/arch/linux/sparc/loadavg.h new file mode 120000 index 00000000..daaed6d5 --- /dev/null +++ b/arch/linux/sparc/loadavg.h @@ -0,0 +1 @@ +../../linux/common/loadavg.h
\ No newline at end of file diff --git a/arch/linux/sparc/memory.h b/arch/linux/sparc/memory.h new file mode 120000 index 00000000..5ffc013e --- /dev/null +++ b/arch/linux/sparc/memory.h @@ -0,0 +1 @@ +../../linux/common/memory.h
\ No newline at end of file diff --git a/arch/linux/sparc/modules.h b/arch/linux/sparc/modules.h new file mode 120000 index 00000000..8ce5a808 --- /dev/null +++ b/arch/linux/sparc/modules.h @@ -0,0 +1 @@ +../../linux/common/modules.h
\ No newline at end of file diff --git a/arch/linux/sparc/net.h b/arch/linux/sparc/net.h new file mode 120000 index 00000000..72d77b26 --- /dev/null +++ b/arch/linux/sparc/net.h @@ -0,0 +1 @@ +../../linux/common/net.h
\ No newline at end of file diff --git a/arch/linux/sparc/os.h b/arch/linux/sparc/os.h new file mode 120000 index 00000000..ef547be5 --- /dev/null +++ b/arch/linux/sparc/os.h @@ -0,0 +1 @@ +../../linux/common/os.h
\ No newline at end of file diff --git a/arch/linux/sparc/pci.h b/arch/linux/sparc/pci.h new file mode 120000 index 00000000..63760048 --- /dev/null +++ b/arch/linux/sparc/pci.h @@ -0,0 +1 @@ +../../linux/common/pci.h
\ No newline at end of file diff --git a/arch/linux/sparc/processor.h b/arch/linux/sparc/processor.h new file mode 100644 index 00000000..211ea56b --- /dev/null +++ b/arch/linux/sparc/processor.h @@ -0,0 +1,59 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static Processor * +computer_get_processor(void) +{ + Processor *processor; + FILE *cpuinfo; + gchar buffer[128]; + + cpuinfo = fopen("/proc/cpuinfo", "r"); + if (!cpuinfo) + return NULL; + + processor = g_new0(Processor, 1); + while (fgets(buffer, 128, cpuinfo)) { + gchar **tmp = g_strsplit(buffer, ":", 2); + + if (tmp[0] && tmp[1]) { + tmp[0] = g_strstrip(tmp[0]); + tmp[1] = g_strstrip(tmp[1]); + + get_str("cpu", processor->model_name); + get_str("fpu", processor->has_fpu); + } + g_strfreev(tmp); + } + + get_processor_strfamily(processor); + + fclose(cpuinfo); + + return processor; +} + +static gchar * +processor_get_info(Processor *processor) +{ + return g_strdup_printf("[Processor]\n" + "CPU=%s\n" + "FPU=%s\n", + processor->model_name, + processor->has_fpu); +} diff --git a/arch/linux/sparc/samba.h b/arch/linux/sparc/samba.h new file mode 120000 index 00000000..9227f722 --- /dev/null +++ b/arch/linux/sparc/samba.h @@ -0,0 +1 @@ +../../linux/common/samba.h
\ No newline at end of file diff --git a/arch/linux/sparc/sensors.h b/arch/linux/sparc/sensors.h new file mode 120000 index 00000000..35e5f37a --- /dev/null +++ b/arch/linux/sparc/sensors.h @@ -0,0 +1 @@ +../../linux/common/sensors.h
\ No newline at end of file diff --git a/arch/linux/sparc/storage.h b/arch/linux/sparc/storage.h new file mode 120000 index 00000000..55b68de3 --- /dev/null +++ b/arch/linux/sparc/storage.h @@ -0,0 +1 @@ +../../linux/common/storage.h
\ No newline at end of file diff --git a/arch/linux/sparc/uptime.h b/arch/linux/sparc/uptime.h new file mode 120000 index 00000000..78c026ff --- /dev/null +++ b/arch/linux/sparc/uptime.h @@ -0,0 +1 @@ +../../linux/common/uptime.h
\ No newline at end of file diff --git a/arch/linux/sparc/usb.h b/arch/linux/sparc/usb.h new file mode 120000 index 00000000..8b8fbb5d --- /dev/null +++ b/arch/linux/sparc/usb.h @@ -0,0 +1 @@ +../../linux/common/usb.h
\ No newline at end of file diff --git a/arch/linux/x86/alsa.h b/arch/linux/x86/alsa.h new file mode 120000 index 00000000..0216845a --- /dev/null +++ b/arch/linux/x86/alsa.h @@ -0,0 +1 @@ +../../linux/common/alsa.h
\ No newline at end of file diff --git a/arch/linux/x86/filesystem.h b/arch/linux/x86/filesystem.h new file mode 120000 index 00000000..6b325b40 --- /dev/null +++ b/arch/linux/x86/filesystem.h @@ -0,0 +1 @@ +../../linux/common/filesystem.h
\ No newline at end of file diff --git a/arch/linux/x86/inputdevices.h b/arch/linux/x86/inputdevices.h new file mode 120000 index 00000000..b9226a29 --- /dev/null +++ b/arch/linux/x86/inputdevices.h @@ -0,0 +1 @@ +../../linux/common/inputdevices.h
\ No newline at end of file diff --git a/arch/linux/x86/loadavg.h b/arch/linux/x86/loadavg.h new file mode 120000 index 00000000..daaed6d5 --- /dev/null +++ b/arch/linux/x86/loadavg.h @@ -0,0 +1 @@ +../../linux/common/loadavg.h
\ No newline at end of file diff --git a/arch/linux/x86/memory.h b/arch/linux/x86/memory.h new file mode 120000 index 00000000..5ffc013e --- /dev/null +++ b/arch/linux/x86/memory.h @@ -0,0 +1 @@ +../../linux/common/memory.h
\ No newline at end of file diff --git a/arch/linux/x86/modules.h b/arch/linux/x86/modules.h new file mode 120000 index 00000000..8ce5a808 --- /dev/null +++ b/arch/linux/x86/modules.h @@ -0,0 +1 @@ +../../linux/common/modules.h
\ No newline at end of file diff --git a/arch/linux/x86/net.h b/arch/linux/x86/net.h new file mode 120000 index 00000000..72d77b26 --- /dev/null +++ b/arch/linux/x86/net.h @@ -0,0 +1 @@ +../../linux/common/net.h
\ No newline at end of file diff --git a/arch/linux/x86/os.h b/arch/linux/x86/os.h new file mode 120000 index 00000000..ef547be5 --- /dev/null +++ b/arch/linux/x86/os.h @@ -0,0 +1 @@ +../../linux/common/os.h
\ No newline at end of file diff --git a/arch/linux/x86/pci.h b/arch/linux/x86/pci.h new file mode 120000 index 00000000..63760048 --- /dev/null +++ b/arch/linux/x86/pci.h @@ -0,0 +1 @@ +../../linux/common/pci.h
\ No newline at end of file diff --git a/arch/linux/x86/processor.h b/arch/linux/x86/processor.h new file mode 100644 index 00000000..571943f6 --- /dev/null +++ b/arch/linux/x86/processor.h @@ -0,0 +1,303 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * This function is partly based on x86cpucaps + * by Osamu Kayasono <jacobi@jcom.home.ne.jp> + */ +static void +get_processor_strfamily(Processor *processor) +{ + gint family = processor->family; + gint model = processor->model; + + if (g_str_equal(processor->vendor_id, "GenuineIntel")) { + if (family == 4) { + processor->strmodel = g_strdup("i486 series"); + } else if (family == 5) { + if (model < 4) { + processor->strmodel = g_strdup("Pentium Classic"); + } else { + processor->strmodel = g_strdup("Pentium MMX"); + } + } else if (family == 6) { + if (model <= 1) { + processor->strmodel = g_strdup("Pentium Pro"); + } else if (model < 7) { + processor->strmodel = g_strdup("Pentium II/Pentium II Xeon/Celeron"); + } else if (model == 9) { + processor->strmodel = g_strdup("Pentium M"); + } else { + processor->strmodel = g_strdup("Pentium III/Pentium III Xeon/Celeron"); + } + } else if (family > 6) { + processor->strmodel = g_strdup("Pentium 4"); + } else { + processor->strmodel = g_strdup("i386 class"); + } + } else if (g_str_equal(processor->vendor_id, "AuthenticAMD")) { + if (family == 4) { + if (model <= 9) { + processor->strmodel = g_strdup("AMD i80486 series"); + } else { + processor->strmodel = g_strdup("AMD 5x86"); + } + } else if (family == 5) { + if (model <= 3) { + processor->strmodel = g_strdup("AMD K5"); + } else if (model <= 7) { + processor->strmodel = g_strdup("AMD K6"); + } else if (model == 8) { + processor->strmodel = g_strdup("AMD K6-2"); + } else if (model == 9) { + processor->strmodel = g_strdup("AMD K6-III"); + } else { + processor->strmodel = g_strdup("AMD K6-2+/III+"); + } + } else if (family == 6) { + if (model == 1) { + processor->strmodel = g_strdup("AMD Athlon (K7"); + } else if (model == 2) { + processor->strmodel = g_strdup("AMD Athlon (K75)"); + } else if (model == 3) { + processor->strmodel = g_strdup("AMD Duron (Spitfire)"); + } else if (model == 4) { + processor->strmodel = g_strdup("AMD Athlon (Thunderbird)"); + } else if (model == 6) { + processor->strmodel = g_strdup("AMD Athlon XP/MP/4 (Palomino)"); + } else if (model == 7) { + processor->strmodel = g_strdup("AMD Duron (Morgan)"); + } else if (model == 8) { + processor->strmodel = g_strdup("AMD Athlon XP/MP (Thoroughbred)"); + } else if (model == 10) { + processor->strmodel = g_strdup("AMD Athlon XP/MP (Barton)"); + } else { + processor->strmodel = g_strdup("AMD Athlon (unknown)"); + } + } else if (family > 6) { + processor->strmodel = g_strdup("AMD Opteron/Athlon64/FX"); + } else { + processor->strmodel = g_strdup("AMD i386 class"); + } + } else if (g_str_equal(processor->vendor_id, "CyrixInstead")) { + if (family == 4) { + processor->strmodel = g_strdup("Cyrix 5x86"); + } else if (family == 5) { + processor->strmodel = g_strdup("Cyrix M1 (6x86)"); + } else if (family == 6) { + if (model == 0) { + processor->strmodel = g_strdup("Cyrix M2 (6x86MX)"); + } else if (model <= 5) { + processor->strmodel = g_strdup("VIA Cyrix III (M2 core)"); + } else if (model == 6) { + processor->strmodel = g_strdup("VIA Cyrix III (WinChip C5A)"); + } else if (model == 7) { + processor->strmodel = g_strdup("VIA Cyrix III (WinChip C5B/C)"); + } else { + processor->strmodel = g_strdup("VIA Cyrix III (WinChip C5C-T)"); + } + } else { + processor->strmodel = g_strdup("Cyrix i386 class"); + } + } else if (g_str_equal(processor->vendor_id, "CentaurHauls")) { + if (family == 5) { + if (model <= 4) { + processor->strmodel = g_strdup("Centaur WinChip C6"); + } else if (model <= 8) { + processor->strmodel = g_strdup("Centaur WinChip 2"); + } else { + processor->strmodel = g_strdup("Centaur WinChip 2A"); + } + } else { + processor->strmodel = g_strdup("Centaur i386 class"); + } + } else if (g_str_equal(processor->vendor_id, "GenuineTMx86")) { + processor->strmodel = g_strdup("Transmeta Crusoe TM3x00/5x00"); + } else { + processor->strmodel = g_strdup("Unknown"); + } +} + +static Processor * +computer_get_processor(void) +{ + Processor *processor; + FILE *cpuinfo; + gchar buffer[128]; + + cpuinfo = fopen("/proc/cpuinfo", "r"); + if (!cpuinfo) + return NULL; + + processor = g_new0(Processor, 1); + while (fgets(buffer, 128, cpuinfo)) { + gchar **tmp = g_strsplit(buffer, ":", 2); + + if (tmp[0] && tmp[1]) { + tmp[0] = g_strstrip(tmp[0]); + tmp[1] = g_strstrip(tmp[1]); + + get_str("model name", processor->model_name); + get_str("vendor_id", processor->vendor_id); + get_str("flags", processor->flags); + get_int("cache size", processor->cache_size); + get_float("cpu MHz", processor->cpu_mhz); + get_float("bogomips", processor->bogomips); + + get_str("fpu", processor->has_fpu); + + get_str("fdiv_bug", processor->bug_fdiv); + get_str("hlt_bug", processor->bug_hlt); + get_str("f00f_bug", processor->bug_f00f); + get_str("coma_bug", processor->bug_coma); + + get_int("model", processor->model); + get_int("cpu family", processor->family); + get_int("stepping", processor->stepping); + } + g_strfreev(tmp); + } + + get_processor_strfamily(processor); + + fclose(cpuinfo); + + return processor; +} + +static struct { + char *name, *meaning; +} flag_meaning[] = { + { "3dnow", "3DNow! Technology" }, + { "3dnowext", "Extended 3DNow! Technology" }, + { "fpu", "Floating Point Unit" }, + { "vme", "Virtual 86 Mode Extension" }, + { "de", "Debug Extensions - I/O breakpoints" }, + { "pse", "Page Size Extensions (4MB pages)" }, + { "tsc", "Time Stamp Counter and RDTSC instruction" }, + { "msr", "Model Specific Registers" }, + { "pae", "Physical Address Extensions (36-bit address, 2MB pages)" }, + { "mce", "Machine Check Architeture" }, + { "cx8", "CMPXCHG8 instruction" }, + { "apic", "Advanced Programmable Interrupt Controller" }, + { "sep", "Fast System Call (SYSENTER/SYSEXIT instructions)" }, + { "mtrr", "Memory Type Range Registers" }, + { "pge", "Page Global Enable" }, + { "mca", "Machine Check Architecture" }, + { "cmov", "Conditional Move instruction" }, + { "pat", "Page Attribute Table" }, + { "pse36", "36bit Page Size Extensions" }, + { "psn", "96 bit Processor Serial Number" }, + { "mmx", "MMX technology" }, + { "mmxext", "Extended MMX Technology" }, + { "cflush", "Cache Flush" }, + { "dtes", "Debug Trace Store" }, + { "fxsr", "FXSAVE and FXRSTOR instructions" }, + { "kni", "Streaming SIMD instructions" }, + { "xmm", "Streaming SIMD instructions" }, + { "ht", "HyperThreading" }, + { "mp", "Multiprocessing Capable" }, + { "sse", "SSE instructions" }, + { "sse2", "SSE2 (WNI) instructions" }, + { "acc", "Automatic Clock Control" }, + { "ia64", "IA64 Instructions" }, + { "syscall", "SYSCALL and SYSEXIT instructions" }, + { "nx", "No-execute Page Protection" }, + { "xd", "Execute Disable" }, + { "clflush", "Cache Line Flush instruction" }, + { "acpi", "Thermal Monitor and Software Controlled Clock Facilities" }, + { "dts", "Debug Store" }, + { "ss", "Self Snoop" }, + { "tm", "Thermal Monitor" }, + { "pbe", "Pending Break Enable" }, + { "pb", "Pending Break Enable" }, + { NULL, NULL} +}; + +gchar * +processor_get_capabilities_from_flags(gchar * strflags) +{ + /* FIXME: * Separate between processor capabilities, additional instructions and whatnot. */ + gchar **flags, **old; + gchar *tmp = ""; + gint i; + + flags = g_strsplit(strflags, " ", 0); + old = flags; + + while (*flags) { + gchar *meaning = ""; + for (i = 0; flag_meaning[i].name != NULL; i++) { + if (!strcmp(*flags, flag_meaning[i].name)) { + meaning = flag_meaning[i].meaning; + break; + } + } + + tmp = g_strdup_printf("%s%s=%s\n", tmp, *flags, meaning); + *flags++; + } + + g_strfreev(old); + return tmp; +} + +static gchar * +processor_get_info(Processor *processor) +{ + gchar *tmp = processor_get_capabilities_from_flags(processor-> + flags); + gchar *ret = g_strdup_printf("[Processor]\n" + "Name=%s\n" + "Specification=%s\n" + "Family, model, stepping=%d, %d, %d\n" + "Vendor=%s\n" + "Cache Size=%dkb\n" + "Frequency=%.2fMHz\n" + "BogoMips=%.2f\n" + "Byte Order=%s\n" + "[Features]\n" + "FDIV Bug=%s\n" + "HLT Bug=%s\n" + "F00F Bug=%s\n" + "Coma Bug=%s\n" + "Has FPU=%s\n" + "[Capabilities]\n" "%s", + processor->strmodel, + processor->model_name, + processor->family, + processor->model, + processor->stepping, + processor->vendor_id, + processor->cache_size, + processor->cpu_mhz, + processor->bogomips, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + "Little Endian", +#else + "Big Endian", +#endif + processor->bug_fdiv, + processor->bug_hlt, + processor->bug_f00f, + processor->bug_coma, + processor->has_fpu, + tmp); + g_free(tmp); + return ret; +} diff --git a/arch/linux/x86/samba.h b/arch/linux/x86/samba.h new file mode 120000 index 00000000..9227f722 --- /dev/null +++ b/arch/linux/x86/samba.h @@ -0,0 +1 @@ +../../linux/common/samba.h
\ No newline at end of file diff --git a/arch/linux/x86/sensors.h b/arch/linux/x86/sensors.h new file mode 120000 index 00000000..35e5f37a --- /dev/null +++ b/arch/linux/x86/sensors.h @@ -0,0 +1 @@ +../../linux/common/sensors.h
\ No newline at end of file diff --git a/arch/linux/x86/storage.h b/arch/linux/x86/storage.h new file mode 120000 index 00000000..55b68de3 --- /dev/null +++ b/arch/linux/x86/storage.h @@ -0,0 +1 @@ +../../linux/common/storage.h
\ No newline at end of file diff --git a/arch/linux/x86/uptime.h b/arch/linux/x86/uptime.h new file mode 120000 index 00000000..78c026ff --- /dev/null +++ b/arch/linux/x86/uptime.h @@ -0,0 +1 @@ +../../linux/common/uptime.h
\ No newline at end of file diff --git a/arch/linux/x86/usb.h b/arch/linux/x86/usb.h new file mode 120000 index 00000000..8b8fbb5d --- /dev/null +++ b/arch/linux/x86/usb.h @@ -0,0 +1 @@ +../../linux/common/usb.h
\ No newline at end of file diff --git a/arch/linux/x86_64 b/arch/linux/x86_64 new file mode 120000 index 00000000..f4bad791 --- /dev/null +++ b/arch/linux/x86_64 @@ -0,0 +1 @@ +x86
\ No newline at end of file diff --git a/benchmark.c b/benchmark.c new file mode 100644 index 00000000..f4cb904c --- /dev/null +++ b/benchmark.c @@ -0,0 +1,163 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <hardinfo.h> +#include <iconcache.h> +#include <shell.h> +#include <config.h> + +enum { + BENCHMARK_ZLIB, + BENCHMARK_FIB, + BENCHMARK_MD5, + BENCHMARK_SHA1, + BENCHMARK_BLOWFISH +} Entries; + +static ModuleEntry hi_entries[] = { + {"CPU ZLib", "compress.png"}, + {"CPU Fibonacci", "module.png"}, + {"CPU MD5", "module.png"}, + {"CPU SHA1", "module.png"}, + {"CPU Blowfish", "blowfish.png"} +}; + +static gchar * +benchmark_include_results(gchar *results, const gchar *benchmark) +{ + GKeyFile *conf; + gchar **machines; + int i; + + conf = g_key_file_new(); + g_key_file_load_from_file(conf, PREFIX "benchmark.conf", 0, NULL); + + machines = g_key_file_get_keys(conf, benchmark, NULL, NULL); + for (i = 0; machines && machines[i]; i++) { + gchar *value = g_key_file_get_value(conf, benchmark, machines[i], NULL); + results = g_strconcat(results, machines[i], "=", value, "\n", NULL); + g_free(value); + } + + g_strfreev(machines); + g_key_file_free(conf); + + return g_strconcat(results, "[$ShellParam$]\n" + "Zebra=1\n", NULL); +} + +#include <arch/common/fib.h> +#include <arch/common/zlib.h> +#include <arch/common/md5.h> +#include <arch/common/sha1.h> +#include <arch/common/blowfish.h> + +static gchar *bench_zlib = NULL, + *bench_fib = NULL, + *bench_md5 = NULL, + *bench_sha1 = NULL, + *bench_fish = NULL; + +gchar * +hi_info(gint entry) +{ + switch (entry) { + case BENCHMARK_ZLIB: + if (bench_zlib) + return g_strdup(bench_zlib); + + bench_zlib = benchmark_zlib(); + return g_strdup(bench_zlib); + + case BENCHMARK_BLOWFISH: + if (bench_fish) + return g_strdup(bench_fish); + + bench_fish = benchmark_fish(); + return g_strdup(bench_fish); + + case BENCHMARK_MD5: + if (bench_md5) + return g_strdup(bench_md5); + + bench_md5 = benchmark_md5(); + return g_strdup(bench_md5); + + case BENCHMARK_FIB: + if (bench_fib) + return g_strdup(bench_fib); + + bench_fib = benchmark_fib(); + return g_strdup(bench_fib); + + case BENCHMARK_SHA1: + if (bench_sha1) + return g_strdup(bench_sha1); + + bench_sha1 = benchmark_sha1(); + return g_strdup(bench_sha1); + + default: + return g_strdup("[Empty]\n"); + } +} + +void +hi_reload(gint entry) +{ + switch (entry) { + case BENCHMARK_ZLIB: + if (bench_zlib) g_free(bench_zlib); + bench_zlib = benchmark_zlib(); + break; + case BENCHMARK_BLOWFISH: + if (bench_fish) g_free(bench_fish); + bench_fish = benchmark_fish(); + break; + case BENCHMARK_MD5: + if (bench_md5) g_free(bench_md5); + bench_md5 = benchmark_md5(); + break; + case BENCHMARK_FIB: + if (bench_fib) g_free(bench_fib); + bench_fib = benchmark_fib(); + break; + case BENCHMARK_SHA1: + if (bench_sha1) g_free(bench_sha1); + bench_sha1 = benchmark_sha1(); + break; + } +} + +gint +hi_n_entries(void) +{ + return G_N_ELEMENTS(hi_entries) - 1; +} + +GdkPixbuf * +hi_icon(gint entry) +{ + return icon_cache_get_pixbuf(hi_entries[entry].icon); +} + +gchar * +hi_name(gint entry) +{ + return hi_entries[entry].name; +} diff --git a/benchmark.conf b/benchmark.conf new file mode 100644 index 00000000..2db3f3b8 --- /dev/null +++ b/benchmark.conf @@ -0,0 +1,38 @@ +[ZLib] +# RAM:1024,Board:GA-7NNXP,OS:Linux 2.6.15 +AMD Athlon XP 3200+=4.33 +# RAM:512,Board:Toshiba M45-S165,OS:Linux 2.6.15,Compiler:GCC 3.3.5 +Intel Celeron M 1.5GHz=5.63 +AMD Athlon XP 2200+=7.38 +# RAM:128,Board:XingLing,OS:Linux 2.4.20 +Intel Pentium 200MHz=117.79 +# RAM:1024,Board:GA-7NNXP,OS:Linux 2.6.15 +Valgrind/AMD Athlon XP 3200+=155.91 +# RAM:32,Board:Toshiba Libretto 50CT,OS:Linux 2.4.20 +Intel Pentium 75MHz=173.06 + +[Fibonacci] +# RAM:1024,Board:GA-7NNXP,OS:Linux 2.6.15 +AMD Athlon XP 3200+=6.64 +#AMD Athlon XP 2200+=3.54 +# RAM:512,Board:Toshiba M45-S165,OS:Linux 2.6.15,Compiler:GCC 3.3.5 +Intel Celeron M 1.5GHz=11.10 +# RAM:128,Board:XingLing,OS:Linux 2.4.20 +#Intel Pentium 200MHz=35.02 +# RAM:32,Board:Toshiba Libretto 50CT,OS:Linux 2.4.20 +#Intel Pentium 75MHz=110.20 +# RAM:1024,Board:GA-7NNXP,OS:Linux 2.6.15 +#Valgrind/AMD Athlon XP 3200+=164.92 + + +[MD5] +# RAM:512,Board:Toshiba M45-S165,OS:Linux 2.6.15,Compiler:GCC 3.3.5 +Intel Celeron M 1.5GHz=3.42 +# RAM:1024,Board:GA-7NNXP,OS:Linux 2.6.15 +AMD Athlon XP 3200+=5.04 + +[SHA1] +# RAM:1024,Board:GA-7NNXP,OS:Linux 2.6.15 +AMD Athlon XP 3200+=4.88 +# RAM:512,Board:Toshiba M45-S165,OS:Linux 2.6.15,Compiler:GCC 3.3.5 +Intel Celeron M 1.5GHz=5.50 diff --git a/benchmark.data b/benchmark.data Binary files differnew file mode 100644 index 00000000..efb964db --- /dev/null +++ b/benchmark.data diff --git a/blowfish.c b/blowfish.c new file mode 100644 index 00000000..929bfb14 --- /dev/null +++ b/blowfish.c @@ -0,0 +1,451 @@ +/*
+blowfish.c: C implementation of the Blowfish algorithm.
+
+Copyright (C) 1997 by Paul Kocher
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+
+
+COMMENTS ON USING THIS CODE:
+
+Normal usage is as follows:
+ [1] Allocate a BLOWFISH_CTX. (It may be too big for the stack.)
+ [2] Call Blowfish_Init with a pointer to your BLOWFISH_CTX, a pointer to
+ the key, and the number of bytes in the key.
+ [3] To encrypt a 64-bit block, call Blowfish_Encrypt with a pointer to
+ BLOWFISH_CTX, a pointer to the 32-bit left half of the plaintext
+ and a pointer to the 32-bit right half. The plaintext will be
+ overwritten with the ciphertext.
+ [4] Decryption is the same as encryption except that the plaintext and
+ ciphertext are reversed.
+
+Warning #1: The code does not check key lengths. (Caveat encryptor.)
+Warning #2: Beware that Blowfish keys repeat such that "ab" = "abab".
+Warning #3: It is normally a good idea to zeroize the BLOWFISH_CTX before
+ freeing it.
+Warning #4: Endianness conversions are the responsibility of the caller.
+ (To encrypt bytes on a little-endian platforms, you'll probably want
+ to swap bytes around instead of just casting.)
+Warning #5: Make sure to use a reasonable mode of operation for your
+ application. (If you don't know what CBC mode is, see Warning #7.)
+Warning #6: This code is susceptible to timing attacks.
+Warning #7: Security engineering is risky and non-intuitive. Have someone
+ check your work. If you don't know what you are doing, get help.
+
+
+This is code is fast enough for most applications, but is not optimized for
+speed.
+
+If you require this code under a license other than LGPL, please ask. (I
+can be located using your favorite search engine.) Unfortunately, I do not
+have time to provide unpaid support for everyone who uses this code.
+
+ -- Paul Kocher
+*/
+
+
+#include "blowfish.h"
+
+#define N 16
+
+static const unsigned long ORIG_P[16 + 2] = {
+ 0x243F6A88L, 0x85A308D3L, 0x13198A2EL, 0x03707344L,
+ 0xA4093822L, 0x299F31D0L, 0x082EFA98L, 0xEC4E6C89L,
+ 0x452821E6L, 0x38D01377L, 0xBE5466CFL, 0x34E90C6CL,
+ 0xC0AC29B7L, 0xC97C50DDL, 0x3F84D5B5L, 0xB5470917L,
+ 0x9216D5D9L, 0x8979FB1BL
+};
+
+static const unsigned long ORIG_S[4][256] = {
+ { 0xD1310BA6L, 0x98DFB5ACL, 0x2FFD72DBL, 0xD01ADFB7L,
+ 0xB8E1AFEDL, 0x6A267E96L, 0xBA7C9045L, 0xF12C7F99L,
+ 0x24A19947L, 0xB3916CF7L, 0x0801F2E2L, 0x858EFC16L,
+ 0x636920D8L, 0x71574E69L, 0xA458FEA3L, 0xF4933D7EL,
+ 0x0D95748FL, 0x728EB658L, 0x718BCD58L, 0x82154AEEL,
+ 0x7B54A41DL, 0xC25A59B5L, 0x9C30D539L, 0x2AF26013L,
+ 0xC5D1B023L, 0x286085F0L, 0xCA417918L, 0xB8DB38EFL,
+ 0x8E79DCB0L, 0x603A180EL, 0x6C9E0E8BL, 0xB01E8A3EL,
+ 0xD71577C1L, 0xBD314B27L, 0x78AF2FDAL, 0x55605C60L,
+ 0xE65525F3L, 0xAA55AB94L, 0x57489862L, 0x63E81440L,
+ 0x55CA396AL, 0x2AAB10B6L, 0xB4CC5C34L, 0x1141E8CEL,
+ 0xA15486AFL, 0x7C72E993L, 0xB3EE1411L, 0x636FBC2AL,
+ 0x2BA9C55DL, 0x741831F6L, 0xCE5C3E16L, 0x9B87931EL,
+ 0xAFD6BA33L, 0x6C24CF5CL, 0x7A325381L, 0x28958677L,
+ 0x3B8F4898L, 0x6B4BB9AFL, 0xC4BFE81BL, 0x66282193L,
+ 0x61D809CCL, 0xFB21A991L, 0x487CAC60L, 0x5DEC8032L,
+ 0xEF845D5DL, 0xE98575B1L, 0xDC262302L, 0xEB651B88L,
+ 0x23893E81L, 0xD396ACC5L, 0x0F6D6FF3L, 0x83F44239L,
+ 0x2E0B4482L, 0xA4842004L, 0x69C8F04AL, 0x9E1F9B5EL,
+ 0x21C66842L, 0xF6E96C9AL, 0x670C9C61L, 0xABD388F0L,
+ 0x6A51A0D2L, 0xD8542F68L, 0x960FA728L, 0xAB5133A3L,
+ 0x6EEF0B6CL, 0x137A3BE4L, 0xBA3BF050L, 0x7EFB2A98L,
+ 0xA1F1651DL, 0x39AF0176L, 0x66CA593EL, 0x82430E88L,
+ 0x8CEE8619L, 0x456F9FB4L, 0x7D84A5C3L, 0x3B8B5EBEL,
+ 0xE06F75D8L, 0x85C12073L, 0x401A449FL, 0x56C16AA6L,
+ 0x4ED3AA62L, 0x363F7706L, 0x1BFEDF72L, 0x429B023DL,
+ 0x37D0D724L, 0xD00A1248L, 0xDB0FEAD3L, 0x49F1C09BL,
+ 0x075372C9L, 0x80991B7BL, 0x25D479D8L, 0xF6E8DEF7L,
+ 0xE3FE501AL, 0xB6794C3BL, 0x976CE0BDL, 0x04C006BAL,
+ 0xC1A94FB6L, 0x409F60C4L, 0x5E5C9EC2L, 0x196A2463L,
+ 0x68FB6FAFL, 0x3E6C53B5L, 0x1339B2EBL, 0x3B52EC6FL,
+ 0x6DFC511FL, 0x9B30952CL, 0xCC814544L, 0xAF5EBD09L,
+ 0xBEE3D004L, 0xDE334AFDL, 0x660F2807L, 0x192E4BB3L,
+ 0xC0CBA857L, 0x45C8740FL, 0xD20B5F39L, 0xB9D3FBDBL,
+ 0x5579C0BDL, 0x1A60320AL, 0xD6A100C6L, 0x402C7279L,
+ 0x679F25FEL, 0xFB1FA3CCL, 0x8EA5E9F8L, 0xDB3222F8L,
+ 0x3C7516DFL, 0xFD616B15L, 0x2F501EC8L, 0xAD0552ABL,
+ 0x323DB5FAL, 0xFD238760L, 0x53317B48L, 0x3E00DF82L,
+ 0x9E5C57BBL, 0xCA6F8CA0L, 0x1A87562EL, 0xDF1769DBL,
+ 0xD542A8F6L, 0x287EFFC3L, 0xAC6732C6L, 0x8C4F5573L,
+ 0x695B27B0L, 0xBBCA58C8L, 0xE1FFA35DL, 0xB8F011A0L,
+ 0x10FA3D98L, 0xFD2183B8L, 0x4AFCB56CL, 0x2DD1D35BL,
+ 0x9A53E479L, 0xB6F84565L, 0xD28E49BCL, 0x4BFB9790L,
+ 0xE1DDF2DAL, 0xA4CB7E33L, 0x62FB1341L, 0xCEE4C6E8L,
+ 0xEF20CADAL, 0x36774C01L, 0xD07E9EFEL, 0x2BF11FB4L,
+ 0x95DBDA4DL, 0xAE909198L, 0xEAAD8E71L, 0x6B93D5A0L,
+ 0xD08ED1D0L, 0xAFC725E0L, 0x8E3C5B2FL, 0x8E7594B7L,
+ 0x8FF6E2FBL, 0xF2122B64L, 0x8888B812L, 0x900DF01CL,
+ 0x4FAD5EA0L, 0x688FC31CL, 0xD1CFF191L, 0xB3A8C1ADL,
+ 0x2F2F2218L, 0xBE0E1777L, 0xEA752DFEL, 0x8B021FA1L,
+ 0xE5A0CC0FL, 0xB56F74E8L, 0x18ACF3D6L, 0xCE89E299L,
+ 0xB4A84FE0L, 0xFD13E0B7L, 0x7CC43B81L, 0xD2ADA8D9L,
+ 0x165FA266L, 0x80957705L, 0x93CC7314L, 0x211A1477L,
+ 0xE6AD2065L, 0x77B5FA86L, 0xC75442F5L, 0xFB9D35CFL,
+ 0xEBCDAF0CL, 0x7B3E89A0L, 0xD6411BD3L, 0xAE1E7E49L,
+ 0x00250E2DL, 0x2071B35EL, 0x226800BBL, 0x57B8E0AFL,
+ 0x2464369BL, 0xF009B91EL, 0x5563911DL, 0x59DFA6AAL,
+ 0x78C14389L, 0xD95A537FL, 0x207D5BA2L, 0x02E5B9C5L,
+ 0x83260376L, 0x6295CFA9L, 0x11C81968L, 0x4E734A41L,
+ 0xB3472DCAL, 0x7B14A94AL, 0x1B510052L, 0x9A532915L,
+ 0xD60F573FL, 0xBC9BC6E4L, 0x2B60A476L, 0x81E67400L,
+ 0x08BA6FB5L, 0x571BE91FL, 0xF296EC6BL, 0x2A0DD915L,
+ 0xB6636521L, 0xE7B9F9B6L, 0xFF34052EL, 0xC5855664L,
+ 0x53B02D5DL, 0xA99F8FA1L, 0x08BA4799L, 0x6E85076AL },
+ { 0x4B7A70E9L, 0xB5B32944L, 0xDB75092EL, 0xC4192623L,
+ 0xAD6EA6B0L, 0x49A7DF7DL, 0x9CEE60B8L, 0x8FEDB266L,
+ 0xECAA8C71L, 0x699A17FFL, 0x5664526CL, 0xC2B19EE1L,
+ 0x193602A5L, 0x75094C29L, 0xA0591340L, 0xE4183A3EL,
+ 0x3F54989AL, 0x5B429D65L, 0x6B8FE4D6L, 0x99F73FD6L,
+ 0xA1D29C07L, 0xEFE830F5L, 0x4D2D38E6L, 0xF0255DC1L,
+ 0x4CDD2086L, 0x8470EB26L, 0x6382E9C6L, 0x021ECC5EL,
+ 0x09686B3FL, 0x3EBAEFC9L, 0x3C971814L, 0x6B6A70A1L,
+ 0x687F3584L, 0x52A0E286L, 0xB79C5305L, 0xAA500737L,
+ 0x3E07841CL, 0x7FDEAE5CL, 0x8E7D44ECL, 0x5716F2B8L,
+ 0xB03ADA37L, 0xF0500C0DL, 0xF01C1F04L, 0x0200B3FFL,
+ 0xAE0CF51AL, 0x3CB574B2L, 0x25837A58L, 0xDC0921BDL,
+ 0xD19113F9L, 0x7CA92FF6L, 0x94324773L, 0x22F54701L,
+ 0x3AE5E581L, 0x37C2DADCL, 0xC8B57634L, 0x9AF3DDA7L,
+ 0xA9446146L, 0x0FD0030EL, 0xECC8C73EL, 0xA4751E41L,
+ 0xE238CD99L, 0x3BEA0E2FL, 0x3280BBA1L, 0x183EB331L,
+ 0x4E548B38L, 0x4F6DB908L, 0x6F420D03L, 0xF60A04BFL,
+ 0x2CB81290L, 0x24977C79L, 0x5679B072L, 0xBCAF89AFL,
+ 0xDE9A771FL, 0xD9930810L, 0xB38BAE12L, 0xDCCF3F2EL,
+ 0x5512721FL, 0x2E6B7124L, 0x501ADDE6L, 0x9F84CD87L,
+ 0x7A584718L, 0x7408DA17L, 0xBC9F9ABCL, 0xE94B7D8CL,
+ 0xEC7AEC3AL, 0xDB851DFAL, 0x63094366L, 0xC464C3D2L,
+ 0xEF1C1847L, 0x3215D908L, 0xDD433B37L, 0x24C2BA16L,
+ 0x12A14D43L, 0x2A65C451L, 0x50940002L, 0x133AE4DDL,
+ 0x71DFF89EL, 0x10314E55L, 0x81AC77D6L, 0x5F11199BL,
+ 0x043556F1L, 0xD7A3C76BL, 0x3C11183BL, 0x5924A509L,
+ 0xF28FE6EDL, 0x97F1FBFAL, 0x9EBABF2CL, 0x1E153C6EL,
+ 0x86E34570L, 0xEAE96FB1L, 0x860E5E0AL, 0x5A3E2AB3L,
+ 0x771FE71CL, 0x4E3D06FAL, 0x2965DCB9L, 0x99E71D0FL,
+ 0x803E89D6L, 0x5266C825L, 0x2E4CC978L, 0x9C10B36AL,
+ 0xC6150EBAL, 0x94E2EA78L, 0xA5FC3C53L, 0x1E0A2DF4L,
+ 0xF2F74EA7L, 0x361D2B3DL, 0x1939260FL, 0x19C27960L,
+ 0x5223A708L, 0xF71312B6L, 0xEBADFE6EL, 0xEAC31F66L,
+ 0xE3BC4595L, 0xA67BC883L, 0xB17F37D1L, 0x018CFF28L,
+ 0xC332DDEFL, 0xBE6C5AA5L, 0x65582185L, 0x68AB9802L,
+ 0xEECEA50FL, 0xDB2F953BL, 0x2AEF7DADL, 0x5B6E2F84L,
+ 0x1521B628L, 0x29076170L, 0xECDD4775L, 0x619F1510L,
+ 0x13CCA830L, 0xEB61BD96L, 0x0334FE1EL, 0xAA0363CFL,
+ 0xB5735C90L, 0x4C70A239L, 0xD59E9E0BL, 0xCBAADE14L,
+ 0xEECC86BCL, 0x60622CA7L, 0x9CAB5CABL, 0xB2F3846EL,
+ 0x648B1EAFL, 0x19BDF0CAL, 0xA02369B9L, 0x655ABB50L,
+ 0x40685A32L, 0x3C2AB4B3L, 0x319EE9D5L, 0xC021B8F7L,
+ 0x9B540B19L, 0x875FA099L, 0x95F7997EL, 0x623D7DA8L,
+ 0xF837889AL, 0x97E32D77L, 0x11ED935FL, 0x16681281L,
+ 0x0E358829L, 0xC7E61FD6L, 0x96DEDFA1L, 0x7858BA99L,
+ 0x57F584A5L, 0x1B227263L, 0x9B83C3FFL, 0x1AC24696L,
+ 0xCDB30AEBL, 0x532E3054L, 0x8FD948E4L, 0x6DBC3128L,
+ 0x58EBF2EFL, 0x34C6FFEAL, 0xFE28ED61L, 0xEE7C3C73L,
+ 0x5D4A14D9L, 0xE864B7E3L, 0x42105D14L, 0x203E13E0L,
+ 0x45EEE2B6L, 0xA3AAABEAL, 0xDB6C4F15L, 0xFACB4FD0L,
+ 0xC742F442L, 0xEF6ABBB5L, 0x654F3B1DL, 0x41CD2105L,
+ 0xD81E799EL, 0x86854DC7L, 0xE44B476AL, 0x3D816250L,
+ 0xCF62A1F2L, 0x5B8D2646L, 0xFC8883A0L, 0xC1C7B6A3L,
+ 0x7F1524C3L, 0x69CB7492L, 0x47848A0BL, 0x5692B285L,
+ 0x095BBF00L, 0xAD19489DL, 0x1462B174L, 0x23820E00L,
+ 0x58428D2AL, 0x0C55F5EAL, 0x1DADF43EL, 0x233F7061L,
+ 0x3372F092L, 0x8D937E41L, 0xD65FECF1L, 0x6C223BDBL,
+ 0x7CDE3759L, 0xCBEE7460L, 0x4085F2A7L, 0xCE77326EL,
+ 0xA6078084L, 0x19F8509EL, 0xE8EFD855L, 0x61D99735L,
+ 0xA969A7AAL, 0xC50C06C2L, 0x5A04ABFCL, 0x800BCADCL,
+ 0x9E447A2EL, 0xC3453484L, 0xFDD56705L, 0x0E1E9EC9L,
+ 0xDB73DBD3L, 0x105588CDL, 0x675FDA79L, 0xE3674340L,
+ 0xC5C43465L, 0x713E38D8L, 0x3D28F89EL, 0xF16DFF20L,
+ 0x153E21E7L, 0x8FB03D4AL, 0xE6E39F2BL, 0xDB83ADF7L },
+ { 0xE93D5A68L, 0x948140F7L, 0xF64C261CL, 0x94692934L,
+ 0x411520F7L, 0x7602D4F7L, 0xBCF46B2EL, 0xD4A20068L,
+ 0xD4082471L, 0x3320F46AL, 0x43B7D4B7L, 0x500061AFL,
+ 0x1E39F62EL, 0x97244546L, 0x14214F74L, 0xBF8B8840L,
+ 0x4D95FC1DL, 0x96B591AFL, 0x70F4DDD3L, 0x66A02F45L,
+ 0xBFBC09ECL, 0x03BD9785L, 0x7FAC6DD0L, 0x31CB8504L,
+ 0x96EB27B3L, 0x55FD3941L, 0xDA2547E6L, 0xABCA0A9AL,
+ 0x28507825L, 0x530429F4L, 0x0A2C86DAL, 0xE9B66DFBL,
+ 0x68DC1462L, 0xD7486900L, 0x680EC0A4L, 0x27A18DEEL,
+ 0x4F3FFEA2L, 0xE887AD8CL, 0xB58CE006L, 0x7AF4D6B6L,
+ 0xAACE1E7CL, 0xD3375FECL, 0xCE78A399L, 0x406B2A42L,
+ 0x20FE9E35L, 0xD9F385B9L, 0xEE39D7ABL, 0x3B124E8BL,
+ 0x1DC9FAF7L, 0x4B6D1856L, 0x26A36631L, 0xEAE397B2L,
+ 0x3A6EFA74L, 0xDD5B4332L, 0x6841E7F7L, 0xCA7820FBL,
+ 0xFB0AF54EL, 0xD8FEB397L, 0x454056ACL, 0xBA489527L,
+ 0x55533A3AL, 0x20838D87L, 0xFE6BA9B7L, 0xD096954BL,
+ 0x55A867BCL, 0xA1159A58L, 0xCCA92963L, 0x99E1DB33L,
+ 0xA62A4A56L, 0x3F3125F9L, 0x5EF47E1CL, 0x9029317CL,
+ 0xFDF8E802L, 0x04272F70L, 0x80BB155CL, 0x05282CE3L,
+ 0x95C11548L, 0xE4C66D22L, 0x48C1133FL, 0xC70F86DCL,
+ 0x07F9C9EEL, 0x41041F0FL, 0x404779A4L, 0x5D886E17L,
+ 0x325F51EBL, 0xD59BC0D1L, 0xF2BCC18FL, 0x41113564L,
+ 0x257B7834L, 0x602A9C60L, 0xDFF8E8A3L, 0x1F636C1BL,
+ 0x0E12B4C2L, 0x02E1329EL, 0xAF664FD1L, 0xCAD18115L,
+ 0x6B2395E0L, 0x333E92E1L, 0x3B240B62L, 0xEEBEB922L,
+ 0x85B2A20EL, 0xE6BA0D99L, 0xDE720C8CL, 0x2DA2F728L,
+ 0xD0127845L, 0x95B794FDL, 0x647D0862L, 0xE7CCF5F0L,
+ 0x5449A36FL, 0x877D48FAL, 0xC39DFD27L, 0xF33E8D1EL,
+ 0x0A476341L, 0x992EFF74L, 0x3A6F6EABL, 0xF4F8FD37L,
+ 0xA812DC60L, 0xA1EBDDF8L, 0x991BE14CL, 0xDB6E6B0DL,
+ 0xC67B5510L, 0x6D672C37L, 0x2765D43BL, 0xDCD0E804L,
+ 0xF1290DC7L, 0xCC00FFA3L, 0xB5390F92L, 0x690FED0BL,
+ 0x667B9FFBL, 0xCEDB7D9CL, 0xA091CF0BL, 0xD9155EA3L,
+ 0xBB132F88L, 0x515BAD24L, 0x7B9479BFL, 0x763BD6EBL,
+ 0x37392EB3L, 0xCC115979L, 0x8026E297L, 0xF42E312DL,
+ 0x6842ADA7L, 0xC66A2B3BL, 0x12754CCCL, 0x782EF11CL,
+ 0x6A124237L, 0xB79251E7L, 0x06A1BBE6L, 0x4BFB6350L,
+ 0x1A6B1018L, 0x11CAEDFAL, 0x3D25BDD8L, 0xE2E1C3C9L,
+ 0x44421659L, 0x0A121386L, 0xD90CEC6EL, 0xD5ABEA2AL,
+ 0x64AF674EL, 0xDA86A85FL, 0xBEBFE988L, 0x64E4C3FEL,
+ 0x9DBC8057L, 0xF0F7C086L, 0x60787BF8L, 0x6003604DL,
+ 0xD1FD8346L, 0xF6381FB0L, 0x7745AE04L, 0xD736FCCCL,
+ 0x83426B33L, 0xF01EAB71L, 0xB0804187L, 0x3C005E5FL,
+ 0x77A057BEL, 0xBDE8AE24L, 0x55464299L, 0xBF582E61L,
+ 0x4E58F48FL, 0xF2DDFDA2L, 0xF474EF38L, 0x8789BDC2L,
+ 0x5366F9C3L, 0xC8B38E74L, 0xB475F255L, 0x46FCD9B9L,
+ 0x7AEB2661L, 0x8B1DDF84L, 0x846A0E79L, 0x915F95E2L,
+ 0x466E598EL, 0x20B45770L, 0x8CD55591L, 0xC902DE4CL,
+ 0xB90BACE1L, 0xBB8205D0L, 0x11A86248L, 0x7574A99EL,
+ 0xB77F19B6L, 0xE0A9DC09L, 0x662D09A1L, 0xC4324633L,
+ 0xE85A1F02L, 0x09F0BE8CL, 0x4A99A025L, 0x1D6EFE10L,
+ 0x1AB93D1DL, 0x0BA5A4DFL, 0xA186F20FL, 0x2868F169L,
+ 0xDCB7DA83L, 0x573906FEL, 0xA1E2CE9BL, 0x4FCD7F52L,
+ 0x50115E01L, 0xA70683FAL, 0xA002B5C4L, 0x0DE6D027L,
+ 0x9AF88C27L, 0x773F8641L, 0xC3604C06L, 0x61A806B5L,
+ 0xF0177A28L, 0xC0F586E0L, 0x006058AAL, 0x30DC7D62L,
+ 0x11E69ED7L, 0x2338EA63L, 0x53C2DD94L, 0xC2C21634L,
+ 0xBBCBEE56L, 0x90BCB6DEL, 0xEBFC7DA1L, 0xCE591D76L,
+ 0x6F05E409L, 0x4B7C0188L, 0x39720A3DL, 0x7C927C24L,
+ 0x86E3725FL, 0x724D9DB9L, 0x1AC15BB4L, 0xD39EB8FCL,
+ 0xED545578L, 0x08FCA5B5L, 0xD83D7CD3L, 0x4DAD0FC4L,
+ 0x1E50EF5EL, 0xB161E6F8L, 0xA28514D9L, 0x6C51133CL,
+ 0x6FD5C7E7L, 0x56E14EC4L, 0x362ABFCEL, 0xDDC6C837L,
+ 0xD79A3234L, 0x92638212L, 0x670EFA8EL, 0x406000E0L },
+ { 0x3A39CE37L, 0xD3FAF5CFL, 0xABC27737L, 0x5AC52D1BL,
+ 0x5CB0679EL, 0x4FA33742L, 0xD3822740L, 0x99BC9BBEL,
+ 0xD5118E9DL, 0xBF0F7315L, 0xD62D1C7EL, 0xC700C47BL,
+ 0xB78C1B6BL, 0x21A19045L, 0xB26EB1BEL, 0x6A366EB4L,
+ 0x5748AB2FL, 0xBC946E79L, 0xC6A376D2L, 0x6549C2C8L,
+ 0x530FF8EEL, 0x468DDE7DL, 0xD5730A1DL, 0x4CD04DC6L,
+ 0x2939BBDBL, 0xA9BA4650L, 0xAC9526E8L, 0xBE5EE304L,
+ 0xA1FAD5F0L, 0x6A2D519AL, 0x63EF8CE2L, 0x9A86EE22L,
+ 0xC089C2B8L, 0x43242EF6L, 0xA51E03AAL, 0x9CF2D0A4L,
+ 0x83C061BAL, 0x9BE96A4DL, 0x8FE51550L, 0xBA645BD6L,
+ 0x2826A2F9L, 0xA73A3AE1L, 0x4BA99586L, 0xEF5562E9L,
+ 0xC72FEFD3L, 0xF752F7DAL, 0x3F046F69L, 0x77FA0A59L,
+ 0x80E4A915L, 0x87B08601L, 0x9B09E6ADL, 0x3B3EE593L,
+ 0xE990FD5AL, 0x9E34D797L, 0x2CF0B7D9L, 0x022B8B51L,
+ 0x96D5AC3AL, 0x017DA67DL, 0xD1CF3ED6L, 0x7C7D2D28L,
+ 0x1F9F25CFL, 0xADF2B89BL, 0x5AD6B472L, 0x5A88F54CL,
+ 0xE029AC71L, 0xE019A5E6L, 0x47B0ACFDL, 0xED93FA9BL,
+ 0xE8D3C48DL, 0x283B57CCL, 0xF8D56629L, 0x79132E28L,
+ 0x785F0191L, 0xED756055L, 0xF7960E44L, 0xE3D35E8CL,
+ 0x15056DD4L, 0x88F46DBAL, 0x03A16125L, 0x0564F0BDL,
+ 0xC3EB9E15L, 0x3C9057A2L, 0x97271AECL, 0xA93A072AL,
+ 0x1B3F6D9BL, 0x1E6321F5L, 0xF59C66FBL, 0x26DCF319L,
+ 0x7533D928L, 0xB155FDF5L, 0x03563482L, 0x8ABA3CBBL,
+ 0x28517711L, 0xC20AD9F8L, 0xABCC5167L, 0xCCAD925FL,
+ 0x4DE81751L, 0x3830DC8EL, 0x379D5862L, 0x9320F991L,
+ 0xEA7A90C2L, 0xFB3E7BCEL, 0x5121CE64L, 0x774FBE32L,
+ 0xA8B6E37EL, 0xC3293D46L, 0x48DE5369L, 0x6413E680L,
+ 0xA2AE0810L, 0xDD6DB224L, 0x69852DFDL, 0x09072166L,
+ 0xB39A460AL, 0x6445C0DDL, 0x586CDECFL, 0x1C20C8AEL,
+ 0x5BBEF7DDL, 0x1B588D40L, 0xCCD2017FL, 0x6BB4E3BBL,
+ 0xDDA26A7EL, 0x3A59FF45L, 0x3E350A44L, 0xBCB4CDD5L,
+ 0x72EACEA8L, 0xFA6484BBL, 0x8D6612AEL, 0xBF3C6F47L,
+ 0xD29BE463L, 0x542F5D9EL, 0xAEC2771BL, 0xF64E6370L,
+ 0x740E0D8DL, 0xE75B1357L, 0xF8721671L, 0xAF537D5DL,
+ 0x4040CB08L, 0x4EB4E2CCL, 0x34D2466AL, 0x0115AF84L,
+ 0xE1B00428L, 0x95983A1DL, 0x06B89FB4L, 0xCE6EA048L,
+ 0x6F3F3B82L, 0x3520AB82L, 0x011A1D4BL, 0x277227F8L,
+ 0x611560B1L, 0xE7933FDCL, 0xBB3A792BL, 0x344525BDL,
+ 0xA08839E1L, 0x51CE794BL, 0x2F32C9B7L, 0xA01FBAC9L,
+ 0xE01CC87EL, 0xBCC7D1F6L, 0xCF0111C3L, 0xA1E8AAC7L,
+ 0x1A908749L, 0xD44FBD9AL, 0xD0DADECBL, 0xD50ADA38L,
+ 0x0339C32AL, 0xC6913667L, 0x8DF9317CL, 0xE0B12B4FL,
+ 0xF79E59B7L, 0x43F5BB3AL, 0xF2D519FFL, 0x27D9459CL,
+ 0xBF97222CL, 0x15E6FC2AL, 0x0F91FC71L, 0x9B941525L,
+ 0xFAE59361L, 0xCEB69CEBL, 0xC2A86459L, 0x12BAA8D1L,
+ 0xB6C1075EL, 0xE3056A0CL, 0x10D25065L, 0xCB03A442L,
+ 0xE0EC6E0EL, 0x1698DB3BL, 0x4C98A0BEL, 0x3278E964L,
+ 0x9F1F9532L, 0xE0D392DFL, 0xD3A0342BL, 0x8971F21EL,
+ 0x1B0A7441L, 0x4BA3348CL, 0xC5BE7120L, 0xC37632D8L,
+ 0xDF359F8DL, 0x9B992F2EL, 0xE60B6F47L, 0x0FE3F11DL,
+ 0xE54CDA54L, 0x1EDAD891L, 0xCE6279CFL, 0xCD3E7E6FL,
+ 0x1618B166L, 0xFD2C1D05L, 0x848FD2C5L, 0xF6FB2299L,
+ 0xF523F357L, 0xA6327623L, 0x93A83531L, 0x56CCCD02L,
+ 0xACF08162L, 0x5A75EBB5L, 0x6E163697L, 0x88D273CCL,
+ 0xDE966292L, 0x81B949D0L, 0x4C50901BL, 0x71C65614L,
+ 0xE6C6C7BDL, 0x327A140AL, 0x45E1D006L, 0xC3F27B9AL,
+ 0xC9AA53FDL, 0x62A80F00L, 0xBB25BFE2L, 0x35BDD2F6L,
+ 0x71126905L, 0xB2040222L, 0xB6CBCF7CL, 0xCD769C2BL,
+ 0x53113EC0L, 0x1640E3D3L, 0x38ABBD60L, 0x2547ADF0L,
+ 0xBA38209CL, 0xF746CE76L, 0x77AFA1C5L, 0x20756060L,
+ 0x85CBFE4EL, 0x8AE88DD8L, 0x7AAAF9B0L, 0x4CF9AA7EL,
+ 0x1948C25CL, 0x02FB8A8CL, 0x01C36AE4L, 0xD6EBE1F9L,
+ 0x90D4F869L, 0xA65CDEA0L, 0x3F09252DL, 0xC208E69FL,
+ 0xB74E6132L, 0xCE77E25BL, 0x578FDFE3L, 0x3AC372E6L }
+};
+
+
+static unsigned long F(BLOWFISH_CTX *ctx, unsigned long x) {
+ unsigned short a, b, c, d;
+ unsigned long y;
+
+ d = (unsigned short)(x & 0xFF);
+ x >>= 8;
+ c = (unsigned short)(x & 0xFF);
+ x >>= 8;
+ b = (unsigned short)(x & 0xFF);
+ x >>= 8;
+ a = (unsigned short)(x & 0xFF);
+ y = ctx->S[0][a] + ctx->S[1][b];
+ y = y ^ ctx->S[2][c];
+ y = y + ctx->S[3][d];
+
+ return y;
+}
+
+
+void Blowfish_Encrypt(BLOWFISH_CTX *ctx, unsigned long *xl, unsigned long *xr){
+ unsigned long Xl;
+ unsigned long Xr;
+ unsigned long temp;
+ short i;
+
+ Xl = *xl;
+ Xr = *xr;
+
+ for (i = 0; i < N; ++i) {
+ Xl = Xl ^ ctx->P[i];
+ Xr = F(ctx, Xl) ^ Xr;
+
+ temp = Xl;
+ Xl = Xr;
+ Xr = temp;
+ }
+
+ temp = Xl;
+ Xl = Xr;
+ Xr = temp;
+
+ Xr = Xr ^ ctx->P[N];
+ Xl = Xl ^ ctx->P[N + 1];
+
+ *xl = Xl;
+ *xr = Xr;
+}
+
+
+void Blowfish_Decrypt(BLOWFISH_CTX *ctx, unsigned long *xl, unsigned long *xr){
+ unsigned long Xl;
+ unsigned long Xr;
+ unsigned long temp;
+ short i;
+
+ Xl = *xl;
+ Xr = *xr;
+
+ for (i = N + 1; i > 1; --i) {
+ Xl = Xl ^ ctx->P[i];
+ Xr = F(ctx, Xl) ^ Xr;
+
+ /* Exchange Xl and Xr */
+ temp = Xl;
+ Xl = Xr;
+ Xr = temp;
+ }
+
+ /* Exchange Xl and Xr */
+ temp = Xl;
+ Xl = Xr;
+ Xr = temp;
+
+ Xr = Xr ^ ctx->P[1];
+ Xl = Xl ^ ctx->P[0];
+
+ *xl = Xl;
+ *xr = Xr;
+}
+
+
+void Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen) {
+ int i, j, k;
+ unsigned long data, datal, datar;
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 256; j++)
+ ctx->S[i][j] = ORIG_S[i][j];
+ }
+
+ j = 0;
+ for (i = 0; i < N + 2; ++i) {
+ data = 0x00000000;
+ for (k = 0; k < 4; ++k) {
+ data = (data << 8) | key[j];
+ j = j + 1;
+ if (j >= keyLen)
+ j = 0;
+ }
+ ctx->P[i] = ORIG_P[i] ^ data;
+ }
+
+ datal = 0x00000000;
+ datar = 0x00000000;
+
+ for (i = 0; i < N + 2; i += 2) {
+ Blowfish_Encrypt(ctx, &datal, &datar);
+ ctx->P[i] = datal;
+ ctx->P[i + 1] = datar;
+ }
+
+ for (i = 0; i < 4; ++i) {
+ for (j = 0; j < 256; j += 2) {
+ Blowfish_Encrypt(ctx, &datal, &datar);
+ ctx->S[i][j] = datal;
+ ctx->S[i][j + 1] = datar;
+ }
+ }
+}
+
+
diff --git a/blowfish.h b/blowfish.h new file mode 100644 index 00000000..3f33e945 --- /dev/null +++ b/blowfish.h @@ -0,0 +1,33 @@ +/*
+blowfish.h: Header file for blowfish.c
+
+Copyright (C) 1997 by Paul Kocher
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+See blowfish.c for more information about this file.
+*/
+
+
+typedef struct {
+ unsigned long P[16 + 2];
+ unsigned long S[4][256];
+} BLOWFISH_CTX;
+
+void Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen);
+void Blowfish_Encrypt(BLOWFISH_CTX *ctx, unsigned long *xl, unsigned long *xr);
+void Blowfish_Decrypt(BLOWFISH_CTX *ctx, unsigned long *xl, unsigned long *xr);
+
+
+
diff --git a/build-stamp b/build-stamp deleted file mode 100644 index e69de29b..00000000 --- a/build-stamp +++ /dev/null diff --git a/callbacks.c b/callbacks.c new file mode 100644 index 00000000..cfab4b2c --- /dev/null +++ b/callbacks.c @@ -0,0 +1,81 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdlib.h> +#include <gtk/gtk.h> + +#include <callbacks.h> +#include <iconcache.h> + +#include <shell.h> +#include <report.h> + +#include <config.h> + +void cb_refresh() +{ + shell_do_reload(); +} + +void cb_left_pane() +{ + gboolean visible; + + visible = shell_action_get_active("LeftPaneAction"); + shell_set_left_pane_visible(visible); +} + +void cb_toolbar() +{ + gboolean visible; + + visible = shell_action_get_active("ToolbarAction"); + shell_ui_manager_set_visible("/MainMenuBarAction", visible); +} + +void cb_about() +{ + GtkWidget *about; + + about = gtk_about_dialog_new(); + gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(about), "HardInfo"); + gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about), VERSION); + gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about), + "Copyright \302\251 2003-2006 " + "Leandro A. F. Pereira"); + gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about), + "System information and benchmark tool"); + gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(about), + icon_cache_get_pixbuf("logo.png")); + + gtk_dialog_run(GTK_DIALOG(about)); + gtk_widget_destroy(about); +} + +void cb_generate_report() +{ + Shell *shell = shell_get_main_shell(); + + report_dialog_show(shell->tree->model, shell->window); +} + +void cb_quit(void) +{ + gtk_main_quit(); + exit(0); +} diff --git a/callbacks.h b/callbacks.h new file mode 100644 index 00000000..f0f28322 --- /dev/null +++ b/callbacks.h @@ -0,0 +1,29 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __CALLBACKS_H__ +#define __CALLBACKS_H__ + +void cb_about(); +void cb_generate_report(); +void cb_quit(); +void cb_refresh(); +void cb_left_pane(); +void cb_toolbar(); + +#endif /* __CALLBACKS_H__ */ @@ -1,642 +1,322 @@ /* - * Distribuition detection routines - * Copyright (c) 2003 Leandro Pereira <leandro@linuxmag.com.br> + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> * - * May be distributed under the terms of GNU General Public License version 2. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "hardinfo.h" -#include "computer.h" - +#include <stdlib.h> +#include <string.h> #include <gtk/gtk.h> +#include <config.h> +#include <time.h> +#include <string.h> #include <sys/utsname.h> -#include <unistd.h> -#include <fcntl.h> -#include <stdlib.h> - -static struct { - gchar *file, *codename; -} distro_db[] = { - { DB_PREFIX "debian_version", "deb" }, - { DB_PREFIX "slackware-version", "slk" }, - { DB_PREFIX "mandrake-release", "mdk" }, - { DB_PREFIX "gentoo-release", "gnt" }, - { DB_PREFIX "conectiva-release", "cnc" }, - { DB_PREFIX "versão-conectiva", "cnc" }, - { DB_PREFIX "turbolinux-release", "tl" }, - { DB_PREFIX "yellowdog-release", "yd" }, - { DB_PREFIX "SuSE-release", "suse" }, - /* - * RedHat must be the *last* one to be checked, since - * some distros (like Mandrake) includes a redhat-relase - * file too. - */ - { DB_PREFIX "redhat-release", "rh" }, - { NULL, NULL } -}; - -#define get_int_val(var) { \ - walk_until_inclusive(':'); buf++; \ - var = atoi(buf); \ - continue; \ - } - -#define get_str_val(var) { \ - walk_until_inclusive(':'); buf++; \ - var = g_strdup(buf); \ - continue; \ - } - -#ifdef ARCH_i386 -static struct { - char *small, *large; -} small2large[] = { - { "fpu", "Floating Point Unit" }, - { "vme", "Virtual Mode Extension" }, - { "de", "Debugging Extensions" }, - { "pse", "Page Size Extensions" }, - { "tsc", "Time Stamp Counter" }, - { "msr", "Model Specific Registers" }, - { "pae", "Physical Address Extensions" }, - { "mce", "Machine Check Architeture" }, - { "cx8", "CMPXCHG8 instruction" }, - { "apic", "Advanced Programmable Interrupt Controller" }, - { "sep", "Fast System Call" }, - { "mtrr", "Memory Type Range Registers" }, - { "pge", "Page Global Enable" }, - { "cmov", "Conditional Move instruction" }, - { "pat", "Page Attribute Table" }, - { "pse36", "36bit Page Size Extensions" }, - { "psn", "96 bit Processor Serial Number" }, - { "mmx", "MMX technology" }, - { "fxsr", "fxsr" }, - { "kni", "Streaming SIMD instructions" }, - { "xmm", "Streaming SIMD instructions" }, - { "ht", "HyperThreading" }, - { NULL, NULL } +#include <sys/stat.h> + +#include <hardinfo.h> +#include <iconcache.h> +#include <shell.h> + +#include <expr.h> + +enum { + COMPUTER_SUMMARY, + COMPUTER_PROCESSORS, + COMPUTER_OPERATING_SYSTEM, + COMPUTER_LANGUAGE, + COMPUTER_SENSORS, + COMPUTER_FILESYSTEMS, + COMPUTER_SHARES, + COMPUTER_DISPLAY, + COMPUTER_NETWORK, +} Entries; + +static ModuleEntry hi_entries[] = { + {"Summary", "summary.png"}, + {"Processor", "processor.png"}, + {"Operating System", "os.png"}, + {"Languages", "language.png"}, + {"Sensors", "therm.png"}, + {"Filesystems", "dev_removable.png"}, + {"Shared Directories", "shares.png"}, + {"Display", "monitor.png"}, + {"Network Interfaces", "network.png"}, }; -static GtkWidget *get_features_widget(CPUDevice * device) -{ - GtkWidget *widget, *scroll; - GtkTextBuffer *buffer; - GtkTextIter iter; - gchar **flags; - gint i, j; - - if (!device->flags) - return NULL; - - buffer = gtk_text_buffer_new(FALSE); - gtk_text_buffer_set_text(buffer, "", -1); - gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0); - - flags = g_strsplit(device->flags, " ", G_N_ELEMENTS(small2large)); - for (i = 0; *(flags + i); i++) { - for (j = 0; j < G_N_ELEMENTS(small2large); j++) { - if (small2large[j].small && - !strncmp(small2large[j].small, *(flags + i), - strlen(small2large[j].small))) { -// gtk_text_buffer_insert(buffer, &iter, small2large[j].small, -// -1); - gtk_text_buffer_insert(buffer, &iter, "â— ", -1); - gtk_text_buffer_insert(buffer, &iter, small2large[j].large, - -1); - gtk_text_buffer_insert(buffer, &iter, "\n", -1); - break; - } - } - } - g_strfreev(flags); - - scroll = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_container_set_border_width(GTK_CONTAINER(scroll), 4); - gtk_widget_show(scroll); - - widget = gtk_text_view_new(); - gtk_text_view_set_buffer(GTK_TEXT_VIEW(widget), buffer); - gtk_text_view_set_editable(GTK_TEXT_VIEW(widget), FALSE); - gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(widget), FALSE); - gtk_text_view_set_indent(GTK_TEXT_VIEW(widget), 5); - gtk_widget_show(widget); - - gtk_container_add(GTK_CONTAINER(scroll), widget); - - return scroll; -} -#endif +#include "computer.h" -void hi_show_cpu_info(MainWindow * mainwindow, CPUDevice * device) +static GHashTable *moreinfo = NULL; + +#include <arch/common/languages.h> +#include <arch/this/alsa.h> +#include <arch/common/display.h> +#include <arch/this/loadavg.h> +#include <arch/this/memory.h> +#include <arch/this/uptime.h> +#include <arch/this/processor.h> +#include <arch/this/os.h> +#include <arch/this/filesystem.h> +#include <arch/this/samba.h> +#include <arch/this/sensors.h> +#include <arch/this/net.h> + +static Computer * +computer_get_info(void) { - gchar *buf; - - if (!device) - return; - - gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), - device->processor); - detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "cpu.png"); - detail_window_set_dev_name(mainwindow->det_window, device->processor); - detail_window_set_dev_type(mainwindow->det_window, device->machine); - - detail_window_append_info_int(mainwindow->det_window, _("Number"), - device->procno, FALSE); - buf = g_strdup_printf("%dMHz", device->frequency); - detail_window_append_info(mainwindow->det_window, _("Frequency"), buf); - g_free(buf); - - detail_window_append_separator(mainwindow->det_window); -#ifdef ARCH_i386 - detail_window_append_info_int(mainwindow->det_window, _("Family"), - device->family, FALSE); - detail_window_append_info_int(mainwindow->det_window, _("Model"), - device->model, FALSE); - detail_window_append_info_int(mainwindow->det_window, _("Stepping"), - device->stepping, FALSE); - detail_window_append_separator(mainwindow->det_window); + Computer *computer; + + computer = g_new0(Computer, 1); + + if (moreinfo) { +#ifdef g_hash_table_unref + g_hash_table_unref(moreinfo); +#else + g_free(moreinfo); #endif - - if (device->cachel2) { - buf = g_strdup_printf("%dkB", device->cachel2); - detail_window_append_info(mainwindow->det_window, _("Cache L2"), - buf); - g_free(buf); - } - - buf = g_strdup_printf("%d bogomips", device->bogomips); - detail_window_append_info(mainwindow->det_window, _("Bogomips"), buf); - g_free(buf); - -#ifdef ARCH_i386 - { - GtkWidget *features, *label; - - label = gtk_label_new(_("Features")); - gtk_widget_show(label); - - features = get_features_widget(device); - gtk_notebook_append_page(GTK_NOTEBOOK - (mainwindow->det_window->notebook), - features, label); } -#endif -} - -MemoryInfo *memory_get_info(void) -{ - MemoryInfo *mi; - FILE *procmem; - gchar buffer[128]; - gint memfree = 0, memused; + moreinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); - mi = g_new0(MemoryInfo, 1); + shell_status_update("Getting processor information..."); + computer->processor = computer_get_processor(); - procmem = fopen("/proc/meminfo", "r"); - while (fgets(buffer, 128, procmem)) { - gchar *buf = buffer; + shell_status_update("Getting memory information..."); + computer->memory = computer_get_memory(); - buf = g_strstrip(buf); + shell_status_update("Getting operating system information..."); + computer->os = computer_get_os(); - if (!strncmp(buf, "MemTotal", 8)) - get_int_val(mi->total) - else if (!strncmp(buf, "MemFree", 7)) - get_int_val(memfree) - else if (!strncmp(buf, "Cached", 6)) - get_int_val(mi->cached) - } - fclose(procmem); + shell_status_update("Getting display information..."); + computer->display = computer_get_display(); - mi->used = mi->total - memfree; + shell_status_update("Getting sound card information..."); + computer->alsa = computer_get_alsainfo(); - mi->total /= 1000; - mi->cached /= 1000; - mi->used /= 1000; - memfree /= 1000; + shell_status_update("Getting mounted file system information..."); + scan_filesystems(); - memused = mi->total - mi->used + mi->cached; + shell_status_update("Getting shared directories..."); + scan_shared_directories(); + + shell_status_update("Reading sensors..."); + read_sensors(); - mi->ratio = 1 - (gdouble) memused / mi->total; + shell_status_update("Obtaining network information..."); + scan_net_interfaces(); - return mi; + computer->date_time = "..."; + return computer; } -#if defined(ARCH_i386) || defined(ARCH_x86_64) || defined(ARCH_PARISC) -#define PARSE_PROC_CPU() \ - if(!strncmp(buf, "bogomips", 8)) \ - get_int_val(ci->bogomips) \ - else if(!strncmp(buf, "cpu family", 10)) \ - get_int_val(ci->family) \ - else if(!strncmp(buf, "model name", 10)) \ - get_str_val(ci->processor) \ - else if(!strncmp(buf, "flags", 5)) \ - get_str_val(ci->flags) \ - else if(!strncmp(buf, "vendor_id", 8)) \ - get_str_val(ci->machine) \ - else if(!strncmp(buf, "stepping", 8)) \ - get_int_val(ci->stepping) \ - else if(!strncmp(buf, "cpu MHz", 7)) \ - get_int_val(ci->frequency) \ - else if(!strncmp(buf, "cache size", 10)) \ - get_int_val(ci->cachel2) \ - else if(!strncmp(buf, "model", 5)) \ - get_int_val(ci->model) -#endif -#ifdef ARCH_PPC -#define PARSE_PROC_CPU() \ - if(!strncmp(buf, "bogomips", 8)) \ - get_int_val(ci->bogomips) \ - else if(!strncmp(buf, "cpu", 3)) \ - get_str_val(ci->processor) \ - else if(!strncmp(buf, "machine", 7)) \ - get_str_val(ci->machine) \ - else if(!strncmp(buf, "clock", 5)) \ - get_int_val(ci->frequency) \ - else if(!strncmp(buf, "L2 cache", 8)) \ - get_int_val(ci->cachel2) -#endif -#ifdef ARCH_m68k -#define PARSE_PROC_CPU() \ - if (!strncmp(buf, "CPU", 3)) \ - get_str_val(ci->processor) \ - else if (!strncmp(buf, "BogoMips", 8)) \ - get_int_val(ci->bogomips) \ - else if (!strncmp(buf, "Clocking", 8)) \ - get_int_val(ci->frequency) -#endif -#ifdef ARCH_MIPS -#define PARSE_PROC_CPU() \ - if (!strncmp(buf, "cpu model", 9)) \ - get_str_val(ci->processor) \ - else if (!strncmp(buf, "BogoMIPS", 8)) \ - get_int_val(ci->bogomips) \ - else if (!strncmp(buf, "system type", 11)) \ - get_str_val(ci->machine) -#endif - -#ifndef PARSE_PROC_CPU -#error PARSE_PROC_CPU not defined! Maybe your arch is not supported yet; -#error please send me your /proc/cpuinfo and/or 'uname -a' output to -#error leandro@linuxmag.com.br; thanks. -#endif - -static void computer_processor_info(ComputerInfo * ci) +void +hi_reload(gint entry) { - FILE *proccpu; - gchar buffer[128]; - - proccpu = fopen("/proc/cpuinfo", "r"); - while (fgets(buffer, 128, proccpu)) { - gchar *buf = buffer; - - buf = g_strstrip(buf); - - PARSE_PROC_CPU(); - } - fclose(proccpu); - -#ifdef ARCH_PPC - { - gchar *proctemp; - - proctemp = g_strdup_printf("PowerPC %s", ci->processor); - g_free(ci->processor); - ci->processor = proctemp; + switch (entry) { + case COMPUTER_FILESYSTEMS: + scan_filesystems(); + break; + case COMPUTER_NETWORK: + scan_net_interfaces(); + break; + case COMPUTER_SENSORS: + read_sensors(); + break; } -#endif -#ifdef ARCH_m68k - { - gchar *proctemp; - - proctemp = g_strdup_printf("Motorola %s", ci->processor); - g_free(ci->processor); - ci->processor = proctemp; - } -#endif - } -ComputerInfo *computer_get_info(void) +gchar * +hi_more_info(gchar * entry) { - gint i; - struct stat st; - ComputerInfo *ci; - struct utsname utsbuf; - - ci = g_new0(ComputerInfo, 1); - - for (i = 0;; i++) { - if (distro_db[i].file == NULL) { - ci->distrocode = g_strdup("unk"); - ci->distroinfo = g_strdup(_("Unknown distribution")); - break; - } - - if (!stat(distro_db[i].file, &st)) { - FILE *distro_ver; - char buf[128]; - - distro_ver = fopen(distro_db[i].file, "r"); - fgets(buf, 128, distro_ver); - fclose(distro_ver); - - buf[strlen(buf) - 1] = 0; - - /* - * HACK: Some Debian systems doesn't include - * the distribuition name in /etc/debian_release, - * so add them here. - */ - if (!strncmp(distro_db[i].codename, "deb", 3) && - ((buf[0] >= '0' && buf[0] <= '9') || buf[0] != 'D')) { - ci->distroinfo = g_strdup_printf - ("Debian GNU/Linux %s", buf); - } else { - ci->distroinfo = g_strdup(buf); - } - - ci->distrocode = g_strdup(distro_db[i].codename); - - break; - } - } - - uname(&utsbuf); - ci->kernel = g_strdup_printf("%s %s (%s)", utsbuf.sysname, - utsbuf.release, utsbuf.machine); - - ci->hostname = g_strdup(utsbuf.nodename); + gchar *info = (gchar *) g_hash_table_lookup(moreinfo, entry); - computer_processor_info(ci); + if (info) + return g_strdup(info); - return ci; + return g_strdup_printf("[Empty %s]", entry); } -/* - * Code stolen from GKrellM <http://www.gkrellm.net> - * Copyright (c) 1999-2002 Bill Wilson <bill@gkrellm.net> - */ -gboolean uptime_update(gpointer data) +gchar * +hi_get_field(gchar * field) { - MainWindow *mainwindow = (MainWindow *) data; - gchar *buf; - gint days, hours; - FILE *procuptime; - gulong minutes = 0; - - if (!mainwindow) - return FALSE; - -#define plural(a) (a == 1) ? "" : "s" - - if ((procuptime = fopen("/proc/uptime", "r")) != NULL) { - fscanf(procuptime, "%lu", &minutes); - minutes /= 60; - fclose(procuptime); - } else - return FALSE; - - hours = minutes / 60; - minutes %= 60; - days = hours / 24; - hours %= 24; - - if (days < 1) { - buf = g_strdup_printf(_("%d hour%s and %ld minute%s"), hours, - plural(hours), minutes, plural(minutes)); + gchar *tmp; + + if (!strcmp(field, "Memory")) { + MemoryInfo *mi; + + mi = computer_get_memory(); + tmp = g_strdup_printf("%dMB (%dMB used)", mi->total, mi->used); + + g_free(mi); + } else if (!strcmp(field, "Random")) { + return g_strdup_printf("%d", rand() % 200); + } else if (!strcmp(field, "Uptime")) { + tmp = computer_get_formatted_uptime(); + } else if (!strcmp(field, "Date/Time")) { + time_t t = time(NULL); + + tmp = g_new0(gchar, 32); + strftime(tmp, 32, "%D / %R", localtime(&t)); + } else if (!strcmp(field, "Load Average")) { + tmp = computer_get_formatted_loadavg(); } else { - buf = - g_strdup_printf(_("%d day%s, %d hour%s and %ld minute%s"), - days, plural(days), hours, plural(hours), - minutes, plural(minutes)); + tmp = g_strdup(""); } - gtk_label_set_text(GTK_LABEL(mainwindow->uptime), buf); - g_free(buf); - - return TRUE; -} - -GtkWidget *os_get_widget(MainWindow * mainwindow) -{ - GtkWidget *label, *hbox; - GtkWidget *table; - GtkWidget *pixmap; - gchar *buf; - ComputerInfo *info; - - if (!mainwindow) - return NULL; - - info = computer_get_info(); - - hbox = gtk_hbox_new(FALSE, 0); - gtk_widget_show(hbox); - - buf = - g_strdup_printf("%s/distro/%s.png", IMG_PREFIX, info->distrocode); - pixmap = gtk_image_new_from_file(buf); - gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0); - gtk_widget_show(pixmap); - gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); - g_free(buf); - - table = gtk_table_new(4, 2, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 0); - gtk_container_set_border_width(GTK_CONTAINER(table), 10); - gtk_table_set_row_spacings(GTK_TABLE(table), 4); - gtk_table_set_col_spacings(GTK_TABLE(table), 4); - - /* - * Table headers - */ - label = gtk_label_new(_("<b>Computer name:</b>")); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - label = gtk_label_new(_("<b>Distribution:</b>")); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - label = gtk_label_new(_("<b>Kernel:</b>")); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - label = gtk_label_new(_("<b>Uptime:</b>")); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - - /* - * Table content - */ - label = gtk_label_new(info->hostname); - gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - label = gtk_label_new(info->distroinfo); - gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - label = gtk_label_new(info->kernel); - gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - label = gtk_label_new(_("Updating...")); - gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 3, 4); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - mainwindow->uptime = label; - - uptime_update(mainwindow); - gtk_timeout_add(30000, uptime_update, mainwindow); - - g_free(info); - - return hbox; + return tmp; } -gboolean memory_update(gpointer data) +gchar * +hi_info(gint entry) { - MainWindow *mainwindow = (MainWindow *) data; - MemoryInfo *mi; - - if (!mainwindow) - return FALSE; - - mi = memory_get_info(); + static Computer *computer = NULL; + static gchar *tmp = NULL; - gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwindow->membar), - mi->ratio); + /*if (tmp != NULL) { + g_free(tmp); + tmp = NULL; + } */ - g_free(mi); + if (!computer) { + computer = computer_get_info(); + } - return TRUE; + switch (entry) { + case COMPUTER_NETWORK: + return g_strdup_printf("[$ShellParam$]\n" + "ReloadInterval=3000\n" + "ViewType=1\n" + "%s", network_interfaces); + case COMPUTER_SENSORS: + return g_strdup_printf("[$ShellParam$]\n" + "ReloadInterval=3000\n" + "%s", sensors); + case COMPUTER_SHARES: + return g_strdup_printf("[SAMBA]\n" + "%s", shares_list); + case COMPUTER_FILESYSTEMS: + return g_strdup_printf("[$ShellParam$]\n" + "ViewType=1\n" + "ReloadInterval=5000\n" + "[Mounted File Systems]\n%s\n", fs_list); + case COMPUTER_SUMMARY: + tmp = computer_get_alsacards(computer); + return g_strdup_printf("[$ShellParam$]\n" + "UpdateInterval$Memory=1000\n" + "UpdateInterval$Date/Time=1000\n" + "[Computer]\n" + "Processor=%s\n" + "Memory=...\n" + "Operating System=%s\n" + "User Name=%s\n" + "Date/Time=%s\n" + "[Display]\n" + "Resolution=%dx%d pixels\n" + "OpenGL Renderer=%s\n" + "X11 Vendor=%s\n" + "[Multimedia]\n" + "%s\n" + "#[Storage]\n" + "#IDE Controller=\n" + "#SCSI Controller=\n" + "#Floppy Drive=\n" + "#Disk Drive=\n", + computer->processor->model_name, + computer->os->distro, + computer->os->username, + computer->date_time, + computer->display->width, + computer->display->height, + computer->display->ogl_renderer, + computer->display->vendor, + tmp); + case COMPUTER_DISPLAY: + return g_strdup_printf("[Display]\n" + "Resolution=%dx%d pixels\n" + "Vendor=%s\n" + "Version=%s\n" + "[Monitors]\n" + "%s" + "[Extensions]\n" + "%s" + "[OpenGL]\n" + "Vendor=%s\n" + "Renderer=%s\n" + "Version=%s\n", + computer->display->width, + computer->display->height, + computer->display->vendor, + computer->display->version, + computer->display->monitors, + computer->display->extensions, + computer->display->ogl_vendor, + computer->display->ogl_renderer, + computer->display->ogl_version); + case COMPUTER_OPERATING_SYSTEM: + tmp = computer_get_formatted_uptime(); + return g_strdup_printf("[$ShellParam$]\n" + "UpdateInterval$Uptime=10000\n" + "UpdateInterval$Load Average=1000\n" + "[Version]\n" + "Kernel=%s\n" + "Compiled=%s\n" + "C Library=%s\n" + "Distribution=%s\n" + "[Current Session]\n" + "Computer Name=%s\n" + "User Name=%s\n" + "#Language=%s\n" + "Home Directory=%s\n" + "Desktop Environment=%s\n" + "[Misc]\n" + "Uptime=%s\n" + "Load Average=...", + computer->os->kernel, + computer->os->compiled_date, + computer->os->libc, + computer->os->distro, + computer->os->hostname, + computer->os->username, + computer->os->language, + computer->os->homedir, + computer->os->desktop, tmp); + case COMPUTER_LANGUAGE: + return g_strdup_printf("[$ShellParam$]\n" + "ViewType=1\n" + "[Available Languages]\n" + "%s", computer->os->languages); + case COMPUTER_PROCESSORS: + return processor_get_info(computer->processor); + default: + return g_strdup("[Empty]\nNo info available="); + } } -GtkWidget *memory_get_widget(MainWindow * mainwindow) +gint +hi_n_entries(void) { - GtkWidget *label, *vbox, *hbox, *hbox2, *progress; - GtkWidget *pixmap; - MemoryInfo *mi; - gchar *buf; - - mi = memory_get_info(); - - hbox = gtk_hbox_new(FALSE, 0); - gtk_widget_show(hbox); - - buf = g_strdup_printf("%s/mem.png", IMG_PREFIX); - pixmap = gtk_image_new_from_file(buf); - gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0); - gtk_widget_show(pixmap); - gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); - g_free(buf); - - vbox = gtk_vbox_new(FALSE, 0); - gtk_widget_show(vbox); - gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); - gtk_box_set_spacing(GTK_BOX(vbox), 4); - - hbox2 = gtk_hbox_new(FALSE, 5); - gtk_widget_show(hbox2); - gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0); - - label = gtk_label_new("0MB"); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - buf = g_strdup_printf("%dMB", mi->total); - label = gtk_label_new(buf); - gtk_widget_show(label); - gtk_box_pack_end(GTK_BOX(hbox2), label, FALSE, FALSE, 0); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - g_free(buf); - - progress = gtk_progress_bar_new(); - mainwindow->membar = progress; - gtk_widget_show(progress); - gtk_box_pack_start(GTK_BOX(vbox), progress, TRUE, TRUE, 0); - - memory_update(mainwindow); - - gtk_timeout_add(2000, memory_update, mainwindow); - - g_free(mi); - return hbox; + return G_N_ELEMENTS(hi_entries) - 1; } -GtkWidget *processor_get_widget(void) +GdkPixbuf * +hi_icon(gint entry) { - GtkWidget *label, *vbox, *hbox; - GtkWidget *pixmap; - ComputerInfo *info; - gchar *buf; - - info = computer_get_info(); - - hbox = gtk_hbox_new(FALSE, 0); - gtk_widget_show(hbox); - - buf = g_strdup_printf("%s/cpu.png", IMG_PREFIX); - pixmap = gtk_image_new_from_file(buf); - gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0); - gtk_widget_show(pixmap); - gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); - g_free(buf); - - vbox = gtk_vbox_new(FALSE, 0); - gtk_widget_show(vbox); - gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); - gtk_box_set_spacing(GTK_BOX(vbox), 4); - - buf = g_strdup_printf(_("<b>%s</b> at %d MHz"), - info->processor, info->frequency); - - label = gtk_label_new(buf); - gtk_widget_show(label); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - g_free(buf); - -#ifdef ARCH_i386 - buf = g_strdup_printf(_("Family %d, model %d, stepping %d"), - info->family, info->model, info->stepping); - label = gtk_label_new(buf); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - g_free(buf); -#endif - - if (info->cachel2) { - buf = g_strdup_printf(_("%d KB L2 cache"), info->cachel2); - label = gtk_label_new(buf); - gtk_widget_show(label); - - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - g_free(buf); - } + return icon_cache_get_pixbuf(hi_entries[entry].icon); +} - g_free(info); - return hbox; +gchar * +hi_name(gint entry) +{ + return hi_entries[entry].name; } @@ -1,50 +1,162 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #ifndef __COMPUTER_H__ #define __COMPUTER_H__ -#include <glib.h> +#define DB_PREFIX "/etc/" -#define DB_PREFIX "/etc/" +static struct { + gchar *file, *codename; +} distro_db[] = { + { DB_PREFIX "debian_version", "deb" }, + { DB_PREFIX "slackware-version", "slk" }, + { DB_PREFIX "mandrake-release", "mdk" }, + { DB_PREFIX "gentoo-release", "gnt" }, + { DB_PREFIX "conectiva-release", "cnc" }, + { DB_PREFIX "versão-conectiva", "cnc" }, + { DB_PREFIX "turbolinux-release", "tl" }, + { DB_PREFIX "yellowdog-release", "yd" }, + { DB_PREFIX "SuSE-release", "suse" }, + { DB_PREFIX "sun-release", "sun" }, + /* + * RedHat must be the *last* one to be checked, since + * some distros (like Mandrake) includes a redhat-relase + * file too. + */ + { DB_PREFIX "redhat-release", "rh" }, + { NULL, NULL } +}; -typedef struct _ComputerInfo ComputerInfo; -typedef struct _MemoryInfo MemoryInfo; -typedef struct _ComputerInfo CPUDevice; +typedef struct _Computer Computer; +typedef struct _Processor Processor; +typedef struct _OperatingSystem OperatingSystem; +typedef struct _MemoryInfo MemoryInfo; +typedef struct _UptimeInfo UptimeInfo; +typedef struct _LoadInfo LoadInfo; +typedef struct _DisplayInfo DisplayInfo; -struct _MemoryInfo { - gint total; - gint used; - gint cached; +typedef struct _AlsaInfo AlsaInfo; +typedef struct _AlsaCard AlsaCard; + +typedef struct _FileSystem FileSystem; +typedef struct _FileSystemEntry FileSystemEntry; + +struct _AlsaCard { + gchar *alsa_name; + gchar *friendly_name; +/* + gchar *board; + gchar revision, compat_class; + gint subsys_vendorid, subsys_id; + + gint cap_dac_res, cap_adc_res; + gboolean cap_3d_enh; + + gint curr_mic_gain; + gboolean curr_3d_enh, + curr_loudness, + curr_simstereo; + gchar *curr_mic_select; +*/ +}; - gdouble ratio; +struct _AlsaInfo { + GSList *cards; }; -struct _ComputerInfo { - gchar *distrocode; - gchar *distroinfo; - - gchar *kernel; - - gchar *hostname; - - gint procno; - gchar *processor; - gchar *flags; - gchar *machine; - gint frequency; - gint family, model, stepping; - gint cachel2; - gint bogomips; +struct _DisplayInfo { + gchar *ogl_vendor, *ogl_renderer, *ogl_version; + gchar *display_name, *vendor, *version; + gchar *extensions; + gchar *monitors; + + gint width, height; }; -ComputerInfo *computer_get_info(void); -MemoryInfo *memory_get_info(void); +struct _LoadInfo { + float load1, load5, load15; +}; + +struct _UptimeInfo { + int days, hours, minutes; +}; -GtkWidget *os_get_widget(MainWindow *mainwindow); -GtkWidget *memory_get_widget(MainWindow *mainwindow); -GtkWidget *processor_get_widget(void); +struct _Computer { + Processor *processor; + MemoryInfo *memory; + OperatingSystem *os; + DisplayInfo *display; + AlsaInfo *alsa; + + gchar *date_time; +}; -gboolean uptime_update(gpointer data); -gboolean memory_update(gpointer data); +struct _Processor { + gchar *model_name; + gchar *vendor_id; + gchar *flags; + gint cache_size; + gfloat bogomips, cpu_mhz; + + gchar *has_fpu; + gchar *bug_fdiv, *bug_hlt, *bug_f00f, *bug_coma; + + gint model, family, stepping; + gchar *strmodel; +}; + +struct _OperatingSystem { + gchar *kernel; + gchar *libc; + gchar *distrocode, *distro; + gchar *hostname; + gchar *language; + gchar *homedir; + gchar *compiled_date; + + gchar *languages; + + gchar *desktop; + gchar *username; +}; + +struct _MemoryInfo { + gint total, used, free, cached; + gfloat ratio; +}; -void hi_show_cpu_info(MainWindow *mainwindow, ComputerInfo *ci); +#define get_str(field_name,ptr) \ + if (g_str_has_prefix(tmp[0], field_name)) { \ + ptr = g_strdup(tmp[1]); \ + g_strfreev(tmp); \ + continue; \ + } +#define get_int(field_name,ptr) \ + if (g_str_has_prefix(tmp[0], field_name)) { \ + ptr = atoi(tmp[1]); \ + g_strfreev(tmp); \ + continue; \ + } +#define get_float(field_name,ptr) \ + if (g_str_has_prefix(tmp[0], field_name)) { \ + ptr = atof(tmp[1]); \ + g_strfreev(tmp); \ + continue; \ + } -#endif +#endif /* __COMPUTER_H__ */ @@ -19,44 +19,13 @@ # (yes, I did a copy&paste from the BSD license, eat me) # # --------------------------------------------------------------------------- -# Some defaults - -DISABLE_NLS=0 -IGNORE_LSPCI=0 - -# --------------------------------------------------------------------------- PACKAGE=`basename ${PWD} | cut -d"-" -f1`; VERSION=`basename ${PWD} | cut -d"-" -f2`; -echo "ToscoConf (version 0.04) for $PACKAGE version $VERSION" - -# --------------------------------------------------------------------------- -# Damn-cool command line argument parsing. Yay. - -while [ "$1" != "" ]; do - case $1 in - --disable-lspci) - echo "Disabling lspci" - IGNORE_LSPCI=1;; - --disable-nls) - echo "NLS disabled." - DISABLE_NLS=1 ;; - --help) - echo "" - echo " --disable-nls Don't use i18n." - echo " --disable-lspci Disable lspci." - echo "" - echo " --help This help screen." - - exit 1;; - *) - echo "Please use the --help switch." - exit 1;; - esac - shift -done +[ "$PACKAGE" == "$VERSION" ] && VERSION="SVN_$(date)" +echo "ToscoConf (version 0.04) for $PACKAGE version $VERSION" # --------------------------------------------------------------------------- @@ -74,21 +43,28 @@ esac PROC=`uname -m` case $PROC in i?86) + ln -sf linux/x86 arch/this ARCH="ARCH_i386" ;; ppc) + ln -sf linux/ppc arch/this ARCH="ARCH_PPC" ;; x86_64) + ln -sf linux/x86_64 arch/this ARCH="ARCH_x86_64" ;; mips) + ln -sf linux/mips arch/this ARCH="ARCH_MIPS" ;; parisc*) + ln -sf linux/parisc arch/this ARCH="ARCH_PARISC" ;; - ia64) - ARCH="ARCH_IA64" ;; + sparc*) + ln -sf linux/sparc arch/this + ARCH="ARCH_SPARC" ;; *) # uname -m on m68k doesn't return anything useful :/ - cat /proc/cpuinfo | grep "680?0" >/dev/null + grep "680?0" /proc/cpuinfo > /dev/null if [ "$?" == "0" ]; then + ln -sf linux/m68k arch/this ARCH="ARCH_m68k" else echo "Architeture \"$ARCH\" not supported." @@ -103,11 +79,10 @@ echo "$PROC ($ARCH)" # --------------------------------------------------------------------------- echo -n "Checking for lspci... " -LSPCIPATH="`which lspci` /sbin/lspci /usr/sbin/lspci /bin/lspci /usr/bin/lspci" +LSPCIPATH="/sbin/lspci /usr/sbin/lspci /bin/lspci /usr/bin/lspci `which lspci`" for i in $LSPCIPATH; do if [ -x "$i" ]; then - USE_LSPCI=1 - LSPCI=$i + LSPCI=$i break; fi done @@ -115,26 +90,14 @@ done if [ -e "$LSPCI" ]; then echo $LSPCI else - if [ -e "/proc/pci" ]; then - echo "not found, will parse /proc/pci" - else - echo "no lspci, no /proc/pci..." - echo "Are you sure you're running Linux?" - exit - fi -fi - -if [ "$IGNORE_LSPCI" -eq 1 ]; then - echo "Ignoring lspci (as requested)..." - LSPCI="" - USE_LSPCI=0 + echo "lspci cannot be found" + exit fi # --------------------------------------------------------------------------- - GTK2=-1 -MIN_VERSION="2.2.0" +MIN_VERSION="2.6.0" echo -n "Checking for GTK ${MIN_VERSION}... " for i in `which pkg-config`; do pkg-config --errors-to-stdout gtk+-2.0 \ @@ -150,9 +113,6 @@ for i in `which pkg-config`; do esac done -# If the user doesn't have GTK2, try to compile with GTK1.2 :) -# GTK 1.2 is no longer supported - # -------------------------------------------------------------------------- if [ $GTK2 -eq -1 ]; then @@ -172,31 +132,29 @@ echo -e "#ifndef __CONFIG_H__\n#define __CONFIG_H__\n" > config.h echo "#define VERSION \"$VERSION\"" >> config.h if [ "$LSPCI" ]; then - echo "#define USE_LSPCI" >> config.h echo "#define LSPCI \"$LSPCI -v\"" >> config.h fi -echo "#define GTK2" >> config.h - -if [ "$DISABLE_NLS" != "1" ]; then - echo "#define ENABLE_NLS" >> config.h -fi - echo "#define $ARCH" >> config.h echo "#define PLATFORM \"`uname`\"" >> config.h echo "#define KERNEL \"`uname -r`\"" >> config.h echo "#define HOSTNAME \"`hostname`\"" >> config.h +echo "#define PREFIX \"/usr/share/hardinfo/\"" >> config.h +echo "#define DEBUG 1" >> config.h + echo -e "\n#endif /* __CONFIG_H__ */" >> config.h echo "Writing Makefile..." rm -f Makefile -echo "TARGET = GTK2" > Makefile -echo "GTK_LIBS = ${GTK_LIBS}" >> Makefile +echo "GTK_LIBS = ${GTK_LIBS}" > Makefile echo "GTK_CFLAGS = ${GTK_FLAGS}" >> Makefile +echo "GLADE_LIBS = ${GLADE_LIBS}" >> Makefile +echo "GLADE_CFLAGS = ${GLADE_FLAGS}" >> Makefile echo "PACKAGE = `basename ${PWD}`" >> Makefile +echo "ARCHOPTS = " >> Makefile cat Makefile.in >> Makefile @@ -204,4 +162,3 @@ echo -e "\nDone. Type \"make\" to compile the program.\n" echo "If you get errors, probably you don't have the right libraries," echo "includes or utilities. However, if you're sure this is a bug in my" echo -e "code, please send a patch (use \"diff -u\") to <leandro@linuxmag.com.br>.\n" - diff --git a/configure-stamp b/configure-stamp deleted file mode 100644 index e69de29b..00000000 --- a/configure-stamp +++ /dev/null diff --git a/default.lang b/default.lang deleted file mode 100644 index 8c525152..00000000 --- a/default.lang +++ /dev/null @@ -1,148 +0,0 @@ -[Translation] -translated-by=Unknown - -[about.c] - -[computer.c] -Number=Number -Frequency=Frequency -Family=Family -Model=Model -Stepping=Stepping -Cache L2=Cache L2 -Bogomips=Bogomips -Features=Features -Unknown distribution=Unknown distribution -%d hour%s and %ld minute%s=%d hour%s and %ld minute%s -%d day%s, %d hour%s and %ld minute%s=%d day%s, %d hour%s and %ld minute%s -<b>Computer name:</b>=<b>Computer name:</b> -<b>Distribution:</b>=<b>Distribution:</b> -<b>Kernel:</b>=<b>Kernel:</b> -<b>Uptime:</b>=<b>Uptime:</b> -Updating...=Updating... -<b>%s</b> at %d MHz=<b>%s</b> at %d MHz -Family %d, model %d, stepping %d=Family %d, model %d, stepping %d -%d KB L2 cache=%d KB L2 cache - -[details.c] -Information=Information -No device selected.=No device selected. - -[hardinfo.c] -System information tool for GNU/Linux.\n=System information tool for GNU/Linux.\n -System Information=System Information -Computer=Computer -<b><big>Operating System</big></b>=<b><big>Operating System</big></b> -<b><big>Processor</big></b>=<b><big>Processor</big></b> -<b><big>Memory Usage</big></b>=<b><big>Memory Usage</big></b> -Details=Details -Environment=Environment -<b><big>X-Window System</big></b>=<b><big>X-Window System</big></b> -Network=Network -<b><big>Interfaces</big></b>=<b><big>Interfaces</big></b> -Scanning Devices=Scanning Devices -Scanning devices...=Scanning devices... -Scanning %s devices...=Scanning %s devices... -Processor=Processor -PCI Devices=PCI Devices -ISA PnP Devices=ISA PnP Devices -ATA/IDE Block Devices=ATA/IDE Block Devices -SCSI Devices=SCSI Devices -Video for Linux=Video for Linux -Communication Ports=Communication Ports -Parallel Ports=Parallel Ports -Kernel Modules=Kernel Modules -for more information.\n\n=for more information.\n\n - -[ide.c] -ATA/IDE %s Device=ATA/IDE %s Device -Cache (kb)=Cache (kb) -Physical geometry=Physical geometry -Logical geometry=Logical geometry - -[intl.c] - -[isapnp.c] -ISA Plug and Play Device=ISA Plug and Play Device -Card ID=Card ID -PnP version=PnP version -Product version=Product version - -[modules.c] -Author=Author -License=License -Depends on=Depends on - -[net.c] - -[parport.c] -N/A=N/A -Parallel Port=Parallel Port -Description=Description -Command set=Command set -Base I/O address=Base I/O address -Modes=Modes -Uses DMA=Uses DMA -Yes=Yes -No=No - -[pci.c] -0x%x to 0x%x=0x%x to 0x%x -I/O Address=I/O Address -%d%s=%d%s -Memory=Memory -%dMHz=%dMHz -Frequency=Frequency -Latency=Latency -Bus master=Bus master -Yes=Yes -No=No -Domain=Domain -Bus=Bus -Device=Device -Function=Function - -[scsi.c] -SCSI %s Device=SCSI %s Device -Revision=Revision -Type=Type -Controller=Controller -Channel=Channel -ID=ID -LUN=LUN - -[serial.c] -Serial Port (tty%d)=Serial Port (tty%d) -Communication Port=Communication Port -Communication Port=Communication Port -I/O port=I/O port -IRQ=IRQ - -[status.c] - -[stock.c] - -[usb.c] -USB Devices=USB Devices -Unknown device (%s)=Unknown device (%s) -USB Device=USB Device -Class=Class -Version=Version -Revision=Revision -Vendor ID=Vendor ID -Product ID=Product ID - -[v4l.c] -Device Information=Device Information -Type=Type - -[x11.c] -Local display (%s)=Local display (%s) -Remote display (%s)=Remote display (%s) -XFree86 version %s (protocol version %d.%d)=XFree86 version %s (protocol version %d.%d) -%d (protocol version %d.%d)=%d (protocol version %d.%d) -<b>Display:</b>=<b>Display:</b> -<b>Vendor:</b>=<b>Vendor:</b> -<b>Release:</b>=<b>Release:</b> -<b>Resolution:</b>=<b>Resolution:</b> - diff --git a/details.c b/details.c deleted file mode 100644 index 7c624366..00000000 --- a/details.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Hardware Information, version 0.3.2 - * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> - * - * May be modified and/or distributed under the terms of GNU GPL version 2. - * - */ - -#include "details.h" -#include "hardinfo.h" - -gboolean -detail_window_close(GtkWidget *widget, gpointer data) -{ - DetailWindow *dw = (DetailWindow *) data; - - gtk_widget_destroy(dw->window); - - return FALSE; -} - -void -detail_window_set_title(DetailWindow *dw, const gchar *title) -{ - if (!dw) return; - - gtk_window_set_title(GTK_WINDOW(dw->window), title); -} - -void -detail_window_update_names(DetailWindow *dw) -{ - gchar *buf; - - if (dw->device_name && strstr(dw->device_name, "&")) { - gchar *temp, *temp2; - - temp = (gchar *) malloc (strlen (dw->device_name) * 2); - - temp2 = temp; - - while (*(dw->device_name)) { - if (*(dw->device_name) == '&') { - *(temp++) = '&'; - *(temp++) = 'a'; - *(temp++) = 'm'; - *(temp++) = 'p'; - *(temp++) = ';'; - } else { - *(temp++) = *(dw->device_name); - } - dw->device_name++; - } - - *(temp++) = 0; - - temp = temp2; - - g_free(dw->device_name); - dw->device_name = g_strdup(temp); - - g_free(temp); - } - - if (!dw->device_type) - dw->device_type = ""; - - buf = g_strdup_printf("<big><b>%s</b></big>\n%s", - dw->device_name, dw->device_type); - - gtk_label_set_markup(GTK_LABEL(dw->name_label), buf); - - g_free(buf); -} - -void -detail_window_append_separator(DetailWindow *dw) -{ - GtkWidget *sep; - - sep = gtk_hseparator_new(); - gtk_widget_show(sep); - - gtk_table_attach_defaults(GTK_TABLE(dw->info_table), sep, 0, 2, dw->last_info, - dw->last_info + 1); - - dw->last_info++; -} - -void -detail_window_set_dev_type(DetailWindow *dw, const gchar *type) -{ - dw->device_type = g_strdup(type); - - detail_window_update_names(dw); -} - -void -detail_window_set_dev_name(DetailWindow *dw, const gchar *name) -{ - dw->device_name = g_strdup(name); - - detail_window_update_names(dw); -} - -void -detail_window_append_info_int(DetailWindow *dw, const gchar *name, gint val, - gboolean hex) -{ - gchar *buf; - - buf = g_strdup_printf(hex ? "0x%X" : "%d", val); - detail_window_append_info(dw, name, buf); - g_free(buf); -} - -void -detail_window_append_info(DetailWindow *dw, const gchar *name, gchar *val) -{ - GtkWidget *label; - gchar *buf; - - if (dw->last_info == 0) - dw->last_info = 1; - - buf = g_strdup_printf("<b>%s:</b>", name); - label = gtk_label_new(buf); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_table_attach_defaults(GTK_TABLE(dw->info_table), label, 0, 1, dw->last_info, - dw->last_info + 1); - g_free(buf); - - label = gtk_label_new(val); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_widget_show(label); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_label_set_selectable(GTK_LABEL(label), TRUE); - gtk_table_attach(GTK_TABLE(dw->info_table), label, 1, 2, dw->last_info, - dw->last_info + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - dw->last_info++; - -} - -static gboolean -notebook_hide_tabs(GtkWidget *widget, gpointer data) -{ - if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(widget)) == 1) { - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(widget), FALSE); - gtk_notebook_set_show_border(GTK_NOTEBOOK(widget), FALSE); - } else { - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(widget), TRUE); - gtk_notebook_set_show_border(GTK_NOTEBOOK(widget), TRUE); - } - - return FALSE; -} - -void -detail_window_set_icon(DetailWindow *dw, const gchar *path) -{ - if (!dw || !dw->icon) return; - - gtk_image_set_from_file(GTK_IMAGE(dw->icon), path); -} - -DetailWindow * -detail_window_new(void) -{ - DetailWindow *dw; - GtkWidget *window, *vbox, *btn, *hbbox, *notebook, *table, - *label, *info_table; - GtkWidget *icon, *vb, *hb; - - dw = g_new0(DetailWindow, 1); - - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_container_set_border_width(GTK_CONTAINER(window), 5); - gtk_window_set_title(GTK_WINDOW(window), "Hardware Details"); - gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_UTILITY); - gtk_window_set_resizable(GTK_WINDOW(window), FALSE); - gtk_widget_realize(window); - - dw->window = window; - - vbox = gtk_vbox_new(FALSE, 0); - gtk_widget_show(vbox); - gtk_container_add(GTK_CONTAINER(window), vbox); - - dw->vbox = vbox; - - notebook = gtk_notebook_new(); - gtk_widget_show(notebook); - gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE); - gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE); - dw->notebook = notebook; - - g_signal_connect(G_OBJECT(notebook), "expose-event", - G_CALLBACK(notebook_hide_tabs), notebook); - - table = gtk_table_new(1, 2, FALSE); - gtk_container_set_border_width(GTK_CONTAINER(table), 8); - gtk_table_set_row_spacings(GTK_TABLE(table), 4); - gtk_table_set_col_spacings(GTK_TABLE(table), 16); - gtk_widget_show(table); - - label = gtk_label_new(_("Information")); - gtk_widget_show(label); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, - label); - - hb = gtk_hbox_new(FALSE, 5); - gtk_widget_show(hb); - gtk_table_attach_defaults(GTK_TABLE(table), hb, 0, 1, 0, 1); - - icon = gtk_image_new(); - gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0); - gtk_widget_show(icon); - dw->icon = icon; - - gtk_table_attach_defaults(GTK_TABLE(table), icon, 0, 1, 0, 1); - - vb = gtk_vbox_new(FALSE, 5); - gtk_widget_show(vb); - gtk_box_pack_start(GTK_BOX(hb), vb, TRUE, TRUE, 0); - - label = gtk_label_new(_("No device selected.")); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1, - GTK_FILL | GTK_EXPAND, 0, 0, 0); - dw->name_label = label; - - info_table = gtk_table_new(0, 0, FALSE); - gtk_widget_show(info_table); - gtk_table_attach(GTK_TABLE(table), info_table, 1, 2, 2, 3, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - gtk_table_set_col_spacings(GTK_TABLE(info_table), 4); - gtk_table_set_row_spacings(GTK_TABLE(info_table), 2); - dw->info_table = info_table; - - hbbox = gtk_hbutton_box_new(); - gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4); - gtk_widget_show(hbbox); - gtk_box_pack_start(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0); - gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6); - gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END); - - btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE); - g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(detail_window_close), dw); - gtk_widget_show(btn); - gtk_box_pack_end(GTK_BOX(hbbox), btn, FALSE, FALSE, 0); - - detail_window_set_icon(dw, IMG_PREFIX "logo.png"); - - return dw; -} - -void -detail_window_show(GtkWidget *widget, gpointer data) -{ - MainWindow *mainwindow = (MainWindow *) data; - GenericDevice *dev; - - mainwindow->det_window = detail_window_new(); - - dev = (GenericDevice *) gtk_ctree_node_get_row_data - (GTK_CTREE(mainwindow->ctree), GTK_CLIST(mainwindow->ctree)-> - selection->data); - - hi_show_device_info_real(mainwindow, dev); - - gtk_window_set_modal(GTK_WINDOW(mainwindow->det_window->window), TRUE); - gtk_window_set_position(GTK_WINDOW(mainwindow->det_window->window), GTK_WIN_POS_CENTER_ON_PARENT); - gtk_window_set_transient_for(GTK_WINDOW(mainwindow->det_window->window), - GTK_WINDOW(mainwindow->window)); - gtk_widget_show(mainwindow->det_window->window); -} diff --git a/details.h b/details.h deleted file mode 100644 index e7512173..00000000 --- a/details.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __DETAILS_H__ -#define __DETAILS_H__ - -#include <gtk/gtk.h> -#include "config.h" - -typedef struct _DetailWindow DetailWindow; - -struct _DetailWindow { - GtkWidget *window; - GtkWidget *vbox; - GtkWidget *notebook; - GtkWidget *icon; - GtkWidget *name_label; - - gchar *device_name; - gchar *device_type; - gchar *manufacturer; - - GtkWidget *info_table; - gint last_info; -}; - -gboolean detail_window_close(GtkWidget *widget, gpointer data); -DetailWindow *detail_window_new(void); -void detail_window_set_icon(DetailWindow *dw, const gchar *path); -void detail_window_show(GtkWidget *widget, gpointer data); - -void detail_window_set_dev_name(DetailWindow *dw, const gchar *name); -void detail_window_set_dev_type(DetailWindow *dw, const gchar *type); -void detail_window_update_names(DetailWindow *dw); - -void detail_window_append_info(DetailWindow *dw, const gchar *name, - gchar *val); -void detail_window_append_info_int(DetailWindow *dw, const gchar *name, - gint val, gboolean hex); -void detail_window_append_separator(DetailWindow *dw); - - -#endif diff --git a/devices.c b/devices.c new file mode 100644 index 00000000..07946755 --- /dev/null +++ b/devices.c @@ -0,0 +1,193 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <gtk/gtk.h> +#include <config.h> +#include <string.h> + +#include <hardinfo.h> +#include <shell.h> +#include <iconcache.h> + +enum { + DEVICES_KERNEL_MODULES, + DEVICES_PCI, + DEVICES_USB, + DEVICES_PRINTERS, + DEVICES_INPUT, + DEVICES_STORAGE, +} Entries; + +static ModuleEntry hi_entries[] = { + {"Kernel Modules", "module.png"}, + {"PCI Devices", "devices.png"}, + {"USB Devices", "usb.png"}, + {"Printers", "printer.png"}, + {"Input Devices", "keyboard.png"}, + {"Storage", "hdd.png"}, +}; + +static GHashTable *devices = NULL; +static gchar *module_list = ""; +static gchar *printer_list = NULL; +static gchar *pci_list = ""; +static gchar *input_list = NULL; +static gchar *storage_list = ""; + +#define WALK_UNTIL(x) while((*buf != '\0') && (*buf != x)) buf++ + +#define GET_STR(field_name,ptr) \ + if (strstr(tmp[0], field_name)) { \ + ptr = g_markup_escape_text(g_strstrip(tmp[1]), strlen(tmp[1])); \ + g_strfreev(tmp); \ + continue; \ + } + +#include <arch/this/pci.h> +#include <arch/this/modules.h> +#include <arch/common/printers.h> +#include <arch/this/inputdevices.h> +#include <arch/this/usb.h> +#include <arch/this/storage.h> + +static void +detect_devices(void) +{ + devices = g_hash_table_new(g_str_hash, g_str_equal); + + shell_status_update("Getting loaded modules information..."); + scan_modules(); + + shell_status_update("Scanning PCI devices..."); + scan_pci(); + + shell_status_update("Searching for printers..."); + scan_printers(); + + shell_status_update("Scanning input devices..."); + scan_inputdevices(); + + shell_status_update("Scanning USB devices..."); + scan_usb(); + + shell_status_update("Scanning IDE devices..."); + scan_ide(); + + shell_status_update("Scanning SCSI devices..."); + scan_scsi(); +} + +gchar * +hi_more_info(gchar * entry) +{ + gchar *info = (gchar *) g_hash_table_lookup(devices, entry); + + if (info) + return g_strdup(info); + return g_strdup("[Empty]"); +} + +void +hi_reload(gint entry) +{ + switch (entry) { + case DEVICES_INPUT: + scan_inputdevices(); + break; + case DEVICES_PRINTERS: + scan_printers(); + break; + case DEVICES_USB: + scan_usb(); + break; + case DEVICES_STORAGE: + if (storage_list) { + g_free(storage_list); + g_free(storage_icons); + storage_list = g_strdup(""); + storage_icons = g_strdup(""); + } + scan_ide(); + scan_scsi(); + break; + } +} + +gchar * +hi_info(gint entry) +{ + if (!devices) { + detect_devices(); + } + + switch (entry) { + case DEVICES_KERNEL_MODULES: + return g_strdup_printf("[Loaded Modules]\n" + "%s" + "[$ShellParam$]\n" + "ViewType=1", + module_list); + case DEVICES_PCI: + return g_strdup_printf("[PCI Devices]\n" + "%s" + "[$ShellParam$]\n" + "ViewType=1\n", + pci_list); + case DEVICES_PRINTERS: + return g_strdup_printf("%s\n" + "[$ShellParam$]\n" + "ReloadInterval=5000", printer_list); + case DEVICES_STORAGE: + return g_strdup_printf("%s\n" + "[$ShellParam$]\n" + "ReloadInterval=5000\n" + "ViewType=1\n%s", storage_list, storage_icons); + case DEVICES_INPUT: + return g_strdup_printf("[Input Devices]\n" + "%s" + "[$ShellParam$]\n" + "ViewType=1\n" + "ReloadInterval=5000\n%s", input_list, input_icons); + case DEVICES_USB: + return g_strdup_printf("%s" + "[$ShellParam$]\n" + "ViewType=1\n" + "ReloadInterval=5000\n", + usb_list); + default: + return g_strdup("[Empty]\nNo info available="); + } +} + +gint +hi_n_entries(void) +{ + return G_N_ELEMENTS(hi_entries) - 1; +} + +GdkPixbuf * +hi_icon(gint entry) +{ + return icon_cache_get_pixbuf(hi_entries[entry].icon); +} + +gchar * +hi_name(gint entry) +{ + return hi_entries[entry].name; +} @@ -0,0 +1,242 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +/* + * This is only used to compute sensor values, hence the only variable supported is '@'. + * The '`' operator (ln(x)) is not available, nor multi-line formulas. + */ + +#include <glib.h> +#include <string.h> +#include <stdio.h> +#include <ctype.h> +#include <math.h> +#include <expr.h> + +static MathToken *new_operator(gchar op) +{ + MathToken *t = g_new0(MathToken, 1); + + t->val.op = op; + t->type = TOKEN_OPERATOR; /* operator */ + + return t; +} + +static MathToken *new_variable(gchar var) +{ + MathToken *t = g_new0(MathToken, 1); + + t->val.op = '@'; + t->type = TOKEN_VARIABLE; /* variable */ + + return t; +} + +static MathToken *new_value(gfloat value) +{ + MathToken *t = g_new0(MathToken, 1); + + t->val.value = value; + t->type = TOKEN_VALUE; /* value */ + + return t; +} + +static inline gint priority(char operation) +{ + switch (operation) { + case '^': + return 3; + case '*': + case '/': + return 2; + case '+': + case '-': + return 1; + case '(': + return 0; + } + + return 0; +} + +GSList *math_infix_to_postfix(GSList *infix) +{ + MathToken *stack[500]; + gint t_sp = 0; + + GSList *postfix = NULL, *p; + MathToken *top; + + for (p = infix; p; p = p->next) { + MathToken *t = (MathToken *) p->data; + + if (t->type == TOKEN_OPERATOR && t->val.op == '(') { + stack[++t_sp] = t; + } else if (t->type == TOKEN_OPERATOR && t->val.op == ')') { + for (top = stack[t_sp]; t_sp != 0 && top->val.op != '('; top = stack[t_sp]) + postfix = g_slist_append(postfix, stack[t_sp--]); + t_sp--; + } else if (t->type != TOKEN_OPERATOR) { + postfix = g_slist_append(postfix, t); + } else if (t_sp == 0) { + stack[++t_sp] = t; + } else { + while (t_sp != 0 && priority(t->val.op) <= priority(stack[t_sp]->val.op)) + postfix = g_slist_append(postfix, stack[t_sp--]); + stack[++t_sp] = t; + } + } + + while (t_sp) + postfix = g_slist_append(postfix, stack[t_sp--]); + + return postfix; +} + +static inline gfloat __result(gfloat op1, gfloat op2, gchar operation) +{ + switch (operation) { + case '^': + return powf(op1, op2); + case '+': + return op1 + op2; + case '-': + return op1 - op2; + case '/': + return op1 / op2; + case '*': + return op1 * op2; + } + + return 0; +} + +gfloat math_postfix_eval(GSList *postfix, gfloat at_value) +{ + GSList *p; + gfloat stack[500]; + gint sp = 0; + + memset(stack, 0, sizeof(gfloat) * 500); + + for (p = postfix; p; p = p->next) { + MathToken *t = (MathToken *) p->data; + + if (t->type == TOKEN_VARIABLE) { + stack[++sp] = at_value; + } else if (t->type == TOKEN_VALUE) { + stack[++sp] = t->val.value; + } else { + gfloat op1, op2; + + op2 = stack[sp--]; + op1 = stack[sp]; + + stack[sp] = __result(op1, op2, t->val.op); + } + } + + return stack[sp]; +} + +GSList *math_string_to_infix(gchar *string) +{ + GSList *infix = NULL; + gchar *expr = string; + + for (; *expr; expr++) { + if (strchr("+-/*^()", *expr)) { + infix = g_slist_append(infix, new_operator(*expr)); + } else if (strchr("@", *expr)) { + infix = g_slist_append(infix, new_variable(*expr)); + } else if (strchr("-.1234567890", *expr)) { + gfloat value; + + sscanf(expr, "%f", &value); + + while (*expr && strchr(".1234567890", *expr)) + expr++; + expr--; + + infix = g_slist_append(infix, new_value(value)); + } else if (!isspace(*expr)) { + g_print("Invalid token: [%c][%d]\n", *expr, *expr); + math_infix_free(infix, TRUE); + return NULL; + } + } + + return infix; +} + +void math_infix_free(GSList *infix, gboolean free_tokens) +{ + GSList *p; + + if (!free_tokens) + for (p = infix; p; p = g_slist_delete_link(p, p)); + else + for (p = infix; p; p = g_slist_delete_link(p, p)) { + MathToken *t = (MathToken *)p->data; + g_free(t); + } +} + +GSList *math_string_to_postfix(gchar *string) +{ + GSList *infix; + GSList *postfix; + + infix = math_string_to_infix(string); + if (!infix) + return NULL; + + postfix = math_infix_to_postfix(infix); + math_infix_free(infix, FALSE); + + return postfix; +} + +gfloat math_string_eval(gchar *string, gfloat at_value) +{ + GSList *postfix; + gfloat val; + + postfix = math_string_to_postfix(string); + val = math_postfix_eval(postfix, at_value); + math_postfix_free(postfix, TRUE); + + return val; +} + +#ifdef MATH_TEST +int main(void) +{ + GSList *postfix; + + gchar *expr = "0.9*(@+(5.2*0.923+3*(2.0)))"; + + postfix = math_string_to_postfix(expr); + g_print("%s = %f (must be 18.71964)\n", expr, + math_postfix_eval(postfix, 10)); + math_postfix_free(postfix, TRUE); + + return 0; +} +#endif @@ -0,0 +1,48 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __EXPR_H__ +#define __EXPR_H__ + +typedef struct _MathToken MathToken; + +typedef enum { + TOKEN_OPERATOR, + TOKEN_VARIABLE, + TOKEN_VALUE +} MathTokenType; + +struct _MathToken { + union { + gfloat value; + gchar op; + } val; + MathTokenType type; +}; + +#define math_postfix_free math_infix_free + +GSList *math_infix_to_postfix(GSList *infix); +void math_infix_free(GSList *infix, gboolean free_tokens); + +GSList *math_string_to_infix(gchar *string); +GSList *math_string_to_postfix(gchar *string); + +gfloat math_postfix_eval(GSList *postfix, gfloat at_value); +gfloat math_string_eval(gchar *string, gfloat at_value); + +#endif /* __EXPR_H__ */ diff --git a/genintl.pl b/genintl.pl deleted file mode 100755 index 0e19846c..00000000 --- a/genintl.pl +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/perl -# -# Script para gerar arquivo de internacionalização -# Versão 1.0 -# -# Copyright (c) 2002-2003 Leandro Pereira <leandro@linuxmag.com.br> -# Copyright (c) 2003 RadSys Software Ltda. -# Todos os direitos reservados. -# -# É permitida a distribuição e modificação deste, desde que os créditos -# estejam presentes e que exista uma notificação sobre as modificações -# feitas. -# Não há restrição de uso. -# - -print "Generating `default.lang' catalog...\n"; - -@list=`find *.c`; - -$maxsize=0; -foreach $i (0..$#list){ - $maxsize=length($list[$i]) if(length($list[$i]) > $maxsize); -} - -open(B, ">default.lang"); - -print B "[Translation]\n"; -print B "translated-by=Unknown\n\n"; - -$messages=0; - -foreach $k (0..$#list){ - $line=0; - $thismsg=0; - - $file=$list[$k]; - chomp($file); - print B "[$file]\n"; - print STDERR "Searching in `$file':"; - print STDERR " " x ($maxsize - length($file) + 2); - - open(A, $file); - while(<A>){ - $line++; - if(/_\(/){ - chomp; - $_=~s/\t//g; - $_=~s/_ \(/_\(/g; - - for($i=0; $i<=length($_); $i++){ - if(substr($_, $i, 1) eq "_" && - substr($_, $i+1, 1) eq "\("){ - for($j=$i+3; substr($_, $j, 1) ne "\""; $j++){ - print B substr($_, $j, 1); - } - print B "="; - for($j=$i+3; substr($_, $j, 1) ne "\""; $j++){ - print B substr($_, $j, 1); - } - print B "\n"; - - $messages++; - $thismsg++; - } - } - } - } - close(A); - print B "\n"; - if($thismsg){ - printf "%02d messages", $thismsg; - }else{ - print "Nothing"; - } - print " found.\n"; -} - -close(B); - -print "$messages messages saved in `default.lang'\n"; @@ -1,586 +1,37 @@ /* - * Hardware Information, version 0.3.2 - * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> * - * May be modified and/or distributed under the terms of GNU GPL version 2. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "hardinfo.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/stat.h> - -#include "pixmaps/pci.xpm" -#include "pixmaps/usb.xpm" -#include "pixmaps/hdd.xpm" -#include "pixmaps/gen_connector.xpm" -#include "pixmaps/scsi.xpm" -#include "pixmaps/processor.xpm" - -#include "computer.h" -#include "status.h" -#include "stock.h" - -GenericDevice *generic_devices = NULL; - -void hi_enable_details_button(GtkCTree * tree, GList * node, - gint column, gpointer user_data); -void hi_enable_details_button_real(MainWindow *mainwindow, GenericDevice *dev); -void hi_disable_details_button(GtkCTree * tree, GList * node, - gint column, gpointer user_data); -void hi_scan_all(MainWindow * mainwindow); - -void -main_window_refresh(GtkWidget * widget, gpointer data) -{ - MainWindow *mainwindow = (MainWindow *) data; - - if (!mainwindow) - return; - - hi_disable_details_button(NULL, NULL, 0, mainwindow); - - memory_update(mainwindow); - uptime_update(mainwindow); - net_update(mainwindow); - - hi_scan_all(mainwindow); -} - -static void -about_window_create(void) -{ - GtkAbout *about; - const gchar *sysinfo = HOSTNAME " (" PLATFORM KERNEL ")"; - const gchar *authors[] = { - ">Written by:", - "Leandro A. F. Pereira (leandro@linuxmag.com.br)", - ">Disclaimer:", - "This is free software; you can modify and/or distribute it", - "under the terms of GNU GPL version 2. See http://www.fsf.org/", - "for more information.", - ">Compiled on:", - sysinfo, - NULL - }; - - about = gtk_about_new("HardInfo", VERSION, - _("System information tool for GNU/Linux.\n"), - authors, IMG_PREFIX "logo.png"); - -} - -MainWindow * -main_window_create(void) -{ - GtkWidget *window, *mbox, *vbox, *ctree, *scroll; - GtkWidget *notebook, *label, *hbox, *btn, *hbbox; - MainWindow *mainwindow; - - mainwindow = g_new0(MainWindow, 1); - - mainwindow->det_window = detail_window_new(); - - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_container_set_border_width(GTK_CONTAINER(window), 4); - gtk_window_set_title(GTK_WINDOW(window), _("System Information")); - - g_signal_connect(G_OBJECT(window), "delete-event", gtk_main_quit, NULL); - gtk_window_set_icon_from_file(GTK_WINDOW(window), IMG_PREFIX "logo.png", NULL); - - mbox = gtk_vbox_new(FALSE, 5); - gtk_widget_show(mbox); - gtk_container_add(GTK_CONTAINER(window), mbox); - - notebook = gtk_notebook_new(); - gtk_box_pack_start(GTK_BOX(mbox), notebook, TRUE, TRUE, 0); - - /* - * Computer tab - */ - vbox = gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); - gtk_widget_show(vbox); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, - gtk_label_new(_("Computer"))); - - label = gtk_label_new(_("<b><big>Operating System</big></b>")); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), os_get_widget(mainwindow), - FALSE, FALSE, 0); - - label = gtk_label_new(_("<b><big>Processor</big></b>")); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), processor_get_widget(), FALSE, - FALSE, 0); - - label = gtk_label_new(_("<b><big>Memory Usage</big></b>")); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), memory_get_widget(mainwindow), - FALSE, FALSE, 0); - - /* - * Devices tab - */ - vbox = gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); - gtk_widget_show(vbox); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, - gtk_label_new(_("Details"))); - - hbbox = gtk_hbutton_box_new(); - gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4); - gtk_widget_show(hbbox); - gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0); - gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6); - gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END); - - btn = gtk_button_new_from_stock(HI_DETAILS); - g_signal_connect(G_OBJECT(btn), "clicked", - (GCallback) detail_window_show, mainwindow); - gtk_widget_show(btn); - gtk_box_pack_end(GTK_BOX(hbbox), btn, FALSE, FALSE, 0); - mainwindow->details_button = btn; - - scroll = gtk_scrolled_window_new(NULL, NULL); - gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - ctree = gtk_ctree_new(2, 0); - gtk_container_add(GTK_CONTAINER(scroll), ctree); - gtk_widget_set_usize(GTK_WIDGET(ctree), 400, 300); - gtk_ctree_set_expander_style(GTK_CTREE(ctree), - GTK_CTREE_EXPANDER_TRIANGLE); - gtk_ctree_set_line_style(GTK_CTREE(ctree), GTK_CTREE_LINES_NONE); - gtk_clist_set_column_width(GTK_CLIST(ctree), 0, 32); - gtk_clist_set_column_width(GTK_CLIST(ctree), 1, 32); - gtk_clist_set_row_height(GTK_CLIST(ctree), 18); - g_signal_connect(G_OBJECT(ctree), "tree-select-row", - (GCallback) hi_enable_details_button, mainwindow); - g_signal_connect(G_OBJECT(ctree), "tree-unselect-row", - (GCallback) hi_disable_details_button, mainwindow); - - /* - * Environment tab - */ - vbox = gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); - gtk_widget_show(vbox); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, - gtk_label_new(_("Environment"))); - - label = gtk_label_new(_("<b><big>X-Window System</big></b>")); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -// gtk_box_pack_start(GTK_BOX(vbox), x11_get_widget(mainwindow), -// FALSE, FALSE, 0); - - /* - * Network tab - */ - vbox = gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); - gtk_widget_show(vbox); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, - gtk_label_new(_("Network"))); - - label = gtk_label_new(_("<b><big>Interfaces</big></b>")); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), net_get_widget(mainwindow), - TRUE, TRUE, 0); - - /* - * Buttons - */ - hbox = gtk_hbox_new(FALSE, 5); - gtk_widget_show(hbox); - gtk_box_pack_start(GTK_BOX(mbox), hbox, FALSE, FALSE, 0); - - hbbox = gtk_hbutton_box_new(); - gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4); - gtk_widget_show(hbbox); - gtk_box_pack_start(GTK_BOX(hbox), hbbox, FALSE, FALSE, 0); - gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6); - gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_START); - - btn = gtk_button_new_from_stock(HI_ABOUT); - g_signal_connect(G_OBJECT(btn), "clicked", - (GCallback) about_window_create, NULL); - gtk_widget_show(btn); - gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0); - - hbbox = gtk_hbutton_box_new(); - gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4); - gtk_widget_show(hbbox); - gtk_box_pack_end(GTK_BOX(hbox), hbbox, FALSE, FALSE, 0); - gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6); - gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END); - - btn = gtk_button_new_from_stock(GTK_STOCK_REFRESH); - g_signal_connect(G_OBJECT(btn), "clicked", - (GCallback) main_window_refresh, mainwindow); - gtk_widget_show(btn); - gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0); - - btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE); - g_signal_connect(G_OBJECT(btn), "clicked", gtk_main_quit, NULL); - gtk_widget_show(btn); - gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0); - - gtk_widget_show_all(window); - - mainwindow->window = window; - mainwindow->ctree = ctree; - - return mainwindow; -} - -static GdkColor -gdk_color_from_rgb(gint r, gint g, gint b) -{ - GdkColormap *cmap = NULL; - GdkColor color; - - if (!cmap) { - cmap = gdk_colormap_get_system(); - gdk_colormap_ref(cmap); - } - - color.red = r * 255; - color.green = g * 255; - color.blue = b * 255; - - gdk_color_alloc(cmap, &color); - gdk_colormap_unref(cmap); - - return color; -} - -GtkCTreeNode * -tree_group_new(MainWindow * mainwindow, const gchar * name, DeviceType type) -{ - GtkCTreeNode *node; - const gchar *text[] = { NULL, name, NULL }; - GdkPixmap *pixmap = NULL; - GdkBitmap *mask = NULL; - GdkColor color; - GdkColormap *colormap = NULL; - - if (!name) - return NULL; - if (type == NONE) - return NULL; - if (!mainwindow) - return NULL; - - colormap = gtk_widget_get_colormap(mainwindow->window); - - switch (type) { - case PARPORT: - case SERIAL: - pixmap = gdk_pixmap_colormap_create_from_xpm_d - (NULL, colormap, &mask, NULL, gen_connector_xpm); - break; - case V4L: - case PCI: - case ISAPnP: - pixmap = gdk_pixmap_colormap_create_from_xpm_d - (NULL, colormap, &mask, NULL, pci_xpm); - break; - case SCSI: - pixmap = gdk_pixmap_colormap_create_from_xpm_d - (NULL, colormap, &mask, NULL, scsi_xpm); - break; - case IDE: - pixmap = gdk_pixmap_colormap_create_from_xpm_d - (NULL, colormap, &mask, NULL, hdd_xpm); - break; - case USB: - pixmap = gdk_pixmap_colormap_create_from_xpm_d - (NULL, colormap, &mask, NULL, usb_xpm); - break; - case MODULE: - case PROCESSOR: - pixmap = gdk_pixmap_colormap_create_from_xpm_d - (NULL, colormap, &mask, NULL, processor_xpm); - break; - default: - mask = pixmap = NULL; - break; - } - - node = gtk_ctree_insert_node(GTK_CTREE(mainwindow->ctree), - NULL, NULL, text, 0, pixmap, mask, pixmap, - mask, FALSE, TRUE); - - color = gdk_color_from_rgb(0xcc, 0xcc, 0xcc); - gtk_ctree_node_set_background(GTK_CTREE(mainwindow->ctree), - node, &color); - - gdk_pixmap_unref(pixmap); - gdk_bitmap_unref(mask); - - return node; -} - -void -tree_insert_item(MainWindow * mainwindow, GtkCTreeNode * group, gchar * name, - gpointer data) -{ - GtkCTreeNode *node; - gchar *text[] = { NULL, name, NULL }; - - if (!mainwindow) - return; - if (!name) - return; - if (!group) - return; - - node = gtk_ctree_insert_node(GTK_CTREE(mainwindow->ctree), - group, NULL, - text, 0, - NULL, NULL, NULL, NULL, FALSE, TRUE); - gtk_ctree_node_set_row_data(GTK_CTREE(mainwindow->ctree), node, data); -} - -void -hi_insert_generic(gpointer device, DeviceType type) -{ - GenericDevice *generic; - - generic = g_new0(GenericDevice, 1); - - generic->next = generic_devices; - generic_devices = generic; - - generic_devices->device = device; - generic_devices->type = type; -} - -void -hi_disable_details_button(GtkCTree * tree, GList * node, - gint column, gpointer user_data) -{ - MainWindow *mainwindow = (MainWindow *) user_data; - - gtk_widget_set_sensitive(GTK_WIDGET(mainwindow->details_button), FALSE); -} - -void hi_enable_details_button(GtkCTree * tree, GList * node, - gint column, gpointer user_data) -{ - MainWindow *mainwindow = (MainWindow *) user_data; - - gtk_widget_set_sensitive(GTK_WIDGET(mainwindow->details_button), TRUE); -} - -void hi_show_device_info_real(MainWindow *mainwindow, GenericDevice *dev) -{ - if (!dev) - return; - -#define dev_info(type,name,func) \ - { \ - type *name; \ - name = (type *)dev->device; \ - func(mainwindow, name); \ - } \ - break; - - switch (dev->type) { - case MODULE: - dev_info(ModInfo, mod, hi_show_module_info); - case PROCESSOR: - dev_info(CPUDevice, cpu, hi_show_cpu_info); - case PCI: - dev_info(PCIDevice, pci, hi_show_pci_info); - case ISAPnP: - dev_info(ISADevice, isa, hi_show_isa_info); - case USB: - dev_info(USBDevice, usb, hi_show_usb_info); - case SERIAL: - dev_info(SerialDevice, serial, hi_show_serial_info); - case PARPORT: - dev_info(ParportDevice, parport, hi_show_parport_info); - case IDE: - dev_info(IDEDevice, ide, hi_show_ide_info); - case SCSI: - dev_info(SCSIDevice, scsi, hi_show_scsi_info); - case V4L: - dev_info(V4LDevice, v4l, hi_show_v4l_info); - default: - g_print("Showing info of device type %d not implemented yet.\n", - dev->type); - return; - break; - } -} - -void -hi_scan_all(MainWindow * mainwindow) -{ - myStatus *status; - PCIDevice *pci; - ISADevice *isa; - IDEDevice *ide; - CPUDevice *cpu; - SCSIDevice *scsi; - V4LDevice *v4l; - ParportDevice *pp; - SerialDevice *sd; - GtkCTreeNode *node; - ModInfo *mod; - GenericDevice *gd = generic_devices; - gchar *buf; - - status = my_status_new(_("Scanning Devices"), _("Scanning devices...")); - -#define DEVICE_SCAN(name,ptr,func) \ - ptr = func(); \ - buf = g_strdup_printf(_("Scanning %s devices..."), name); \ - my_status_set_text(status, buf); \ - g_free(buf); \ - my_status_pulse(status) - - DEVICE_SCAN("CPU", cpu, computer_get_info); - DEVICE_SCAN("PCI", pci, hi_scan_pci); - DEVICE_SCAN("ISA PnP", isa, hi_scan_isapnp); - DEVICE_SCAN("IDE", ide, hi_scan_ide); - DEVICE_SCAN("SCSI", scsi, hi_scan_scsi); - DEVICE_SCAN("V4L", v4l, hi_scan_v4l); - DEVICE_SCAN("Parallel", pp, hi_scan_parport); - DEVICE_SCAN("Serial", sd, hi_scan_serial); - DEVICE_SCAN("modules", mod, hi_scan_modules); - - gtk_clist_freeze(GTK_CLIST(mainwindow->ctree)); - - /* - * Free the generic_devices stuff and remove all device-related - * nodes. - */ - if (gd != NULL) { - for (; gd != NULL; gd = gd->next) { - g_free(gd->device); - gtk_ctree_remove_node(GTK_CTREE(mainwindow->ctree), - gd->node); - g_free(gd); - } - generic_devices = NULL; - } - -#define CHECK_INSERT(a,b,c,d) \ - if (a) { \ - node = tree_group_new(mainwindow, b, c); \ - for (; a != NULL; a = a->next) { \ - if (a->d) { \ - hi_insert_generic(a, c); \ - tree_insert_item(mainwindow, node, a->d, \ - generic_devices); \ - } \ - } \ - } - - - /* - * Processor info - */ - node = tree_group_new(mainwindow, _("Processor"), PROCESSOR); - hi_insert_generic(cpu, PROCESSOR); - tree_insert_item(mainwindow, node, cpu->processor, generic_devices); +#include <config.h> +#include <shell.h> - CHECK_INSERT(pci, _("PCI Devices"), PCI, name); - CHECK_INSERT(isa, _("ISA PnP Devices"), ISAPnP, card); - - /* - * USB is different since it's Plug'n'Pray, so we have a - * routine just for it :) - */ - usb_update(mainwindow); - - CHECK_INSERT(ide, _("ATA/IDE Block Devices"), IDE, model); - CHECK_INSERT(scsi, _("SCSI Devices"), SCSI, model); - CHECK_INSERT(v4l, _("Video for Linux"), V4L, name); - CHECK_INSERT(sd, _("Communication Ports"), SERIAL, name); - CHECK_INSERT(pp, _("Parallel Ports"), PARPORT, name); - - CHECK_INSERT(mod, _("Kernel Modules"), MODULE, description); - - gtk_clist_thaw(GTK_CLIST(mainwindow->ctree)); - - my_status_destroy(status); -} - -static void -usage(char *argv0) -{ - g_print("%s [--help] [--prefix <prefix>]\n", argv0); - exit(1); -} +#include <iconcache.h> +#include <stock.h> int main(int argc, char **argv) { - MainWindow *mainwindow; - gint i; - -#ifdef ENABLE_NLS - intl_init(); -#endif - - g_print("HardInfo " VERSION); - if (strstr(VERSION, "pre")) { - g_print(" *** PRE-RELEASE ***"); - } - g_print - ("\nCopyright (c) 2003 Leandro Pereira <leandro@linuxmag.com.br>\n\n"); - g_print(_ - ("This is free software; you can modify and/or distribute it\n")); - g_print(_ - ("under the terms of GNU GPL version 2. See http://www.fsf.org/\n")); - g_print(_("for more information.\n\n")); - - gtk_init(&argc, &argv); - - hi_stock_init(); - - for (i = 1; i < argc; i++) { - if (!strncmp(argv[i], "--help", 6) || - !strncmp(argv[i], "-h", 2)) { - usage(argv[0]); - } else - if (!strncmp(argv[i], "--prefix", 8) || - !strncmp(argv[i], "-p", 2)) { - i++; - if (argv[i][0] == '-') - usage(argv[0]); - - g_print("prefix = %s\n", argv[i]); - } - } + gtk_init(&argc, &argv); - mainwindow = main_window_create(); - main_window_refresh(NULL, mainwindow); + icon_cache_init(); + stock_icons_init(); + shell_init(); - gtk_main(); + gtk_main(); - return 0; + return 0; } diff --git a/hardinfo.desktop b/hardinfo.desktop deleted file mode 100644 index 32895d6d..00000000 --- a/hardinfo.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Name=System Information (hardinfo) -Name[pt_BR]=Informações do Sistema (hardinfo) -Comment=Information on your hardware devices -Comment[pt_BR]=Informações sobre seus dispositivos de hardware -Exec=hardinfo -Icon=/usr/share/hardinfo/pixmaps/logo.png -Terminal=false -MultipleArgs=false -Type=Application -StartupNotify=true -Categories=Application;System @@ -1,91 +1,36 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + #ifndef __HARDINFO_H__ #define __HARDINFO_H__ -#define walk_until(x) while((*buf != '\0') && (*buf != x)) buf++ -#define walk_until_inclusive(x) walk_until(x); buf++ - -#define PREFIX "/usr/share/hardinfo/" -#define IMG_PREFIX PREFIX "pixmaps/" - #include <gtk/gtk.h> -#include <stdio.h> -#include <string.h> -#include <sys/stat.h> - -#include "config.h" -#include "stock.h" - -#ifdef ENABLE_NLS -#define INTL_PREFIX PREFIX "lang/" -#include "intl.h" -#else -#define _(x) (x) -#endif - -typedef struct _GenericDevice GenericDevice; -typedef enum _DeviceType DeviceType; -typedef struct _MainWindow MainWindow; - -enum _DeviceType { - NONE, PCI, ISAPnP, USB, - IDE, SCSI, SERIAL, PARPORT, - V4L, PROCESSOR, MODULE -}; - -struct _GenericDevice { - gpointer device; - DeviceType type; - - GtkCTreeNode *node; - - GenericDevice *next; -}; -#include "details.h" +typedef struct _ModuleEntry ModuleEntry; -struct _MainWindow { - GtkWidget *window; - - GtkWidget *ctree; - - GtkWidget *membar; - GtkWidget *uptime; - - GtkWidget *recv_bytes; - GtkWidget *recv_errors; - GtkWidget *recv_packets; - - GtkWidget *trans_bytes; - GtkWidget *trans_errors; - GtkWidget *trans_packets; - - GtkWidget *details_button; - DetailWindow *det_window; +struct _ModuleEntry { + gchar *name; + gchar *icon; }; -extern GenericDevice *generic_devices; - -#include "ide.h" -#include "scsi.h" -#include "isapnp.h" -#include "usb.h" -#include "pci.h" -#include "serial.h" -#include "parport.h" -#include "v4l.h" -#include "modules.h" -#include "x11.h" -#include "net.h" - -#include "about.h" -#include "details.h" - -GtkCTreeNode *tree_group_new(MainWindow *mainwindow, const gchar *name, - DeviceType type); -void tree_insert_item(MainWindow *mainwindow, GtkCTreeNode *group, gchar *name, - gpointer data); -void hi_insert_generic(gpointer device, DeviceType type); -void hi_show_device_info_real(MainWindow *mainwindow, - GenericDevice *dev); +inline void remove_quotes(gchar *str); +inline void strend(gchar *str, gchar chr); +inline void remove_linefeed(gchar *str); + void widget_set_cursor(GtkWidget *widget, GdkCursorType cursor_type); -#endif +#endif /* __HARDINFO_H__ */ diff --git a/iconcache.c b/iconcache.c new file mode 100644 index 00000000..5ef2bc3c --- /dev/null +++ b/iconcache.c @@ -0,0 +1,80 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include <iconcache.h> +#include <config.h> + +static GHashTable *cache = NULL; + +void icon_cache_init(void) +{ + if (!cache) { + cache = g_hash_table_new(g_str_hash, g_str_equal); + } +} + +GdkPixbuf *icon_cache_get_pixbuf(const gchar *file) +{ + GdkPixbuf *icon; + + icon = g_hash_table_lookup(cache, file); + + if (!icon) { + gchar *tmp = g_strdup_printf(PREFIX "pixmaps/%s", file); + + icon = gdk_pixbuf_new_from_file(tmp, NULL); + g_hash_table_insert(cache, g_strdup(file), icon); + + g_free(tmp); + } + + return icon; +} + +GtkWidget *icon_cache_get_image(const gchar *file) +{ + GdkPixbuf *icon; + + icon = icon_cache_get_pixbuf(file); + return gtk_image_new_from_pixbuf(icon); +} + +GdkPixbuf *icon_cache_get_pixbuf_at_size(const gchar *file, gint wid, gint hei) +{ + GdkPixbuf *icon; + + icon = g_hash_table_lookup(cache, file); + + if (!icon) { + gchar *tmp = g_strdup_printf(PREFIX "pixmaps/%s", file); + + icon = gdk_pixbuf_new_from_file_at_size(tmp, wid, hei, NULL); + g_hash_table_insert(cache, g_strdup(file), icon); + + g_free(tmp); + } + + return icon; +} + +GtkWidget *icon_cache_get_image_at_size(const gchar *file, gint wid, gint hei) +{ + GdkPixbuf *icon; + + icon = icon_cache_get_pixbuf_at_size(file, wid, hei); + return gtk_image_new_from_pixbuf(icon); +} diff --git a/iconcache.h b/iconcache.h new file mode 100644 index 00000000..e528b090 --- /dev/null +++ b/iconcache.h @@ -0,0 +1,30 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __ICONCACHE_H__ +#define __ICONCACHE_H__ + +#include <gtk/gtk.h> + +void icon_cache_init(void); +GdkPixbuf *icon_cache_get_pixbuf(const gchar *file); +GtkWidget *icon_cache_get_image(const gchar *file); +GdkPixbuf *icon_cache_get_pixbuf_at_size(const gchar *file, gint wid, gint hei); +GtkWidget *icon_cache_get_image_at_size(const gchar *file, gint wid, gint hei); + +#endif /* __ICONCACHE_H__ */ @@ -1,140 +0,0 @@ - -/* - * Hardware Information, version 0.3 - * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> - * - * May be modified and/or distributed under the terms of GNU GPL version 2. - * - */ - -#include "hardinfo.h" -#include "ide.h" - -#include <stdlib.h> - -IDEDevice *hi_scan_ide(void) -{ - FILE *proc_ide; - gchar *device, iface; - gint n = 0, i = 0; - struct stat st; - IDEDevice *ide_dev, *ide; - - ide = NULL; - - for (i=0; i<=16; i++) { - iface='a'+i; - device = g_strdup_printf("/proc/ide/hd%c/model", iface); - if (!stat(device, &st)) { - gchar buf[64]; - - ide_dev = g_new0(IDEDevice, 1); - ide_dev->next = ide; - ide = ide_dev; - - proc_ide = fopen(device, "r"); - fgets(buf, 64, proc_ide); - fclose(proc_ide); - - buf[strlen(buf)-1]=0; - - ide_dev->model = g_strdup(buf); - - g_free(device); - - device = g_strdup_printf("/proc/ide/hd%c/media", iface); - proc_ide = fopen(device, "r"); - fgets(buf, 64, proc_ide); - fclose(proc_ide); - buf[strlen(buf)-1]=0; - - ide_dev->media = g_strdup(buf); - - g_free(device); - - device = g_strdup_printf("/proc/ide/hd%c/cache", iface); - if (!stat(device, &st)) { - proc_ide = fopen(device, "r"); - fgets(buf, 64, proc_ide); - fclose(proc_ide); - - ide_dev->cache = atoi(buf); - } - g_free(device); - - device = g_strdup_printf("/proc/ide/hd%c/geometry", iface); - if (!stat(device, &st)) { - gchar *tmp; - - proc_ide = fopen(device, "r"); - - fgets(buf, 64, proc_ide); - for (tmp = buf; *tmp; tmp++) { - if (*tmp >= '0' && *tmp <= '9') break; - } - - ide_dev->phy_geometry = g_strdup(g_strstrip(tmp)); - - fgets(buf, 64, proc_ide); - for (tmp = buf; *tmp; tmp++) { - if (*tmp >= '0' && *tmp <= '9') break; - } - ide_dev->log_geometry = g_strdup(g_strstrip(tmp)); - - fclose(proc_ide); - } - g_free(device); - - n++; - } else - g_free(device); - } - - return ide; -} - -void hi_show_ide_info(MainWindow *mainwindow, IDEDevice *device) -{ - static struct { - char *type; - char *label; - char *icon; - } type2icon[] = { - {"cdrom", "CD-ROM", "cd.png"}, - {"disk", "Hard Disk", "hdd.png"} - }; - int i; - gchar *buf; - - if(!device) return; - - for (i = 0; type2icon[i].type != NULL; ++i) { - if (!strcmp(device->media, type2icon[i].type)) break; - } - - buf = g_strdup_printf("%s%s", IMG_PREFIX, type2icon[i].icon); - detail_window_set_icon(mainwindow->det_window, buf); - g_free(buf); - - buf = g_strdup_printf(_("ATA/IDE %s Device"), type2icon[i].label); - gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), buf); - detail_window_set_dev_type(mainwindow->det_window, buf); - g_free(buf); - - detail_window_set_dev_name(mainwindow->det_window, device->model); - - if (device->cache) { - detail_window_append_info_int(mainwindow->det_window, _("Cache (kb)"), - device->cache, FALSE); - } - - if (device->phy_geometry) { - detail_window_append_info(mainwindow->det_window, _("Physical geometry"), - device->phy_geometry); - } - if (device->log_geometry) { - detail_window_append_info(mainwindow->det_window, _("Logical geometry"), - device->log_geometry); - } - -} @@ -1,20 +0,0 @@ -#ifndef __IDE_H__ -#define __IDE_H__ - -typedef struct _IDEDevice IDEDevice; - -struct _IDEDevice { - gchar *model; - - gchar *media; - gchar *phy_geometry; - gchar *log_geometry; - gint cache; - - IDEDevice *next; -}; - -void hi_show_ide_info(MainWindow *mainwindow, IDEDevice *device); -IDEDevice *hi_scan_ide(void); - -#endif diff --git a/intl.c b/intl.c deleted file mode 100644 index 82ac163f..00000000 --- a/intl.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * ToscoIntl version 0.1 - * Copyright (c) 2002-2003 Leandro Pereira <leandro@linuxmag.com.br> - * All rights reserved. - * - * This script is in the Tosco Public License. It may be copied and/or - * modified, in whole or in part, provided that all copies and related - * documentation includes the above copyright notice, this condition - * and the following disclaimer. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * - * (yes, the disclaimer is a copy from the BSD license, eat me!) - */ - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <sys/stat.h> - -#include "hardinfo.h" - -#ifdef ENABLE_NLS - -void intl_init(void) -{ - const gchar *by; - - g_print("Translation module registered.\n"); - - by = intl_translate("translated-by", "Translation"); - if (strcmp(by, "translated-by")) { - g_print("Translated by: %s\n", by); - } -} - -/* - * GNU's gettext is cool and all... but hey, this is smaller, - * but slower :P - */ -const gchar * -intl_translate(const gchar * string, const gchar * source) __THROW -{ - FILE *file; - gchar buffer[256], *keyname, *lang = NULL, *langenv = NULL; - const gchar *retval, *langvars[] = - {"LANG", "LC_MESSAGES", "LC_ALL", NULL}; - gboolean found = FALSE; - struct stat st; - gint i = 0; - - keyname = g_strdup_printf("[%s]", source); - - for (; langvars[i]; i++) - if (getenv(langvars[i])) { - langenv = getenv(langvars[i]); - goto langenv_ok; - } - - goto not_found; - - langenv_ok: - lang = g_strconcat(INTL_PREFIX, langenv, ".lang", NULL); - if (stat(lang, &st)) { - g_free(lang); - lang = g_strconcat(INTL_PREFIX, "default.lang", NULL); - if (stat(lang, &st)) { - not_found: - retval = string; - goto finished; - } - } - - retval = string; - - file = fopen(lang, "r"); - if (!file) - goto finished; - - while (fgets(buffer, 256, file)) { - const gchar *buf = buffer; - - buf = g_strstrip(buf); - - if (*buf == '[' && !found && - !strncmp(buf, keyname, strlen(keyname))) - found = TRUE; - if (found && !strncmp(buf, string, strlen(string)) && - *(buf + strlen(string)) == '=') { - walk_until_inclusive('='); - retval = g_strdup(buf); - - fclose(file); - - goto finished; - } - } - fclose(file); - - finished: - g_free(keyname); - g_free(lang); - - return retval; -} - -#endif diff --git a/intl.h b/intl.h deleted file mode 100644 index 35684866..00000000 --- a/intl.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef __INTL_H__ -#define __INTL_H__ - -#include "config.h" - -void intl_init(void); -const gchar *intl_translate(const gchar *string, const gchar *source) __THROW; - -#define _(x) (intl_translate(x, __FILE__)) - -#endif /* __INTL_H__ */ diff --git a/isapnp.c b/isapnp.c deleted file mode 100644 index 6fc7c8b3..00000000 --- a/isapnp.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Hardware Information, version 0.3.1b - * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> - * - * May be modified and/or distributed under the terms of GNU GPL version 2. - * - */ - -#include "hardinfo.h" -#include "isapnp.h" - -ISADevice *hi_scan_isapnp(void) -{ - FILE *proc_isapnp; - gchar buffer[256], *buf; - gint n=0; - ISADevice *isa_dev, *isa; - struct stat st; - - isa = NULL; - - if(stat("/proc/isapnp", &st)) return NULL; - - proc_isapnp = fopen("/proc/isapnp", "r"); - while(fgets(buffer, 256, proc_isapnp)){ - buf = g_strstrip(buffer); - if(!strncmp(buf, "Card", 4)){ - gboolean lock = FALSE; - gfloat pnpversion, prodversion; - gint card_id; - gpointer start = NULL, end = NULL; - - sscanf(buf, "Card %d", &card_id); - - for (; buf != NULL; buf++) { - if (lock && *buf == '\'') { - end = buf; - break; - } else if (!lock && *buf == ':') { - start = buf+1; - lock = TRUE; - } - } - buf += 2; - - sscanf(buf, "PnP version %f Product version %f", &pnpversion, &prodversion); - - buf = end; - *buf=0; - buf = start; - - isa_dev = g_new0(ISADevice, 1); - - isa_dev->next = isa; - isa = isa_dev; - - isa_dev->pnpversion = pnpversion; - isa_dev->prodversion = prodversion; - isa_dev->card_id = card_id; - - isa_dev->card = g_strdup(buf); - - n++; - } - } - fclose(proc_isapnp); - - return isa; -} - -void hi_show_isa_info(MainWindow *mainwindow, ISADevice *device) -{ - gchar *buf; - - if(!device) return; - - gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("ISA Plug and Play Device")); - - detail_window_set_dev_name(mainwindow->det_window, device->card); - detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "pci.png"); - - detail_window_append_info_int(mainwindow->det_window, _("Card ID"), - device->card_id, FALSE); - buf = g_strdup_printf("%.2f", device->pnpversion); - detail_window_append_info(mainwindow->det_window, _("PnP version"), - buf); - g_free(buf); - - buf = g_strdup_printf("%.2f", device->prodversion); - detail_window_append_info(mainwindow->det_window, _("Product version"), - buf); - g_free(buf); -} - diff --git a/isapnp.h b/isapnp.h deleted file mode 100644 index e6e283c9..00000000 --- a/isapnp.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __ISAPnP_H__ -#define __ISAPnP_H__ - -#include "hardinfo.h" - -typedef struct _ISADevice ISADevice; - -struct _ISADevice { - gchar *card; - gint card_id; - gfloat pnpversion, prodversion; - - ISADevice *next; -}; - -ISADevice *hi_scan_isapnp(void); -void hi_show_isa_info(MainWindow *mainwindow, ISADevice *device); - - -#endif diff --git a/lang/es_CO.lang b/lang/es_CO.lang deleted file mode 120000 index 990137fc..00000000 --- a/lang/es_CO.lang +++ /dev/null @@ -1 +0,0 @@ -es_MX.ISO-8859-1.lang
\ No newline at end of file diff --git a/lang/es_DO.lang b/lang/es_DO.lang deleted file mode 120000 index 990137fc..00000000 --- a/lang/es_DO.lang +++ /dev/null @@ -1 +0,0 @@ -es_MX.ISO-8859-1.lang
\ No newline at end of file diff --git a/lang/es_ES.lang b/lang/es_ES.lang deleted file mode 120000 index 990137fc..00000000 --- a/lang/es_ES.lang +++ /dev/null @@ -1 +0,0 @@ -es_MX.ISO-8859-1.lang
\ No newline at end of file diff --git a/lang/es_GT.lang b/lang/es_GT.lang deleted file mode 120000 index 990137fc..00000000 --- a/lang/es_GT.lang +++ /dev/null @@ -1 +0,0 @@ -es_MX.ISO-8859-1.lang
\ No newline at end of file diff --git a/lang/es_MX.ISO-8859-1.lang b/lang/es_MX.ISO-8859-1.lang deleted file mode 100644 index 79511225..00000000 --- a/lang/es_MX.ISO-8859-1.lang +++ /dev/null @@ -1,117 +0,0 @@ -[Translation] -translated-by=Erica Andrews <PhrozenSmoke@yahoo.com> - -[computer.c] -Unknown distribution=Distribución desconocido -%d hour%s and %ld minute%s=%d hora%s y %ld minuto%s -%d day%s, %d hour%s and %ld minute%s=%d dia%s, %d hora%s y %ld minuto%s -<b>Computer name:</b>=<b>Nombre de computadora:</b> -Computer name:=Nombre de computadora: -<b>Distribution:</b>=<b>Distribución:</b> -Distribution:=Distribución: -<b>Kernel:</b>=<b>Kernel:</b> -Kernel:=Kernel: -<b>Uptime:</b>=<b>Uptime:</b> -Uptime:=Uptime: -Updating...=Atualizando... -<b>%s</b> at %d MHz (%d bogomips)=<b>%s</b> en %d MHz (%d bogomips) -%s at %d MHz (%d bogomips)=%s en %d MHz (%d bogomips) -Family %d, model %d, stepping %d=Familia %d, modelo %d, stepping %d -%d KB L2 cache=%d KB de caché L2 - -[hardinfo.c] -System Information=Información de Sistema -Computer=Computadora -<b><big>Operating System</big></b>=<b><big>Sistema Operativo</big></b> -Operating System=Sistema Operativo -<b><big>Processor</big></b>=<b><big>Procesador</big></b> -Processor=Procesador -<b><big>Memory Usage</big></b>=<b><big>Uso de Memoria</big></b> -Memory Usage=Uso de Memoria -Devices=Dispositivos -Device information=Información de Dispositivo -Refresh=Refrescar -Close=Cerrar -Environment=Ambiente -<b><big>X-Window System</big></b>=<b><big>X-Window System</big></b> -X-Window System=Sistema X-Window -PCI Devices=Dispositivos PCI -ISA PnP Devices=Dispositivos ISA PnP -ATA/IDE Block Devices=Dispositivos ATA/IDE -SCSI Devices=Dispositivos SCSI -Communication Ports=Puertos de Communicación -Parallel Ports=Puertos Paralelos -This is free software; you can modify and/or distribute it\n=Este programa es software libre; puede modficarlo o distribuirlo\n -under the terms of GNU GPL version 2. See http://www.fsf.org/\n=conforme a los termos de la licencia GNU GPL versión 2. Vea http://www.fsf.org/\n -for more information.\n\n=para más información.\n\n -Translation module registered.\n=Módulo de traducción registrado.\n - -[ide.c] -ATA/IDE %s Device=%s ATA/IDE -Cache: %d KB=Caché: %d KB - -[intl.c] - -[isapnp.c] -ISA Plug and Play Device=Dispositivo ISA Plug and Play -Card ID: %d=Identificación de tarjeta: %d -PnP version: %.2f, Product version: %.2f=Versión PnP: %.2f, versión de producto: %.2f - -[parport.c] -N/A=N/D -Printer=Impresora -Multimedia=Multimedia -Legacy Device=Dispositivo Legado -Parallel Port=Puerto paralelo -Description: %s=Descripción: %s -Command set: %s=Mandos: %s -Class: %s=Clase: %s -Base I/O address: 0x%x=Direccion I/O básico: 0x%x -Modes: %s=Modos: %s -Uses DMA=Uso acesso directo a memoria - -[pci.c] -I/O address: 0x%x to 0x%x=Direccion de I/O: desde 0x%x hasta 0x%x -Memory: %ld KB=Memoria: %ld KB -Frequency: %dMHz=Frecuencia: %dMHz -Latency: %d=Tiempo de Latencia: %d -Bus master=Bus master -Bus: %d, Device: %d, Function: %d=Bus: %d, Unidad: %d, Función: %d - -[scsi.c] -Disk=Disco -Tape=Cinta -Printer=Impresora -CD-ROM=CD-ROM -CD-ROM=CD-ROM -Scanner=Escáner -Generic=Genérico -SCSI %s Device=%s SCSI -Revision: %s=Revisión: %s -Type: %s=Tipo: %s -Controller: %d, Bus: %d, ID: %d, LUN: %d=Controlador: %d, Bus: %d, ID: %d, LUN: %d - -[serial.c] -Communication Port=Puerto de Communicación -I/O port: 0x%x, IRQ: %d=Puerto de I/O: 0x%x, IRQ: %d - -[usb.c] -USB Device=Dispositivo USB -Manufacturer: %s=Fabricante: %s -Class: %s (%d)=Clase: %s (%d) -Version: %.2f, Revision: %.2f=Versión: %.2f, Revisión: %.2f -Vendor ID: 0x%X, Product ID: 0x%X=Identificación de fabricante: 0x%X, producto: 0x%X -USB Devices=Dispositivos USB -Unknown device (%s)=Dispositivo desconocido (%s) - -[x11.c] -<b>Display:</b>=<b>Display:</b> -Display:=Display: -<b>Vendor:</b>=<b>Distribuidor:</b> -Vendor:=Distribuidor: -<b>Release:</b>=<b>Versión:</b> -Release:=Versión: -<b>Resolution:</b>=<b>Resolución:</b> -Resolution:=Resolución: -Local display (%s)=Pantalla local (%s) -Remote display (%s)=Pantalla remota (%s) diff --git a/lang/es_MX.lang b/lang/es_MX.lang deleted file mode 120000 index 990137fc..00000000 --- a/lang/es_MX.lang +++ /dev/null @@ -1 +0,0 @@ -es_MX.ISO-8859-1.lang
\ No newline at end of file diff --git a/lang/es_PR.lang b/lang/es_PR.lang deleted file mode 120000 index 990137fc..00000000 --- a/lang/es_PR.lang +++ /dev/null @@ -1 +0,0 @@ -es_MX.ISO-8859-1.lang
\ No newline at end of file diff --git a/lang/es_US.lang b/lang/es_US.lang deleted file mode 120000 index 990137fc..00000000 --- a/lang/es_US.lang +++ /dev/null @@ -1 +0,0 @@ -es_MX.ISO-8859-1.lang
\ No newline at end of file diff --git a/lang/pt_BR.lang b/lang/pt_BR.lang deleted file mode 100644 index 8d45505e..00000000 --- a/lang/pt_BR.lang +++ /dev/null @@ -1,117 +0,0 @@ -[Translation] -translated-by=Leandro Pereira <leandro@linuxmag.com.br> - -[computer.c] -Unknown distribution=Distribuição desconhecida -%d hour%s and %ld minute%s=%d hora%s e %ld minuto%s -%d day%s, %d hour%s and %ld minute%s=%d dia%s, %d hora%s e %ld minuto%s -<b>Computer name:</b>=<b>Nome do computador:</b> -Computer name:=Nome do computador: -<b>Distribution:</b>=<b>Distribuição:</b> -Distribution:=Distribuição: -<b>Kernel:</b>=<b>Kernel:</b> -Kernel:=Kernel: -<b>Uptime:</b>=<b>Uptime:</b> -Uptime:=Uptime: -Updating...=Atualizando... -<b>%s</b> at %d MHz (%d bogomips)=<b>%s</b> em %d MHz (%d bogomips) -%s at %d MHz (%d bogomips)=%s em %d MHz (%d bogomips) -Family %d, model %d, stepping %d=FamÃlia %d, modelo %d, stepping %d -%d KB L2 cache=%d KB de cache nÃvel 2 - -[hardinfo.c] -System Information=Informações do Sistema -Computer=Computador -<b><big>Operating System</big></b>=<b><big>Sistema Operacional</big></b> -Operating System=Sistema Operacional -<b><big>Processor</big></b>=<b><big>Processador</big></b> -Processor=Processador -<b><big>Memory Usage</big></b>=<b><big>Uso da Memória</big></b> -Memory Usage=Uso da Memória -Devices=Dipositivos -Device information=Informação do Dispositivo -Refresh=Atualizar -Close=Fechar -Environment=Ambiente -<b><big>X-Window System</big></b>=<b><big>X-Window System</big></b> -X-Window System=Sistema X-Window -PCI Devices=Dispositivos PCI -ISA PnP Devices=Dispositivos ISA PnP -ATA/IDE Block Devices=Dispositivos ATA/IDE -SCSI Devices=Dispositivos SCSI -Communication Ports=Portas de Comunicação -Parallel Ports=Portas Paralelas -This is free software; you can modify and/or distribute it\n=Este programa é software livre; você pode modificá-lo e/ou distribuÃ-lo\n -under the terms of GNU GPL version 2. See http://www.fsf.org/\n=sob os termos da GNU GPL versão 2. Veja http://www.fsf.org/\n -for more information.\n\n=para maiores informações.\n\n -Translation module registered.\n=Módulo de tradução registrado.\n - -[ide.c] -ATA/IDE %s Device=%s ATA/IDE -Cache: %d KB=Cache: %d KB - -[intl.c] - -[isapnp.c] -ISA Plug and Play Device=Dispositivo ISA Plug and Play -Card ID: %d=Identificação da placa: %d -PnP version: %.2f, Product version: %.2f=Versão PnP: %.2f, versão do produto: %.2f - -[parport.c] -N/A=N/D -Printer=Impressora -Multimedia=MultimÃdia -Legacy Device=Dispositivo Legado -Parallel Port=Porta paralela -Description: %s=Descrição: %s -Command set: %s=Comandos: %s -Class: %s=Classe: %s -Base I/O address: 0x%x=Endereço E/S base: 0x%x -Modes: %s=Modos: %s -Uses DMA=Usa acesso direto à memória - -[pci.c] -I/O address: 0x%x to 0x%x=Endereço de E/S: 0x%x até 0x%x -Memory: %ld KB=Memória: %ld KB -Frequency: %dMHz=Frequência: %dMHz -Latency: %d=Latência: %d -Bus master=Bus master -Bus: %d, Device: %d, Function: %d=Barramento: %d, Dispositivo: %d, Função: %d - -[scsi.c] -Disk=Disco -Tape=Fita -Printer=Impressora -CD-ROM=CD-ROM -CD-ROM=CD-ROM -Scanner=Scanner -Generic=Genérico -SCSI %s Device=%s SCSI -Revision: %s=Revisão: %s -Type: %s=Tipo: %s -Controller: %d, Bus: %d, ID: %d, LUN: %d=Controlador: %d, Barramento: %d, ID: %d, LUN: %d - -[serial.c] -Communication Port=Porta de Comunicação -I/O port: 0x%x, IRQ: %d=Porta de E/S: 0x%x, IRQ: %d - -[usb.c] -USB Device=Dispositivo USB -Manufacturer: %s=Fabricante: %s -Class: %s (%d)=Classe: %s (%d) -Version: %.2f, Revision: %.2f=Versão: %.2f, Revisão: %.2f -Vendor ID: 0x%X, Product ID: 0x%X=Identificação do fabricante: 0x%X, produto: 0x%X -USB Devices=Dispositivos USB -Unknown device (%s)=Dispositivo desconhecido (%s) - -[x11.c] -<b>Display:</b>=<b>Display:</b> -Display:=Display: -<b>Vendor:</b>=<b>Distribuidor:</b> -Vendor:=Distribuidor: -<b>Release:</b>=<b>Versão:</b> -Release:=Versão: -<b>Resolution:</b>=<b>Resolução:</b> -Resolution:=Resolução: -Local display (%s)=Display local (%s) -Remote display (%s)=Display remoto (%s) diff --git a/loadgraph.c b/loadgraph.c new file mode 100644 index 00000000..a15af347 --- /dev/null +++ b/loadgraph.c @@ -0,0 +1,266 @@ +/* + * Simple Load Graph + * Version 0.1 - Wed, Jan 11 2006 + * - initial release + * Version 0.1.1 - Fri, Jan 13 2006 + * - fixes autoscaling + * - add color + * + * Copyright (C) 2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * The Simple Load Graph is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License, version 2.1, as published by the Free Software Foundation. + * + * The Simple Load Graph is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the Simple Load Graph; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#include "loadgraph.h" + +static void _draw(LoadGraph *lg); + +LoadGraph *load_graph_new(gint size) +{ + LoadGraph *lg; + + lg = g_new0(LoadGraph, 1); + + lg->area = gtk_drawing_area_new(); + lg->size = size; + lg->data = g_new0(gint, size); + + lg->scale = 1.0; + + lg->width = size * 4; + lg->height = size * 2; + + gtk_widget_set_size_request(lg->area, lg->width, lg->height); + gtk_widget_show(lg->area); + + return lg; +} + +GtkWidget *load_graph_get_framed(LoadGraph *lg) +{ + GtkWidget *align, *frame; + + align = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_widget_show(align); + + frame = gtk_frame_new(NULL); + gtk_widget_show(frame); + gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); + + gtk_container_add(GTK_CONTAINER(align), frame); + gtk_container_add(GTK_CONTAINER(frame), lg->area); + + return align; +} + +void load_graph_clear(LoadGraph *lg) +{ + gint i; + + for (i = 0; i < lg->size; i++) + lg->data[i] = 0; + + lg->scale = 1.0; + _draw(lg); +} + +void load_graph_set_color(LoadGraph *lg, LoadGraphColor color) +{ + lg->color = color; + gdk_rgb_gc_set_foreground(lg->trace, lg->color); +} + +void load_graph_destroy(LoadGraph *lg) +{ + g_free(lg->data); + gtk_widget_destroy(lg->area); + gdk_pixmap_unref(lg->buf); + g_object_unref(lg->trace); + g_object_unref(lg->grid); + g_free(lg); +} + +static gboolean _expose(GtkWidget *widget, GdkEventExpose *event, + gpointer user_data) +{ + LoadGraph *lg = (LoadGraph *)user_data; + GdkDrawable *draw = GDK_DRAWABLE(lg->buf); + + gdk_draw_drawable(lg->area->window, + lg->area->style->white_gc, + draw, + 0, 0, + 0, 0, + lg->width, lg->height); + return FALSE; +} + +void load_graph_configure_expose(LoadGraph *lg) +{ + /* creates the backing store pixmap */ + gtk_widget_realize(lg->area); + lg->buf = gdk_pixmap_new(lg->area->window, lg->width, lg->height, -1); + + /* create the graphic contexts */ + lg->grid = gdk_gc_new(GDK_DRAWABLE(lg->buf)); + lg->trace = gdk_gc_new(GDK_DRAWABLE(lg->buf)); + + /* the default color is green */ + load_graph_set_color(lg, LG_COLOR_GREEN); + + /* init graphic contexts */ + gdk_gc_set_line_attributes(lg->grid, + 1, GDK_LINE_ON_OFF_DASH, + GDK_CAP_NOT_LAST, + GDK_JOIN_ROUND); + gdk_rgb_gc_set_foreground(lg->grid, 0x707070); + + gdk_gc_set_line_attributes(lg->trace, + 2, GDK_LINE_SOLID, + GDK_CAP_NOT_LAST, + GDK_JOIN_ROUND); + + /* configures the expose event */ + g_signal_connect(G_OBJECT(lg->area), "expose-event", + (GCallback) _expose, lg); +} + +static void +_draw(LoadGraph *lg) +{ + GdkDrawable *draw = GDK_DRAWABLE(lg->buf); + gint i, d; + + /* clears the drawing area */ + gdk_draw_rectangle(draw, lg->area->style->black_gc, + TRUE, 0, 0, lg->width, lg->height); + + /* horizontal bars; 25%, 50% and 75% */ + d = lg->height / 4; + gdk_draw_line(draw, lg->grid, 0, d, lg->width, d); + d = lg->height / 2; + gdk_draw_line(draw, lg->grid, 0, d, lg->width, d); + d = 3 * (lg->height / 4); + gdk_draw_line(draw, lg->grid, 0, d, lg->width, d); + + /* vertical bars */ + for (i = lg->width, d = 0; i > 1; i--, d++) + if ((d % 45) == 0 && d) + gdk_draw_line(draw, lg->grid, i, 0, i, lg->height); + + /* the graph */ + for (i = 0; i < lg->size; i++) { + gint this = lg->height - lg->data[i]; + gint next = lg->height - lg->data[i+1]; + + gdk_draw_line(draw, lg->trace, i * 4, this, i * 4 + 2, + (this + next) / 2); + gdk_draw_line(draw, lg->trace, i * 4 + 2, (this + next) / 2, + i * 4 + 4, next); + } + + gtk_widget_queue_draw(lg->area); +} + +static inline int +_max(LoadGraph *lg) +{ + gint i; + gint max = 0; + + for (i = 0; i < lg->size; i++) { + if (lg->data[i] > max) + max = lg->data[i]; + } + + return max; +} + +void +load_graph_update(LoadGraph *lg, gint value) +{ + gint i; + + if (value < 0) + return; + else if (value > _max(lg) && value > lg->height) { + /* FIXME: make scale work correctly :P */ + gfloat nscale = (gfloat)lg->height / ceilf((float)value * lg->scale); + + while (value * nscale > lg->height) { + nscale *= .90; + } + + if (nscale < lg->scale) { + lg->scale = nscale; + + for (i = 0; i < lg->size; i++) { + lg->data[i] = (int)((float)lg->data[i] * lg->scale); + } + } + } + + value = (int)ceilf((float)value * lg->scale); + + /* shift-right our data */ + for (i = 0; i < lg->size; i++) { + lg->data[i] = lg->data[i+1]; + } + + /* insert the updated value */ + lg->data[i] = value; + + /* redraw */ + _draw(lg); +} + +#ifdef LOADGRAPH_UNIT_TEST +gboolean lg_update(gpointer d) +{ + LoadGraph *lg = (LoadGraph *)d; + + int i = 0; + if ((rand() % 10) == 0) { + i = rand() % 1000 + 500; + } + + load_graph_update(lg, rand() % 200 + i); + + return TRUE; +} + +int main(int argc, char **argv) +{ + LoadGraph *lg; + GtkWidget *window; + + gtk_init(&argc, &argv); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_widget_show(window); + + lg = load_graph_new(100); + gtk_container_add(GTK_CONTAINER(window), lg->area); + load_graph_configure_expose(lg); + + lg_update(lg); + + g_timeout_add(100, lg_update, lg); + + gtk_main(); + + return 0; +} +#endif diff --git a/loadgraph.h b/loadgraph.h new file mode 100644 index 00000000..81bdcde4 --- /dev/null +++ b/loadgraph.h @@ -0,0 +1,61 @@ +/* + * Simple Load Graph + * Copyright (C) 2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * The Simple Load Graph is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License, version 2.1, as published by the Free Software Foundation. + * + * The Simple Load Graph is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the Simple Load Graph; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + + +#ifndef __LOADGRAPH_H__ +#define __LOADGRAPH_H__ + +#include <stdlib.h> +#include <gtk/gtk.h> +#include <math.h> + +typedef struct _LoadGraph LoadGraph; + +typedef enum { + LG_COLOR_GREEN = 0x4FB05A, + LG_COLOR_BLUE = 0x4F58B0, + LG_COLOR_RED = 0xB04F4F +} LoadGraphColor; + +struct _LoadGraph { + GdkPixmap *buf; + GtkWidget *area; + + GdkGC *grid; + GdkGC *trace; + + gint *data; + gfloat scale; + + gint size; + gint width, height; + LoadGraphColor color; + +}; + +LoadGraph *load_graph_new(gint size); +void load_graph_destroy(LoadGraph *lg); +void load_graph_configure_expose(LoadGraph *lg); +GtkWidget *load_graph_get_framed(LoadGraph *lg); + +void load_graph_update(LoadGraph *lg, gint value); +void load_graph_set_color(LoadGraph *lg, LoadGraphColor color); +void load_graph_clear(LoadGraph *lg); + +#endif /* __LOADGRAPH_H__ */ @@ -0,0 +1,318 @@ +/* + * This code implements the MD5 message-digest algorithm. + * The algorithm is due to Ron Rivest. This code was + * written by Colin Plumb in 1993, no copyright is claimed. + * This code is in the public domain; do with it what you wish. + * + * Equivalent code is available from RSA Data Security, Inc. + * This code has been tested against that, and is equivalent, + * except that you don't need to include two pages of legalese + * with every copy. + * + * To compute the message digest of a chunk of bytes, declare an + * MD5Context structure, pass it to MD5Init, call MD5Update as + * needed on buffers full of bytes, and then call MD5Final, which + * will fill a supplied 16-byte array with the digest. + */ + +/* This code was modified in 1997 by Jim Kingdon of Cyclic Software to + not require an integer type which is exactly 32 bits. This work + draws on the changes for the same purpose by Tatu Ylonen + <ylo@cs.hut.fi> as part of SSH, but since I didn't actually use + that code, there is no copyright issue. I hereby disclaim + copyright in any changes I have made; this code remains in the + public domain. */ + +#include <string.h> /* for memcpy() and memset() */ + +/* Add prototype support. */ +#ifndef PROTO +#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) +#define PROTO(ARGS) ARGS +#else +#define PROTO(ARGS) () +#endif +#endif + +#include "md5.h" + +#if defined(__OPTIMIZE__) +#error You must compile this program without "-O". (Or else the benchmark results may be different!) +#endif + +/* Little-endian byte-swapping routines. Note that these do not + depend on the size of datatypes such as uint32, nor do they require + us to detect the endianness of the machine we are running on. It + is possible they should be macros for speed, but I would be + surprised if they were a performance bottleneck for MD5. */ + +static uint32 getu32(addr) +const unsigned char *addr; +{ + return (((((unsigned long) addr[3] << 8) | addr[2]) << 8) + | addr[1]) << 8 | addr[0]; +} + +static void putu32(data, addr) +uint32 data; +unsigned char *addr; +{ + addr[0] = (unsigned char) data; + addr[1] = (unsigned char) (data >> 8); + addr[2] = (unsigned char) (data >> 16); + addr[3] = (unsigned char) (data >> 24); +} + +/* + * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious + * initialization constants. + */ +void MD5Init(ctx) +struct MD5Context *ctx; +{ + ctx->buf[0] = 0x67452301; + ctx->buf[1] = 0xefcdab89; + ctx->buf[2] = 0x98badcfe; + ctx->buf[3] = 0x10325476; + + ctx->bits[0] = 0; + ctx->bits[1] = 0; +} + +/* + * Update context to reflect the concatenation of another buffer full + * of bytes. + */ +void MD5Update(ctx, buf, len) +struct MD5Context *ctx; +unsigned char const *buf; +unsigned len; +{ + uint32 t; + + /* Update bitcount */ + + t = ctx->bits[0]; + if ((ctx->bits[0] = (t + ((uint32) len << 3)) & 0xffffffff) < t) + ctx->bits[1]++; /* Carry from low to high */ + ctx->bits[1] += len >> 29; + + t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ + + /* Handle any leading odd-sized chunks */ + + if (t) { + unsigned char *p = ctx->in + t; + + t = 64 - t; + if (len < t) { + memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + MD5Transform(ctx->buf, ctx->in); + buf += t; + len -= t; + } + + /* Process data in 64-byte chunks */ + + while (len >= 64) { + memcpy(ctx->in, buf, 64); + MD5Transform(ctx->buf, ctx->in); + buf += 64; + len -= 64; + } + + /* Handle any remaining bytes of data. */ + + memcpy(ctx->in, buf, len); +} + +/* + * Final wrapup - pad to 64-byte boundary with the bit pattern + * 1 0* (64-bit count of bits processed, MSB-first) + */ +void MD5Final(digest, ctx) +unsigned char digest[16]; +struct MD5Context *ctx; +{ + unsigned count; + unsigned char *p; + + /* Compute number of bytes mod 64 */ + count = (ctx->bits[0] >> 3) & 0x3F; + + /* Set the first char of padding to 0x80. This is safe since there is + always at least one byte free */ + p = ctx->in + count; + *p++ = 0x80; + + /* Bytes of padding needed to make 64 bytes */ + count = 64 - 1 - count; + + /* Pad out to 56 mod 64 */ + if (count < 8) { + /* Two lots of padding: Pad the first block to 64 bytes */ + memset(p, 0, count); + MD5Transform(ctx->buf, ctx->in); + + /* Now fill the next block with 56 bytes */ + memset(ctx->in, 0, 56); + } else { + /* Pad block to 56 bytes */ + memset(p, 0, count - 8); + } + + /* Append length in bits and transform */ + putu32(ctx->bits[0], ctx->in + 56); + putu32(ctx->bits[1], ctx->in + 60); + + MD5Transform(ctx->buf, ctx->in); + putu32(ctx->buf[0], digest); + putu32(ctx->buf[1], digest + 4); + putu32(ctx->buf[2], digest + 8); + putu32(ctx->buf[3], digest + 12); + memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ +} + +#ifndef ASM_MD5 + +/* The four core functions - F1 is optimized somewhat */ + +/* #define F1(x, y, z) (x & y | ~x & z) */ +#define F1(x, y, z) (z ^ (x & (y ^ z))) +#define F2(x, y, z) F1(z, x, y) +#define F3(x, y, z) (x ^ y ^ z) +#define F4(x, y, z) (y ^ (x | ~z)) + +/* This is the central step in the MD5 algorithm. */ +#define MD5STEP(f, w, x, y, z, data, s) \ + ( w += f(x, y, z) + data, w &= 0xffffffff, w = w<<s | w>>(32-s), w += x ) + +/* + * The core of the MD5 algorithm, this alters an existing MD5 hash to + * reflect the addition of 16 longwords of new data. MD5Update blocks + * the data and converts bytes into longwords for this routine. + */ +void MD5Transform(buf, inraw) +uint32 buf[4]; +const unsigned char inraw[64]; +{ + register uint32 a, b, c, d; + uint32 in[16]; + int i; + + for (i = 0; i < 16; ++i) + in[i] = getu32(inraw + 4 * i); + + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; + + MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); + MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); + MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); + MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); + MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); + MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); + MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); + MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); + + MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); + MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); + MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); + + MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); + MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); + MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); + + MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); + MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); + MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); + MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; +} +#endif + +#ifdef TEST +/* Simple test program. Can use it to manually run the tests from + RFC1321 for example. */ +#include <stdio.h> + +int main(int argc, char **argv) +{ + struct MD5Context context; + unsigned char checksum[16]; + int i; + int j; + + if (argc < 2) { + fprintf(stderr, "usage: %s string-to-hash\n", argv[0]); + exit(1); + } + for (j = 1; j < argc; ++j) { + printf("MD5 (\"%s\") = ", argv[j]); + MD5Init(&context); + MD5Update(&context, argv[j], strlen(argv[j])); + MD5Final(checksum, &context); + for (i = 0; i < 16; i++) { + printf("%02x", (unsigned int) checksum[i]); + } + printf("\n"); + } + return 0; +} +#endif /* TEST */ +
\ No newline at end of file @@ -0,0 +1,26 @@ +/* See md5.c for explanation and copyright information. */ + +#ifndef MD5_H +#define MD5_H + +/* Unlike previous versions of this code, uint32 need not be exactly + 32 bits, merely 32 bits or more. Choosing a data type which is 32 + bits instead of 64 is not important; speed is considerably more + important. ANSI guarantees that "unsigned long" will be big enough, + and always using it seems to have few disadvantages. */ +typedef unsigned long uint32; + +struct MD5Context { + uint32 buf[4]; + uint32 bits[2]; + unsigned char in[64]; +}; + +void MD5Init (struct MD5Context *context); +void MD5Update (struct MD5Context *context, + unsigned char const *buf, unsigned len); +void MD5Final (unsigned char digest[16], + struct MD5Context *context); +void MD5Transform (uint32 buf[4], const unsigned char in[64]); + +#endif /* !MD5_H */ @@ -0,0 +1,125 @@ +/* + * HardInfo + * Copyright(C) 2003-2006 Leandro A. F. Pereira. + * + * menu.c is based on UI Manager tutorial by Ryan McDougall + * Copyright(C) 2005 Ryan McDougall. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <gtk/gtk.h> +#include <menu.h> +#include <config.h> + +#include <stock.h> + +#include <callbacks.h> + +static GtkActionEntry entries[] = +{ + { "FileMenuAction", NULL, "_File" }, /* name, stock id, label */ + { "ViewMenuAction", NULL, "_View" }, + { "HelpMenuAction", NULL, "_Help" }, + { "MainMenuBarAction", NULL, "" }, + + { "ReportAction", HI_STOCK_REPORT, /* name, stock id */ + "Generate _Report", "<control>R", /* label, accelerator */ + "Creates a report in HTML", /* tooltip */ + G_CALLBACK(cb_generate_report) }, + + { "RefreshAction", GTK_STOCK_REFRESH, + "_Refresh", "F5", + NULL, + G_CALLBACK(cb_refresh) }, + + { "AboutAction", GTK_STOCK_ABOUT, + "_About\342\200\246", NULL, + "Displays program version information", + G_CALLBACK(cb_about) }, + + { "QuitAction", GTK_STOCK_QUIT, + "_Quit", "<control>Q", + NULL, + G_CALLBACK(cb_quit) } +}; + +static GtkToggleActionEntry toggle_entries[] = +{ + { "LeftPaneAction", NULL, + "_Left Pane", NULL, + "Toggles left pane visibility", + G_CALLBACK(cb_left_pane) }, + { "ToolbarAction", NULL, + "_Toolbar", NULL, + NULL, + G_CALLBACK(cb_toolbar) }, +}; + +/* Implement a handler for GtkUIManager's "add_widget" signal. The UI manager + * will emit this signal whenever it needs you to place a new widget it has. */ +static void +menu_add_widget(GtkUIManager *ui, GtkWidget *widget, GtkContainer *container) +{ + gtk_box_pack_start(GTK_BOX(container), widget, FALSE, FALSE, 0); + gtk_widget_show(widget); +} + +void menu_init(Shell *shell) +{ + GtkWidget *menu_box; /* Packing box for the menu and toolbars */ + GtkActionGroup *action_group; /* Packing group for our Actions */ + GtkUIManager *menu_manager; /* The magic widget! */ + GError *error; /* For reporting exceptions or errors */ + + /* Create our objects */ + menu_box = shell->vbox; + action_group = gtk_action_group_new("HardInfo"); + menu_manager = gtk_ui_manager_new(); + + shell->action_group = action_group; + shell->ui_manager = menu_manager; + + /* Pack up our objects: + * menu_box -> window + * actions -> action_group + * action_group -> menu_manager */ + gtk_action_group_add_actions(action_group, entries, G_N_ELEMENTS(entries), + NULL); + gtk_action_group_add_toggle_actions(action_group, toggle_entries, + G_N_ELEMENTS(toggle_entries), NULL); + gtk_ui_manager_insert_action_group(menu_manager, action_group, 0); + + /* Read in the UI from our XML file */ + error = NULL; + gtk_ui_manager_add_ui_from_file(menu_manager, PREFIX "uidefs.xml", &error); + + if (error) { + g_error("building menus failed: %s", error->message); + g_error_free(error); + } + + /* Connect up important signals */ + /* This signal is necessary in order to place widgets from the UI manager + * into the menu_box */ + g_signal_connect(menu_manager, "add_widget", + G_CALLBACK(menu_add_widget), + menu_box); + + /* Show the window and run the main loop, we're done! */ + gtk_widget_show(menu_box); + + gtk_toolbar_set_style(GTK_TOOLBAR(gtk_ui_manager_get_widget(shell->ui_manager, "/MainMenuBarAction")), + GTK_TOOLBAR_BOTH_HORIZ); +} @@ -0,0 +1,25 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __MENU_H__ +#define __MENU_H__ + +#include <shell.h> + +void menu_init(Shell *shell); + +#endif /* __MENU_H__ */ diff --git a/modules.c b/modules.c deleted file mode 100644 index ddee1def..00000000 --- a/modules.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Hardware Information, version 0.3 - * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> - * - * May be modified and/or distributed under the terms of GNU GPL version 2. - * - */ - -#include <gtk/gtk.h> - -#include "hardinfo.h" -#include "modules.h" - -void hi_show_module_info(MainWindow *mainwindow, ModInfo *device) -{ - if(!device) return; - - gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), device->description); - detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "module.png"); - detail_window_set_dev_name(mainwindow->det_window, device->name); - detail_window_set_dev_type(mainwindow->det_window, device->description); - - if (device->author && strlen(device->author)) { - detail_window_append_info(mainwindow->det_window, _("Author"), - device->author); - detail_window_append_separator(mainwindow->det_window); - } - - if (device->license && strlen(device->license)) - detail_window_append_info(mainwindow->det_window, _("License"), - device->license); - - if (device->depends &&strlen(device->depends)) - detail_window_append_info(mainwindow->det_window, _("Depends on"), - device->depends); - -} - -GtkWidget *module_get_widget(void) -{ -#if 0 - GtkWidget *vbox, *hbbox, *scroll, *clist, *btn; - - vbox = gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); - gtk_widget_show(vbox); - - hbbox = gtk_hbutton_box_new(); - gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4); - gtk_widget_show(hbbox); - gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0); - gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6); - gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END); - - btn = gtk_button_new_from_stock(HI_DETAILS); - g_signal_connect(G_OBJECT(btn), "clicked", - (GCallback) detail_window_show, mainwindow); - gtk_widget_show(btn); - gtk_box_pack_end(GTK_BOX(hbbox), btn, FALSE, FALSE, 0); - mainwindow->details_button = btn; - - scroll = gtk_scrolled_window_new(NULL, NULL); - gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - ctree = gtk_ctree_new(2, 0); - gtk_container_add(GTK_CONTAINER(scroll), ctree); - gtk_widget_set_usize(GTK_WIDGET(ctree), 400, 300); - gtk_ctree_set_expander_style(GTK_CTREE(ctree), - GTK_CTREE_EXPANDER_TRIANGLE); - gtk_ctree_set_line_style(GTK_CTREE(ctree), GTK_CTREE_LINES_NONE); - gtk_clist_set_column_width(GTK_CLIST(ctree), 0, 32); - gtk_clist_set_column_width(GTK_CLIST(ctree), 1, 32); - gtk_clist_set_row_height(GTK_CLIST(ctree), 18); - g_signal_connect(G_OBJECT(ctree), "tree-select-row", - (GCallback) hi_enable_details_button, mainwindow); - g_signal_connect(G_OBJECT(ctree), "tree-unselect-row", - (GCallback) hi_disable_details_button, mainwindow); - - - return vbox; -#endif - - return NULL; -} - -#define SET_VAR(vname,var) \ - if (!strncmp(buffer, vname, strlen(vname))) { \ - gchar *_b = buffer; \ - while (*_b && *_b != ':') _b++; _b++; \ - while (*_b && (*_b == ' ' || *_b == '\t')) _b++; \ - modinfo->var = g_strdup(g_strstrip(_b)); \ - } - -ModInfo *hi_scan_modules(void) -{ - FILE *lsmod; - gchar buffer[256]; - ModInfo *modinfo = NULL, *mod = NULL; - - lsmod = popen("/sbin/lsmod", "r"); - if(!lsmod) return NULL; - - fgets(buffer, 256, lsmod); /* Discards the first line */ - - while(fgets(buffer, 256, lsmod)){ - gchar *start, *buf; - FILE *modi; - - start = buf = buffer; - - walk_until_inclusive(' '); - *buf = 0; - - modinfo = g_new0(ModInfo, 1); - - modinfo->name = g_strdup(start); - - buf = g_strdup_printf("/sbin/modinfo %s", start); - modi = popen(buf, "r"); - while (fgets(buffer, 256, modi)) { - SET_VAR("author", author); - SET_VAR("description", description); - SET_VAR("license", license); - SET_VAR("depends", depends); - } - pclose(modi); - - modinfo->next = mod; - mod = modinfo; - } - pclose(lsmod); - - return mod; -} diff --git a/modules.conf b/modules.conf new file mode 100644 index 00000000..1dbaf07f --- /dev/null +++ b/modules.conf @@ -0,0 +1,7 @@ +[general] +version=2 + +[categories] +Computer=computer +Devices=devices +Benchmarks=benchmark diff --git a/modules.h b/modules.h deleted file mode 100644 index 046d4b94..00000000 --- a/modules.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __MODULES_H__ -#define __MODULES_H__ - -#include <gtk/gtk.h> - -typedef struct _ModInfo ModInfo; - -struct _ModInfo { - gchar *name; - gchar *author; - gchar *description; - gchar *license; - gchar *depends; - - ModInfo *next; -}; - -void hi_show_module_info(MainWindow *mainwindow, ModInfo *modinfo); -ModInfo *hi_scan_modules(void); - -#endif @@ -1,105 +0,0 @@ -/* - * Hardware Information, version 0.3 - * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> - * - * May be modified and/or distributed under the terms of GNU GPL version 2. - */ - -#include <stdio.h> -#include "config.h" -#include "hardinfo.h" -#include "net.h" - -gboolean net_update(gpointer data); - -GtkWidget *net_get_widget(MainWindow * mainwindow) -{ - return gtk_label_new("Not implemented yet."); -} - -gboolean net_update(gpointer data) -{ - MainWindow *mainwindow = (MainWindow *) data; - NetDevice *net; - static NetDevice *netold = NULL; - - if (!mainwindow) - return FALSE; - - net = hi_scan_net(); - - if (!net) - return FALSE; - - if (!netold) { - netold = net; - } else { - NetDevice *nd1, *nd2; - - for (nd1 = netold, nd2 = net; nd1 && nd2; - nd1 = nd1->next, nd2 = nd2->next) { - - g_print ("iface %s: %ld bytes/s up, %ld bytes/s down\n", - nd1->iface, - nd2->trans_bytes - nd1->trans_bytes, - nd2->recv_bytes - nd1->recv_bytes); - } - - netold = net; - } - - g_print("\n\n"); - - return TRUE; -} - -NetDevice *hi_scan_net(void) -{ - FILE *proc_net; - gchar buffer[256]; - NetDevice *net_dev, *net; - struct stat st; - - net = NULL; - - if (stat("/proc/net/dev", &st)) - return NULL; - - proc_net = fopen("/proc/net/dev", "r"); - while (fgets(buffer, 256, proc_net)) { - if (strchr(buffer, ':')) { - gint trash; - gchar ifacename[16]; - gchar *buf = buffer; - gint i; - - net_dev = g_new0(NetDevice, 1); - net_dev->next = net; - net = net_dev; - - buf = g_strstrip(buf); - - memset(ifacename, 0, 16); - - for (i = 0; buffer[i] != ':' && i < 16; i++) { - ifacename[i] = buffer[i]; - } - - walk_until_inclusive(':'); - - /* iface: bytes packets errs drop fifo frame compressed multicast */ - sscanf(buf, "%ld %ld %ld %d %d %d %d %d %ld %ld %ld", - &net_dev->recv_bytes, &net_dev->recv_packets, - &net_dev->recv_errors, &trash, &trash, &trash, &trash, - &trash, &net_dev->trans_bytes, &net_dev->trans_packets, - &net_dev->trans_errors); - - g_print("%ld\n", net_dev->recv_bytes); - - net_dev->iface = g_strdup(ifacename); - } - } - fclose(proc_net); - - return net; -} @@ -1,29 +0,0 @@ -#ifndef __NET_H__ -#define __NET_H__ - -#include "hardinfo.h" - -typedef struct _NetDevice NetDevice; - -struct _NetDevice { - gchar *iface; - - gulong recv_bytes; - gulong recv_errors; - gulong recv_packets; - - gulong trans_bytes; - gulong trans_errors; - gulong trans_packets; - - NetDevice *next; -}; - - -NetDevice *hi_scan_net(void); -GtkWidget *net_get_widget(MainWindow *mainwindow); -void hi_show_net_info(MainWindow *mainwindow, NetDevice *device); - -gboolean net_update(gpointer data); - -#endif diff --git a/parport.c b/parport.c deleted file mode 100644 index 3c64b87c..00000000 --- a/parport.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Hardware Information, version 0.3.1b - * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> - * - * May be modified and/or distributed under the terms of GNU GPL version 2. - * - * Tested only with 2.4.x kernels on ix86. - * USB support needs usbdevfs. - */ - -#include "hardinfo.h" -#include "parport.h" - -#define srch_def(str,len,var) \ - if (!strncmp(buffer, str, len)) { \ - walk_until_inclusive(':'); \ - parport_dev->var = g_strdup(buf); \ - } - -ParportDevice *hi_scan_parport(void) -{ - FILE *autoprobe; - struct stat st; - gint n=0, i; - ParportDevice *parport_dev, *parport; - - parport = NULL; - - for (i = 0; i <= 16; i++) { - gchar *file; - gchar buffer[128]; - gint port, dma; - - file = g_strdup_printf(PARPORT_PROC_BASE "parport%d", i); - - if (stat(file, &st)) { - g_free(file); - continue; - } - g_free(file); - - file = g_strdup_printf - (PARPORT_PROC_BASE "parport%d/autoprobe", i); - - parport_dev = g_new0(ParportDevice, 1); - parport_dev->next = parport; - parport = parport_dev; - - n++; - - parport_dev->number = i; - - autoprobe = fopen(file, "r"); - while (autoprobe && fgets(buffer, 128, autoprobe)) { - char *buf; - - buf = g_strstrip(buffer); - *(buf + strlen(buf) - 1) = 0; - - srch_def("CLASS:", 6, pclass); - srch_def("MODEL:", 6, model); - srch_def("MANUFA", 6, manufacturer); - srch_def("DESCRI", 6, description); - srch_def("COMMAN", 6, cmdset); - } - if(autoprobe) fclose(autoprobe); - - g_free(file); - - if (parport_dev->model) { - parport_dev->name = - g_strdup_printf("%s %s (lp%d)", - parport_dev->manufacturer, - parport_dev->model, i); - } else { - parport_dev->name = - g_strdup_printf ("Parallel port (lp%d)", i); - } - - file = g_strdup_printf - (PARPORT_PROC_BASE "parport%d/base-addr", i); - autoprobe = fopen(file, "r"); - if (autoprobe) { - fscanf(autoprobe, "%d", &port); - fclose(autoprobe); - - parport_dev->port = port; - } - g_free(file); - - file = g_strdup_printf - (PARPORT_PROC_BASE "parport%d/dma", i); - autoprobe = fopen(file, "r"); - if (autoprobe) { - fscanf(autoprobe, "%d", &dma); - fclose(autoprobe); - - parport_dev->dma = (dma == -1) ? FALSE : TRUE; - } - g_free(file); - - file = g_strdup_printf - (PARPORT_PROC_BASE "parport%d/modes", i); - autoprobe = fopen(file, "r"); - if (autoprobe) { - gchar modes[64]; - - fgets(modes, 64, autoprobe); - fclose(autoprobe); - - modes[strlen(modes)-1]=0; - parport_dev->modes = g_strdup(modes); - - } - if(!parport_dev->modes) - parport_dev->modes = g_strdup(_("N/A")); - - g_free(file); - } - - return parport; - -} - -void hi_show_parport_info(MainWindow *mainwindow, ParportDevice *device) -{ - gchar *buf; - static struct { - gchar *type, *label, *icon; - } type2icon[] = { - {"PRINTER", "Printer", "lpr.png" }, - {"MEDIA", "Multimedia", "media.png" }, - {NULL, "Legacy Device", "gen_connector.png"}, - }; - gint i; - - if(!device) return; - - if (device->pclass) { - for (i = 0; type2icon[i].type != NULL; ++i) - if(!strcmp(device->pclass, type2icon[i].type)) - break; - } else - i = sizeof(type2icon) / sizeof(type2icon[0]) - 1; - - - buf = g_strdup_printf("%s%s", IMG_PREFIX, type2icon[i].icon); - detail_window_set_icon(mainwindow->det_window, buf); - g_free(buf); - - gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("Parallel Port")); - - detail_window_set_dev_name(mainwindow->det_window, device->name); - detail_window_set_dev_type(mainwindow->det_window, type2icon[i].label); - - if (device->description) - detail_window_append_info(mainwindow->det_window, _("Description"), - device->description); - - if (device->cmdset) - detail_window_append_info(mainwindow->det_window, _("Command set"), - device->cmdset); - - detail_window_append_info_int(mainwindow->det_window, _("Base I/O address"), - device->port, TRUE); - detail_window_append_info(mainwindow->det_window, _("Modes"), - device->modes); - detail_window_append_info(mainwindow->det_window, _("Uses DMA"), - device->dma ? _("Yes") : _("No")); -} diff --git a/parport.h b/parport.h deleted file mode 100644 index 1461a909..00000000 --- a/parport.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __PARPORT_H__ -#define __PARPORT_H__ - -#include "hardinfo.h" - -#define PARPORT_PROC_BASE "/proc/sys/dev/parport/" - -typedef struct _ParportDevice ParportDevice; - -struct _ParportDevice { - gchar *name; - - gchar *cmdset; - gchar *model; - gchar *manufacturer; - gchar *description; - gchar *pclass; - - gint number, port; - gboolean dma; - - gchar *modes; - - ParportDevice *next; -}; - -ParportDevice *hi_scan_parport(void); -void hi_show_parport_info(MainWindow *mainwindow, ParportDevice *device); - -#endif @@ -1,274 +0,0 @@ -/* - * Hardware Information, version 0.3 - * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> - * - * May be modified and/or distributed under the terms of GNU GPL version 2. - * - */ - -#include "hardinfo.h" -#include "pci.h" - -void hi_show_pci_info(MainWindow *mainwindow, PCIDevice *device) -{ - gchar *buf; - - if(!device) return; - - gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), device->category); - detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "pci.png"); - detail_window_set_dev_name(mainwindow->det_window, device->name); - detail_window_set_dev_type(mainwindow->det_window, device->category); - - if (device->irq) - detail_window_append_info_int(mainwindow->det_window, "IRQ", - device->irq, FALSE); - - if(device->io_addr) { - buf = g_strdup_printf(_("0x%x to 0x%x"), device->io_addr, - device->io_addr_end); - - detail_window_append_info(mainwindow->det_window, - _("I/O Address"), buf); - g_free(buf); - } - - if(device->memory) { - buf = g_strdup_printf(_("%d%s"), - (device->memory <= 1024) ? device->memory : - device->memory / 1000, - (device->memory <= 1024) ? "bytes" : "KB"); - - detail_window_append_info(mainwindow->det_window, - _("Memory"), buf); - - g_free(buf); - } - - if(device->freq) { - buf = g_strdup_printf(_("%dMHz"), device->freq); - - detail_window_append_info(mainwindow->det_window, - _("Frequency"), buf); - - g_free(buf); - } - - if (device->latency) - detail_window_append_info_int(mainwindow->det_window, - _("Latency"), device->latency, - FALSE); - - detail_window_append_info(mainwindow->det_window, _("Bus master"), - (gchar*)((device->bus_master) ? _("Yes") : _("No"))); - - detail_window_append_separator(mainwindow->det_window); - - detail_window_append_info_int(mainwindow->det_window, _("Domain"), - device->domain, FALSE); - detail_window_append_info_int(mainwindow->det_window, _("Bus"), - device->bus, FALSE); - detail_window_append_info_int(mainwindow->det_window, _("Device"), - device->device, FALSE); - detail_window_append_info_int(mainwindow->det_window, _("Function"), - device->function, FALSE); -} - -#ifdef USE_LSPCI -PCIDevice *hi_scan_pci(void) -{ - FILE *lspci; - gchar buffer[256], *buf; - gint n=0; - PCIDevice *pci_dev = NULL, *pci; - - pci = NULL; - - lspci = popen(LSPCI, "r"); - if(!lspci) return NULL; - - while(fgets(buffer, 256, lspci)){ - buf = g_strstrip(buffer); - - if(!strncmp(buf, "Flags", 5)){ - gint irq=0, freq=0, latency=0, i; - gchar **list; - - buf+=7; - - pci_dev->bus_master = FALSE; - - list = g_strsplit(buf, ", ", 10); - for (i = 0; i <= 10; i++) { - if(!list[i]) break; - - if(!strncmp(list[i], "IRQ", 3)) - sscanf(list[i], "IRQ %d", &irq); - else if(strstr(list[i], "Mhz")) - sscanf(list[i], "%dMhz", &freq); - else if(!strncmp(list[i], "bus master", 10)) - pci_dev->bus_master = TRUE; - else if(!strncmp(list[i], "latency", 7)) - sscanf(list[i], "latency %d", &latency); - } - g_strfreev(list); - - if (irq) pci_dev->irq = irq; - if (freq) pci_dev->freq = freq; - if (latency) pci_dev->latency = latency; - } else if(!strncmp(buf, "Memory at", 9) && - strstr(buf, "[size=")) { - gulong mem; - gchar unit; - - walk_until('['); - sscanf(buf, "[size=%ld%c", &mem, &unit); - - mem *= (unit == ']') ? 1 : - (unit == 'K') ? 1024 : - (unit == 'M') ? 1024 * 1000 : - (unit == 'G') ? 1024 * 1000 * 1000 : 1; - - pci_dev->memory += mem; - - } else if(!strncmp(buf, "I/O", 3)){ - guint io_addr, io_size; - - sscanf(buf, "I/O ports at %x [size=%d]", &io_addr, &io_size); - - pci_dev->io_addr = io_addr; - pci_dev->io_addr_end = io_addr+io_size; - - } else if((buf[0] >= '0' && buf[0] <= '9') && buf[4] == ':'){ - gint bus, device, function, domain; - gpointer start, end; - - pci_dev = g_new0(PCIDevice, 1); - - pci_dev->next = pci; - pci = pci_dev; - - sscanf(buf, "%x:%x:%x.%d", &domain, &bus, &device, &function); - - pci_dev->domain = domain; - pci_dev->bus = bus; - pci_dev->device = device; - pci_dev->function = function; - - walk_until(' '); - - start = buf; - - walk_until(':'); - end = buf+1; - *buf=0; - - buf = start+1; - pci_dev->category = g_strdup(buf); - - buf = end; - start = buf; - walk_until('('); - *buf = 0; - buf = start+1; - - pci_dev->name = g_strdup(buf); - - n++; - } - } - pclose(lspci); - - return pci; -} - -#else - -#warning Using /proc/pci is deprecated, please install pciutils! - -PCIDevice *hi_scan_pci(void) -{ - FILE *proc_pci; - gchar buffer[256], *buf; - gboolean next_is_name = FALSE; - gint n=0; - PCIDevice *pci_dev, *pci; - struct stat st; - - g_print("Scanning PCI devices... "); - - pci = NULL; - - if(stat("/proc/pci", &st)) return NULL; - - proc_pci = fopen("/proc/pci", "r"); - while(fgets(buffer, 256, proc_pci)){ - buf = g_strstrip(buffer); - if(next_is_name == TRUE) { - gpointer start, end; - - start = buf; - - walk_until(':'); - end = buf+1; - *buf=0; - - buf = start; - pci_dev->category = g_strdup(buf); - - buf = end; - buf[strlen(buf)-1]=0; - pci_dev->name = g_strdup(buf); - - next_is_name = FALSE; - } else if(!strncmp(buf, "IRQ", 3)){ - gint irq; - - sscanf(buf, "IRQ %d", &irq); - - pci_dev->irq = irq; - } else if(!strncmp(buf, "Prefetchable 32 bit", 19) || - !strncmp(buf, "Non-prefetchable 32 bit", 23)){ - gulong mem_st, mem_end; - - if(*buf == 'N') buf+=4; - buf++; - - sscanf(buf, "refetchable 32 bit memory at %lx [%lx]", - &mem_st, &mem_end); - - pci_dev->memory+=(mem_end-mem_st)/1024; - } else if(!strncmp(buf, "I/O", 3)){ - guint io_addr, io_addr_end; - - sscanf(buf, "I/O at %x [%x]", &io_addr, &io_addr_end); - - pci_dev->io_addr = io_addr; - pci_dev->io_addr_end = io_addr_end; - } else if(!strncmp(buf, "Bus", 3)){ - gint bus, device, function; - - pci_dev = g_new0(PCIDevice, 1); - - pci_dev->next = pci; - pci = pci_dev; - - sscanf(buf, "Bus %d, device %d, function %d:", - &bus, &device, &function); - - pci_dev->bus = bus; - pci_dev->device = device; - pci_dev->function = function; - - next_is_name = TRUE; - n++; - } - } - fclose(proc_pci); - - g_print ("%d devices found\n", n); - - return pci; -} -#endif - @@ -1,32 +0,0 @@ -#ifndef __PCI_H__ -#define __PCI_H__ - -typedef struct _PCIDevice PCIDevice; - -struct _PCIDevice { - gchar *name; - gchar *category; - - gint irq; - guint io_addr; - guint io_addr_end; - - gulong memory; - - gint domain; - gint bus; - gint device; - gint function; - - gint latency; - gint freq; - - gboolean bus_master; - - PCIDevice *next; -}; - -void hi_show_pci_info(MainWindow *mainwindow, PCIDevice *device); -PCIDevice *hi_scan_pci(void); - -#endif diff --git a/pixmaps/2computer.png b/pixmaps/2computer.png Binary files differnew file mode 100644 index 00000000..46f29204 --- /dev/null +++ b/pixmaps/2computer.png diff --git a/pixmaps/athlon.png b/pixmaps/athlon.png Binary files differnew file mode 100644 index 00000000..81a1b314 --- /dev/null +++ b/pixmaps/athlon.png diff --git a/pixmaps/audio.png b/pixmaps/audio.png Binary files differnew file mode 100644 index 00000000..45096651 --- /dev/null +++ b/pixmaps/audio.png diff --git a/pixmaps/benchmark.png b/pixmaps/benchmark.png Binary files differnew file mode 100644 index 00000000..1be159b7 --- /dev/null +++ b/pixmaps/benchmark.png diff --git a/pixmaps/blowfish.png b/pixmaps/blowfish.png Binary files differnew file mode 100644 index 00000000..22c68614 --- /dev/null +++ b/pixmaps/blowfish.png diff --git a/pixmaps/cd.png b/pixmaps/cd.png Binary files differdeleted file mode 100644 index c4c7806d..00000000 --- a/pixmaps/cd.png +++ /dev/null diff --git a/pixmaps/cdrom.png b/pixmaps/cdrom.png Binary files differnew file mode 100644 index 00000000..eb65bcbb --- /dev/null +++ b/pixmaps/cdrom.png diff --git a/pixmaps/compress.png b/pixmaps/compress.png Binary files differnew file mode 100644 index 00000000..e5dee194 --- /dev/null +++ b/pixmaps/compress.png diff --git a/pixmaps/computer.png b/pixmaps/computer.png Binary files differnew file mode 100644 index 00000000..f0de0386 --- /dev/null +++ b/pixmaps/computer.png diff --git a/pixmaps/cpu.png b/pixmaps/cpu.png Binary files differdeleted file mode 100755 index da4f71d2..00000000 --- a/pixmaps/cpu.png +++ /dev/null diff --git a/pixmaps/dev_removable.png b/pixmaps/dev_removable.png Binary files differnew file mode 100644 index 00000000..2453d8dc --- /dev/null +++ b/pixmaps/dev_removable.png diff --git a/pixmaps/devices.png b/pixmaps/devices.png Binary files differnew file mode 100644 index 00000000..0ad1400b --- /dev/null +++ b/pixmaps/devices.png diff --git a/pixmaps/distro/cnc.png b/pixmaps/distro/cnc.png Binary files differdeleted file mode 100755 index 3967c237..00000000 --- a/pixmaps/distro/cnc.png +++ /dev/null diff --git a/pixmaps/distro/deb.png b/pixmaps/distro/deb.png Binary files differdeleted file mode 100755 index 0ced3130..00000000 --- a/pixmaps/distro/deb.png +++ /dev/null diff --git a/pixmaps/distro/gnt.png b/pixmaps/distro/gnt.png Binary files differdeleted file mode 100755 index bf4290a9..00000000 --- a/pixmaps/distro/gnt.png +++ /dev/null diff --git a/pixmaps/distro/mdk.png b/pixmaps/distro/mdk.png Binary files differdeleted file mode 100755 index a997ea10..00000000 --- a/pixmaps/distro/mdk.png +++ /dev/null diff --git a/pixmaps/distro/rh.png b/pixmaps/distro/rh.png Binary files differdeleted file mode 100755 index f612354b..00000000 --- a/pixmaps/distro/rh.png +++ /dev/null diff --git a/pixmaps/distro/slk.png b/pixmaps/distro/slk.png Binary files differdeleted file mode 100755 index fd6d3365..00000000 --- a/pixmaps/distro/slk.png +++ /dev/null diff --git a/pixmaps/distro/suse.png b/pixmaps/distro/suse.png Binary files differdeleted file mode 100755 index 0c7759a1..00000000 --- a/pixmaps/distro/suse.png +++ /dev/null diff --git a/pixmaps/distro/tl.png b/pixmaps/distro/tl.png Binary files differdeleted file mode 100755 index 353bddd2..00000000 --- a/pixmaps/distro/tl.png +++ /dev/null diff --git a/pixmaps/distro/unk.png b/pixmaps/distro/unk.png Binary files differdeleted file mode 100755 index ed850e40..00000000 --- a/pixmaps/distro/unk.png +++ /dev/null diff --git a/pixmaps/distro/yd.png b/pixmaps/distro/yd.png Binary files differdeleted file mode 100755 index bde8c6ba..00000000 --- a/pixmaps/distro/yd.png +++ /dev/null diff --git a/pixmaps/distro/yellow-dog.gif b/pixmaps/distro/yellow-dog.gif Binary files differdeleted file mode 100755 index cf143ce1..00000000 --- a/pixmaps/distro/yellow-dog.gif +++ /dev/null diff --git a/pixmaps/gen_connector.png b/pixmaps/gen_connector.png Binary files differdeleted file mode 100755 index 477e55ff..00000000 --- a/pixmaps/gen_connector.png +++ /dev/null diff --git a/pixmaps/gen_connector.xpm b/pixmaps/gen_connector.xpm deleted file mode 100755 index 28aa0382..00000000 --- a/pixmaps/gen_connector.xpm +++ /dev/null @@ -1,46 +0,0 @@ -/* XPM */ -static char * gen_connector_xpm[] = { -"16 16 27 1", -" c None", -". c #000000", -"+ c #F0F0F0", -"@ c #FFFFFF", -"# c #EEEEEE", -"$ c #EBEBEB", -"% c #E4E4E4", -"& c #C5C5C5", -"* c #C9C9C9", -"= c #D2D2D2", -"- c #BABABA", -"; c #A1A1A1", -"> c #F7F7F7", -", c #EDEDED", -"' c #B8B8B8", -") c #8C8C8C", -"! c #989898", -"~ c #ADADAD", -"{ c #7B7B7B", -"] c #BDBDBD", -"^ c #D0D0D0", -"/ c #CECECE", -"( c #DBDBDB", -"_ c #DFDFDF", -": c #464646", -"< c #DDDDDD", -"[ c #7E7E7E", -" ", -" ........... ", -" .+@#$%%%%&. ", -" . .*@=*----;. .", -" ............. ", -" .>,,,,,,,,,'. ", -" .,)!!!!!!!~{. ", -" .,;-------*{. ", -" .,]^^^^^^/({. ", -" ._{{{{{{{{{:. ", -" ...{{{{{... ", -" .<-[. ", -" ..-.. ", -" .-. ", -" .-. ", -" .-. "}; diff --git a/pixmaps/gnome-dev-removable-usb.png b/pixmaps/gnome-dev-removable-usb.png Binary files differnew file mode 100644 index 00000000..fb83bab2 --- /dev/null +++ b/pixmaps/gnome-dev-removable-usb.png diff --git a/pixmaps/gnome-devel.png b/pixmaps/gnome-devel.png Binary files differnew file mode 100644 index 00000000..4c63e7dd --- /dev/null +++ b/pixmaps/gnome-devel.png diff --git a/pixmaps/gnome-terminal.png b/pixmaps/gnome-terminal.png Binary files differnew file mode 100644 index 00000000..2fe2d14d --- /dev/null +++ b/pixmaps/gnome-terminal.png diff --git a/pixmaps/gnome-window-manager.png b/pixmaps/gnome-window-manager.png Binary files differnew file mode 100644 index 00000000..d5f0d3d9 --- /dev/null +++ b/pixmaps/gnome-window-manager.png diff --git a/pixmaps/graphics.png b/pixmaps/graphics.png Binary files differnew file mode 100644 index 00000000..a70492c1 --- /dev/null +++ b/pixmaps/graphics.png diff --git a/pixmaps/hdd.png b/pixmaps/hdd.png Binary files differindex e02487eb..bbcdc825 100644 --- a/pixmaps/hdd.png +++ b/pixmaps/hdd.png diff --git a/pixmaps/hdd.xpm b/pixmaps/hdd.xpm deleted file mode 100755 index 7f1d54f7..00000000 --- a/pixmaps/hdd.xpm +++ /dev/null @@ -1,138 +0,0 @@ -/* XPM */ -static char * hdd_xpm[] = { -"16 16 119 2", -" c None", -". c #5A5A5A", -"+ c #626262", -"@ c #363636", -"# c #434343", -"$ c #686868", -"% c #6E6356", -"& c #A87B4A", -"* c #EBCAA5", -"= c #E3B88A", -"- c #AA9277", -"; c #7C746C", -"> c #877159", -", c #B06F28", -"' c #C58C4D", -") c #EDCCA9", -"! c #EBC7A1", -"~ c #F2D8BC", -"{ c #EBD0B2", -"] c #8A7E71", -"^ c #5D5852", -"/ c #C79055", -"( c #BC7F3E", -"_ c #C28544", -": c #B28C64", -"< c #CCA276", -"[ c #EFD3B6", -"} c #EFD3B5", -"| c #B79672", -"1 c #666666", -"2 c #5D5D5D", -"3 c #745A3F", -"4 c #E5BD92", -"5 c #E4BA8E", -"6 c #70471D", -"7 c #83684A", -"8 c #84582B", -"9 c #C79967", -"0 c #E8C096", -"a c #E8C196", -"b c #423426", -"c c #565656", -"d c #272624", -"e c #796045", -"f c #F0D4B7", -"g c #EBCBA9", -"h c #7A4F22", -"i c #A67F56", -"j c #513416", -"k c #986E42", -"l c #EAC6A1", -"m c #ECCAA6", -"n c #352615", -"o c #6B6A6A", -"p c #6A6A6A", -"q c #7A7A7A", -"r c #797877", -"s c #938A80", -"t c #B2A89E", -"u c #A39A8F", -"v c #7F6E5B", -"w c #7A5734", -"x c #744F28", -"y c #B27532", -"z c #CE975A", -"A c #B38350", -"B c #494745", -"C c #606060", -"D c #747474", -"E c #858585", -"F c #656463", -"G c #767575", -"H c #514F4C", -"I c #776C5F", -"J c #BFB0A0", -"K c #F0D4B6", -"L c #EECEAB", -"M c #DAAC79", -"N c #B37736", -"O c #AF6E28", -"P c #715E4B", -"Q c #282828", -"R c #474747", -"S c #A5A5A5", -"T c #797979", -"U c #171310", -"V c #15110D", -"W c #2A2015", -"X c #B89C7D", -"Y c #EDCCA8", -"Z c #F0D1AF", -"` c #E0B78C", -" . c #B97E3F", -".. c #78624A", -"+. c #616161", -"@. c #4D4D4D", -"#. c #A4A4A4", -"$. c #767473", -"%. c #261A0E", -"&. c #5C4D3D", -"*. c #55412B", -"=. c #4F4C4C", -"-. c #4B4B4B", -";. c #A2A2A2", -">. c #474542", -",. c #5F5F5F", -"'. c #262626", -"). c #A7A7A7", -"!. c #474441", -"~. c #5C5C5C", -"{. c #252525", -"]. c #4E4E4E", -"^. c #AAAAAA", -"/. c #8D8D8D", -"(. c #5B5B5B", -"_. c #4F4F4F", -":. c #999999", -"<. c #777777", -"[. c #242424", -" . + ", -" . @ # $ ", -" % & * = - ; ", -" > , ' ) ! ~ { ] ", -" ^ / ( _ : < [ } | 1 ", -" 2 3 4 5 6 7 8 9 0 a b $ ", -" c d e f g h i j k l m n o ", -" p q r s t u v w x y z A B C ", -"D E F G H I J K L M N O P C Q ", -"R S T U V W X Y Z ` ...+.Q ", -" @.#.$.V V V %.&.*.=.C Q ", -" -.;.$.V V V V >.,.'. ", -" @.).$.U V !.~.{. ", -" ].^./.1 (.{. ", -" _.:.<.[. ", -" "}; diff --git a/pixmaps/joystick.png b/pixmaps/joystick.png Binary files differnew file mode 100644 index 00000000..954cca4b --- /dev/null +++ b/pixmaps/joystick.png diff --git a/pixmaps/kblayout.png b/pixmaps/kblayout.png Binary files differnew file mode 100644 index 00000000..b99e27d1 --- /dev/null +++ b/pixmaps/kblayout.png diff --git a/pixmaps/keyboard.png b/pixmaps/keyboard.png Binary files differnew file mode 100644 index 00000000..a716f07e --- /dev/null +++ b/pixmaps/keyboard.png diff --git a/pixmaps/language.png b/pixmaps/language.png Binary files differnew file mode 100644 index 00000000..ab82b50f --- /dev/null +++ b/pixmaps/language.png diff --git a/pixmaps/logo.png b/pixmaps/logo.png Binary files differindex d2dee31e..d2dee31e 100755..100644 --- a/pixmaps/logo.png +++ b/pixmaps/logo.png diff --git a/pixmaps/logo.xpm b/pixmaps/logo.xpm deleted file mode 100644 index 18701670..00000000 --- a/pixmaps/logo.xpm +++ /dev/null @@ -1,349 +0,0 @@ -/* XPM */ -static char * logo_xpm[] = { -"32 32 314 2", -" c None", -". c #F3F3F3", -"+ c #F2F2F2", -"@ c #F1F1F1", -"# c #F0F0F0", -"$ c #EFEFEF", -"% c #EEEEEE", -"& c #ECECEC", -"* c #EAEAEA", -"= c #E8E8E8", -"- c #E7E7E7", -"; c #E3E3E3", -"> c #AEAEAE", -", c #F4F4F4", -"' c #DCDCDC", -") c #D8D8D8", -"! c #D6D6D6", -"~ c #D5D5D5", -"{ c #D3D3D3", -"] c #D1D1D1", -"^ c #D0D0D0", -"/ c #CFCFCF", -"( c #CECECE", -"_ c #CCCCCC", -": c #CBCBCB", -"< c #CDCDCD", -"[ c #626262", -"} c #898989", -"| c #383838", -"1 c #373737", -"2 c #363636", -"3 c #353535", -"4 c #343434", -"5 c #424242", -"6 c #E2E2E2", -"7 c #D9D9D9", -"8 c #3F3F3F", -"9 c #6E6E6E", -"0 c #888682", -"a c #E2E2DF", -"b c #EDEAE6", -"c c #DFDED9", -"d c #C9CAC7", -"e c #BFC0BD", -"f c #C4C1BA", -"g c #C1BCB2", -"h c #B8B4AA", -"i c #ABA69C", -"j c #919089", -"k c #7D7C76", -"l c #282724", -"m c #E5E5E5", -"n c #D7D7D7", -"o c #9A9793", -"p c #EEF0F1", -"q c #FFFFFF", -"r c #EDEDEC", -"s c #D8DADA", -"t c #D0D2D2", -"u c #CAC7C1", -"v c #C1BDB3", -"w c #AAA49B", -"x c #797E7F", -"y c #89846E", -"z c #2C2B27", -"A c #E4E4E4", -"B c #6D6D6D", -"C c #96948F", -"D c #F7F6F5", -"E c #FAF9F8", -"F c #EEECEA", -"G c #EBE9E6", -"H c #E7E5E1", -"I c #D0CDC5", -"J c #C0BCB2", -"K c #B8B3A9", -"L c #A8A399", -"M c #9D9685", -"N c #8C7D76", -"O c #2B2926", -"P c #EBEBEB", -"Q c #6C6C6C", -"R c #908E89", -"S c #F3F2F0", -"T c #F4F2F1", -"U c #ECEAE7", -"V c #E9E7E4", -"W c #E6E3DF", -"X c #CECBC4", -"Y c #BEBAB0", -"Z c #B7B2A8", -"` c #A6A197", -" . c #937162", -".. c #8B6863", -"+. c #2A2826", -"@. c #D2D2D2", -"#. c #464C52", -"$. c #49525D", -"%. c #3F4954", -"&. c #3E4852", -"*. c #4D545B", -"=. c #8E8F90", -"-. c #C8C8C6", -";. c #E5E3DF", -">. c #E5E2DF", -",. c #E2DFDB", -"'. c #CAC7BE", -"). c #BAB5AC", -"!. c #B3ADA4", -"~. c #A39E94", -"{. c #928E84", -"]. c #928E86", -"^. c #2A2825", -"/. c #E1E1E1", -"(. c #6F7A86", -"_. c #8397AB", -":. c #7D96B2", -"<. c #7B95B1", -"[. c #758CA7", -"}. c #637282", -"|. c #5B5F63", -"1. c #BAB9B6", -"2. c #D8D6D3", -"3. c #DAD8D3", -"4. c #C3BFB7", -"5. c #B3AEA4", -"6. c #ACA79D", -"7. c #9D988E", -"8. c #8F8A80", -"9. c #908B84", -"0. c #292724", -"a. c #E0E0E0", -"b. c #41464D", -"c. c #7D8A98", -"d. c #8199B4", -"e. c #7590AE", -"f. c #849CB7", -"g. c #A3B5C9", -"h. c #94A9C0", -"i. c #7892AF", -"j. c #778BA1", -"k. c #585D60", -"l. c #A6A4A1", -"m. c #C7C4C0", -"n. c #B3AFA7", -"o. c #A5A097", -"p. c #9E998F", -"q. c #928D83", -"r. c #858077", -"s. c #8A867F", -"t. c #272623", -"u. c #DFDFDF", -"v. c #606A75", -"w. c #8097B1", -"x. c #D1DAE4", -"y. c #627182", -"z. c #676868", -"A. c #B4B2AF", -"B. c #AFABA5", -"C. c #A6A29A", -"D. c #A09C94", -"E. c #97938B", -"F. c #908C85", -"G. c #8D8A83", -"H. c #272522", -"I. c #DEDEDE", -"J. c #C9C9C9", -"K. c #222528", -"L. c #7C8EA2", -"M. c #7892B0", -"N. c #B2C1D2", -"O. c #6B84A0", -"P. c #394048", -"Q. c #54514C", -"R. c #5D5A55", -"S. c #5C5A54", -"T. c #5A5852", -"U. c #54514B", -"V. c #4F4C47", -"W. c #474540", -"X. c #151413", -"Y. c #C6C6C6", -"Z. c #33373C", -"`. c #889FB8", -" + c #708AA7", -".+ c #3D4752", -"++ c #838383", -"@+ c #989898", -"#+ c #9C9C9C", -"$+ c #9B9B9B", -"%+ c #C4C4C4", -"&+ c #393F44", -"*+ c #89A0BA", -"=+ c #E0E6ED", -"-+ c #718BA8", -";+ c #35404B", -">+ c #B0B0B0", -",+ c #D4D4D4", -"'+ c #D7D4C3", -")+ c #E2DAA9", -"!+ c #B5B5B5", -"~+ c #BCBCBC", -"{+ c #3E3E3E", -"]+ c #5F5F5F", -"^+ c #3B3F45", -"/+ c #6F89A6", -"(+ c #999999", -"_+ c #CACACA", -":+ c #C0BDAC", -"<+ c #A09766", -"[+ c #A5A5A5", -"}+ c #7D7D7D", -"|+ c #323232", -"1+ c #9E9E9E", -"2+ c #8394A6", -"3+ c #7A94B1", -"4+ c #5B7188", -"5+ c #262B31", -"6+ c #3A3A3A", -"7+ c #404040", -"8+ c #454545", -"9+ c #434343", -"0+ c #2E2E2E", -"a+ c #1E1E1E", -"b+ c #797979", -"c+ c #565F69", -"d+ c #8198B1", -"e+ c #738DAB", -"f+ c #3D4B5A", -"g+ c #16181A", -"h+ c #1D1D1D", -"i+ c #222222", -"j+ c #212121", -"k+ c #262626", -"l+ c #242424", -"m+ c #252525", -"n+ c #202020", -"o+ c #090909", -"p+ c #6B7580", -"q+ c #748FAD", -"r+ c #6A829E", -"s+ c #465668", -"t+ c #0B0D10", -"u+ c #000000", -"v+ c #535353", -"w+ c #515A65", -"x+ c #76889C", -"y+ c #7D95B0", -"z+ c #748EAA", -"A+ c #6E87A4", -"B+ c #5F758D", -"C+ c #3E4A58", -"D+ c #575A5F", -"E+ c #808080", -"F+ c #969696", -"G+ c #A2A2A2", -"H+ c #A3A3A3", -"I+ c #F5F5F5", -"J+ c #5B5B5B", -"K+ c #7F7F80", -"L+ c #7E8083", -"M+ c #494D52", -"N+ c #464B51", -"O+ c #484B4F", -"P+ c #7A7A7A", -"Q+ c #A1A1A1", -"R+ c #BBBBBB", -"S+ c #C5C5C5", -"T+ c #A9A9A9", -"U+ c #C0C0C0", -"V+ c #B6B6B6", -"W+ c #606060", -"X+ c #727272", -"Y+ c #7E7E7E", -"Z+ c #ABABAB", -"`+ c #AFAFAF", -" @ c #B4B4B4", -".@ c #C3C3C3", -"+@ c #B8B8B8", -"@@ c #A0A0A0", -"#@ c #929292", -"$@ c #525252", -"%@ c #515151", -"&@ c #DADADA", -"*@ c #BDBDBD", -"=@ c #555555", -"-@ c #111111", -";@ c #B7B7B7", -">@ c #BFBFBF", -",@ c #DDDDDD", -"'@ c #9D9D9D", -")@ c #2B2B2B", -"!@ c #9A9A9A", -"~@ c #979797", -"{@ c #939393", -"]@ c #919191", -"^@ c #959595", -"/@ c #848484", -"(@ c #7C7C7C", -"_@ c #757575", -":@ c #8E8E8E", -"<@ c #646464", -"[@ c #6A6A6A", -"}@ c #696969", -"|@ c #686868", -"1@ c #676767", -"2@ c #666666", -"3@ c #656565", -"4@ c #636363", -"5@ c #5E5E5E", -"6@ c #5D5D5D", -"7@ c #5A5A5A", -"8@ c #585858", -"9@ c #575757", -" ", -" ", -" ", -" . . . + @ @ # $ % % & & * * = - ; > ", -" , @ ' ) ! ~ { { ] ^ / ( _ : < ! ' : [ ", -" , @ } | 1 1 2 2 3 3 3 3 3 4 1 5 6 7 8 ", -" . $ 9 0 a b c d e f g h i j k l m n | ", -" . $ 9 o p q r s t u v h w x y z A ! | ", -" . % B C D E F G H I J K L M N O ; { | ", -" @ P Q R S T U V W X Y Z ` ...+.6 @.| ", -" #.$.%.&.*.=.-.;.>.,.'.).!.~.{.].^././ | ", -" (._.:.:.<.[.}.|.1.2.3.4.5.6.7.8.9.0.a.< | ", -" b.c.d.e.f.g.h.e.i.j.k.l.m.n.o.p.q.r.s.t.u.: | ", -" v.w.e.e.g.q x.e.e.i.y.z.A.B.C.D.E.F.G.H.I.J.| ", -" K.L.M.e.e.h.x.N.e.e.e.O.P.Q.R.S.T.U.V.W.X.' Y.| ", -" Z.`.e.e.e.x.x.N.e.e.e. +.+++@+#+#+$+$+$+@+' %+| ", -" &+*+e.e.e.=+q x.e.e.e.-+;+>+: ,+@.( _ '+)+!+~+{+]+ ", -" ^+`.e.e.e.g.q x.e.e.e./+$.(+~+@.^ < _+:+<+[+}+|+3 1+ ", -" 2+3+e.e.g.q x.e.e.e.4+5+6+7+8+8+5 8+9+9+0+a+ 1+b+ ", -" c+d+e.e.g.q x.e.e.e+f+g+h+i+j+k+j+l+m+n+o+ 1+b+ ", -" p+d+3+e.e.e.q+r+s+t+u+u+u+u+u+u+u+u+u+u+ 1+v+ ", -" w+x+y+z+A+B+C+D+E+F+G+H+H+H+H+H+H+H+H+@.I+#+ 1+J+ ", -" K+L+M+N+N+O+P+Q+R+! @.~ S+%+! { Y._ T+U+V+W+X+Y+ ", -" : 7 Z+`+ @Z+.@R+) _ S+%+Y.] ~++@T+`+F+Z+@@#@$@%@ ", -" @ /.) ~ ) { &@^ { *@n J._ ( ^ S+_+/ !+R+ @#+=@-@ ", -" I+# _ ^ &@a.= ' - ,+a.! > ~+;@>@S+,@; _+'@T+U+[ )@ ", -" % R+.@= @.[+H+'@!@~@{@]@`+@. @G+~+^@/@(@_@T+:@Z+<@ ", -" (@[@[@[@}@}@|@1@1@2@3@<@<@4@[ W+]+5@6@J+7@8@9@=@1 u+ ", -" u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+ ", -" ", -" ", -" "}; diff --git a/pixmaps/lpr.png b/pixmaps/lpr.png Binary files differdeleted file mode 100644 index 7bfdefd1..00000000 --- a/pixmaps/lpr.png +++ /dev/null diff --git a/pixmaps/media.png b/pixmaps/media.png Binary files differdeleted file mode 100755 index cd061e66..00000000 --- a/pixmaps/media.png +++ /dev/null diff --git a/pixmaps/mem.png b/pixmaps/mem.png Binary files differdeleted file mode 100755 index a852520b..00000000 --- a/pixmaps/mem.png +++ /dev/null diff --git a/pixmaps/memory.png b/pixmaps/memory.png Binary files differnew file mode 100644 index 00000000..1ea66b8a --- /dev/null +++ b/pixmaps/memory.png diff --git a/pixmaps/modem.png b/pixmaps/modem.png Binary files differnew file mode 100644 index 00000000..8d1ea2b0 --- /dev/null +++ b/pixmaps/modem.png diff --git a/pixmaps/module.png b/pixmaps/module.png Binary files differindex 80dc788d..8f1279d0 100644 --- a/pixmaps/module.png +++ b/pixmaps/module.png diff --git a/pixmaps/monitor.png b/pixmaps/monitor.png Binary files differnew file mode 100644 index 00000000..669086a4 --- /dev/null +++ b/pixmaps/monitor.png diff --git a/pixmaps/mouse.png b/pixmaps/mouse.png Binary files differnew file mode 100644 index 00000000..4043722d --- /dev/null +++ b/pixmaps/mouse.png diff --git a/pixmaps/network.png b/pixmaps/network.png Binary files differnew file mode 100644 index 00000000..f8c623b6 --- /dev/null +++ b/pixmaps/network.png diff --git a/pixmaps/os.png b/pixmaps/os.png Binary files differnew file mode 100644 index 00000000..166c2201 --- /dev/null +++ b/pixmaps/os.png diff --git a/pixmaps/pci.png b/pixmaps/pci.png Binary files differdeleted file mode 100755 index 21905108..00000000 --- a/pixmaps/pci.png +++ /dev/null diff --git a/pixmaps/pci.xpm b/pixmaps/pci.xpm deleted file mode 100755 index 3e6f936a..00000000 --- a/pixmaps/pci.xpm +++ /dev/null @@ -1,136 +0,0 @@ -/* XPM */ -static char * pci_xpm[] = { -"16 16 111 2", -" c None", -". c #030303", -"+ c #D6DDD0", -"@ c #A5B393", -"# c #95B882", -"$ c #B8CAB0", -"% c #A9BEA2", -"& c #809A75", -"* c #93AB88", -"= c #ACBEA4", -"- c #3C5234", -"; c #3F5A32", -"> c #738B57", -", c #4B673F", -"' c #546B47", -") c #3B542F", -"! c #FFFFFF", -"~ c #717171", -"{ c #DADBDA", -"] c #B9B691", -"^ c #55643F", -"/ c #A0A591", -"( c #606950", -"_ c #A0A593", -": c #2C3A21", -"< c #A9AAA9", -"[ c #B1B1B1", -"} c #A4A4A4", -"| c #A9A9A9", -"1 c #6D6B59", -"2 c #3E4832", -"3 c #8F9391", -"4 c #4F4436", -"5 c #8F9393", -"6 c #1E2416", -"7 c #B0BFA7", -"8 c #8A866E", -"9 c #000000", -"0 c #848069", -"a c #B9B086", -"b c #474736", -"c c #343E25", -"d c #6A706E", -"e c #443B33", -"f c #606769", -"g c #1D2416", -"h c #FAFAFA", -"i c #BEBEBE", -"j c #475236", -"k c #383E2B", -"l c #313726", -"m c #313425", -"n c #363A28", -"o c #1F2317", -"p c #3A4225", -"q c #3C502C", -"r c #334425", -"s c #364525", -"t c #27341C", -"u c #4D6538", -"v c #556437", -"w c #48552F", -"x c #4A552F", -"y c #4D5932", -"z c #3F4D29", -"A c #4D6433", -"B c #658042", -"C c #658248", -"D c #8F976F", -"E c #57604B", -"F c #848257", -"G c #939165", -"H c #B1B091", -"I c #9E9E77", -"J c #6B6942", -"K c #45592F", -"L c #4D6B36", -"M c #658442", -"N c #62824B", -"O c #80887A", -"P c #545454", -"Q c #343A21", -"R c #2B311C", -"S c #474D2B", -"T c #2C321D", -"U c #2D311C", -"V c #556736", -"W c #778F4A", -"X c #648241", -"Y c #648047", -"Z c #485441", -"` c #262925", -" . c #547E47", -".. c #A0A95E", -"+. c #D1CC84", -"@. c #8B9752", -"#. c #BBBB75", -"$. c #989E55", -"%. c #CAC77F", -"&. c #91A054", -"*. c #CFCB83", -"=. c #27361C", -"-. c #10140D", -";. c #0B0D09", -">. c #B8B078", -",. c #DDD58F", -"'. c #A5A161", -"). c #D4CD84", -"!. c #ADA772", -"~. c #D7D088", -"{. c #DAD38B", -" . ", -" . ", -" . ", -" . . . . . . . . . . . . . ", -". + @ @ @ @ @ @ @ @ @ @ @ . ", -". # $ % & * = - ; > , ' ) . ", -". # ! ~ ! ~ { ] ^ / ( _ : . ", -". ! < [ } | ~ 1 2 3 4 5 6 . . ", -". 7 8 9 0 9 a b c d e f g . h ", -". # j k l m n o p q r s t . 9 ", -". # u v w x y z A B C D E . ", -". # F G H I J K L M N O P . ", -". # Q R S T U V W X Y Z ` . ", -". ...+.@.#.$.%.&.*.=.-.;.. ", -" . >.,.'.).!.~.'.{.. . ", -" . . . . . . . . . . . "}; - - -/* - * Ripped from Ximian Setup Tools <http://www.ximian.com> - * Unknown author - */ diff --git a/pixmaps/pcmcia.png b/pixmaps/pcmcia.png Binary files differnew file mode 100644 index 00000000..2baac660 --- /dev/null +++ b/pixmaps/pcmcia.png diff --git a/pixmaps/printer.png b/pixmaps/printer.png Binary files differnew file mode 100644 index 00000000..dd814d6c --- /dev/null +++ b/pixmaps/printer.png diff --git a/pixmaps/processor.png b/pixmaps/processor.png Binary files differnew file mode 100644 index 00000000..7b2a3fb1 --- /dev/null +++ b/pixmaps/processor.png diff --git a/pixmaps/processor.xpm b/pixmaps/processor.xpm deleted file mode 100644 index 7a7970d5..00000000 --- a/pixmaps/processor.xpm +++ /dev/null @@ -1,116 +0,0 @@ -/* XPM */ -static char * processor_xpm[] = { -"16 16 97 2", -" c None", -". c #000000", -"+ c #090600", -"@ c #030000", -"# c #E8E6E1", -"$ c #A3A09C", -"% c #010000", -"& c #080000", -"* c #D6D2CD", -"= c #8F8A84", -"- c #FFFAF7", -"; c #98938D", -"> c #F1EDE9", -", c #88827E", -"' c #181510", -") c #F8EEE4", -"! c #F8ECE0", -"~ c #F8ECDE", -"{ c #0D0600", -"] c #F8EBDE", -"^ c #F6E7D7", -"/ c #C4B5A7", -"( c #070000", -"_ c #F6E5D3", -": c #F7E9D9", -"< c #D5C5B6", -"[ c #050200", -"} c #080300", -"| c #312722", -"1 c #EFE7E0", -"2 c #F6F2EF", -"3 c #F6F1EE", -"4 c #EDE4DB", -"5 c #F1E4D6", -"6 c #9D9790", -"7 c #12110D", -"8 c #B1A79F", -"9 c #DDCFC2", -"0 c #F6E8D9", -"a c #F6F1EC", -"b c #F5F1EE", -"c c #E5D7CB", -"d c #F7E8D8", -"e c #EEDFD3", -"f c #CAC0B6", -"g c #645951", -"h c #E7D9CA", -"i c #F6E6D5", -"j c #F7EBDE", -"k c #E9DCD2", -"l c #756F6D", -"m c #F7EFE7", -"n c #EDDECF", -"o c #D6C8BA", -"p c #CBB9AC", -"q c #D2C8BC", -"r c #F8EEE3", -"s c #F5EEE8", -"t c #EFE3D7", -"u c #B8A99D", -"v c #060000", -"w c #DBD3CB", -"x c #F8F1E8", -"y c #F3E3D4", -"z c #F1DFCF", -"A c #E6D7C7", -"B c #F8F2ED", -"C c #EDE1D4", -"D c #9D8E84", -"E c #090200", -"F c #DBD3CD", -"G c #F8F0EA", -"H c #F1E0D1", -"I c #F6EEE8", -"J c #56504A", -"K c #130D0D", -"L c #ADA3A2", -"M c #C8BDBC", -"N c #BEB3AB", -"O c #9E9A96", -"P c #A8A09E", -"Q c #0E0403", -"R c #0A0000", -"S c #0A0200", -"T c #040000", -"U c #FCF4F2", -"V c #F9F1EF", -"W c #F8F0EE", -"X c #F2EDEA", -"Y c #DDD9D6", -"Z c #E5E4E0", -"` c #030400", -" . c #0B0505", -".. c #050000", -"+. c #14100F", -"@. c #090806", -"#. c #000100", -" . . ", -" + @ # $ % % ", -" & * = - ; > , ' ", -" & ) ; ! ; ~ ; { ", -" & ] ; ^ ; ] ; / ( ", -" & _ ; _ ; : ; < ( ", -" [ } | 1 2 3 4 5 6 < ( ", -" 7 _ 8 & 9 _ 0 a b c < ( ", -" % d e f g h i _ j k < ( ", -" l m n o p q r s t u ( ", -" v w x y z A B C _ D ( ", -" E F G _ H I _ < J ", -" K L M _ _ N O & ", -" P v Q R S T } ", -" T U V W X Y Z ` ", -" T ...+.@ @.. #. "}; diff --git a/pixmaps/report.png b/pixmaps/report.png Binary files differnew file mode 100644 index 00000000..48bd5d01 --- /dev/null +++ b/pixmaps/report.png diff --git a/pixmaps/scanner.png b/pixmaps/scanner.png Binary files differdeleted file mode 100644 index cfede3e5..00000000 --- a/pixmaps/scanner.png +++ /dev/null diff --git a/pixmaps/scsi.png b/pixmaps/scsi.png Binary files differdeleted file mode 100755 index 23dd73fd..00000000 --- a/pixmaps/scsi.png +++ /dev/null diff --git a/pixmaps/scsi.xpm b/pixmaps/scsi.xpm deleted file mode 100755 index 402906f0..00000000 --- a/pixmaps/scsi.xpm +++ /dev/null @@ -1,79 +0,0 @@ -/* XPM */ -static char * scsi_xpm[] = { -"16 16 60 1", -" g None", -". g #696969", -"+ g #B4B4B4", -"@ g #B1B1B1", -"# g #6D6D6D", -"$ g #B2B2B2", -"% g #ADADAD", -"& g #A5A5A5", -"* g #5E5E5E", -"= g #B0B0B0", -"- g #A3A3A3", -"; g #595959", -"> g #969696", -", g #9A9A9A", -"' g #585858", -") g #818181", -"! g #616161", -"~ g #8C8C8C", -"{ g #868686", -"] g #505050", -"^ g #797979", -"/ g #515151", -"( g #464646", -"_ g #747474", -": g #9C9C9C", -"< g #7C7C7C", -"[ g #5B5B5B", -"} g #A7A7A7", -"| g #5D5D5D", -"1 g #6A6A6A", -"2 g #666666", -"3 g #636363", -"4 g #5F5F5F", -"5 g #575757", -"6 g #A6A6A6", -"7 g #919191", -"8 g #676767", -"9 g #404040", -"0 g #5C5C5C", -"a g #555555", -"b g #4E4E4E", -"c g #737373", -"d g #7D7D7D", -"e g #707070", -"f g #3E3E3E", -"g g #2F2F2F", -"h g #606060", -"i g #474747", -"j g #3B3B3B", -"k g #4B4B4B", -"l g #3F3F3F", -"m g #4F4F4F", -"n g #545454", -"o g #3C3C3C", -"p g #373737", -"q g #414141", -"r g #454545", -"s g #363636", -"t g #353535", -"u g #313131", -" . ", -" +@# ", -" $@%&* ", -" =-*;>,' ", -" )! ~{] ", -" ^/ (_ ", -" :<[ ", -" }-| (1234[5 ", -" 678 9!0aa]b ", -" cd| ", -" 8e] fbg ", -" ;hi jkl ", -" mnop(o ", -" qrqs ", -" tu ", -" "}; diff --git a/pixmaps/shares.png b/pixmaps/shares.png Binary files differnew file mode 100644 index 00000000..ab4e197d --- /dev/null +++ b/pixmaps/shares.png diff --git a/pixmaps/stock-about-16.png b/pixmaps/stock-about-16.png Binary files differdeleted file mode 100755 index d66bfd7b..00000000 --- a/pixmaps/stock-about-16.png +++ /dev/null diff --git a/pixmaps/stock_channel.png b/pixmaps/stock_channel.png Binary files differnew file mode 100644 index 00000000..2a74f2e6 --- /dev/null +++ b/pixmaps/stock_channel.png diff --git a/pixmaps/stock_insert-floating-frame.png b/pixmaps/stock_insert-floating-frame.png Binary files differnew file mode 100644 index 00000000..8f82250f --- /dev/null +++ b/pixmaps/stock_insert-floating-frame.png diff --git a/pixmaps/stock_landline-phone.png b/pixmaps/stock_landline-phone.png Binary files differnew file mode 100644 index 00000000..61da5dab --- /dev/null +++ b/pixmaps/stock_landline-phone.png diff --git a/pixmaps/stock_macro-watch-variable.png b/pixmaps/stock_macro-watch-variable.png Binary files differnew file mode 100644 index 00000000..2e52ddc9 --- /dev/null +++ b/pixmaps/stock_macro-watch-variable.png diff --git a/pixmaps/stock-details.png b/pixmaps/summary.png Binary files differindex 5a2cd965..5a2cd965 100644 --- a/pixmaps/stock-details.png +++ b/pixmaps/summary.png diff --git a/pixmaps/tape.png b/pixmaps/tape.png Binary files differdeleted file mode 100755 index 90b2e297..00000000 --- a/pixmaps/tape.png +++ /dev/null diff --git a/pixmaps/therm.png b/pixmaps/therm.png Binary files differnew file mode 100644 index 00000000..3dac3913 --- /dev/null +++ b/pixmaps/therm.png diff --git a/pixmaps/usb.png b/pixmaps/usb.png Binary files differindex a662ce55..7c7c6746 100755..100644 --- a/pixmaps/usb.png +++ b/pixmaps/usb.png diff --git a/pixmaps/usb.xpm b/pixmaps/usb.xpm deleted file mode 100755 index 476432fd..00000000 --- a/pixmaps/usb.xpm +++ /dev/null @@ -1,49 +0,0 @@ -/* XPM */ -static char * usb_xpm[] = { -"16 16 30 1", -" c None", -". c #929292", -"+ c #464646", -"@ c #313131", -"# c #353535", -"$ c #424242", -"% c #000000", -"& c #2E2E2E", -"* c #878787", -"= c #272727", -"- c #242424", -"; c #717171", -"> c #4B4B4B", -", c #2B2B2B", -"' c #323232", -") c #808080", -"! c #010101", -"~ c #C6C6C6", -"{ c #040404", -"] c #0D0D0D", -"^ c #0B0B0B", -"/ c #131313", -"( c #7D7D7D", -"_ c #030303", -": c #787878", -"< c #999999", -"[ c #CCCCCC", -"} c #959595", -"| c #8E8E8E", -"1 c #C2C2C2", -" ", -" ", -" ", -" ", -" ", -" .+@@@@# ", -" $%%%%%%&*=-; ", -" >%%%%%%% ,,') ", -"%%%%%%%%%% !,%~ ", -"%%{%%%%%%] ^,/ ", -" (_%%%%%> ::< ", -" [}||||1 ", -" ", -" ", -" ", -" "}; diff --git a/pixmaps/users.png b/pixmaps/users.png Binary files differnew file mode 100644 index 00000000..cbc62084 --- /dev/null +++ b/pixmaps/users.png diff --git a/pixmaps/v4l.png b/pixmaps/v4l.png Binary files differdeleted file mode 100755 index 88801a39..00000000 --- a/pixmaps/v4l.png +++ /dev/null diff --git a/pixmaps/videocap.png b/pixmaps/videocap.png Binary files differnew file mode 100644 index 00000000..8bbea0ba --- /dev/null +++ b/pixmaps/videocap.png diff --git a/pixmaps/x11.png b/pixmaps/x11.png Binary files differdeleted file mode 100755 index 49924ba2..00000000 --- a/pixmaps/x11.png +++ /dev/null diff --git a/report.c b/report.c new file mode 100644 index 00000000..990abd8b --- /dev/null +++ b/report.c @@ -0,0 +1,461 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <report.h> +#include <stdio.h> +#include <string.h> +#include <shell.h> +#include <hardinfo.h> + +static ReportDialog *report_dialog_new(GtkTreeModel *model, GtkWidget *parent); +static void set_all_active(ReportDialog *rd, gboolean setting); + +static void +report_html_header(ReportContext *ctx) +{ + fprintf(ctx->stream, + "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Final//EN\">\n" \ + "<html><head>\n" \ + "<title>HardInfo System Report</title>\n" \ + "<style>\n" \ + "body { background: #fff }\n" \ + ".title { font: bold 130%% serif; color: #0066FF; padding: 30px 0 10px 0 }\n" \ + ".stitle { font: bold 100%% sans-serif; color: #0044DD; padding: 30px 0 10px 0 }\n" \ + ".sstitle{ font: bold 80%% serif; color: #000000; background: #efefef }\n" \ + ".field { font: 80%% sans-serif; color: #000000; padding: 2px; padding-left: 50px }\n" \ + ".value { font: 80%% sans-serif; color: #505050 }\n" \ + "</style>\n" \ + "</head><body>\n" \ + "<table width=\"100%%\"><tbody>"); +} + +static void +report_html_footer(ReportContext *ctx) +{ + fprintf(ctx->stream, + "</tbody></table></body></html>"); +} + +static void +report_html_title(ReportContext *ctx, gchar *text) +{ + fprintf(ctx->stream, + "<tr><td colspan=\"2\" class=\"title\">%s</td></tr>\n", text); +} + +static void +report_html_subtitle(ReportContext *ctx, gchar *text) +{ + fprintf(ctx->stream, + "<tr><td colspan=\"2\" class=\"stitle\">%s</td></tr>\n", text); +} +static void +report_html_subsubtitle(ReportContext *ctx, gchar *text) +{ + fprintf(ctx->stream, + "<tr><td colspan=\"2\" class=\"sstitle\">%s</td></tr>\n", text); +} + +static void +report_html_key_value(ReportContext *ctx, gchar *key, gchar *value) +{ + fprintf(ctx->stream, + "<tr><td class=\"field\">%s</td>" \ + "<td class=\"value\">%s</td></tr>\n", key, value); +} + +static void +report_html_table(ReportContext *ctx, gchar *text) +{ + GKeyFile *key_file = g_key_file_new(); + gchar **groups; + gint i; + + g_key_file_load_from_data(key_file, text, strlen(text), 0, NULL); + groups = g_key_file_get_groups(key_file, NULL); + + for (i = 0; groups[i]; i++) { + gchar *group, *tmpgroup; + gchar **keys; + gint j; + + if (groups[i][0] == '$') + continue; + + group = groups[i]; + keys = g_key_file_get_keys(key_file, group, NULL, NULL); + + tmpgroup = g_strdup(group); + strend(group, '#'); + + report_html_subsubtitle(ctx, group); + + for (j = 0; keys[j]; j++) { + gchar *key = keys[j]; + gchar *value; + + value = g_key_file_get_value(key_file, tmpgroup, key, NULL); + + if (g_utf8_validate(key, -1, NULL) && g_utf8_validate(value, -1, NULL)) { + strend(key, '#'); + + if (g_str_equal(value, "...")) { + g_free(value); + value = ctx->entry->fieldfunc(key); + } + + if (*key == '$') { + gchar **tmp; + + tmp = g_strsplit(++key, "$", 0); + report_html_key_value(ctx, tmp[1], value); + g_strfreev(tmp); + } else { + report_html_key_value(ctx, key, value); + } + + } + + g_free(value); + } + + g_free(tmpgroup); + g_strfreev(keys); + } + + g_strfreev(groups); + g_key_file_free(key_file); +} + +static void +report_generate_child(ReportContext *ctx, GtkTreeIter *iter) +{ + ShellModuleEntry *entry; + gboolean selected; + + gtk_tree_model_get(ctx->rd->model, iter, TREE_COL_SEL, &selected, -1); + if (!selected) + return; + + gtk_tree_model_get(ctx->rd->model, iter, TREE_COL_DATA, &entry, -1); + + ctx->entry = entry; + + report_html_subtitle(ctx, entry->name); + report_html_table(ctx, entry->func(entry->number)); +} + +static void +report_generate_children(ReportContext *ctx, GtkTreeIter *iter) +{ + GtkTreeModel *model = ctx->rd->model; + gchar *name; + + gtk_tree_model_get(model, iter, TREE_COL_NAME, &name, -1); + report_html_title(ctx, name); + + if (gtk_tree_model_iter_has_child(model, iter)) { + gint children = gtk_tree_model_iter_n_children(model, iter); + gint i; + + for (i = 0; i < children; i++) { + GtkTreeIter child; + + gtk_tree_model_iter_nth_child(model, &child, iter, i); + report_generate_child(ctx, &child); + } + } +} + +static gchar * +report_get_filename(void) +{ + GtkWidget *dialog; + gchar *filename = NULL; + + dialog = gtk_file_chooser_dialog_new("Save File", + NULL, + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, + NULL); + gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), + TRUE); + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), + "hardinfo report.html"); + + if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + } + + gtk_widget_destroy (dialog); + return filename; +} + +static gboolean +report_generate(ReportDialog *rd) +{ + GtkTreeIter iter; + GtkTreeModel *model; + ReportContext *ctx; + gchar *file; + FILE *stream; + + file = report_get_filename(); + if (!file) + return FALSE; + stream = fopen(file, "w+"); + if (!stream) + return FALSE; + + model = rd->model; + ctx = g_new0(ReportContext, 1); + ctx->rd = rd; + ctx->stream = stream; + + report_html_header(ctx); + + gtk_tree_model_get_iter_first(model, &iter); + + do { + report_generate_children(ctx, &iter); + } while (gtk_tree_model_iter_next(model, &iter)); + + report_html_footer(ctx); + + fclose(ctx->stream); + g_free(ctx); + + return TRUE; +} + +void +report_dialog_show(GtkTreeModel *model, GtkWidget *parent) +{ + gboolean success; + ReportDialog *rd = report_dialog_new(model, parent); + + if (gtk_dialog_run(GTK_DIALOG(rd->dialog)) == GTK_RESPONSE_ACCEPT) { + shell_status_update("Generating report..."); + gtk_widget_hide(rd->dialog); + shell_view_set_enabled(FALSE); + shell_status_set_enabled(TRUE); + + success = report_generate(rd); + + shell_status_set_enabled(FALSE); + + if (success) + shell_status_update("Report saved."); + else + shell_status_update("Error while creating the report."); + } + + set_all_active(rd, FALSE); + gtk_widget_destroy(rd->dialog); + g_free(rd); +} + +static void +set_children_active(GtkTreeModel *model, GtkTreeIter *iter, gboolean setting) +{ + if (gtk_tree_model_iter_has_child(model, iter)) { + gint children = gtk_tree_model_iter_n_children(model, iter); + + gtk_tree_store_set(GTK_TREE_STORE(model), iter, TREE_COL_SEL, setting, -1); + + for (children--; children >= 0; children--) { + GtkTreeIter child; + + gtk_tree_model_iter_nth_child(model, &child, iter, children); + gtk_tree_store_set(GTK_TREE_STORE(model), &child, TREE_COL_SEL, setting, -1); + } + } +} + +static void +set_all_active(ReportDialog *rd, gboolean setting) +{ + GtkTreeIter iter; + GtkTreeModel *model = rd->model; + + gtk_tree_model_get_iter_first(model, &iter); + + do { + set_children_active(model, &iter, setting); + } while (gtk_tree_model_iter_next(model, &iter)); +} + +static void +report_dialog_sel_none(GtkWidget *widget, ReportDialog *rd) +{ + set_all_active(rd, FALSE); +} + +static void +report_dialog_sel_all(GtkWidget *widget, ReportDialog *rd) +{ + set_all_active(rd, TRUE); +} + +static void +report_dialog_sel_toggle(GtkCellRendererToggle *cellrenderertoggle, + gchar *path_str, + ReportDialog *rd) +{ + GtkTreeModel *model = rd->model; + GtkTreeIter iter; + GtkTreePath *path = gtk_tree_path_new_from_string(path_str); + gboolean active; + + gtk_tree_model_get_iter(model, &iter, path); + gtk_tree_model_get(model, &iter, TREE_COL_SEL, &active, -1); + + active = !active; + gtk_tree_store_set(GTK_TREE_STORE(model), &iter, TREE_COL_SEL, active, -1); + set_children_active(model, &iter, active); + + gtk_tree_path_free(path); +} + +static ReportDialog +*report_dialog_new(GtkTreeModel *model, GtkWidget *parent) +{ + ReportDialog *rd; + GtkWidget *dialog; + GtkWidget *dialog1_vbox; + GtkWidget *scrolledwindow2; + GtkWidget *treeview2; + GtkWidget *hbuttonbox3; + GtkWidget *button3; + GtkWidget *button6; + GtkWidget *dialog1_action_area; + GtkWidget *button8; + GtkWidget *button7; + GtkWidget *label; + + GtkTreeViewColumn *column; + GtkCellRenderer *cr_text, *cr_pbuf, *cr_toggle; + + rd = g_new0(ReportDialog, 1); + + dialog = gtk_dialog_new(); + gtk_window_set_title(GTK_WINDOW(dialog), "Generate Report"); + gtk_container_set_border_width(GTK_CONTAINER(dialog), 5); + gtk_window_set_default_size(GTK_WINDOW(dialog), 420, 260); + gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent)); + gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT); + gtk_window_set_type_hint(GTK_WINDOW(dialog), + GDK_WINDOW_TYPE_HINT_DIALOG); + + dialog1_vbox = GTK_DIALOG(dialog)->vbox; + gtk_box_set_spacing(GTK_BOX(dialog1_vbox), 5); + gtk_container_set_border_width(GTK_CONTAINER(dialog1_vbox), 4); + gtk_widget_show(dialog1_vbox); + + label = gtk_label_new("<big><b>Generate Report</b></big>\n" \ + "Please choose the information that you wish " \ + "to view in your report:"); + gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(dialog1_vbox), label, FALSE, FALSE, 0); + + scrolledwindow2 = gtk_scrolled_window_new(NULL, NULL); + gtk_widget_show(scrolledwindow2); + gtk_box_pack_start(GTK_BOX(dialog1_vbox), scrolledwindow2, TRUE, TRUE, 0); + gtk_widget_set_size_request(scrolledwindow2, -1, 200); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow2), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW + (scrolledwindow2), GTK_SHADOW_IN); + + treeview2 = gtk_tree_view_new_with_model(model); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview2), FALSE); + gtk_widget_show(treeview2); + gtk_container_add(GTK_CONTAINER(scrolledwindow2), treeview2); + + column = gtk_tree_view_column_new(); + gtk_tree_view_append_column(GTK_TREE_VIEW(treeview2), column); + + cr_toggle = gtk_cell_renderer_toggle_new(); + gtk_tree_view_column_pack_start(column, cr_toggle, FALSE); + g_signal_connect(cr_toggle, "toggled", G_CALLBACK(report_dialog_sel_toggle), rd); + gtk_tree_view_column_add_attribute(column, cr_toggle, "active", + TREE_COL_SEL); + + cr_pbuf = gtk_cell_renderer_pixbuf_new(); + gtk_tree_view_column_pack_start(column, cr_pbuf, FALSE); + gtk_tree_view_column_add_attribute(column, cr_pbuf, "pixbuf", + TREE_COL_PBUF); + + cr_text = gtk_cell_renderer_text_new(); + gtk_tree_view_column_pack_start(column, cr_text, TRUE); + gtk_tree_view_column_add_attribute(column, cr_text, "markup", + TREE_COL_NAME); + + hbuttonbox3 = gtk_hbutton_box_new(); + gtk_widget_show(hbuttonbox3); + gtk_box_pack_start(GTK_BOX(dialog1_vbox), hbuttonbox3, FALSE, TRUE, 0); + gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox3), + GTK_BUTTONBOX_SPREAD); + + button3 = gtk_button_new_with_mnemonic("Select _None"); + gtk_widget_show(button3); + gtk_container_add(GTK_CONTAINER(hbuttonbox3), button3); + GTK_WIDGET_SET_FLAGS(button3, GTK_CAN_DEFAULT); + g_signal_connect(button3, "clicked", G_CALLBACK(report_dialog_sel_none), rd); + + button6 = gtk_button_new_with_mnemonic("Select _All"); + gtk_widget_show(button6); + gtk_container_add(GTK_CONTAINER(hbuttonbox3), button6); + GTK_WIDGET_SET_FLAGS(button6, GTK_CAN_DEFAULT); + g_signal_connect(button6, "clicked", G_CALLBACK(report_dialog_sel_all), rd); + + dialog1_action_area = GTK_DIALOG(dialog)->action_area; + gtk_widget_show(dialog1_action_area); + gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog1_action_area), + GTK_BUTTONBOX_END); + + button8 = gtk_button_new_from_stock(GTK_STOCK_CANCEL); + gtk_widget_show(button8); + gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button8, + GTK_RESPONSE_CANCEL); + GTK_WIDGET_SET_FLAGS(button8, GTK_CAN_DEFAULT); + + button7 = gtk_button_new_with_mnemonic("_Generate"); + gtk_widget_show(button7); + gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button7, + GTK_RESPONSE_ACCEPT); + GTK_WIDGET_SET_FLAGS(button7, GTK_CAN_DEFAULT); + + rd->dialog = dialog; + rd->btn_cancel = button8; + rd->btn_generate = button7; + rd->btn_sel_all = button6; + rd->btn_sel_none = button3; + rd->treeview = treeview2; + rd->model = model; + + gtk_tree_view_collapse_all(GTK_TREE_VIEW(treeview2)); + set_all_active(rd, TRUE); + + return rd; +} diff --git a/report.h b/report.h new file mode 100644 index 00000000..e2bfc912 --- /dev/null +++ b/report.h @@ -0,0 +1,48 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __REPORT_H__ +#define __REPORT_H__ +#include <gtk/gtk.h> +#include <shell.h> + +typedef struct _ReportDialog ReportDialog; +typedef struct _ReportContext ReportContext; + +struct _ReportContext { + ReportDialog *rd; + ShellModuleEntry *entry; + + FILE *stream; +}; + +struct _ReportDialog { + GtkWidget *dialog; + GtkWidget *filechooser; + GtkWidget *btn_cancel; + GtkWidget *btn_generate; + GtkWidget *btn_sel_all; + GtkWidget *btn_sel_none; + GtkWidget *treeview; + + GtkTreeModel *model; +}; + +void report_dialog_show(); + +#endif /* __REPORT_H__ */ diff --git a/scsi.c b/scsi.c deleted file mode 100644 index fc1dd40d..00000000 --- a/scsi.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Hardware Information, version 0.3 - * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> - * SCSI support by Pascal F.Martin <pascalmartin@earthlink.net> - * - * May be modified and/or distributed under the terms of GNU GPL version 2. - */ - -#include "hardinfo.h" -#include "scsi.h" - -SCSIDevice *hi_scan_scsi(void) -{ - FILE *proc_scsi; - gchar buffer[256], *buf; - gint n=0; - SCSIDevice *scsi_dev = NULL, *scsi; - struct stat st; - - scsi = NULL; - - if(stat("/proc/scsi/scsi", &st)) return NULL; - - proc_scsi = fopen("/proc/scsi/scsi", "r"); - while(fgets(buffer, 256, proc_scsi)) { - buf = g_strstrip(buffer); - if(!strncmp(buf, "Host: scsi", 10)) { - gint scsi_controller; - gint scsi_channel; - gint scsi_id; - gint scsi_lun; - - sscanf(buf, - "Host: scsi%d Channel: %d Id: %d Lun: %d", - &scsi_controller, - &scsi_channel, - &scsi_id, - &scsi_lun); - - buf = strstr (buffer, "Rev: "); - if (buf == NULL) { - buf = "(unknown)"; - } else { - buf += 5; - } - scsi_dev = g_new0(SCSIDevice, 1); - - scsi_dev->next = scsi; - scsi = scsi_dev; - - scsi_dev->controller = scsi_controller; - scsi_dev->channel = scsi_channel; - scsi_dev->id = scsi_id; - scsi_dev->lun = scsi_lun; - - n++; - - } else if (!strncmp(buf, "Vendor: ", 8)) { - - char *p; - char *model = strstr (buf, "Model: "); - char *rev = strstr (buf, "Rev: "); - - if (model == NULL) { - model = buf + strlen(buf); - } - p = model; - while (*(--p) == ' ') ; - *(++p) = 0; - scsi_dev->vendor = g_strdup(buf+8); - - if (rev != NULL) { - scsi_dev->revision = g_strdup(rev+5); - } else { - rev = model + strlen(model); - } - p = rev; - while (*(--p) == ' ') ; - *(++p) = 0; - scsi_dev->model = - g_strdup_printf - ("%s %s", scsi_dev->vendor, model+7); - - } else if (!strncmp(buf, "Type: ", 8)) { - char *p = strstr (buf, "ANSI SCSI revi"); - - if (p != NULL) { - while (*(--p) == ' ') ; - *(++p) = 0; - scsi_dev->type = g_strdup(buf+8); - } - } - } - fclose(proc_scsi); - - return scsi; -} - -void hi_show_scsi_info(MainWindow *mainwindow, SCSIDevice *device) -{ - static struct { - char *type; - char *label; - char *icon; - } type2icon[] = { - {"Direct-Access", "Disk", "hdd.png"}, - {"Sequential-Access", "Tape", "tape.png"}, - {"Printer", "Printer", "lpr.png"}, - {"WORM", "CD-ROM", "cd.png"}, - {"CD-ROM", "CD-ROM", "cd.png"}, - {"Scanner", "Scanner", "scan.png"}, - {NULL, "Generic", "scsi.png"} - }; - - int i; - gchar *buf; - - if(!device) return; - - for (i = 0; type2icon[i].type != NULL; ++i) { - if (!strcmp(device->type, type2icon[i].type)) break; - } - - buf = g_strdup_printf("%s%s", IMG_PREFIX, type2icon[i].icon); - detail_window_set_icon(mainwindow->det_window, buf); - g_free(buf); - - buf = g_strdup_printf(_("SCSI %s Device"), type2icon[i].label); - gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), buf); - detail_window_set_dev_type(mainwindow->det_window, buf); - g_free(buf); - - detail_window_set_dev_name(mainwindow->det_window, device->model); - - - detail_window_append_info(mainwindow->det_window, _("Revision"), device->revision); - detail_window_append_info(mainwindow->det_window, _("Type"), device->type); - - detail_window_append_separator(mainwindow->det_window); - - detail_window_append_info_int(mainwindow->det_window, _("Controller"), device->controller, FALSE); - detail_window_append_info_int(mainwindow->det_window, _("Channel"), device->channel, FALSE); - detail_window_append_info_int(mainwindow->det_window, _("ID"), device->id, FALSE); - detail_window_append_info_int(mainwindow->det_window, _("LUN"), device->lun, FALSE); -} diff --git a/scsi.h b/scsi.h deleted file mode 100644 index 430d9e76..00000000 --- a/scsi.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __SCSI_H__ -#define __SCSI_H__ - -typedef struct _SCSIDevice SCSIDevice; - -struct _SCSIDevice { - gchar *model; - - gchar *vendor; - gchar *type; - gchar *revision; - gint controller; - gint channel; - gint id; - gint lun; - - SCSIDevice *next; -}; - -void hi_show_scsi_info(MainWindow *mainwindow, SCSIDevice *device); -SCSIDevice *hi_scan_scsi(void); - -#endif diff --git a/serial.c b/serial.c deleted file mode 100644 index 7bb5ebc7..00000000 --- a/serial.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Hardware Information, version 0.3.1b - * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> - * - * May be modified and/or distributed under the terms of GNU GPL version 2. - */ - -#include "hardinfo.h" -#include "serial.h" - -SerialDevice *hi_scan_serial(void) -{ - FILE *proc_tty; - struct stat st; - const gchar *ser_drv = "/proc/tty/driver/serial"; - gint n = 0; - SerialDevice *serial_dev, *serial; - - serial = NULL; - - if (!stat(ser_drv, &st)) { - gchar buffer[256]; - - proc_tty = fopen(ser_drv, "r"); - while(fgets(buffer, 256, proc_tty)){ - gint port, irq; - gpointer start, end; - gchar *buf = buffer; - - if(*buf == 's') continue; - if(strstr(buffer, "unknown")) continue; - - serial_dev = g_new0(SerialDevice, 1); - - serial_dev->next = serial; - serial = serial_dev; - - serial_dev->name = g_strdup_printf - (_("Serial Port (tty%d)"), buffer[0]-'0'); - - walk_until('t'); - buf += 2; - start = buf; - walk_until(' '); - end = buf; - *buf = 0; - buf = start; - - serial_dev->uart = g_strdup(buf); - - buf = end; - *buf = ' '; - - sscanf(buf, " port:%x irq:%d", &port, &irq); - serial->port = port; - serial->irq = irq; - n++; - } - fclose(proc_tty); - } - - return serial; -} - -void hi_show_serial_info(MainWindow *mainwindow, SerialDevice *device) -{ - if(!device) return; - - detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "gen_connector.png"); - gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("Communication Port")); - - detail_window_set_dev_name(mainwindow->det_window, device->name); - detail_window_set_dev_type(mainwindow->det_window, _("Communication Port")); - - detail_window_append_info_int(mainwindow->det_window, _("I/O port"), - device->port, TRUE); - detail_window_append_info_int(mainwindow->det_window, _("IRQ"), - device->irq, TRUE); - detail_window_append_info(mainwindow->det_window, "UART", device->uart); -} diff --git a/serial.h b/serial.h deleted file mode 100644 index e2d3e5e8..00000000 --- a/serial.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __SERIAL_H__ -#define __SERIAL_H__ - -#include "hardinfo.h" - -typedef struct _SerialDevice SerialDevice; - -struct _SerialDevice { - gchar *name; - gchar *uart; - gint port, irq, baud; - - SerialDevice *next; -}; - -SerialDevice *hi_scan_serial(void); -void hi_show_serial_info(MainWindow *mainwindow, SerialDevice *device); - -#endif @@ -0,0 +1,340 @@ +/* +SHA-1 in C +By Steve Reid <steve@edmweb.com> +100% Public Domain + +Test Vectors (from FIPS PUB 180-1) +"abc" + A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D +"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" + 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 +A million repetitions of "a" + 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F +*/ + + +/* #define SHA1HANDSOFF * Copies data before messing with it. */ + +#include <stdio.h> +#include <string.h> +#include <sha1.h> + +#include <glib.h> +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +#define LITTLE_ENDIAN /* This should be #define'd if true. */ +#endif + +#if defined(__OPTIMIZE__) +#error You must compile this program without "-O". +#endif + + +#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) + +/* blk0() and blk() perform the initial expand. */ +/* I got the idea of expanding during the round function from SSLeay */ +#ifdef LITTLE_ENDIAN +#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ + |(rol(block->l[i],8)&0x00FF00FF)) +#else +#define blk0(i) block->l[i] +#endif +#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ + ^block->l[(i+2)&15]^block->l[i&15],1)) + +/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ +#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); +#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); +#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); +#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); +#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); + + +/* Hash a single 512-bit block. This is the core of the algorithm. */ + +void SHA1Transform(unsigned long state[5], unsigned char buffer[64]) +{ + unsigned long a, b, c, d, e; + typedef union { + unsigned char c[64]; + unsigned long l[16]; + } CHAR64LONG16; + CHAR64LONG16 *block; +#ifdef SHA1HANDSOFF + static unsigned char workspace[64]; + block = (CHAR64LONG16 *) workspace; + memcpy(block, buffer, 64); +#else + block = (CHAR64LONG16 *) buffer; +#endif + /* Copy context->state[] to working vars */ + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + /* 4 rounds of 20 operations each. Loop unrolled. */ + R0(a, b, c, d, e, 0); + R0(e, a, b, c, d, 1); + R0(d, e, a, b, c, 2); + R0(c, d, e, a, b, 3); + R0(b, c, d, e, a, 4); + R0(a, b, c, d, e, 5); + R0(e, a, b, c, d, 6); + R0(d, e, a, b, c, 7); + R0(c, d, e, a, b, 8); + R0(b, c, d, e, a, 9); + R0(a, b, c, d, e, 10); + R0(e, a, b, c, d, 11); + R0(d, e, a, b, c, 12); + R0(c, d, e, a, b, 13); + R0(b, c, d, e, a, 14); + R0(a, b, c, d, e, 15); + R1(e, a, b, c, d, 16); + R1(d, e, a, b, c, 17); + R1(c, d, e, a, b, 18); + R1(b, c, d, e, a, 19); + R2(a, b, c, d, e, 20); + R2(e, a, b, c, d, 21); + R2(d, e, a, b, c, 22); + R2(c, d, e, a, b, 23); + R2(b, c, d, e, a, 24); + R2(a, b, c, d, e, 25); + R2(e, a, b, c, d, 26); + R2(d, e, a, b, c, 27); + R2(c, d, e, a, b, 28); + R2(b, c, d, e, a, 29); + R2(a, b, c, d, e, 30); + R2(e, a, b, c, d, 31); + R2(d, e, a, b, c, 32); + R2(c, d, e, a, b, 33); + R2(b, c, d, e, a, 34); + R2(a, b, c, d, e, 35); + R2(e, a, b, c, d, 36); + R2(d, e, a, b, c, 37); + R2(c, d, e, a, b, 38); + R2(b, c, d, e, a, 39); + R3(a, b, c, d, e, 40); + R3(e, a, b, c, d, 41); + R3(d, e, a, b, c, 42); + R3(c, d, e, a, b, 43); + R3(b, c, d, e, a, 44); + R3(a, b, c, d, e, 45); + R3(e, a, b, c, d, 46); + R3(d, e, a, b, c, 47); + R3(c, d, e, a, b, 48); + R3(b, c, d, e, a, 49); + R3(a, b, c, d, e, 50); + R3(e, a, b, c, d, 51); + R3(d, e, a, b, c, 52); + R3(c, d, e, a, b, 53); + R3(b, c, d, e, a, 54); + R3(a, b, c, d, e, 55); + R3(e, a, b, c, d, 56); + R3(d, e, a, b, c, 57); + R3(c, d, e, a, b, 58); + R3(b, c, d, e, a, 59); + R4(a, b, c, d, e, 60); + R4(e, a, b, c, d, 61); + R4(d, e, a, b, c, 62); + R4(c, d, e, a, b, 63); + R4(b, c, d, e, a, 64); + R4(a, b, c, d, e, 65); + R4(e, a, b, c, d, 66); + R4(d, e, a, b, c, 67); + R4(c, d, e, a, b, 68); + R4(b, c, d, e, a, 69); + R4(a, b, c, d, e, 70); + R4(e, a, b, c, d, 71); + R4(d, e, a, b, c, 72); + R4(c, d, e, a, b, 73); + R4(b, c, d, e, a, 74); + R4(a, b, c, d, e, 75); + R4(e, a, b, c, d, 76); + R4(d, e, a, b, c, 77); + R4(c, d, e, a, b, 78); + R4(b, c, d, e, a, 79); + /* Add the working vars back into context.state[] */ + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + /* Wipe variables */ + a = b = c = d = e = 0; +} + + +/* SHA1Init - Initialize new context */ + +void SHA1Init(SHA1_CTX * context) +{ + /* SHA1 initialization constants */ + context->state[0] = 0x67452301; + context->state[1] = 0xEFCDAB89; + context->state[2] = 0x98BADCFE; + context->state[3] = 0x10325476; + context->state[4] = 0xC3D2E1F0; + context->count[0] = context->count[1] = 0; +} + + +/* Run your data through this. */ + +void SHA1Update(SHA1_CTX * context, unsigned char *data, unsigned int len) +{ + unsigned int i, j; + + j = (context->count[0] >> 3) & 63; + if ((context->count[0] += len << 3) < (len << 3)) + context->count[1]++; + context->count[1] += (len >> 29); + if ((j + len) > 63) { + memcpy(&context->buffer[j], data, (i = 64 - j)); + SHA1Transform(context->state, context->buffer); + for (; i + 63 < len; i += 64) { + SHA1Transform(context->state, &data[i]); + } + j = 0; + } else + i = 0; + memcpy(&context->buffer[j], &data[i], len - i); +} + + +/* Add padding and return the message digest. */ + +void SHA1Final(unsigned char digest[20], SHA1_CTX * context) +{ + unsigned long i, j; + unsigned char finalcount[8]; + + for (i = 0; i < 8; i++) { + finalcount[i] = (unsigned char) ((context->count[(i >= 4 ? 0 : 1)] + >> ((3 - (i & 3)) * 8)) & 255); /* Endian independent */ + } + SHA1Update(context, (unsigned char *) "\200", 1); + while ((context->count[0] & 504) != 448) { + SHA1Update(context, (unsigned char *) "\0", 1); + } + SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */ + for (i = 0; i < 20; i++) { + digest[i] = (unsigned char) + ((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255); + } + /* Wipe variables */ + i = j = 0; + memset(context->buffer, 0, 64); + memset(context->state, 0, 20); + memset(context->count, 0, 8); + memset(&finalcount, 0, 8); +#ifdef SHA1HANDSOFF /* make SHA1Transform overwrite it's own static vars */ + SHA1Transform(context->state, context->buffer); +#endif +} + +#ifdef SHA1_TEST +static char *b32_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; + +void g_assert(int a) +{ + /* Bah, who needs testing anyway... ;) */ +} + +static void base32_encode_exactly(unsigned char *buf, int len, + unsigned char *encbuf, int enclen) +{ + int i = 0; + unsigned char *ip = buf + len; + unsigned char *op = encbuf + enclen; + + switch (len % 5) { + case 0: + do { + g_assert(op - encbuf >= 8); + i = *--ip; /* Input #4 */ + *--op = b32_alphabet[i & 0x1f]; /* Ouput #7 */ + i >>= 5; /* upper <234>, input #4 */ + /* FALLTHROUGH */ + case 4: + i |= ((unsigned int) *--ip) << 3; /* had 3 bits in `i' */ + *--op = b32_alphabet[i & 0x1f]; /* Output #6 */ + i >>= 5; /* upper <401234>, input #3 */ + *--op = b32_alphabet[i & 0x1f]; /* Output #5 */ + i >>= 5; /* upper <4>, input #3 */ + /* FALLTHROUGH */ + case 3: + i |= ((unsigned int) *--ip) << 1; /* had 1 bits in `i' */ + *--op = b32_alphabet[i & 0x1f]; /* Output #4 */ + i >>= 5; /* upper <1234>, input #2 */ + /* FALLTHROUGH */ + case 2: + i |= ((unsigned int) *--ip) << 4; /* had 4 bits in `i' */ + *--op = b32_alphabet[i & 0x1f]; /* Output #3 */ + i >>= 5; /* upper <3401234>, input #1 */ + *--op = b32_alphabet[i & 0x1f]; /* Output #2 */ + i >>= 5; /* upper <34>, input #1 */ + /* FALLTHROUGH */ + case 1: + i |= ((unsigned int) *--ip) << 2; /* had 2 bits in `i' */ + *--op = b32_alphabet[i & 0x1f]; /* Output #1 */ + i >>= 5; /* upper <01234>, input #0 */ + *--op = b32_alphabet[i & 0x1f]; /* Output #0 */ + i >>= 5; /* Holds nothing, MBZ */ + g_assert(i == 0); + g_assert(op >= encbuf); + } while (op > encbuf); + } +} + + + +/*************************************************************/ + +int main(int argc, char **argv) +{ + int i, j; + SHA1_CTX context; + unsigned char digest[20], buffer[16384]; + FILE *file; + + if (argc > 2) { + puts("Public domain SHA-1 implementation - by Steve Reid <steve@edmweb.com>"); + puts("Produces the SHA-1 hash of a file, or stdin if no file is specified."); + exit(0); + } + if (argc < 2) { + file = stdin; + } else { + if (!(file = fopen(argv[1], "rb"))) { + fputs("Unable to open file.", stderr); + exit(-1); + } + } + SHA1Init(&context); + while (!feof(file)) { /* note: what if ferror(file) */ + i = fread(buffer, 1, 16384, file); + SHA1Update(&context, buffer, i); + } + SHA1Final(digest, &context); + fclose(file); +/* + for (i = 0; i < 5; i++) { + for (j = 0; j < 4; j++) { + printf("%02X", digest[i*4+j]); + } + putchar(' '); + } + putchar('\n'); +*/ + + { + unsigned char tmp[33]; + tmp[32] = '\0'; + base32_encode_exactly(digest, 20, tmp, 32); + printf("%s\n", tmp); + } + + exit(0); +} +#endif /* SHA1_TEST */ @@ -0,0 +1,21 @@ +/* + * SHA-1 in C + * By Steve Reid <steve@edmweb.com> + * 100% Public Domain + */ + +#ifndef __SHA1_H__ +#define __SHA1_H__ + +typedef struct { + unsigned long state[5]; + unsigned long count[2]; + unsigned char buffer[64]; +} SHA1_CTX; + +void SHA1Transform(unsigned long state[5], unsigned char buffer[64]); +void SHA1Init(SHA1_CTX* context); +void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len); +void SHA1Final(unsigned char digest[20], SHA1_CTX* context); + +#endif /* __SHA1_H__ */ diff --git a/shell.c b/shell.c new file mode 100644 index 00000000..e8ac1f5e --- /dev/null +++ b/shell.c @@ -0,0 +1,1078 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include <stdlib.h> +#include <string.h> +#include <gtk/gtk.h> + +#include <config.h> + +#include <hardinfo.h> + +#include <shell.h> +#include <iconcache.h> +#include <menu.h> +#include <stock.h> + +/* + * Internal Prototypes ******************************************************** + */ + +static void create_window(); +static ShellTree *tree_new(void); +static ShellInfoTree *info_tree_new(gboolean extra); + +static void module_selected(GtkTreeSelection * ts, gpointer data); +static void module_selected_show_info(ShellModuleEntry * entry, + gboolean reload); +static void info_selected(GtkTreeSelection * ts, gpointer data); +static void info_selected_show_extra(gchar * data); +static gboolean reload_section(gpointer data); + +/* + * Globals ******************************************************************** + */ + +static Shell *shell = NULL; +static GHashTable *update_tbl = NULL; + +/* + * Code :) ******************************************************************** + */ + +Shell *shell_get_main_shell(void) +{ + return shell; +} + +void shell_ui_manager_set_visible(const gchar *path, + gboolean setting) +{ + GtkWidget *widget; + + widget = gtk_ui_manager_get_widget(shell->ui_manager, path); + if (!widget) + return; + + if (setting) + gtk_widget_show(widget); + else + gtk_widget_hide(widget); +} + +void shell_action_set_property(const gchar *action_name, + const gchar *property, + gboolean setting) +{ + GtkAction *action; + + action = gtk_action_group_get_action(shell->action_group, action_name); + if (action) { + GValue value = {0}; + + g_value_init(&value, G_TYPE_BOOLEAN); + g_value_set_boolean(&value, setting); + + g_object_set_property(G_OBJECT(action), property, &value); + + g_value_unset(&value); + } +} + +void shell_action_set_enabled(const gchar *action_name, gboolean setting) +{ + GtkAction *action; + + action = gtk_action_group_get_action(shell->action_group, action_name); + if (action) { + gtk_action_set_sensitive(action, setting); + } +} + +void shell_set_left_pane_visible(gboolean setting) +{ + if (setting) + gtk_widget_show(shell->tree->scroll); + else + gtk_widget_hide(shell->tree->scroll); +} + +gboolean shell_action_get_active(const gchar *action_name) +{ + GtkAction *action; + GSList *proxies; + + /* FIXME: Ugh. Are you sure there isn't any simpler way? O_o */ + + action = gtk_action_group_get_action(shell->action_group, action_name); + if (action) { + proxies = gtk_action_get_proxies(action); + + for (; proxies; proxies = proxies->next) { + GtkWidget *widget = (GtkWidget *)proxies->data; + + if (GTK_IS_CHECK_MENU_ITEM(widget)) { + return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); + } + } + } + + return FALSE; +} + +void shell_action_set_active(const gchar *action_name, gboolean setting) +{ + GtkAction *action; + GSList *proxies; + + /* FIXME: Ugh. Are you sure there isn't any simpler way? O_o */ + + action = gtk_action_group_get_action(shell->action_group, action_name); + if (action) { + proxies = gtk_action_get_proxies(action); + + for (; proxies; proxies = proxies->next) { + GtkWidget *widget = (GtkWidget *)proxies->data; + + if (GTK_IS_CHECK_MENU_ITEM(widget)) { + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), setting); + return; + } + } + } +} + +void +shell_status_pulse(void) +{ + gtk_progress_bar_pulse(GTK_PROGRESS_BAR(shell->progress)); + while (gtk_events_pending()) + gtk_main_iteration(); +} + +void +shell_status_set_percentage(gint percentage) +{ + gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(shell->progress), + (float)percentage/100.0); + while (gtk_events_pending()) + gtk_main_iteration(); +} + +void +shell_view_set_enabled(gboolean setting) +{ + if (setting) { + widget_set_cursor(shell->window, GDK_LEFT_PTR); + } else { + widget_set_cursor(shell->window, GDK_WATCH); + } + + gtk_widget_set_sensitive(shell->hpaned, setting); + shell_action_set_enabled("ViewMenuAction", setting); + shell_action_set_enabled("RefreshAction", setting); + shell_action_set_enabled("ReportAction", setting); +} + +void +shell_status_set_enabled(gboolean setting) +{ + if (setting) + gtk_widget_show(shell->progress); + else { + gtk_widget_hide(shell->progress); + shell_view_set_enabled(TRUE); + } +} + +void +shell_do_reload(void) +{ + shell_action_set_enabled("RefreshAction", FALSE); + shell_action_set_enabled("ReportAction", FALSE); + + if (shell->selected && shell->selected->reloadfunc) { + GtkTreeSelection *ts; + + ts = gtk_tree_view_get_selection(GTK_TREE_VIEW(shell->tree->view)); + shell_status_set_enabled(TRUE); + + shell->selected->reloadfunc(shell->selected->number); + module_selected(ts, NULL); + } + + shell_action_set_enabled("RefreshAction", TRUE); + shell_action_set_enabled("ReportAction", TRUE); +} + +void +shell_status_update(const gchar *message) +{ + gtk_label_set_markup(GTK_LABEL(shell->status), message); + gtk_progress_bar_pulse(GTK_PROGRESS_BAR(shell->progress)); + while (gtk_events_pending()) + gtk_main_iteration(); +} + +static void +destroy_me(void) +{ + gtk_main_quit(); + exit(0); +} + +static void +create_window(void) +{ + GtkWidget *vbox, *hbox; + + shell = g_new0(Shell, 1); + + shell->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_icon(GTK_WINDOW(shell->window), + icon_cache_get_pixbuf("logo.png")); + gtk_window_set_title(GTK_WINDOW(shell->window), "System Information"); + gtk_widget_set_size_request(shell->window, 600, 400); + g_signal_connect(G_OBJECT(shell->window), "destroy", destroy_me, NULL); + + vbox = gtk_vbox_new(FALSE, 0); + gtk_widget_show(vbox); + gtk_container_add(GTK_CONTAINER(shell->window), vbox); + shell->vbox = vbox; + + menu_init(shell); + + hbox = gtk_hbox_new(FALSE, 5); + gtk_widget_show(hbox); + gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 3); + + shell->progress = gtk_progress_bar_new(); + gtk_widget_set_size_request(shell->progress, 70, 10); + gtk_widget_hide(shell->progress); + gtk_box_pack_end(GTK_BOX(hbox), shell->progress, FALSE, FALSE, 0); + + shell->status = gtk_label_new(""); + gtk_misc_set_alignment(GTK_MISC(shell->status), 0.0, 0.5); + gtk_widget_show(shell->status); + gtk_box_pack_start(GTK_BOX(hbox), shell->status, FALSE, FALSE, 0); + + shell->hpaned = gtk_hpaned_new(); + gtk_widget_show(shell->hpaned); + gtk_box_pack_end(GTK_BOX(vbox), shell->hpaned, TRUE, TRUE, 0); + gtk_paned_set_position(GTK_PANED(shell->hpaned), 210); + + shell->vpaned = gtk_vpaned_new(); + gtk_widget_show(shell->vpaned); + gtk_paned_add2(GTK_PANED(shell->hpaned), shell->vpaned); + + shell->notebook = gtk_notebook_new(); + gtk_paned_add2(GTK_PANED(shell->vpaned), shell->notebook); + + gtk_widget_show(shell->window); + while (gtk_events_pending()) + gtk_main_iteration(); +} + +static void +shell_tree_modules_load(ShellTree * shelltree) +{ + GKeyFile *keyfile = g_key_file_new(); + guint categories, i; + + keyfile = g_key_file_new(); + g_key_file_load_from_file(keyfile, PREFIX "modules.conf", 0, NULL); + if (g_key_file_get_integer(keyfile, "general", "version", NULL) != 2) { + g_error("Wrong version of modules.conf"); + } + + gchar **cat = g_key_file_get_keys(keyfile, "categories", &categories, NULL); + for (i = 0; i < categories; i++) { + ShellModule *module; + gchar *tmp, *iname; + + module = g_new0(ShellModule, 1); + module->name = g_strdup(cat[i]); + iname = g_key_file_get_value(keyfile, "categories", cat[i], NULL); + + tmp = g_strdup_printf("%s.png", iname); + module->icon = icon_cache_get_pixbuf(tmp); + g_free(tmp); + + tmp = g_strdup_printf(PREFIX "modules/%s.so", iname); + module->dll = g_module_open(tmp, G_MODULE_BIND_LAZY); + g_free(tmp); + + if (module->dll) { + gint(*n_entries) (void); + gint i; + + if (!g_module_symbol(module->dll, "hi_n_entries", (gpointer) & n_entries)) + continue; + + gint j = n_entries(); + for (i = 0; i <= j; i++) { + GdkPixbuf *(*shell_icon) (gint); + const gchar *(*shell_name) (gint); + ShellModuleEntry *entry = g_new0(ShellModuleEntry, 1); + + if (g_module_symbol(module->dll, "hi_icon", (gpointer)&(shell_icon))) { + entry->icon = shell_icon(i); + } + if (g_module_symbol(module->dll, "hi_name", (gpointer)&(shell_name))) { + entry->name = g_strdup(shell_name(i)); + } + g_module_symbol(module->dll, "hi_info", + (gpointer) & (entry->func)); + g_module_symbol(module->dll, "hi_reload", + (gpointer) & (entry->reloadfunc)); + g_module_symbol(module->dll, "hi_more_info", + (gpointer) & (entry->morefunc)); + g_module_symbol(module->dll, "hi_get_field", + (gpointer) & (entry->fieldfunc)); + + entry->number = i; + module->entries = g_slist_append(module->entries, entry); + } + + shelltree->modules = g_slist_append(shelltree->modules, module); + } else { + g_free(module->name); + g_free(module->icon); + g_free(module); + } + + g_free(iname); + } + + g_strfreev(cat); + g_key_file_free(keyfile); +} + +static void view_menu_select_entry(gpointer data, gpointer data2) +{ + GtkTreeSelection *ts; + GtkTreePath *path; + GtkTreeIter *iter = (GtkTreeIter*) data2; + + ts = gtk_tree_view_get_selection(GTK_TREE_VIEW(shell->tree->view)); + path = gtk_tree_model_get_path(shell->tree->model, iter); + + gtk_tree_selection_select_path(ts, path); + gtk_tree_view_set_cursor(GTK_TREE_VIEW(shell->tree->view), path, NULL, FALSE); + gtk_tree_path_free(path); +} + +static void +add_module_to_view_menu(gchar *name, GdkPixbuf *pixbuf) +{ + stock_icon_register_pixbuf(pixbuf, name); + + GtkActionEntry entries[] = { + { name, /* name */ + name, /* stockid */ + name, /* label */ + NULL, /* accelerator */ + NULL, /* tooltip */ + NULL, /* callback */ + }, + }; + + gtk_action_group_add_actions(shell->action_group, entries, 1, NULL); + + gtk_ui_manager_add_ui(shell->ui_manager, + gtk_ui_manager_new_merge_id(shell->ui_manager), + "/menubar/ViewMenu/LastSep", + name, + name, + GTK_UI_MANAGER_MENU, + TRUE); +} + +static void +add_module_entry_to_view_menu(gchar *module, gchar *name, GdkPixbuf *pixbuf, GtkTreeIter *iter) +{ + stock_icon_register_pixbuf(pixbuf, name); + + GtkActionEntry entries[] = { + { name, /* name */ + name, /* stockid */ + name, /* label */ + NULL, /* accelerator */ + NULL, /* tooltip */ + (GCallback)view_menu_select_entry,/* callback */ + }, + }; + + gtk_action_group_add_actions(shell->action_group, entries, 1, iter); + + gtk_ui_manager_add_ui(shell->ui_manager, + gtk_ui_manager_new_merge_id(shell->ui_manager), + g_strdup_printf("/menubar/ViewMenu/%s", module), + name, + name, + GTK_UI_MANAGER_AUTO, + FALSE); +} + +static void +add_modules_to_gui(gpointer data, gpointer user_data) +{ + ShellTree *shelltree = (ShellTree *) user_data; + ShellModule *module = (ShellModule *) data; + GtkTreeStore *store = GTK_TREE_STORE(shelltree->model); + GtkTreeIter parent; + + gtk_tree_store_append(store, &parent, NULL); + gtk_tree_store_set(store, &parent, TREE_COL_NAME, module->name, + TREE_COL_DATA, NULL, + TREE_COL_SEL, FALSE, -1); + + if (module->icon) { + gtk_tree_store_set(store, &parent, TREE_COL_PBUF, module->icon, -1); + } + + add_module_to_view_menu(module->name, module->icon); + + if (module->entries) { + ShellModuleEntry *entry; + GSList *p; + + for (p = module->entries; p; p = g_slist_next(p)) { + GtkTreeIter child; + entry = (ShellModuleEntry *) p->data; + + gtk_tree_store_append(store, &child, &parent); + gtk_tree_store_set(store, &child, TREE_COL_NAME, entry->name, + TREE_COL_DATA, entry, + TREE_COL_SEL, FALSE, -1); + + if (entry->icon) { + gtk_tree_store_set(store, &child, TREE_COL_PBUF, + entry->icon, -1); + } + + add_module_entry_to_view_menu(module->name, entry->name, entry->icon, + gtk_tree_iter_copy(&child)); + + shell_status_pulse(); + } + + } +} + +void +shell_init(void) +{ + if (shell) { + g_error("Shell already created"); + return; + } + + create_window(); + + shell->tree = tree_new(); + shell->info = info_tree_new(FALSE); + shell->moreinfo = info_tree_new(TRUE); + shell->loadgraph = load_graph_new(75); + + gtk_paned_pack1(GTK_PANED(shell->hpaned), shell->tree->scroll, + SHELL_PACK_RESIZE, SHELL_PACK_SHRINK); + gtk_paned_pack1(GTK_PANED(shell->vpaned), shell->info->scroll, + SHELL_PACK_RESIZE, SHELL_PACK_SHRINK); + + gtk_notebook_append_page(GTK_NOTEBOOK(shell->notebook), + shell->moreinfo->scroll, NULL); + gtk_notebook_append_page(GTK_NOTEBOOK(shell->notebook), + load_graph_get_framed(shell->loadgraph), NULL); + + gtk_notebook_set_show_tabs(GTK_NOTEBOOK(shell->notebook), FALSE); + gtk_notebook_set_show_border(GTK_NOTEBOOK(shell->notebook), FALSE); + + shell_status_set_enabled(TRUE); + shell_status_update("Loading modules..."); + + shell_tree_modules_load(shell->tree); + g_slist_foreach(shell->tree->modules, add_modules_to_gui, shell->tree); + gtk_tree_view_expand_all(GTK_TREE_VIEW(shell->tree->view)); + + shell_status_update("Done."); + shell_status_set_enabled(FALSE); + + gtk_widget_show_all(shell->hpaned); + + load_graph_configure_expose(shell->loadgraph); + + gtk_widget_hide(shell->notebook); + + shell_action_set_enabled("RefreshAction", FALSE); + shell_action_set_active("LeftPaneAction", TRUE); + shell_action_set_active("ToolbarAction", TRUE); + shell_action_set_property("RefreshAction", "is-important", TRUE); + shell_action_set_property("ReportAction", "is-important", TRUE); +} + +static gboolean +update_field(gpointer data) +{ + ShellFieldUpdate *fu = (ShellFieldUpdate *) data; + + /* if the entry is still selected, update it */ + if (fu->entry->selected && fu->entry->fieldfunc) { + gchar *value = fu->entry->fieldfunc(fu->field_name); + GtkTreeIter *iter = g_hash_table_lookup(update_tbl, fu->field_name); + + /* this function is also used to feed the load graph when ViewType = + SHELL_VIEW_LOAD_GRAPH */ + if (fu->loadgraph && shell->view_type == SHELL_VIEW_LOAD_GRAPH) { + GtkTreeSelection *ts; + + ts = gtk_tree_view_get_selection(GTK_TREE_VIEW + (shell->info->view)); + + if (iter && gtk_tree_selection_iter_is_selected(ts, iter)) { + load_graph_update(shell->loadgraph, atoi(value)); + } + + g_free(value); + + return TRUE; + } + + if (iter) { + GtkTreeStore *store = GTK_TREE_STORE(shell->info->model); + + gtk_tree_store_set(store, iter, INFO_TREE_COL_VALUE, value, -1); + g_free(value); + + return TRUE; + } + } + + /* otherwise, cleanup and destroy the timeout */ + g_free(fu->field_name); + g_free(fu); + + return FALSE; +} + +static gboolean +reload_section(gpointer data) +{ + ShellModuleEntry *entry = (ShellModuleEntry *) data; + + /* if the entry is still selected, update it */ + if (entry->selected && entry->reloadfunc) { + GtkTreePath *path = NULL; + GtkTreeSelection *ts; + GtkTreeIter iter; + + /* gets the current selected path */ + ts = gtk_tree_view_get_selection(GTK_TREE_VIEW + (shell->info->view)); + if (gtk_tree_selection_get_selected(ts, &shell->info->model, &iter)) + path = gtk_tree_model_get_path(shell->info->model, &iter); + + /* update the information, clear the treeview and populate it again */ + entry->reloadfunc(entry->number); + info_selected_show_extra(NULL); /* clears the more info store */ + module_selected_show_info(entry, TRUE); + + /* if there was a selection, reselect it */ + if (path) { + gtk_tree_selection_select_path(ts, path); + gtk_tree_path_free(path); + } + } + + /* destroy the timeout: it'll be set up again */ + return FALSE; +} + +static void +set_view_type(ShellViewType viewtype) +{ + gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(shell->info->view), FALSE); + + if (viewtype == shell->view_type) + return; + + switch (viewtype) { + default: + case SHELL_VIEW_NORMAL: + gtk_widget_hide(shell->notebook); + + shell->view_type = SHELL_VIEW_NORMAL; + break; + case SHELL_VIEW_DUAL: + gtk_notebook_set_page(GTK_NOTEBOOK(shell->notebook), 0); + gtk_widget_show(shell->notebook); + + shell->view_type = SHELL_VIEW_DUAL; + break; + case SHELL_VIEW_LOAD_GRAPH: + gtk_notebook_set_page(GTK_NOTEBOOK(shell->notebook), 1); + gtk_widget_show(shell->notebook); + load_graph_clear(shell->loadgraph); + + gtk_paned_set_position(GTK_PANED(shell->vpaned), + shell->hpaned->allocation.height - + shell->loadgraph->height - 16); + + shell->view_type = SHELL_VIEW_LOAD_GRAPH; + break; + } +} + +static void +group_handle_special(GKeyFile * key_file, ShellModuleEntry * entry, + gchar * group, gchar ** keys) +{ + if (g_str_equal(group, "$ShellParam$")) { + gint i; + + for (i = 0; keys[i]; i++) { + gchar *key = keys[i]; + + if (g_str_has_prefix(key, "UpdateInterval")) { + gint ms; + ShellFieldUpdate *fu = g_new0(ShellFieldUpdate, 1); + + ms = g_key_file_get_integer(key_file, group, key, NULL); + + fu->field_name = g_strdup(strchr(key, '$') + 1); + fu->entry = entry; + fu->loadgraph = FALSE; + + g_timeout_add(ms, update_field, fu); + } else if (g_str_has_prefix(key, "LoadGraphInterval")) { + gint ms; + ShellFieldUpdate *fu = g_new0(ShellFieldUpdate, 1); + + ms = g_key_file_get_integer(key_file, group, key, NULL); + + fu->field_name = g_strdup(strchr(key, '$') + 1); + fu->entry = entry; + fu->loadgraph = TRUE; + + g_timeout_add(ms, update_field, fu); + } else if (g_str_equal(key, "ReloadInterval")) { + gint ms; + + ms = g_key_file_get_integer(key_file, group, key, NULL); + + g_timeout_add(ms, reload_section, entry); + } else if (g_str_equal(key, "ViewType")) { + set_view_type(g_key_file_get_integer(key_file, group, + key, NULL)); + } else if (g_str_has_prefix(key, "Icon")) { + GtkTreeIter *iter = g_hash_table_lookup(update_tbl, + strchr(key, '$') + 1); + + if (iter) { + gchar *file = g_key_file_get_value(key_file, group, key, NULL); + gtk_tree_store_set(GTK_TREE_STORE(shell->info->model), + iter, INFO_TREE_COL_PBUF, + icon_cache_get_pixbuf_at_size(file, 24, 24), + -1); + g_free(file); + } + } else if (g_str_equal(key, "Zebra")) { + gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(shell->info->view), + g_key_file_get_boolean(key_file, + group, + key, NULL)); + } + } + } else { + g_warning("Unknown parameter group '%s'", group); + } +} + +static void +group_handle_normal(GKeyFile * key_file, ShellModuleEntry * entry, + gchar * group, gchar ** keys) +{ + GtkTreeIter parent; + GtkTreeStore *store = GTK_TREE_STORE(shell->info->model); + gchar *tmp = g_strdup(group); + gint i; + + gtk_tree_store_append(store, &parent, NULL); + + strend(tmp, '#'); + gtk_tree_store_set(store, &parent, INFO_TREE_COL_NAME, tmp, -1); + g_free(tmp); + + for (i = 0; keys[i]; i++) { + gchar *key = keys[i]; + gchar *value; + GtkTreeIter child; + + value = g_key_file_get_value(key_file, group, key, NULL); + + if (g_utf8_validate(key, -1, NULL) && g_utf8_validate(value, -1, NULL)) { + gtk_tree_store_append(store, &child, &parent); + gtk_tree_store_set(store, &child, INFO_TREE_COL_VALUE, value, -1); + + strend(key, '#'); + + if (*key == '$') { + gchar **tmp; + + tmp = g_strsplit(++key, "$", 0); + + gtk_tree_store_set(store, &child, INFO_TREE_COL_NAME, tmp[1], + INFO_TREE_COL_DATA, tmp[0], -1); + + g_strfreev(tmp); + } else { + gtk_tree_store_set(store, &child, INFO_TREE_COL_NAME, key, + INFO_TREE_COL_DATA, NULL, -1); + } + + g_hash_table_insert(update_tbl, g_strdup(key), + gtk_tree_iter_copy(&child)); + + } + + g_free(value); + } +} + +static void +moreinfo_handle_normal(GKeyFile * key_file, gchar * group, gchar ** keys) +{ + GtkTreeIter parent; + GtkTreeStore *store = GTK_TREE_STORE(shell->moreinfo->model); + gint i; + + gtk_tree_store_append(store, &parent, NULL); + gtk_tree_store_set(store, &parent, INFO_TREE_COL_NAME, group, -1); + + for (i = 0; keys[i]; i++) { + gchar *key = keys[i]; + GtkTreeIter child; + gchar *value; + + value = g_key_file_get_value(key_file, group, key, NULL); + + if (g_utf8_validate(key, -1, NULL) && g_utf8_validate(value, -1, NULL)) { + strend(key, '#'); + + gtk_tree_store_append(store, &child, &parent); + gtk_tree_store_set(store, &child, INFO_TREE_COL_VALUE, value, + INFO_TREE_COL_NAME, key, -1); + } + + g_free(value); + } +} + +static gboolean +g_true(gpointer key, gpointer value, gpointer data) +{ + return TRUE; +} + +static void +module_selected_show_info(ShellModuleEntry * entry, gboolean reload) +{ + GKeyFile *key_file = g_key_file_new(); + gchar *key_data; + gchar **groups; + GtkTreeStore *store; + gint i; + + if (entry->func) { + key_data = entry->func(entry->number); + } else { + key_data = g_strdup("[Error]\n" + "Invalid module="); + } + + /* reset the view type to normal */ + set_view_type(SHELL_VIEW_NORMAL); + + /* recreate the iter hash table only if we're not reloading the module section */ + if (!reload) { + if (update_tbl != NULL) { + g_hash_table_foreach_remove(update_tbl, g_true, NULL); + } + update_tbl = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + } + + store = GTK_TREE_STORE(shell->info->model); + gtk_tree_store_clear(store); + + g_key_file_load_from_data(key_file, key_data, strlen(key_data), 0, NULL); + groups = g_key_file_get_groups(key_file, NULL); + + for (i = 0; groups[i]; i++) { + gchar *group = groups[i]; + gchar **keys = g_key_file_get_keys(key_file, group, NULL, NULL); + + if (*group == '$') { + group_handle_special(key_file, entry, group, keys); + } else { + group_handle_normal(key_file, entry, group, keys); + } + } + + gtk_tree_view_expand_all(GTK_TREE_VIEW(shell->info->view)); + + g_strfreev(groups); + g_key_file_free(key_file); + g_free(key_data); +} + +static void +info_selected_show_extra(gchar * data) +{ + GtkTreeStore *store; + + store = GTK_TREE_STORE(shell->moreinfo->model); + gtk_tree_store_clear(store); + + if (!shell->selected->morefunc) + return; + + if (data) { + GKeyFile *key_file = g_key_file_new(); + gchar *key_data = shell->selected->morefunc(data); + gchar **groups; + gint i; + + g_key_file_load_from_data(key_file, key_data, strlen(key_data), 0, + NULL); + groups = g_key_file_get_groups(key_file, NULL); + + for (i = 0; groups[i]; i++) { + gchar *group = groups[i]; + gchar **keys = g_key_file_get_keys(key_file, group, NULL, NULL); + + moreinfo_handle_normal(key_file, group, keys); + } + + gtk_tree_view_expand_all(GTK_TREE_VIEW + (shell->moreinfo->view)); + + g_strfreev(groups); + g_key_file_free(key_file); + g_free(key_data); + } +} + +static void +module_selected(GtkTreeSelection * ts, gpointer data) +{ + ShellTree *shelltree = shell->tree; + GtkTreeModel *model = GTK_TREE_MODEL(shelltree->model); + GtkTreeIter parent; + ShellModuleEntry *entry; + static ShellModuleEntry *current = NULL; + static gboolean updating = FALSE; + + if (updating) + return; + + updating = TRUE; + + /* Gets the currently selected item on the left-side TreeView; if there is no + selection, silently return */ + if (!gtk_tree_selection_get_selected(ts, &model, &parent)) + return; + + /* Mark the currently selected module as "unselected"; this is used to kill the + update timeout. */ + if (current) + current->selected = FALSE; + + /* Get the current selection and shows its related info */ + gtk_tree_model_get(model, &parent, TREE_COL_DATA, &entry, -1); + if (entry && entry->func && !entry->selected) { + shell_status_set_enabled(TRUE); + shell_status_update("Updating..."); + + entry->selected = TRUE; + shell->selected = entry; + module_selected_show_info(entry, FALSE); + + info_selected_show_extra(NULL); /* clears the more info store */ + gtk_tree_view_columns_autosize(GTK_TREE_VIEW(shell->info->view)); + + /* urgh. why don't GTK do this when the model is cleared? */ + gtk_range_set_value(GTK_RANGE(GTK_SCROLLED_WINDOW(shell->info->scroll)->vscrollbar), 0.0); + gtk_range_set_value(GTK_RANGE(GTK_SCROLLED_WINDOW(shell->info->scroll)->hscrollbar), 0.0); + gtk_range_set_value(GTK_RANGE(GTK_SCROLLED_WINDOW(shell->moreinfo->scroll)->vscrollbar), 0.0); + gtk_range_set_value(GTK_RANGE(GTK_SCROLLED_WINDOW(shell->moreinfo->scroll)->hscrollbar), 0.0); + + shell_status_update("Done."); + shell_status_set_enabled(FALSE); + + gchar *tmp = g_strdup_printf("%s - System Information", entry->name); + gtk_window_set_title(GTK_WINDOW(shell->window), tmp); + g_free(tmp); + + shell_action_set_enabled("RefreshAction", entry->reloadfunc ? TRUE : FALSE); + } else { + gtk_window_set_title(GTK_WINDOW(shell->window), "System Information"); + shell_action_set_enabled("RefreshAction", FALSE); + + gtk_tree_store_clear(GTK_TREE_STORE(shell->info->model)); + set_view_type(SHELL_VIEW_NORMAL); + } + + current = entry; + updating = FALSE; +} + +static void +info_selected(GtkTreeSelection * ts, gpointer data) +{ + ShellInfoTree *info = (ShellInfoTree *) data; + GtkTreeModel *model = GTK_TREE_MODEL(info->model); + GtkTreeIter parent; + gchar *datacol; + + if (!gtk_tree_selection_get_selected(ts, &model, &parent)) + return; + + gtk_tree_model_get(model, &parent, INFO_TREE_COL_DATA, &datacol, -1); + info_selected_show_extra(datacol); + gtk_tree_view_columns_autosize(GTK_TREE_VIEW + (shell->moreinfo->view)); +} + +static ShellInfoTree * +info_tree_new(gboolean extra) +{ + ShellInfoTree *info; + GtkWidget *treeview, *scroll; + GtkTreeModel *model; + GtkTreeStore *store; + GtkTreeViewColumn *column; + GtkCellRenderer *cr_text, *cr_pbuf; + + info = g_new0(ShellInfoTree, 1); + + scroll = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW + (scroll), GTK_SHADOW_IN); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + + store = gtk_tree_store_new(INFO_TREE_NCOL, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, GDK_TYPE_PIXBUF); + model = GTK_TREE_MODEL(store); + treeview = gtk_tree_view_new_with_model(model); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); + + column = gtk_tree_view_column_new(); + gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); + + cr_pbuf = gtk_cell_renderer_pixbuf_new(); + gtk_tree_view_column_pack_start(column, cr_pbuf, FALSE); + gtk_tree_view_column_add_attribute(column, cr_pbuf, "pixbuf", + INFO_TREE_COL_PBUF); + + cr_text = gtk_cell_renderer_text_new(); + gtk_tree_view_column_pack_start(column, cr_text, TRUE); + gtk_tree_view_column_add_attribute(column, cr_text, "markup", + INFO_TREE_COL_NAME); + + column = gtk_tree_view_column_new(); + gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); + + cr_text = gtk_cell_renderer_text_new(); + gtk_tree_view_column_pack_start(column, cr_text, TRUE); + gtk_tree_view_column_add_attribute(column, cr_text, "markup", + INFO_TREE_COL_VALUE); + + if (!extra) { + GtkTreeSelection *sel; + + sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); + g_signal_connect(G_OBJECT(sel), "changed", + (GCallback) info_selected, info); + } + + gtk_container_add(GTK_CONTAINER(scroll), treeview); + + info->scroll = scroll; + info->view = treeview; + info->model = model; + + gtk_widget_show_all(scroll); + + return info; +} + +static ShellTree * +tree_new() +{ + ShellTree *shelltree; + GtkWidget *treeview, *scroll; + GtkTreeModel *model; + GtkTreeStore *store; + GtkCellRenderer *cr_text, *cr_pbuf; + GtkTreeViewColumn *column; + GtkTreeSelection *sel; + + shelltree = g_new0(ShellTree, 1); + + scroll = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW + (scroll), GTK_SHADOW_IN); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + + store = gtk_tree_store_new(TREE_NCOL, GDK_TYPE_PIXBUF, G_TYPE_STRING, + G_TYPE_POINTER, G_TYPE_BOOLEAN); + model = GTK_TREE_MODEL(store); + treeview = gtk_tree_view_new_with_model(model); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); + + column = gtk_tree_view_column_new(); + gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); + + cr_pbuf = gtk_cell_renderer_pixbuf_new(); + cr_text = gtk_cell_renderer_text_new(); + gtk_tree_view_column_pack_start(column, cr_pbuf, FALSE); + gtk_tree_view_column_pack_start(column, cr_text, TRUE); + + gtk_tree_view_column_add_attribute(column, cr_pbuf, "pixbuf", + TREE_COL_PBUF); + gtk_tree_view_column_add_attribute(column, cr_text, "markup", + TREE_COL_NAME); + + sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); + g_signal_connect(G_OBJECT(sel), "changed", (GCallback) module_selected, + NULL); + + gtk_container_add(GTK_CONTAINER(scroll), treeview); + + shelltree->scroll = scroll; + shelltree->view = treeview; + shelltree->model = model; + shelltree->modules = NULL; + + gtk_widget_show_all(scroll); + + return shelltree; +} diff --git a/shell.h b/shell.h new file mode 100644 index 00000000..54745bb6 --- /dev/null +++ b/shell.h @@ -0,0 +1,142 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __SHELL_H__ +#define __SHELL_H__ + +#include <gtk/gtk.h> +#include <loadgraph.h> + +typedef struct _Shell Shell; +typedef struct _ShellTree ShellTree; +typedef struct _ShellInfoTree ShellInfoTree; + +typedef struct _ShellModule ShellModule; +typedef struct _ShellModuleEntry ShellModuleEntry; + +typedef struct _ShellFieldUpdate ShellFieldUpdate; + +typedef enum { + SHELL_PACK_RESIZE = 1 << 0, + SHELL_PACK_SHRINK = 1 << 1 +} ShellPackOptions; + +typedef enum { + SHELL_VIEW_NORMAL, + SHELL_VIEW_DUAL, + SHELL_VIEW_LOAD_GRAPH, +} ShellViewType; + +typedef enum { + TREE_COL_PBUF, + TREE_COL_NAME, + TREE_COL_DATA, + TREE_COL_SEL, + TREE_NCOL +} ShellTreeColumns; + +typedef enum { + INFO_TREE_COL_NAME, + INFO_TREE_COL_VALUE, + INFO_TREE_COL_DATA, + INFO_TREE_COL_PBUF, + INFO_TREE_NCOL +} ShellInfoTreeColumns; + +struct _Shell { + GtkWidget *window, *vbox; + GtkWidget *status, *progress; + GtkWidget *notebook; + GtkWidget *hpaned, *vpaned; + + ShellTree *tree; + ShellInfoTree *info, *moreinfo; + ShellModuleEntry *selected; + LoadGraph *loadgraph; + + GtkActionGroup *action_group; + GtkUIManager *ui_manager; + + ShellViewType view_type; +}; + +struct _ShellTree { + GtkWidget *scroll; + GtkWidget *view; + GtkTreeModel *model; + + GSList *modules; +}; + +struct _ShellInfoTree { + GtkWidget *scroll; + GtkWidget *view; + GtkTreeModel *model; +}; + +struct _ShellModule { + gchar *name; + GdkPixbuf *icon; + GModule *dll; + + GSList *entries; +}; + +struct _ShellModuleEntry { + gchar *name; + gint number; + GdkPixbuf *icon; + gboolean selected; + + gchar *(*func) (gint entry); + gchar *(*reloadfunc) (gint entry); + gchar *(*fieldfunc) (gchar * entry); + gchar *(*morefunc) (gchar * entry); +}; + +struct _ShellFieldUpdate { + ShellModuleEntry *entry; + gchar *field_name; + gboolean loadgraph; +}; + +void shell_init(void); +void shell_do_reload(void); + +Shell *shell_get_main_shell(); + +void shell_action_set_enabled(const gchar *action_name, + gboolean setting); +gboolean shell_action_get_active(const gchar *action_name); +void shell_action_set_active(const gchar *action_name, + gboolean setting); +void shell_action_set_property(const gchar *action_name, + const gchar *property, + gboolean setting); + +void shell_set_left_pane_visible(gboolean setting); +void shell_ui_manager_set_visible(const gchar *path, + gboolean setting); + +void shell_status_update(const gchar *message); +void shell_status_pulse(void); +void shell_status_set_percentage(gint percentage); +void shell_status_set_enabled(gboolean setting); + +void shell_view_set_enabled(gboolean setting); + +#endif /* __SHELL_H__ */ diff --git a/status.c b/status.c deleted file mode 100644 index 626093ff..00000000 --- a/status.c +++ /dev/null @@ -1,69 +0,0 @@ -#include "config.h" -#include "status.h" - -myStatus *my_status_new(gchar *title, gchar *text) -{ - GtkWidget *window, *label, *hbox, *img, *vbox, *progress; - myStatus *status; - - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(window), title); - gtk_container_set_border_width(GTK_CONTAINER(window), 15); - gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS); - - hbox = gtk_hbox_new(FALSE, 5); - gtk_widget_show(hbox); - gtk_container_add(GTK_CONTAINER(window), hbox); - - img = gtk_image_new_from_file(IMG_PREFIX "logo.png"); - gtk_widget_show(img); - gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); - gtk_widget_set_usize(GTK_WIDGET(img), 96, 64); - - vbox = gtk_vbox_new(FALSE, 5); - gtk_widget_show(vbox); - gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); - - label = gtk_label_new(text); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); - - progress = gtk_progress_bar_new(); - gtk_widget_show(progress); - gtk_box_pack_start(GTK_BOX(vbox), progress, TRUE, FALSE, 0); - - gtk_widget_show(window); - - status = g_new0(myStatus, 1); - status->window = window; - status->label = label; - status->progress = progress; - - return status; -} - -void my_status_pulse(myStatus *status) -{ - gtk_progress_bar_pulse(GTK_PROGRESS_BAR(status->progress)); - - while (gtk_events_pending()) - gtk_main_iteration(); -} - -void my_status_destroy(myStatus *status) -{ - gtk_widget_destroy(status->window); - g_free(status); - status = NULL; -} - -void my_status_set_text(myStatus *status, gchar *text) -{ - gtk_label_set_markup(GTK_LABEL(status->label), text); - - while (gtk_events_pending()) - gtk_main_iteration(); -} - diff --git a/status.h b/status.h deleted file mode 100644 index a7e6fbe6..00000000 --- a/status.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __STATUS_H__ -#define __STATUS_H__ - -#include <gtk/gtk.h> -#include "hardinfo.h" - -typedef struct _myStatus myStatus; - -struct _myStatus { - GtkWidget *window; - GtkWidget *label; - GtkWidget *progress; -}; - -myStatus *my_status_new(gchar *title, gchar *text); -void my_status_pulse(myStatus *status); -void my_status_destroy(myStatus *status); -void my_status_set_text(myStatus *status, gchar *text); - -#endif /* __STATUS_H__ */ @@ -1,64 +1,80 @@ /* - * Based on GAIM's stock.c - * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org> + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> * - * Also distributed under GNU GPL version 2. - */ - + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + #include <gtk/gtk.h> -#include "stock.h" -#include "hardinfo.h" -#include "config.h" - -static struct StockIcon { - const char *name; - const char *filename; -} const stock_icons[] = { - { HI_ABOUT, "stock-about-16.png" }, - { HI_DETAILS, "stock-details.png" } -}; +#include <stock.h> +#include <iconcache.h> -const GtkStockItem stock_items[] = { - { HI_ABOUT, "About...", 0, 0, NULL }, - { HI_DETAILS, "_Details...", 0, 0, NULL } +static struct { + gchar *filename; + gchar *stock_id; +} stock_icons[] = { + { "report.png", HI_STOCK_REPORT} }; -static gint stock_icon_count = sizeof stock_icons / sizeof(*stock_icons); -static gint stock_item_count = sizeof stock_items / sizeof(*stock_items); -static gboolean stock_inited = FALSE; +static GtkIconFactory *icon_factory; -void hi_stock_init(void) +void stock_icon_register(gchar *filename, gchar *stock_id) { - GtkIconFactory *ift; - int i; - GtkWidget *win; - - if (stock_inited) return; - - ift = gtk_icon_factory_new(); - gtk_icon_factory_add_default(ift); - - win = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_widget_realize(win); - - for (i = 0; i < stock_icon_count; i++) { - GdkPixbuf *pixbuf; - GtkIconSet *iconset; - gchar *filename; - - filename = g_strdup_printf("%s/%s", IMG_PREFIX, stock_icons[i].filename); - pixbuf = gdk_pixbuf_new_from_file(filename, NULL); - g_free(filename); - - iconset = gtk_icon_set_new_from_pixbuf(pixbuf); - gtk_icon_factory_add(ift, stock_icons[i].name, iconset); - gtk_icon_set_unref(iconset); - } - - gtk_widget_destroy(win); - g_object_unref(G_OBJECT(ift)); - gtk_stock_add_static(stock_items, stock_item_count); - - stock_inited = TRUE; + GtkIconSet *icon_set; + GtkIconSource *icon_source; + + icon_set = gtk_icon_set_new(); + icon_source = gtk_icon_source_new(); + + gtk_icon_source_set_pixbuf(icon_source, icon_cache_get_pixbuf(filename)); + gtk_icon_set_add_source(icon_set, icon_source); + gtk_icon_source_free(icon_source); + + gtk_icon_factory_add(icon_factory, stock_id, icon_set); + + gtk_icon_set_unref(icon_set); } +void stock_icon_register_pixbuf(GdkPixbuf *pixbuf, gchar *stock_id) +{ + GtkIconSet *icon_set; + GtkIconSource *icon_source; + + icon_set = gtk_icon_set_new(); + icon_source = gtk_icon_source_new(); + + gtk_icon_source_set_pixbuf(icon_source, pixbuf); + gtk_icon_set_add_source(icon_set, icon_source); + gtk_icon_source_free(icon_source); + + gtk_icon_factory_add(icon_factory, stock_id, icon_set); + + gtk_icon_set_unref(icon_set); +} + +void stock_icons_init(void) +{ + gint i; + guint n_stock_icons = G_N_ELEMENTS(stock_icons); + + icon_factory = gtk_icon_factory_new(); + + for (i = 0; i < n_stock_icons; i++) { + stock_icon_register(stock_icons[i].filename, stock_icons[i].stock_id); + } + + gtk_icon_factory_add_default(icon_factory); + + g_object_unref(icon_factory); +} @@ -1,20 +1,28 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + #ifndef __STOCK_H__ #define __STOCK_H__ -#include "config.h" - -#ifdef GTK2 - -#define HI_ABOUT "hi-about" -#define HI_DETAILS "hi-details" - -#define HI_PCI "hi-pci" -#define HI_HDD "hi-hdd" -#define HI_SCSI "hi-scsi" -#define HI_CONNECTOR "hi-connector" -#define HI_USB "hi-usb" +#define HI_STOCK_REPORT "hi-stock-report" -void hi_stock_init(void); -#endif +void stock_icons_init(void); +void stock_icon_register(gchar *filename, gchar *stock_id); +void stock_icon_register_pixbuf(GdkPixbuf *pixbuf, gchar *stock_id); #endif /* __STOCK_H__ */ diff --git a/uidefs.xml b/uidefs.xml new file mode 100644 index 00000000..f70031c8 --- /dev/null +++ b/uidefs.xml @@ -0,0 +1,29 @@ +<ui> + <menubar> + <menu name="FileMenu" action="FileMenuAction"> + <menuitem name="Generate Report..." action="ReportAction" /> + <separator/> + <menuitem name="Quit" action="QuitAction" /> + <placeholder name="FileMenuAdditions" /> + </menu> + <menu name="ViewMenu" action="ViewMenuAction"> + <menuitem name="LeftPane" action="LeftPaneAction"/> + <menuitem name="Toolbar" action="ToolbarAction"/> + <separator/> + <menuitem name="Refresh" action="RefreshAction"/> + <separator/> + <separator name="LastSep"/> + </menu> + <menu name="HelpMenu" action="HelpMenuAction"> + <menuitem name="About" action="AboutAction"/> + </menu> + </menubar> + + <toolbar action="MainMenuBar" action="MainMenuBarAction"> + <placeholder name="ToolItems"> + <toolitem name="Refresh" action="RefreshAction"/> + <separator/> + <toolitem name="Report" action="ReportAction"/> + </placeholder> + </toolbar> +</ui> @@ -1,259 +0,0 @@ -/* - * Hardware Information, version 0.3 - * Copyright (C) 2003-2004 Leandro Pereira <leandro@linuxmag.com.br> - * USB support rewritten by Christophe Grosjean <christopheg@wanadoo.fr> - * - * May be modified and/or distributed under the terms of GNU GPL version 2. - */ - -#include "hardinfo.h" -#include "usb.h" - -gboolean usb_update(gpointer data) -{ - MainWindow *mainwindow = (MainWindow*)data; - GtkCTreeNode *node; - USBDevice *usb; - - if(!mainwindow) return FALSE; - - gtk_clist_freeze(GTK_CLIST(mainwindow->ctree)); - - usb = hi_scan_usb(); - - if (usb != NULL) { - node = tree_group_new(mainwindow, _("USB Devices"), USB); - for (; usb != NULL; usb = usb->next) { - hi_insert_generic(usb, USB); - if (!usb->product) - usb->product = g_strdup_printf - (_("Unknown device (%s)"), usb->class); - - tree_insert_item(mainwindow, node, usb->product, - generic_devices); - } - } - - gtk_clist_thaw(GTK_CLIST(mainwindow->ctree)); - - return TRUE; -} - - - - USBDevice *hi_scan_usb(void) - { - FILE *proc_usb; - gint n=0; - USBDevice *usb_dev = NULL, *usb = NULL; - struct stat st; - gchar buffer[128]; - - if (stat("/proc/bus/usb/devices", &st)) return NULL; - - proc_usb = fopen("/proc/bus/usb/devices", "r"); - while(fgets(buffer, 128, proc_usb)){ - int lg = strlen(buffer); - if (lg>0 && buffer[lg-1] == '\n'){ - buffer[lg-1]=0; - } - if (strstr(buffer, "Manufacturer=")) { - gchar *buf = buffer; - - for (;*buf; buf++) { - if (*buf == '=') { - if (usb){ - usb->vendor = g_strdup(buf+1); - } - break; - } - } - } else if (strstr(buffer, "Product=")) { - gchar *buf = buffer; - for (; *buf; buf++) { - if (*buf == '=') { - if (usb_dev){ - usb_dev->product = g_strdup(buf+1); - } - } - } - } else if (!strncmp(buffer, "D: Ve", 6)) { - gchar *buf = buffer; - gfloat version; - gint class_id; - - usb_dev = g_new0(USBDevice, 1); - usb_dev->next = usb; - usb = usb_dev; - - buf+=4; - - sscanf(buf, "Ver= %f Cls= %d", &version, &class_id); - - usb_dev->version = version; - usb_dev->class_id= class_id; - - walk_until('('); - buf[6]=0; - usb_dev->class = g_strdup(buf+1); - - n++; - } else if (!strncmp(buffer, "P: Ve", 6)) { - gchar *buf = buffer; - gint vendor_id, prod_id; - gfloat rev; - - buf+=4; - - sscanf(buf, "Vendor= %x ProdID= %x Rev= %f", - &vendor_id, &prod_id, &rev); - if (usb_dev){ - usb_dev->vendor_id = vendor_id; - usb_dev->prod_id = prod_id; - usb_dev->revision = rev; - } - } - } - fclose(proc_usb); - return usb; - } - -#if 0 -USBDevice *hi_scan_usb(void) -{ - FILE *proc_usb; - gchar buffer[64]; - gint n=0; - USBDevice *usb_dev = NULL, *usb = NULL; - struct stat st; - - usb = NULL; - - if (stat("/proc/bus/usb/devices", &st)) return NULL; - - proc_usb = fopen("/proc/bus/usb/devices", "r"); - while(fgets(buffer, 64, proc_usb)){ - if (strstr(buffer, "Manufacturer=")) { - gchar *buf = buffer; - gboolean lock = FALSE; - gpointer start = NULL, end = NULL; - - for (; buf != NULL; buf++) { - if (lock && *buf == '\n') { - end = buf; - break; - } else if (!lock && *buf == '=') { - start = buf+1; - lock = TRUE; - } - } - - buf = end; - *buf = 0; - buf = start; - - usb->vendor = g_strdup(buf); - } else if (strstr(buffer, "Product=")) { - gchar *buf = buffer; - gboolean lock = FALSE; - gpointer start = NULL, end = NULL; - - for (; buf != NULL; buf++) { - if (lock && *buf == '\n') { - end = buf; - break; - } else if (!lock && *buf == '=') { - start = buf+1; - lock = TRUE; - } - } - - buf = end; - *buf=0; - buf = start; - - usb_dev->product = g_strdup(buf); - } else if (!strncmp(buffer, "D: Ve", 6)) { - gchar *buf = buffer; - gpointer start; - gfloat version; - gint class_id; - - usb_dev = g_new0(USBDevice, 1); - usb_dev->next = usb; - usb = usb_dev; - - buf+=4; - - sscanf(buf, "Ver =%f Cls=%d", &version, &class_id); - - usb_dev->version = version; - usb_dev->class_id= class_id; - - walk_until('('); - start = buf+1; - buf+=6; - *buf = 0; - buf = start; - - usb_dev->class = g_strdup(buf); - n++; - } else if (!strncmp(buffer, "P: Ve", 6)) { - gchar *buf = buffer; - gint vendor_id, prod_id; - gfloat rev; - - buf+=4; - - sscanf(buf, "Vendor=%x ProdID=%x Rev= %f", - &vendor_id, &prod_id, &rev); - - usb_dev->vendor_id = vendor_id; - usb_dev->prod_id = prod_id; - usb_dev->revision = rev; - } - } - fclose(proc_usb); - - return usb; -} -#endif - -void hi_show_usb_info(MainWindow *mainwindow, USBDevice *device) -{ - gchar *buf; - - if(!device) return; - - detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "usb.png"); - - gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("USB Device")); - - - detail_window_set_dev_name(mainwindow->det_window, device->product); - detail_window_set_dev_type(mainwindow->det_window, device->vendor ? - device->vendor : ""); - - buf = g_strdup_printf("%s (%d)", device->class, device->class_id); - detail_window_append_info(mainwindow->det_window, _("Class"), buf); - g_free(buf); - - detail_window_append_separator(mainwindow->det_window); - - buf = g_strdup_printf("%.2f", device->version); - detail_window_append_info(mainwindow->det_window, _("Version"), buf); - g_free(buf); - - buf = g_strdup_printf("%.2f", device->revision); - detail_window_append_info(mainwindow->det_window, _("Revision"), buf); - g_free(buf); - - if(!device->prod_id) return; - - detail_window_append_separator(mainwindow->det_window); - - detail_window_append_info_int(mainwindow->det_window, _("Vendor ID"), device->vendor_id, TRUE); - detail_window_append_info_int(mainwindow->det_window, _("Product ID"), device->prod_id, TRUE); - -} - @@ -1,28 +0,0 @@ -#ifndef __USB_H__ -#define __USB_H__ - -#include "hardinfo.h" - -typedef struct _USBDevice USBDevice; - -struct _USBDevice { - gchar *product; - gchar *vendor; - gchar *class; - - gfloat version, revision; - - gint bus, port, vendor_id, prod_id, class_id; - - gchar *driver; - - USBDevice *next; -}; - - -USBDevice *hi_scan_usb(void); -void hi_show_usb_info(MainWindow *mainwindow, USBDevice *device); - -gboolean usb_update(gpointer data); - -#endif @@ -0,0 +1,64 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include <string.h> +#include <hardinfo.h> +#include <gtk/gtk.h> + +inline void +remove_quotes(gchar *str) +{ + if (!str) + return; + + while (*str == '"') + *(str++) = ' '; + + gchar *p; + if ((p = strchr(str, '"'))) + *p = 0; +} + +inline void +strend(gchar *str, gchar chr) +{ + if (!str) + return; + + char *p; + if ((p = strchr(str, chr))) + *p = 0; +} + +inline void +remove_linefeed(gchar * str) +{ + strend(str, '\n'); +} + +void +widget_set_cursor(GtkWidget *widget, GdkCursorType cursor_type) +{ + GdkCursor *cursor; + + cursor = gdk_cursor_new(cursor_type); + gdk_window_set_cursor(GDK_WINDOW(widget->window), cursor); + gdk_cursor_unref(cursor); + + while(gtk_events_pending()) + gtk_main_iteration(); +} @@ -1,96 +0,0 @@ -/* - * Hardware Information, version 0.3 - * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> - * - * May be modified and/or distributed under the terms of GNU GPL version 2. - * - */ - -#include "hardinfo.h" -#include "v4l.h" - -#include <stdlib.h> -#include <dirent.h> - -#define get_str_val(var) { \ - walk_until_inclusive(':'); buf++; \ - var = g_strdup(buf); \ - continue; \ - } - -V4LDevice *hi_scan_v4l(void) -{ - FILE *proc_video; - DIR *proc_dir; - struct dirent *sd; - V4LDevice *v4l_dev, *v4l; - struct stat st; - - v4l = NULL; - - if (stat("/proc/video/dev", &st)) - return NULL; - - proc_dir = opendir("/proc/video/dev"); - if(!proc_dir) - return NULL; - - while ((sd = readdir(proc_dir))) { - gchar *dev, buffer[128]; - - dev = g_strdup_printf("/proc/video/dev/%s", sd->d_name); - proc_video = fopen(dev, "r"); - g_free(dev); - - if(!proc_video) - continue; - - v4l_dev = g_new0(V4LDevice, 1); - v4l_dev->next = v4l; - v4l = v4l_dev; - - while (fgets(buffer, 128, proc_video)) { - char *buf = g_strstrip(buffer); - - if(!strncmp(buf, "name", 4)) - get_str_val(v4l_dev->name) - else if(!strncmp(buf, "type", 4)) - get_str_val(v4l_dev->type) - } - - fclose(proc_video); - } - - return v4l; -} - -void hi_show_v4l_info(MainWindow *mainwindow, V4LDevice *device) -{ - gchar *buf; - - if(!device) return; - - buf = g_strdup_printf("%sv4l.png", IMG_PREFIX); - detail_window_set_icon(mainwindow->det_window, buf); - g_free(buf); - - gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("Device Information")); - - - detail_window_set_dev_name(mainwindow->det_window, device->name); - - if (device->type) { - gchar *b = g_strdup(device->type); - gpointer b_start = b; - - do { - if (*b == '|') *b = '\n'; - b++; - } while(*b); - b = b_start; - - detail_window_append_info(mainwindow->det_window, _("Type"), - b); - g_free(b); - } -} @@ -1,16 +0,0 @@ -#ifndef __V4L_H__ -#define __V4L_H__ - -typedef struct _V4LDevice V4LDevice; - -struct _V4LDevice { - gchar *name; - gchar *type; - - V4LDevice *next; -}; - -void hi_show_v4l_info(MainWindow *mainwindow, V4LDevice *device); -V4LDevice *hi_scan_v4l(void); - -#endif @@ -1,221 +0,0 @@ -/* - * Hardware Information, version 0.3 - * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> - * - * This module contains code from xdpyinfo.c, by Jim Fulton, MIT X Consortium - * Copyright 1988, 1998 The Open Group - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation. - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of The Open Group shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from The Open Group. - */ - -#include "hardinfo.h" -#include "x11.h" - -#include <stdlib.h> - -X11Info * -x11_get_info(void) -{ - X11Info *info; - Display *dpy; - gint default_screen = 0, color_depth = 0; - gchar *buf; - - dpy = XOpenDisplay(NULL); - if(!dpy) return NULL; - - info = g_new0(X11Info, 1); - - buf = DisplayString(dpy); - if (*buf == ':') - info->display = g_strdup_printf(_("Local display (%s)"), buf); - else - info->display = g_strdup_printf(_("Remote display (%s)"), buf); - - info->vendor = g_strdup(ServerVendor(dpy)); - - if (strstr(ServerVendor(dpy), "XFree86")) { - int vendrel = VendorRelease(dpy); - - if (vendrel < 336) { - /* - * vendrel was set incorrectly for 3.3.4 and 3.3.5, so handle - * those cases here. - */ - buf = g_strdup_printf - ("%d.%d.%d", vendrel / 100, (vendrel / 10) % 10, - vendrel % 10); - } else if (vendrel < 3900) { - /* 3.3.x versions, other than the exceptions handled above */ - buf = g_strdup_printf("%d.%d", vendrel / 1000, (vendrel / 100) % 10); - if (((vendrel / 10) % 10) || (vendrel % 10)) { - gchar *buf2; - - buf2 = g_strdup_printf(".%d", (vendrel / 10) % 10); - buf = g_strconcat(buf, buf2, NULL); - g_free(buf2); - - if (vendrel % 10) { - buf2 = g_strdup_printf(".%d", vendrel % 10); - buf = g_strconcat(buf, buf2, NULL); - g_free(buf2); - } - } - } else if (vendrel < 40000000) { - gchar *buf2; - /* 4.0.x versions */ - buf = g_strdup_printf("%d.%d", vendrel / 1000, (vendrel / 10) % 10); - - if (vendrel % 10) { - buf2 = g_strdup_printf(".%d", vendrel % 10); - buf = g_strconcat(buf, buf2, NULL); - g_free(buf2); - } - } else { - /* post-4.0.x */ - buf = g_strdup_printf("%d.%d.%d", vendrel / 10000000, - (vendrel / 100000) % 100, - (vendrel / 1000) % 100); - if (vendrel % 1000) { - gchar *buf2; - - buf2 = g_strdup_printf(".%d", vendrel % 1000); - buf = g_strconcat(buf, buf2, NULL); - g_free(buf2); - } - } - } - if (buf) { - info->xf86version = g_strdup(buf); - g_free(buf); - } - - default_screen = DefaultScreen(dpy); - color_depth = XDefaultDepth(dpy, default_screen); - info->screen_size = g_strdup_printf("%dx%d pixels (%d bpp)", - DisplayWidth(dpy, default_screen), - DisplayHeight(dpy, default_screen), - color_depth); - - - if (info->xf86version) { - info->version = g_strdup_printf(_("XFree86 version %s (protocol version %d.%d)"), - info->xf86version, ProtocolVersion(dpy), - ProtocolRevision(dpy)); - } else { - info->version = g_strdup_printf(_("%d (protocol version %d.%d)"), - VendorRelease(dpy), ProtocolVersion(dpy), - ProtocolRevision(dpy)); - } - - XCloseDisplay(dpy); - - return info; -} - -GtkWidget * -x11_get_widget(MainWindow * mainwindow) -{ - GtkWidget *label, *hbox; - GtkWidget *table; - GtkWidget *pixmap; - gchar *buf; - X11Info *info; - - if (!mainwindow) - return NULL; - - info = x11_get_info(); - - if (!info) - return NULL; - - hbox = gtk_hbox_new(FALSE, 0); - gtk_widget_show(hbox); - - buf = g_strdup_printf("%s/x11.png", IMG_PREFIX); - pixmap = gtk_image_new_from_file(buf); - gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0); - gtk_widget_show(pixmap); - gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); - g_free(buf); - - table = gtk_table_new(4, 2, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 0); - gtk_container_set_border_width(GTK_CONTAINER(table), 10); - gtk_table_set_row_spacings(GTK_TABLE(table), 4); - gtk_table_set_col_spacings(GTK_TABLE(table), 4); - - /* - * Table headers - */ - label = gtk_label_new(_("<b>Display:</b>")); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - label = gtk_label_new(_("<b>Vendor:</b>")); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - label = gtk_label_new(_("<b>Release:</b>")); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - label = gtk_label_new(_("<b>Resolution:</b>")); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - /* - * Table content - */ - label = gtk_label_new(info->display); - gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - label = gtk_label_new(info->vendor); - gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - label = gtk_label_new(info->version); - gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - label = gtk_label_new(info->screen_size); - gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 3, 4); - gtk_widget_show(label); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - g_free(info); - - return hbox; -} @@ -1,20 +0,0 @@ -#ifndef __X11_H__ -#define __X11_H__ - -#include <X11/Xlib.h> -#include <X11/Xutil.h> - -typedef struct _X11Info X11Info; - -struct _X11Info { - gchar *display; - gchar *version; - gchar *vendor; - gchar *xf86version; - gchar *screen_size; -}; - -X11Info *x11_get_info(void); -GtkWidget *x11_get_widget(MainWindow *mainwindow); - -#endif |