aboutsummaryrefslogtreecommitdiff
path: root/hardinfo2/arch/linux/common/resources.h
diff options
context:
space:
mode:
authorLeandro A. F. Pereira <leandro@hardinfo.org>2008-06-30 17:35:58 -0300
committerLeandro A. F. Pereira <leandro@hardinfo.org>2008-06-30 17:35:58 -0300
commit47c10af317faae9184d5d9e1f1f37c2913a16ef7 (patch)
tree51caf0f6eeacc1745092a744f0f27df3686972c1 /hardinfo2/arch/linux/common/resources.h
parent60a29a76b55ec3a075cc585f7bd707bc170afaf4 (diff)
Make "Resources" information a little more meaningful.
If the resource is claimed by a kernel module, use its description. If the resource is reserved by a PCI device, use its name.
Diffstat (limited to 'hardinfo2/arch/linux/common/resources.h')
-rw-r--r--hardinfo2/arch/linux/common/resources.h44
1 files changed, 41 insertions, 3 deletions
diff --git a/hardinfo2/arch/linux/common/resources.h b/hardinfo2/arch/linux/common/resources.h
index 581d7eba..5e767caa 100644
--- a/hardinfo2/arch/linux/common/resources.h
+++ b/hardinfo2/arch/linux/common/resources.h
@@ -17,6 +17,41 @@
*/
gchar *_resources = NULL;
+
+#if GLIB_CHECK_VERSION(2,14,0)
+static GRegex *_regex_pci = NULL,
+ *_regex_module = NULL;
+static gchar *_resource_obtain_name(gchar *name)
+{
+ gchar *temp;
+
+ if (!_regex_pci && !_regex_module) {
+ _regex_pci = g_regex_new("^[0-9a-fA-F]{4}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}\\.[0-9a-fA-F]{1}$",
+ 0, 0, NULL);
+ _regex_module = g_regex_new("^[0-9a-zA-Z\\_\\-]+$", 0, 0, NULL);
+ }
+
+ name = g_strstrip(name);
+
+ if (g_regex_match(_regex_pci, name, 0, NULL)) {
+ temp = module_call_method_param("devices::getPCIDeviceDescription", name);
+ return temp ? temp : name;
+ }
+
+ if (g_regex_match(_regex_module, name, 0, NULL)) {
+ temp = module_call_method_param("computer::getKernelModuleDescription", name);
+ return temp ? temp : name;
+ }
+
+ return name;
+}
+#else
+static gchar *_resource_obtain_name(gchar *name)
+{
+ return name;
+}
+#endif
+
void scan_device_resources(gboolean reload)
{
SCAN_START();
@@ -32,7 +67,8 @@ void scan_device_resources(gboolean reload)
while (fgets(buffer, 256, io)) {
gchar **temp = g_strsplit(buffer, ":", 2);
- _resources = h_strdup_cprintf("%s=%s\n", _resources, temp[0], temp[1]);
+ _resources = h_strdup_cprintf("%s=%s\n", _resources,
+ temp[0], _resource_obtain_name(temp[1]));
g_strfreev(temp);
}
@@ -46,7 +82,8 @@ void scan_device_resources(gboolean reload)
while (fgets(buffer, 256, io)) {
gchar **temp = g_strsplit(buffer, ":", 2);
- _resources = h_strdup_cprintf("%s=%s\n", _resources, temp[0], temp[1]);
+ _resources = h_strdup_cprintf("%s=%s\n", _resources,
+ temp[0], _resource_obtain_name(temp[1]));
g_strfreev(temp);
}
@@ -60,7 +97,8 @@ void scan_device_resources(gboolean reload)
while (fgets(buffer, 256, io)) {
gchar **temp = g_strsplit(buffer, ":", 2);
- _resources = h_strdup_cprintf("%s=%s\n", _resources, temp[0], temp[1]);
+ _resources = h_strdup_cprintf("%s=%s\n", _resources,
+ temp[0], _resource_obtain_name(temp[1]));
g_strfreev(temp);
}