diff options
| author | Agney Lopes Roth Ferraz <agney@debian.org> | 2006-06-21 22:18:24 -0300 | 
|---|---|---|
| committer | Simon Quigley <tsimonq2@ubuntu.com> | 2017-06-19 14:38:36 -0500 | 
| commit | 078e9c700feccfcf1318b7bde49d6e464bc2ac8c (patch) | |
| tree | 4d24c99643f10e4b8b75bebaaec5d48294b3b112 /arch/common | |
| parent | 18820242e374421ebd6d504a20d11f310b2ac023 (diff) | |
| parent | 720f5023a8f68aaaa54cb6b7bf46efee23b5b4c3 (diff) | |
Import Debian changes 0.4.1-1
hardinfo (0.4.1-1) unstable; urgency=low
  * New upstream release. 
Diffstat (limited to 'arch/common')
35 files changed, 927 insertions, 11 deletions
| diff --git a/arch/common/.svn/README.txt b/arch/common/.svn/README.txt new file mode 100644 index 00000000..271a8ce9 --- /dev/null +++ b/arch/common/.svn/README.txt @@ -0,0 +1,2 @@ +This is a Subversion working copy administrative directory. +Visit http://subversion.tigris.org/ for more information. diff --git a/arch/common/.svn/empty-file b/arch/common/.svn/empty-file new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/empty-file diff --git a/arch/common/.svn/entries b/arch/common/.svn/entries new file mode 100644 index 00000000..04b48187 --- /dev/null +++ b/arch/common/.svn/entries @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="utf-8"?> +<wc-entries +   xmlns="svn:"> +<entry +   committed-rev="5" +   name="" +   committed-date="2006-02-01T00:06:47.257372Z" +   url="svn+ssh://lafp@svn.berlios.de/svnroot/repos/hardinfo/trunk/hardinfo2/arch/common" +   last-author="lafp" +   kind="dir" +   uuid="03931a0e-0c0b-0410-87e6-c9e79dddb921" +   repos="svn+ssh://lafp@svn.berlios.de/svnroot/repos/hardinfo" +   revision="9"/> +<entry +   committed-rev="10" +   name="sha1.h" +   text-time="2006-05-20T14:32:18.000000Z" +   committed-date="2006-05-20T14:41:28.523270Z" +   checksum="7254615d07c6be90bdafc764ca8e8f9f" +   last-author="lafp" +   kind="file" +   prop-time="2006-05-20T14:29:28.000000Z" +   revision="10"/> +<entry +   committed-rev="10" +   name="blowfish.h" +   text-time="2006-05-20T14:32:18.000000Z" +   committed-date="2006-05-20T14:41:28.523270Z" +   checksum="d9411117551a66fd14fc8d6b13f1a04c" +   last-author="lafp" +   kind="file" +   prop-time="2006-05-20T14:29:28.000000Z" +   revision="10"/> +<entry +   committed-rev="1" +   name="fib.h" +   text-time="2006-05-20T14:32:18.000000Z" +   committed-date="2006-01-23T22:38:33.949992Z" +   checksum="3de942d27f53135b370c1b88f45220c8" +   last-author="lafp" +   kind="file" +   prop-time="2006-05-20T14:29:28.000000Z"/> +<entry +   committed-rev="10" +   name="zlib.h" +   text-time="2006-05-20T14:32:18.000000Z" +   committed-date="2006-05-20T14:41:28.523270Z" +   checksum="e7c594c5913d0847a0e2b9bfd5d062d4" +   last-author="lafp" +   kind="file" +   prop-time="2006-05-20T14:29:28.000000Z" +   revision="10"/> +<entry +   committed-rev="10" +   name="users.h" +   text-time="2006-05-22T11:31:37.000000Z" +   committed-date="2006-05-20T14:41:28.523270Z" +   checksum="216feeb3fed867dacbc8a8181d0d960d" +   last-author="lafp" +   kind="file" +   revision="10"/> +<entry +   committed-rev="1" +   name="display.h" +   text-time="2006-05-20T14:32:18.000000Z" +   committed-date="2006-01-23T22:38:33.949992Z" +   checksum="9b9fe0f1472481b59436cdd18dbacfd4" +   last-author="lafp" +   kind="file" +   prop-time="2006-05-20T14:29:30.000000Z"/> +<entry +   committed-rev="10" +   name="md5.h" +   text-time="2006-05-20T14:32:18.000000Z" +   committed-date="2006-05-20T14:41:28.523270Z" +   checksum="6f1b0aaf6549a02d95e1a56a42e4088b" +   last-author="lafp" +   kind="file" +   prop-time="2006-05-20T14:29:30.000000Z" +   revision="10"/> +<entry +   committed-rev="10" +   name="languages.h" +   text-time="2006-05-20T14:32:18.000000Z" +   committed-date="2006-05-20T14:41:28.523270Z" +   checksum="5c168fa59cb0589bf24d62cba96943e6" +   last-author="lafp" +   kind="file" +   prop-time="2006-05-20T14:29:30.000000Z" +   revision="10"/> +<entry +   committed-rev="17" +   name="printers.h" +   text-time="2006-06-10T12:43:57.000000Z" +   committed-date="2006-06-10T12:46:54.945064Z" +   checksum="6c4f384feae5b86188161fe27530c3b7" +   last-author="lafp" +   kind="file" +   prop-time="2006-05-20T14:29:30.000000Z" +   revision="17"/> +</wc-entries> diff --git a/arch/common/.svn/format b/arch/common/.svn/format new file mode 100644 index 00000000..b8626c4c --- /dev/null +++ b/arch/common/.svn/format @@ -0,0 +1 @@ +4 diff --git a/arch/common/.svn/prop-base/blowfish.h.svn-base b/arch/common/.svn/prop-base/blowfish.h.svn-base new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/prop-base/blowfish.h.svn-base diff --git a/arch/common/.svn/prop-base/display.h.svn-base b/arch/common/.svn/prop-base/display.h.svn-base new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/prop-base/display.h.svn-base diff --git a/arch/common/.svn/prop-base/fib.h.svn-base b/arch/common/.svn/prop-base/fib.h.svn-base new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/prop-base/fib.h.svn-base diff --git a/arch/common/.svn/prop-base/languages.h.svn-base b/arch/common/.svn/prop-base/languages.h.svn-base new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/prop-base/languages.h.svn-base diff --git a/arch/common/.svn/prop-base/md5.h.svn-base b/arch/common/.svn/prop-base/md5.h.svn-base new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/prop-base/md5.h.svn-base diff --git a/arch/common/.svn/prop-base/printers.h.svn-base b/arch/common/.svn/prop-base/printers.h.svn-base new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/prop-base/printers.h.svn-base diff --git a/arch/common/.svn/prop-base/sha1.h.svn-base b/arch/common/.svn/prop-base/sha1.h.svn-base new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/prop-base/sha1.h.svn-base diff --git a/arch/common/.svn/prop-base/zlib.h.svn-base b/arch/common/.svn/prop-base/zlib.h.svn-base new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/prop-base/zlib.h.svn-base diff --git a/arch/common/.svn/props/blowfish.h.svn-work b/arch/common/.svn/props/blowfish.h.svn-work new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/props/blowfish.h.svn-work diff --git a/arch/common/.svn/props/display.h.svn-work b/arch/common/.svn/props/display.h.svn-work new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/props/display.h.svn-work diff --git a/arch/common/.svn/props/fib.h.svn-work b/arch/common/.svn/props/fib.h.svn-work new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/props/fib.h.svn-work diff --git a/arch/common/.svn/props/languages.h.svn-work b/arch/common/.svn/props/languages.h.svn-work new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/props/languages.h.svn-work diff --git a/arch/common/.svn/props/md5.h.svn-work b/arch/common/.svn/props/md5.h.svn-work new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/props/md5.h.svn-work diff --git a/arch/common/.svn/props/printers.h.svn-work b/arch/common/.svn/props/printers.h.svn-work new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/props/printers.h.svn-work diff --git a/arch/common/.svn/props/sha1.h.svn-work b/arch/common/.svn/props/sha1.h.svn-work new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/props/sha1.h.svn-work diff --git a/arch/common/.svn/props/zlib.h.svn-work b/arch/common/.svn/props/zlib.h.svn-work new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/arch/common/.svn/props/zlib.h.svn-work diff --git a/arch/common/.svn/text-base/blowfish.h.svn-base b/arch/common/.svn/text-base/blowfish.h.svn-base new file mode 100644 index 00000000..ad4bdb92 --- /dev/null +++ b/arch/common/.svn/text-base/blowfish.h.svn-base @@ -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 + */ + +#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; + +    gchar *bdata_path; +     +    bdata_path = g_strdup_printf("%s/hardinfo/benchmark.data", +                                 gbr_find_data_dir(PREFIX)); + +    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { +        g_free(bdata_path); +        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); +    g_free(bdata_path); + +    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/.svn/text-base/display.h.svn-base b/arch/common/.svn/text-base/display.h.svn-base new file mode 100644 index 00000000..6731e3e3 --- /dev/null +++ b/arch/common/.svn/text-base/display.h.svn-base @@ -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/.svn/text-base/fib.h.svn-base b/arch/common/.svn/text-base/fib.h.svn-base new file mode 100644 index 00000000..493cfd0f --- /dev/null +++ b/arch/common/.svn/text-base/fib.h.svn-base @@ -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/.svn/text-base/languages.h.svn-base b/arch/common/.svn/text-base/languages.h.svn-base new file mode 100644 index 00000000..71e05dab --- /dev/null +++ b/arch/common/.svn/text-base/languages.h.svn-base @@ -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[512], *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, 512, 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/.svn/text-base/md5.h.svn-base b/arch/common/.svn/text-base/md5.h.svn-base new file mode 100644 index 00000000..256d6c3b --- /dev/null +++ b/arch/common/.svn/text-base/md5.h.svn-base @@ -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 + */ + +#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; + +    gchar *bdata_path; +     +    bdata_path = g_strdup_printf("%s/hardinfo/benchmark.data", +                                 gbr_find_data_dir(PREFIX)); +    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { +        g_free(bdata_path); +        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); +    g_free(bdata_path); + +    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/.svn/text-base/printers.h.svn-base b/arch/common/.svn/text-base/printers.h.svn-base new file mode 100644 index 00000000..01beb5dd --- /dev/null +++ b/arch/common/.svn/text-base/printers.h.svn-base @@ -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 + */ + +void +scan_printers(void) +{ +    static GModule *cups = NULL; +    static int (*cupsGetPrinters) (char ***printers) = NULL; +    static char *(*cupsGetDefault) (void) = NULL; +    static char *libcups[] = { "libcups", +                               "libcups.so", +                               "libcups.so.1", +                               "libcups.so.2", +                               NULL }; + +    if (printer_list) +	g_free(printer_list); + +    if (!(cupsGetPrinters && cupsGetDefault)) { +        int i; +         +        for (i = 0; libcups[i] != NULL; i++) { +            cups = g_module_open(libcups[i], G_MODULE_BIND_LAZY); +            if (cups) +                break; +        } +         +        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/.svn/text-base/sha1.h.svn-base b/arch/common/.svn/text-base/sha1.h.svn-base new file mode 100644 index 00000000..4bd07276 --- /dev/null +++ b/arch/common/.svn/text-base/sha1.h.svn-base @@ -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 + */ +#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; + +    gchar *bdata_path; +     +    bdata_path = g_strdup_printf("%s/hardinfo/benchmark.data", +                                 gbr_find_data_dir(PREFIX)); + +    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { +        g_free(bdata_path); +        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); +    g_free(bdata_path); + +    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/.svn/text-base/users.h.svn-base b/arch/common/.svn/text-base/users.h.svn-base new file mode 100644 index 00000000..08acd97a --- /dev/null +++ b/arch/common/.svn/text-base/users.h.svn-base @@ -0,0 +1,63 @@ +static gchar *sys_users = NULL, +             *human_users = NULL; + +static gboolean +remove_users(gpointer key, gpointer value, gpointer data) +{ +    if (!strncmp((gchar *) key, "USER", 4)) { +	/* +         * g_free((gchar *) key); +	 * g_free((GtkTreeIter *) value); +         */ +	return TRUE; +    } +    return FALSE; +} + +void scan_users(void) +{ +    FILE *passwd; +    char buffer[512]; +     +    passwd = fopen("/etc/passwd", "r"); +    if (!passwd) +      return; +     +    if (sys_users) { +      g_free(sys_users); +      g_free(human_users); + +      g_hash_table_foreach_remove(moreinfo, remove_users, NULL); +    } +   +    sys_users = g_strdup(""); +    human_users = g_strdup(""); +     +    while (fgets(buffer, 512, passwd)) { +      gchar **tmp; +      gint uid; +       +      tmp = g_strsplit(buffer, ":", 0); +       +      gchar *key = g_strdup_printf("USER%s", tmp[0]); +      gchar *val = g_strdup_printf("[User Information]\n" +                                   "User ID=%s\n" +                                   "Group ID=%s\n" +                                   "Home directory=%s\n" +                                   "Default shell=%s\n", +                                   tmp[2], tmp[3], tmp[5], tmp[6]); +      g_hash_table_insert(moreinfo, key, val); + +      uid = atoi(tmp[2]); +      strend(tmp[4], ','); +      if (uid >= 1000 && uid <= 65530) { +        human_users = g_strdup_printf("%s$%s$%s=%s\n", human_users, key, tmp[0], tmp[4]); +      } else { +        sys_users = g_strdup_printf("%s$%s$%s=%s\n", sys_users, key, tmp[0], tmp[4]); +      }       +       +      g_strfreev(tmp); +    } +     +    fclose(passwd); +} diff --git a/arch/common/.svn/text-base/zlib.h.svn-base b/arch/common/.svn/text-base/zlib.h.svn-base new file mode 100644 index 00000000..2a1007ed --- /dev/null +++ b/arch/common/.svn/text-base/zlib.h.svn-base @@ -0,0 +1,90 @@ +/* + *    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_warning("Cannot load ZLib: %s", 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; +    gchar *bdata_path; +     +    bdata_path = g_strdup_printf("%s/hardinfo/benchmark.data", +                                 gbr_find_data_dir(PREFIX)); + +    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { +        g_free(bdata_path); +        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); +    g_free(bdata_path); + +    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/common/blowfish.h b/arch/common/blowfish.h index 7333d069..ad4bdb92 100644 --- a/arch/common/blowfish.h +++ b/arch/common/blowfish.h @@ -34,8 +34,13 @@ benchmark_fish(void)      L = 0xBEBACAFE;      R = 0xDEADBEEF; -    if (!g_file_get_contents(PREFIX "benchmark.data", -                             &tmpsrc, NULL, NULL)) { +    gchar *bdata_path; +     +    bdata_path = g_strdup_printf("%s/hardinfo/benchmark.data", +                                 gbr_find_data_dir(PREFIX)); + +    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { +        g_free(bdata_path);          return g_strdup("[Error]\n"                          PREFIX "benchmark.data not found=\n");      }      @@ -57,6 +62,7 @@ benchmark_fish(void)      }      g_timer_destroy(timer); +    g_free(bdata_path);      gchar *retval = g_strdup_printf("[Results <i>(in seconds; lower is better)</i>]\n"                             "<b>This Machine</b>=<b>%.2f</b>\n", elapsed); diff --git a/arch/common/languages.h b/arch/common/languages.h index 3a31ef7f..71e05dab 100644 --- a/arch/common/languages.h +++ b/arch/common/languages.h @@ -19,7 +19,7 @@ void  scan_languages(OperatingSystem * os)  {      FILE *locale; -    gchar buf[128], *retval = ""; +    gchar buf[512], *retval = "";      locale = popen("locale -va", "r");      if (!locale) @@ -36,7 +36,7 @@ scan_languages(OperatingSystem * os)  	  *date = NULL,  	  *codeset = NULL; -    while (fgets(buf, 128, locale)) { +    while (fgets(buf, 512, locale)) {  	if (!strncmp(buf, "locale:", 7)) {  	    sscanf(buf, "locale: %s", name);  	    fgets(buf, 128, locale); diff --git a/arch/common/md5.h b/arch/common/md5.h index f61aef0f..256d6c3b 100644 --- a/arch/common/md5.h +++ b/arch/common/md5.h @@ -31,8 +31,12 @@ benchmark_md5(void)      tmpsrc = src; -    if (!g_file_get_contents(PREFIX "benchmark.data", -                             &tmpsrc, NULL, NULL)) { +    gchar *bdata_path; +     +    bdata_path = g_strdup_printf("%s/hardinfo/benchmark.data", +                                 gbr_find_data_dir(PREFIX)); +    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { +        g_free(bdata_path);          return g_strdup("[Error]\n"                          PREFIX "benchmark.data not found=\n");      }      @@ -54,6 +58,7 @@ benchmark_md5(void)      }      g_timer_destroy(timer); +    g_free(bdata_path);      gchar *retval = g_strdup_printf("[Results <i>(in seconds; lower is better)</i>]\n"                             "<b>This Machine</b>=<b>%.2f</b>\n", elapsed); diff --git a/arch/common/sha1.h b/arch/common/sha1.h index 521cbcae..4bd07276 100644 --- a/arch/common/sha1.h +++ b/arch/common/sha1.h @@ -30,8 +30,13 @@ benchmark_sha1(void)      tmpsrc = src; -    if (!g_file_get_contents(PREFIX "benchmark.data", -                             &tmpsrc, NULL, NULL)) { +    gchar *bdata_path; +     +    bdata_path = g_strdup_printf("%s/hardinfo/benchmark.data", +                                 gbr_find_data_dir(PREFIX)); + +    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { +        g_free(bdata_path);          return g_strdup("[Error]\n"                          PREFIX "benchmark.data not found=\n");      }      @@ -53,6 +58,7 @@ benchmark_sha1(void)      }      g_timer_destroy(timer); +    g_free(bdata_path);      gchar *retval = g_strdup_printf("[Results <i>(in seconds; lower is better)</i>]\n"                             "<b>This Machine</b>=<b>%.2f</b>\n", elapsed); diff --git a/arch/common/users.h b/arch/common/users.h new file mode 100644 index 00000000..08acd97a --- /dev/null +++ b/arch/common/users.h @@ -0,0 +1,63 @@ +static gchar *sys_users = NULL, +             *human_users = NULL; + +static gboolean +remove_users(gpointer key, gpointer value, gpointer data) +{ +    if (!strncmp((gchar *) key, "USER", 4)) { +	/* +         * g_free((gchar *) key); +	 * g_free((GtkTreeIter *) value); +         */ +	return TRUE; +    } +    return FALSE; +} + +void scan_users(void) +{ +    FILE *passwd; +    char buffer[512]; +     +    passwd = fopen("/etc/passwd", "r"); +    if (!passwd) +      return; +     +    if (sys_users) { +      g_free(sys_users); +      g_free(human_users); + +      g_hash_table_foreach_remove(moreinfo, remove_users, NULL); +    } +   +    sys_users = g_strdup(""); +    human_users = g_strdup(""); +     +    while (fgets(buffer, 512, passwd)) { +      gchar **tmp; +      gint uid; +       +      tmp = g_strsplit(buffer, ":", 0); +       +      gchar *key = g_strdup_printf("USER%s", tmp[0]); +      gchar *val = g_strdup_printf("[User Information]\n" +                                   "User ID=%s\n" +                                   "Group ID=%s\n" +                                   "Home directory=%s\n" +                                   "Default shell=%s\n", +                                   tmp[2], tmp[3], tmp[5], tmp[6]); +      g_hash_table_insert(moreinfo, key, val); + +      uid = atoi(tmp[2]); +      strend(tmp[4], ','); +      if (uid >= 1000 && uid <= 65530) { +        human_users = g_strdup_printf("%s$%s$%s=%s\n", human_users, key, tmp[0], tmp[4]); +      } else { +        sys_users = g_strdup_printf("%s$%s$%s=%s\n", sys_users, key, tmp[0], tmp[4]); +      }       +       +      g_strfreev(tmp); +    } +     +    fclose(passwd); +} diff --git a/arch/common/zlib.h b/arch/common/zlib.h index f68d60f4..2a1007ed 100644 --- a/arch/common/zlib.h +++ b/arch/common/zlib.h @@ -29,7 +29,7 @@ benchmark_zlib(void)  	if (!libz) {              libz = g_module_open("/lib/libz.so", G_MODULE_BIND_LAZY);              if (!libz) { -                g_print("%s\n", g_module_error()); +                g_warning("Cannot load ZLib: %s", g_module_error());                  return g_strdup("[Error]\n"                         "ZLib not found=");              } @@ -51,9 +51,13 @@ benchmark_zlib(void)      gdouble elapsed = 0;      gchar src[65536], *tmpsrc;      glong srclen = 65536; +    gchar *bdata_path; +     +    bdata_path = g_strdup_printf("%s/hardinfo/benchmark.data", +                                 gbr_find_data_dir(PREFIX)); -    if (!g_file_get_contents(PREFIX "benchmark.data", -                             &tmpsrc, NULL, NULL)) { +    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { +        g_free(bdata_path);          return g_strdup("[Error]\n"                          PREFIX "benchmark.data not found=\n");      }      @@ -77,6 +81,7 @@ benchmark_zlib(void)      }      g_timer_destroy(timer); +    g_free(bdata_path);      gchar *retval = g_strdup_printf("[Results <i>(in seconds; lower is better)</i>]\n"                             "<b>This Machine</b>=<b>%.2f</b>\n", elapsed); | 
