diff options
Diffstat (limited to 'hardinfo2/arch')
| -rw-r--r-- | hardinfo2/arch/common/blowfish.h | 10 | ||||
| -rw-r--r-- | hardinfo2/arch/common/languages.h | 4 | ||||
| -rw-r--r-- | hardinfo2/arch/common/md5.h | 9 | ||||
| -rw-r--r-- | hardinfo2/arch/common/sha1.h | 10 | ||||
| -rw-r--r-- | hardinfo2/arch/common/users.h | 63 | ||||
| -rw-r--r-- | hardinfo2/arch/common/zlib.h | 11 | 
6 files changed, 96 insertions, 11 deletions
| diff --git a/hardinfo2/arch/common/blowfish.h b/hardinfo2/arch/common/blowfish.h index 7333d069..ad4bdb92 100644 --- a/hardinfo2/arch/common/blowfish.h +++ b/hardinfo2/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/hardinfo2/arch/common/languages.h b/hardinfo2/arch/common/languages.h index 3a31ef7f..71e05dab 100644 --- a/hardinfo2/arch/common/languages.h +++ b/hardinfo2/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/hardinfo2/arch/common/md5.h b/hardinfo2/arch/common/md5.h index f61aef0f..256d6c3b 100644 --- a/hardinfo2/arch/common/md5.h +++ b/hardinfo2/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/hardinfo2/arch/common/sha1.h b/hardinfo2/arch/common/sha1.h index 521cbcae..4bd07276 100644 --- a/hardinfo2/arch/common/sha1.h +++ b/hardinfo2/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/hardinfo2/arch/common/users.h b/hardinfo2/arch/common/users.h new file mode 100644 index 00000000..08acd97a --- /dev/null +++ b/hardinfo2/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/hardinfo2/arch/common/zlib.h b/hardinfo2/arch/common/zlib.h index f68d60f4..2a1007ed 100644 --- a/hardinfo2/arch/common/zlib.h +++ b/hardinfo2/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); | 
