diff options
author | Simon Quigley <tsimonq2@ubuntu.com> | 2018-12-23 23:54:25 -0600 |
---|---|---|
committer | Simon Quigley <tsimonq2@ubuntu.com> | 2018-12-23 23:54:25 -0600 |
commit | a739f196cba9e5c4376e97b1ac95e1d15b1ccb55 (patch) | |
tree | eab9260f076de9ba9bf81e44c727c64a963a2895 /modules/devices/resources.c | |
parent | 3972650bc68dc3b846b6eabfd83e37872005741e (diff) |
Remove orig content.
Diffstat (limited to 'modules/devices/resources.c')
-rw-r--r-- | modules/devices/resources.c | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/modules/devices/resources.c b/modules/devices/resources.c deleted file mode 100644 index 15cb8f21..00000000 --- a/modules/devices/resources.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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 - */ - -#include <string.h> - -#include "devices.h" - -static gchar *_resources = NULL; -static gboolean _require_root = FALSE; - -#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); - if (temp) { - return g_strdup_printf("<b><small>PCI</small></b> %s", (gchar *)idle_free(temp)); - } - } else if (g_regex_match(_regex_module, name, 0, NULL)) { - temp = module_call_method_param("computer::getKernelModuleDescription", name); - if (temp) { - return g_strdup_printf("<b><small>Module</small></b> %s", (gchar *)idle_free(temp)); - } - } - - return g_strdup(name); -} -#else -static gchar *_resource_obtain_name(gchar *name) -{ - return g_strdup(name); -} -#endif - -void scan_device_resources(gboolean reload) -{ - SCAN_START(); - FILE *io; - gchar buffer[256]; - gint i; - gint zero_to_zero_addr = 0; - - struct { - gchar *file; - gchar *description; - } resources[] = { - { "/proc/ioports", "[I/O Ports]\n" }, - { "/proc/iomem", "[Memory]\n" }, - { "/proc/dma", "[DMA]\n" } - }; - - g_free(_resources); - _resources = g_strdup(""); - - for (i = 0; i < G_N_ELEMENTS(resources); i++) { - if ((io = fopen(resources[i].file, "r"))) { - _resources = h_strconcat(_resources, resources[i].description, NULL); - - while (fgets(buffer, 256, io)) { - gchar **temp = g_strsplit(buffer, ":", 2); - gchar *name = _resource_obtain_name(temp[1]); - - if (strstr(temp[0], "0000-0000")) - zero_to_zero_addr++; - - _resources = h_strdup_cprintf("<tt>%s</tt>=%s\n", _resources, - temp[0], name); - - g_strfreev(temp); - g_free(name); - } - - fclose(io); - } - } - - _require_root = zero_to_zero_addr > 16; - - SCAN_END(); -} - -gchar *callback_device_resources(void) -{ - return g_strdup(_resources); -} - -gboolean root_required_for_resources(void) -{ - return _require_root; -} |