diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/computer/memory.c | 18 | ||||
| -rw-r--r-- | modules/devices.c | 14 | ||||
| -rw-r--r-- | modules/devices/devmemory.c | 53 | 
3 files changed, 43 insertions, 42 deletions
diff --git a/modules/computer/memory.c b/modules/computer/memory.c index 3d320e8a..44b83df4 100644 --- a/modules/computer/memory.c +++ b/modules/computer/memory.c @@ -28,23 +28,23 @@ computer_get_memory(void)      procmem = fopen("/proc/meminfo", "r");      if (!procmem) -	return NULL; +        return NULL;      mi = g_new0(MemoryInfo, 1);      while (fgets(buffer, 128, procmem)) { -	gchar **tmp = g_strsplit(buffer, ":", 2); +        gchar **tmp = g_strsplit(buffer, ":", 2); -	tmp[0] = g_strstrip(tmp[0]); -	tmp[1] = g_strstrip(tmp[1]); +        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); +        get_int("MemTotal", mi->total); +        get_int("MemFree", mi->free); +        get_int("Cached", mi->cached); -	g_strfreev(tmp); +        g_strfreev(tmp);      }      fclose(procmem); -     +      mi->used = mi->total - mi->free;      mi->total  /= 1000; diff --git a/modules/devices.c b/modules/devices.c index 0cdb9a0d..01021a62 100644 --- a/modules/devices.c +++ b/modules/devices.c @@ -177,22 +177,22 @@ gchar *get_processor_frequency(void)  gchar *get_pci_device_description(gchar *pci_id)  {      gchar *description; -     +      if (!_pci_devices) {          scan_pci(FALSE);      } -     +      if ((description = g_hash_table_lookup(_pci_devices, pci_id))) {          return g_strdup(description);      } -     +      return NULL;  }  gchar *get_memory_total(void)  {      scan_memory(FALSE); -    return moreinfo_lookup ("DEV:Total Memory"); //hi_more_info(N_("Total Memory")); +    return moreinfo_lookup ("DEV:MemTotal");  }  /* information table from: http://elinux.org/RPi_HardwareHistory */ @@ -296,7 +296,7 @@ gchar *get_motherboard(void)      board_name = moreinfo_lookup("DEV:DMI:Board:Name");      board_vendor = moreinfo_lookup("DEV:DMI:Board:Vendor"); -     +      if (board_name && board_vendor && *board_name && *board_vendor)         return g_strconcat(board_vendor, " ", board_name, NULL);      else if (board_name && *board_name) @@ -344,7 +344,7 @@ ShellModuleMethod *hi_exported_methods(void)  gchar *hi_more_info(gchar * entry)  {      gchar *info = moreinfo_lookup_with_prefix("DEV", entry); -     +      if (info)  	return g_strdup(info); @@ -574,7 +574,7 @@ void hi_module_init(void)          .save_to = "cpuflags.conf",          .get_data = NULL        }; -       +        sync_manager_add_entry(&se);      }  #endif	/* defined(ARCH_x86) */ diff --git a/modules/devices/devmemory.c b/modules/devices/devmemory.c index 7131536c..8fef9d6b 100644 --- a/modules/devices/devmemory.c +++ b/modules/devices/devmemory.c @@ -23,10 +23,10 @@ GHashTable *memlabels = NULL;  void scan_memory_do(void)  { -    gchar **keys, *tmp; +    gchar **keys, *tmp, *tmp_label;      static gint offset = -1;      gint i; -     +      if (offset == -1) {          /* gah. linux 2.4 adds three lines of data we don't need in             /proc/meminfo */ @@ -38,38 +38,39 @@ void scan_memory_do(void)              offset = 0;          }      } -     +      g_file_get_contents("/proc/meminfo", &meminfo, NULL, NULL); -     +      keys = g_strsplit(meminfo, "\n", 0);      g_free(meminfo);      g_free(lginterval); -     +      meminfo = g_strdup("");      lginterval = g_strdup(""); -     +      for (i = offset; keys[i]; i++) {          gchar **newkeys = g_strsplit(keys[i], ":", 0); -         +          if (!newkeys[0]) {              g_strfreev(newkeys);              break;          } -         + +        g_strstrip(newkeys[0]);          g_strstrip(newkeys[1]); -         -        if ((tmp = g_hash_table_lookup(memlabels, newkeys[0]))) { -            g_free(newkeys[0]); -            newkeys[0] = g_strdup(tmp); -        } -         + +        /* try to find a localizable label */ +        tmp_label = g_hash_table_lookup(memlabels, newkeys[0]); +        if (tmp_label == NULL) +            tmp_label = newkeys[0]; +          moreinfo_add_with_prefix("DEV", newkeys[0], g_strdup(newkeys[1])); -        tmp = g_strconcat(meminfo, newkeys[0], "=", newkeys[1], "\n", NULL); +        tmp = g_strconcat(meminfo, _(tmp_label), "=", newkeys[1], "\n", NULL);          g_free(meminfo);          meminfo = tmp; -         +          tmp = g_strconcat(lginterval,                            "UpdateInterval$", newkeys[0], "=1000\n", NULL);          g_free(lginterval); @@ -86,21 +87,21 @@ void init_memory_labels(void)          char *proc_label;          char *real_label;      } proc2real[] = { -        { "MemTotal", N_("Total Memory") }, -        { "MemFree", N_("Free Memory") }, -        { "SwapCached",	N_("Cached Swap") }, -        { "HighTotal", N_("High Memory") }, -        { "HighFree", N_("Free High Memory") }, -        { "LowTotal", N_("Low Memory") }, -        { "LowFree", N_("Free Low Memory") }, -        { "SwapTotal", N_("Virtual Memory") }, -        { "SwapFree", N_("Free Virtual Memory") }, +        { "MemTotal",   N_("Total Memory") }, +        { "MemFree",    N_("Free Memory") }, +        { "SwapCached", N_("Cached Swap") }, +        { "HighTotal",  N_("High Memory") }, +        { "HighFree",   N_("Free High Memory") }, +        { "LowTotal",   N_("Low Memory") }, +        { "LowFree",    N_("Free Low Memory") }, +        { "SwapTotal",  N_("Virtual Memory") }, +        { "SwapFree",   N_("Free Virtual Memory") },          { NULL },      };      gint i;      memlabels = g_hash_table_new(g_str_hash, g_str_equal); -     +      for (i = 0; proc2real[i].proc_label; i++) {          g_hash_table_insert(memlabels, proc2real[i].proc_label,              _(proc2real[i].real_label));  | 
