diff options
Diffstat (limited to 'arch/common')
| -rw-r--r-- | arch/common/blowfish.h | 54 | ||||
| -rw-r--r-- | arch/common/cryptohash.h (renamed from arch/common/md5.h) | 67 | ||||
| -rw-r--r-- | arch/common/display.h | 2 | ||||
| -rw-r--r-- | arch/common/environment.h | 42 | ||||
| -rw-r--r-- | arch/common/fft.h | 47 | ||||
| -rw-r--r-- | arch/common/fib.h | 2 | ||||
| -rw-r--r-- | arch/common/languages.h | 4 | ||||
| -rw-r--r-- | arch/common/nqueens.h | 45 | ||||
| -rw-r--r-- | arch/common/printers.h | 256 | ||||
| -rw-r--r-- | arch/common/raytrace.h | 29 | ||||
| -rw-r--r-- | arch/common/sha1.h | 62 | ||||
| -rw-r--r-- | arch/common/users.h | 17 | ||||
| -rw-r--r-- | arch/common/zlib.h | 82 | 
13 files changed, 439 insertions, 270 deletions
| diff --git a/arch/common/blowfish.h b/arch/common/blowfish.h index ceec7a96..5fea2e22 100644 --- a/arch/common/blowfish.h +++ b/arch/common/blowfish.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -18,48 +18,46 @@  #include <blowfish.h> -static void -benchmark_fish(void) +static gpointer +parallel_blowfish(unsigned int start, unsigned int end, void *data, GTimer *timer)  {      BLOWFISH_CTX ctx; -    GTimer *timer = g_timer_new(); -    gdouble elapsed = 0; -    gchar src[65536], *tmpsrc; -    glong srclen = 65536; +    unsigned int i;      unsigned long L, R; -    int i; - -    tmpsrc = src;      L = 0xBEBACAFE;      R = 0xDEADBEEF; +    for (i = start; i <= end; i++) {  +        Blowfish_Init(&ctx, (unsigned char*)data, 65536); +        Blowfish_Encrypt(&ctx, &L, &R); +        Blowfish_Decrypt(&ctx, &L, &R); +    } + +    return NULL; +} + +static void +benchmark_fish(void) +{ +    gdouble elapsed = 0; +    gchar *tmpsrc; +      gchar *bdata_path; -     +      bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL);      if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) {          g_free(bdata_path);          return; -    }      -     +    } +      shell_view_set_enabled(FALSE);      shell_status_update("Performing Blowfish benchmark..."); -     -    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); +    elapsed = benchmark_parallel_for(0, 50000, parallel_blowfish, tmpsrc); +      g_free(bdata_path); -     +    g_free(tmpsrc); +      bench_results[BENCHMARK_BLOWFISH] = elapsed;  } diff --git a/arch/common/md5.h b/arch/common/cryptohash.h index 95d683bd..9897bb6b 100644 --- a/arch/common/md5.h +++ b/arch/common/cryptohash.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -17,21 +17,48 @@   */  #include <md5.h> +#include <sha1.h> -static void -benchmark_md5(void) +static void inline md5_step(char *data, glong srclen)  {      struct MD5Context ctx;      guchar checksum[16]; -    int i; -    GTimer *timer = g_timer_new(); -    gdouble elapsed = 0; -    gchar src[65536], *tmpsrc; -    glong srclen = 65536; +     +    MD5Init(&ctx); +    MD5Update(&ctx, (guchar *)data, srclen); +    MD5Final(checksum, &ctx); +} -    tmpsrc = src; +static void inline sha1_step(char *data, glong srclen) +{ +    SHA1_CTX ctx; +    guchar checksum[20]; +     +    SHA1Init(&ctx); +    SHA1Update(&ctx, (guchar*)data, srclen); +    SHA1Final(checksum, &ctx); +} -    gchar *bdata_path; +static gpointer cryptohash_for(unsigned int start, unsigned int end, void *data, GTimer *timer) +{ +    unsigned int i; +     +    for (i = start; i <= end; i++) {  +        if (i % 2 == 0) { +            md5_step(data, 65536); +        } else { +            sha1_step(data, 65536); +        } +    } +     +    return NULL; +} + +static void +benchmark_cryptohash(void) +{ +    gdouble elapsed = 0; +    gchar *tmpsrc, *bdata_path;      bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL);      if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { @@ -40,24 +67,12 @@ benchmark_md5(void)      }           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_update("Running CryptoHash benchmark..."); -        shell_status_set_percentage(i/50); -    } +    elapsed = benchmark_parallel_for(0, 5000, cryptohash_for, tmpsrc); -    g_timer_destroy(timer);      g_free(bdata_path); +    g_free(tmpsrc); -    bench_results[BENCHMARK_MD5] = 312.0 / elapsed; +    bench_results[BENCHMARK_CRYPTOHASH] = 312.0 / elapsed;  } - diff --git a/arch/common/display.h b/arch/common/display.h index d7cf2ae6..075a0a24 100644 --- a/arch/common/display.h +++ b/arch/common/display.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/arch/common/environment.h b/arch/common/environment.h new file mode 100644 index 00000000..c78c4a73 --- /dev/null +++ b/arch/common/environment.h @@ -0,0 +1,42 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2008 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    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 *_env = NULL; +void scan_env_var(gboolean reload) +{ +    SCAN_START(); +     +    gchar **envlist; +    gint i; +     +    g_free(_env); +     +    _env = g_strdup("[Environment Variables]\n"); +    for (i = 0, envlist = g_listenv(); envlist[i]; i++) { +      _env = h_strdup_cprintf("%s=%s\n", _env, +                              envlist[i], g_getenv(envlist[i])); +    } +    g_strfreev(envlist); +     +    SCAN_END(); +} + +gchar *callback_env_var(void) +{ +    return _env; +} diff --git a/arch/common/fft.h b/arch/common/fft.h new file mode 100644 index 00000000..62daa9fe --- /dev/null +++ b/arch/common/fft.h @@ -0,0 +1,47 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    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 <fftbench.h> + +static gpointer fft_for(unsigned int start, unsigned int end, void *data, GTimer *timer) +{ +    unsigned int i; +     +    for (i = start; i <= end; i++) {  +        fft_bench_start(); +    } +     +    return NULL; +} + +static void +benchmark_fft(void) +{ +    gdouble elapsed = 0; +     +    shell_view_set_enabled(FALSE); +    shell_status_update("Running FFT benchmark..."); +         +    fft_bench_init(); +    elapsed = benchmark_parallel_for(0, 4, fft_for, NULL); +    fft_bench_finish(); +     +    bench_results[BENCHMARK_FFT] = elapsed; +} + + diff --git a/arch/common/fib.h b/arch/common/fib.h index 645002fa..6a216afe 100644 --- a/arch/common/fib.h +++ b/arch/common/fib.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/arch/common/languages.h b/arch/common/languages.h index efc100fb..45eb2b6a 100644 --- a/arch/common/languages.h +++ b/arch/common/languages.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -77,7 +77,7 @@ scan_languages(OperatingSystem * os)  					 "Revision=%s\n"  					 "Date=%s\n"  					 "Codeset=%s\n", -					 FIELD(name), FIELD(title), +					 name, FIELD(title),  					 FIELD(source), FIELD(address),  					 FIELD(email), FIELD(language),  					 FIELD(territory), FIELD(revision), diff --git a/arch/common/nqueens.h b/arch/common/nqueens.h new file mode 100644 index 00000000..2a233722 --- /dev/null +++ b/arch/common/nqueens.h @@ -0,0 +1,45 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    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 <nqueens.h> + +static gpointer nqueens_for(unsigned int start, unsigned int end, void *data, GTimer *timer) +{ +    unsigned int i; +     +    for (i = start; i <= end; i++) {  +        nqueens(0); +    } +     +    return NULL; +} + +static void +benchmark_nqueens(void) +{ +    gdouble elapsed = 0; +     +    shell_view_set_enabled(FALSE); +    shell_status_update("Running N-Queens benchmark..."); +         +    elapsed = benchmark_parallel_for(0, 10, nqueens_for, NULL); +     +    bench_results[BENCHMARK_NQUEENS] = elapsed; +} + + diff --git a/arch/common/printers.h b/arch/common/printers.h index 43ddda0a..2f221252 100644 --- a/arch/common/printers.h +++ b/arch/common/printers.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -16,70 +16,244 @@   *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA   */ -void -__scan_printers(void) +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +typedef struct _CUPSDest	CUPSDest; +typedef struct _CUPSOption	CUPSOption; + +struct _CUPSOption { +    char *name, *value; +}; + +struct _CUPSDest { +    char *name, *instance; +    int is_default; +    int num_options; +    CUPSOption *options;   +}; + +static int (*cups_dests_get) (CUPSDest **dests) = NULL; +static int (*cups_dests_free) (int num_dests, CUPSDest *dests) = NULL; +static gboolean cups_init = FALSE; + +static gboolean +remove_printer_devices(gpointer key, gpointer value, gpointer data)  { -    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 }; +    return g_str_has_prefix(key, "PRN"); +} -    if (printer_list) -	g_free(printer_list); +static void +__init_cups(void) +{ +    static GModule *cups = NULL; +    const char *libcups[] = { "libcups", "libcups.so", "libcups.so.1", "libcups.so.2", NULL }; -    if (!(cupsGetPrinters && cupsGetDefault)) { +    if (!(cups_dests_get && cups_dests_free)) {          int i;          for (i = 0; libcups[i] != NULL; i++) {              cups = g_module_open(libcups[i], G_MODULE_BIND_LAZY);              if (cups) -                break; +                break;           }          if (!cups) { -	    printer_list = g_strdup("[Printers]\n" -	                            "CUPS libraries cannot be found="); +	    cups_init = FALSE;  	    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="); +	if (!g_module_symbol(cups, "cupsGetDests", (gpointer) & cups_dests_get) +	    || !g_module_symbol(cups, "cupsFreeDests", (gpointer) & cups_dests_free)) {              g_module_close(cups); -	    return; +	    cups_init = FALSE;  	}      } +     +    cups_init = TRUE; +} -    gchar **printers; -    int noprinters, i; -    const char *default_printer; - -    noprinters = cupsGetPrinters(&printers); -    default_printer = cupsGetDefault(); +gchar *__cups_callback_ptype(gchar *strvalue) +{ +  if (strvalue) { +    unsigned value = atoi(strvalue); +    gchar *output = g_strdup("\n"); -    if (!default_printer) { -        default_printer = ""; +    if (value & 0x0004) +      output = h_strdup_cprintf("\342\232\254 Can do black and white printing=\n", output); +    if (value & 0x0008) +      output = h_strdup_cprintf("\342\232\254 Can do color printing=\n", output); +    if (value & 0x0010) +      output = h_strdup_cprintf("\342\232\254 Can do duplexing=\n", output); +    if (value & 0x0020) +      output = h_strdup_cprintf("\342\232\254 Can do staple output=\n", output); +    if (value & 0x0040) +      output = h_strdup_cprintf("\342\232\254 Can do copies=\n", output); +    if (value & 0x0080) +      output = h_strdup_cprintf("\342\232\254 Can collate copies=\n", output); +    if (value & 0x80000) +      output = h_strdup_cprintf("\342\232\254 Printer is rejecting jobs=\n", output); +    if (value & 0x1000000) +      output = h_strdup_cprintf("\342\232\254 Printer was automatically discovered and added=\n", output); + +    return output; +  } else { +    return g_strdup("Unknown"); +  } +} + +gchar *__cups_callback_state(gchar *value) +{ +  if (!value) { +    return g_strdup("Unknown"); +  } + +  if (g_str_equal(value, "3")) { +    return g_strdup("Idle"); +  } else if (g_str_equal(value, "4")) { +    return g_strdup("Printing a Job"); +  } else if (g_str_equal(value, "5")) { +    return g_strdup("Stopped"); +  } else { +    return g_strdup("Unknown"); +  } +} + +gchar *__cups_callback_state_change_time(gchar *value) +{ +  struct tm tm; +  char buf[255]; +   +  if (value) { +    strptime(value, "%s", &tm); +    strftime(buf, sizeof(buf), "%c", &tm); + +    return g_strdup(buf); +  } else { +    return g_strdup("Unknown"); +  } +} + +gchar *__cups_callback_boolean(gchar *value) +{ +  if (value) { +    return g_strdup(g_str_equal(value, "1") ? "Yes" : "No"); +  } else { +    return g_strdup("Unknown"); +  } +} + +const struct { +  char *key, *name; +  gchar *(*callback)(gchar *value); +} cups_fields[] = { +  { "Printer Information", NULL, NULL }, +  { "printer-info", "Destination Name", NULL }, +  { "printer-make-and-model", "Make and Model", NULL }, +   +  { "Capabilities", NULL, NULL }, +  { "printer-type", "#", __cups_callback_ptype }, +   +  { "Printer State", NULL, NULL }, +  { "printer-state", "State", __cups_callback_state }, +  { "printer-state-change-time", "Change Time", __cups_callback_state_change_time }, +  { "printer-state-reasons", "State Reasons" }, +   +  { "Sharing Information", NULL, NULL }, +  { "printer-is-shared", "Shared?", __cups_callback_boolean }, +  { "printer-location", "Physical Location" }, +  { "auth-info-required", "Authentication Required", __cups_callback_boolean }, +   +  { "Jobs", NULL, NULL }, +  { "job-hold-until", "Hold Until", NULL }, +  { "job-priority", "Priority", NULL }, +  { "printer-is-accepting-jobs", "Accepting Jobs", __cups_callback_boolean }, +   +  { "Media", NULL, NULL }, +  { "media", "Media", NULL }, +  { "finishings", "Finishings", NULL }, +  { "copies", "Copies", NULL }, +}; + +void +__scan_printers(void) +{ +    int num_dests, i, j; +    CUPSDest *dests; +    gchar *prn_id, *prn_moreinfo; + +    g_free(printer_list); + +    if (!cups_init) { +        __init_cups(); +         +        printer_list = g_strdup("[Printers]\n" +                                "No suitable CUPS library found="); +        return;      } -     -    if (noprinters > 0) { + +    /* remove old devices from global device table */ +    g_hash_table_foreach_remove(moreinfo, remove_printer_devices, NULL); + +    num_dests = cups_dests_get(&dests); +    if (num_dests > 0) {  	printer_list = g_strdup_printf("[Printers (CUPS)]\n"); -	for (i = 0; i < noprinters; i++) { -	    printer_list = h_strdup_cprintf("\n$PRN%d$%s=%s\n", +	for (i = 0; i < num_dests; i++) { +	    GHashTable *options; +	     +	    options = g_hash_table_new(g_str_hash, g_str_equal); +	     +	    for (j = 0; j < dests[i].num_options; j++) { +	      g_hash_table_insert(options, +	                          g_strdup(dests[i].options[j].name), +	                          g_strdup(dests[i].options[j].value)); +	    } +	 +            prn_id = g_strdup_printf("PRN%d", i); +	 +	    printer_list = h_strdup_cprintf("\n$%s$%s=%s\n",  					    printer_list, -					    i,						 -					    printers[i], -                                            g_str_equal(default_printer, printers[i]) ? -				            "<i>(Default)</i>" : ""); -	    g_free(printers[i]); +					    prn_id,						 +					    dests[i].name, +					    dests[i].is_default ? "<i>Default</i>" : ""); + +            prn_moreinfo = g_strdup(""); +            for (j = 0; j < G_N_ELEMENTS(cups_fields); j++) { +              if (!cups_fields[j].name) { +                prn_moreinfo = h_strdup_cprintf("[%s]\n", +                                                prn_moreinfo, +                                                cups_fields[j].key); +              } else { +                gchar *temp; +                 +                temp = g_hash_table_lookup(options, cups_fields[j].key); +                 +                if (cups_fields[j].callback) { +                  temp = cups_fields[j].callback(temp); +                } else { +                  if (temp) { +                    /* FIXME Do proper escaping */ +                    temp = g_strdup(strreplace(temp, "&=", ' ')); +                  } else { +                    temp = g_strdup("Unknown"); +                  } +                } +                 +                prn_moreinfo = h_strdup_cprintf("%s=%s\n", +                                                prn_moreinfo, +                                                cups_fields[j].name, +                                                temp); +                 +                g_free(temp); +              } +            } +             +            g_hash_table_insert(moreinfo, prn_id, prn_moreinfo); +            g_hash_table_destroy(options);  	} -	g_free(printers); +	cups_dests_free(num_dests, dests);      } else {  	printer_list = g_strdup("[Printers]\n"  	                        "No printers found=\n"); diff --git a/arch/common/raytrace.h b/arch/common/raytrace.h index af9f2afa..7fdc5e21 100644 --- a/arch/common/raytrace.h +++ b/arch/common/raytrace.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -18,28 +18,27 @@  void fbench();	/* fbench.c */ +static gpointer +parallel_raytrace(unsigned int start, unsigned int end, gpointer data) +{ +    unsigned int i; +     +    for (i = start; i <= end; i++) {  +        fbench(); +    } +     +    return NULL; +} +  static void  benchmark_raytrace(void)  { -    int i; -    GTimer *timer = g_timer_new();      gdouble elapsed = 0;      shell_view_set_enabled(FALSE);      shell_status_update("Performing John Walker's FBENCH..."); -    for (i = 0; i <= 1000; i++) {  -        g_timer_start(timer); -         -        fbench(); -         -        g_timer_stop(timer); -        elapsed += g_timer_elapsed(timer, NULL); -         -        shell_status_set_percentage(i/10); -    } -     -    g_timer_destroy(timer); +    elapsed = benchmark_parallel_for(0, 1000, parallel_raytrace, NULL);      bench_results[BENCHMARK_RAYTRACE] = elapsed;  } diff --git a/arch/common/sha1.h b/arch/common/sha1.h deleted file mode 100644 index 3b7f7652..00000000 --- a/arch/common/sha1.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 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> - -static void -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_build_filename(params.path_data, "benchmark.data", NULL); -    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { -        g_free(bdata_path); -        return; -    }      -     -    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); -     -    bench_results[BENCHMARK_SHA1] = 312.0 / elapsed; -} - diff --git a/arch/common/users.h b/arch/common/users.h index fd8f7834..2361a4bf 100644 --- a/arch/common/users.h +++ b/arch/common/users.h @@ -1,5 +1,4 @@ -static gchar *sys_users = NULL, -             *human_users = NULL; +static gchar *users = NULL;  static gboolean  remove_users(gpointer key, gpointer value, gpointer data) @@ -17,15 +16,13 @@ scan_users_do(void)      if (!passwd)        return; -    if (sys_users) { -      g_free(sys_users); -      g_free(human_users); +    if (users) { +      g_free(users);        g_hash_table_foreach_remove(moreinfo, remove_users, NULL);      } -    sys_users = g_strdup(""); -    human_users = g_strdup(""); +    users = g_strdup("");      while (fgets(buffer, 512, passwd)) {        gchar **tmp; @@ -44,11 +41,7 @@ scan_users_do(void)        uid = atoi(tmp[2]);        strend(tmp[4], ','); -      if (uid >= 1000 && uid <= 65530) { -        human_users = h_strdup_cprintf("$%s$%s=%s\n", human_users, key, tmp[0], tmp[4]); -      } else { -        sys_users = h_strdup_cprintf("$%s$%s=%s\n", sys_users, key, tmp[0], tmp[4]); -      }       +      users = h_strdup_cprintf("$%s$%s=%s\n", users, key, tmp[0], tmp[4]);        g_strfreev(tmp);      } diff --git a/arch/common/zlib.h b/arch/common/zlib.h deleted file mode 100644 index 96d20944..00000000 --- a/arch/common/zlib.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 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 -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("/usr/lib/libz.so", G_MODULE_BIND_LAZY); -            if (!libz) { -                g_warning("Cannot load ZLib: %s", g_module_error()); -                return; -            } -	} - -	if (!g_module_symbol(libz, "compress", (gpointer) & compress) -	    || !g_module_symbol(libz, "compressBound", (gpointer) & compressBound)) { -	     -            g_module_close(libz); -	    return; -	} -    } - -    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_build_filename(params.path_data, "benchmark.data", NULL); -    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { -        g_free(bdata_path); -        return; -    }      -     -    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); -     -    bench_results[BENCHMARK_ZLIB] = 65536.0 / elapsed; -} | 
