diff options
Diffstat (limited to 'arch/linux/common')
61 files changed, 974 insertions, 2379 deletions
| diff --git a/arch/linux/common/.svn/README.txt b/arch/linux/common/.svn/README.txt deleted file mode 100644 index 271a8ce9..00000000 --- a/arch/linux/common/.svn/README.txt +++ /dev/null @@ -1,2 +0,0 @@ -This is a Subversion working copy administrative directory. -Visit http://subversion.tigris.org/ for more information. diff --git a/arch/linux/common/.svn/empty-file b/arch/linux/common/.svn/empty-file deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/empty-file +++ /dev/null diff --git a/arch/linux/common/.svn/entries b/arch/linux/common/.svn/entries deleted file mode 100644 index 590cfded..00000000 --- a/arch/linux/common/.svn/entries +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<wc-entries -   xmlns="svn:"> -<entry -   committed-rev="9" -   name="" -   committed-date="2006-03-07T18:26:23.507991Z" -   url="svn+ssh://lafp@svn.berlios.de/svnroot/repos/hardinfo/trunk/hardinfo2/arch/linux/common" -   last-author="lafp" -   kind="dir" -   uuid="03931a0e-0c0b-0410-87e6-c9e79dddb921" -   repos="svn+ssh://lafp@svn.berlios.de/svnroot/repos/hardinfo" -   revision="9"/> -<entry -   committed-rev="1" -   name="usb.h" -   text-time="2006-05-20T14:29:25.000000Z" -   committed-date="2006-01-23T22:38:33.949992Z" -   checksum="0c0cac5253587505cc065f0e256a5d4d" -   last-author="lafp" -   kind="file" -   prop-time="2006-05-20T14:29:24.000000Z"/> -<entry -   committed-rev="1" -   name="sensors.h" -   text-time="2006-05-20T14:29:25.000000Z" -   committed-date="2006-01-23T22:38:33.949992Z" -   checksum="29e1c509624467fe7314b4735e7111c0" -   last-author="lafp" -   kind="file" -   prop-time="2006-05-20T14:29:24.000000Z"/> -<entry -   committed-rev="12" -   name="inputdevices.h" -   text-time="2006-05-20T19:41:49.000000Z" -   committed-date="2006-05-20T19:59:34.736889Z" -   checksum="01a7b3bd4ca502e604a6feb9092523d8" -   last-author="lafp" -   kind="file" -   prop-time="2006-05-20T14:29:24.000000Z" -   revision="12"/> -<entry -   committed-rev="1" -   name="uptime.h" -   text-time="2006-05-20T14:29:25.000000Z" -   committed-date="2006-01-23T22:38:33.949992Z" -   checksum="4f5d1b5cb05b0f74f1cc5030d58568a4" -   last-author="lafp" -   kind="file" -   prop-time="2006-05-20T14:29:24.000000Z"/> -<entry -   committed-rev="1" -   name="storage.h" -   text-time="2006-05-20T14:29:25.000000Z" -   committed-date="2006-01-23T22:38:33.949992Z" -   checksum="d5793dc35001654f593b7b20028065d8" -   last-author="lafp" -   kind="file" -   prop-time="2006-05-20T14:29:25.000000Z"/> -<entry -   committed-rev="1" -   name="memory.h" -   text-time="2006-05-20T14:29:25.000000Z" -   committed-date="2006-01-23T22:38:33.949992Z" -   checksum="6003144cee387dca46d2ef91429c1d49" -   last-author="lafp" -   kind="file" -   prop-time="2006-05-20T14:29:25.000000Z"/> -<entry -   committed-rev="1" -   name="modules.h" -   text-time="2006-05-20T14:29:25.000000Z" -   committed-date="2006-01-23T22:38:33.949992Z" -   checksum="1ad54b4dd6e3eec6b953ad4ddf0fd860" -   last-author="lafp" -   kind="file" -   prop-time="2006-05-20T14:29:25.000000Z"/> -<entry -   committed-rev="4" -   name="pci.h" -   text-time="2006-05-20T14:29:25.000000Z" -   committed-date="2006-01-31T23:35:06.244169Z" -   checksum="37a5c5e99c34cbb4adbc4aa31e7fd457" -   last-author="lafp" -   kind="file" -   prop-time="2006-05-20T14:29:24.000000Z"/> -<entry -   committed-rev="1" -   name="loadavg.h" -   text-time="2006-05-20T14:29:25.000000Z" -   committed-date="2006-01-23T22:38:33.949992Z" -   checksum="d5c6e755bc626cbad504197c6806f532" -   last-author="lafp" -   kind="file" -   prop-time="2006-05-20T14:29:24.000000Z"/> -<entry -   committed-rev="1" -   name="alsa.h" -   text-time="2006-05-20T14:29:25.000000Z" -   committed-date="2006-01-23T22:38:33.949992Z" -   checksum="59621ae90495ca734fffde1d5c6a17f8" -   last-author="lafp" -   kind="file" -   prop-time="2006-05-20T14:29:24.000000Z"/> -<entry -   committed-rev="4" -   name="os.h" -   text-time="2006-05-20T14:29:25.000000Z" -   committed-date="2006-01-31T23:35:06.244169Z" -   checksum="5096953136a76251742ceedbe95b4b27" -   last-author="lafp" -   kind="file" -   prop-time="2006-05-20T14:29:24.000000Z"/> -<entry -   committed-rev="18" -   name="samba.h" -   text-time="2006-06-16T14:09:12.000000Z" -   committed-date="2006-06-16T14:09:52.687901Z" -   checksum="41d760d05bea9c45eba0622fe168b2fd" -   last-author="lafp" -   kind="file" -   prop-time="2006-05-20T14:29:24.000000Z" -   revision="18"/> -<entry -   committed-rev="9" -   name="filesystem.h" -   text-time="2006-05-20T14:29:25.000000Z" -   committed-date="2006-03-07T18:26:23.507991Z" -   checksum="964d2ae62a1d35e125607b9e13d56762" -   last-author="lafp" -   kind="file" -   prop-time="2006-05-20T14:29:25.000000Z"/> -<entry -   committed-rev="4" -   name="net.h" -   text-time="2006-05-20T14:29:25.000000Z" -   committed-date="2006-01-31T23:35:06.244169Z" -   checksum="cda86d4df0a7b91c598f6da5ec63b13e" -   last-author="lafp" -   kind="file" -   prop-time="2006-05-20T14:29:25.000000Z"/> -<entry -   committed-rev="14" -   name="nfs.h" -   text-time="2006-05-22T16:03:07.000000Z" -   committed-date="2006-05-22T16:05:56.041082Z" -   checksum="65db4676d1ef228ef7821c71ae185f67" -   last-author="lafp" -   kind="file" -   revision="14"/> -</wc-entries> diff --git a/arch/linux/common/.svn/format b/arch/linux/common/.svn/format deleted file mode 100644 index b8626c4c..00000000 --- a/arch/linux/common/.svn/format +++ /dev/null @@ -1 +0,0 @@ -4 diff --git a/arch/linux/common/.svn/prop-base/alsa.h.svn-base b/arch/linux/common/.svn/prop-base/alsa.h.svn-base deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/prop-base/alsa.h.svn-base +++ /dev/null diff --git a/arch/linux/common/.svn/prop-base/filesystem.h.svn-base b/arch/linux/common/.svn/prop-base/filesystem.h.svn-base deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/prop-base/filesystem.h.svn-base +++ /dev/null diff --git a/arch/linux/common/.svn/prop-base/inputdevices.h.svn-base b/arch/linux/common/.svn/prop-base/inputdevices.h.svn-base deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/prop-base/inputdevices.h.svn-base +++ /dev/null diff --git a/arch/linux/common/.svn/prop-base/loadavg.h.svn-base b/arch/linux/common/.svn/prop-base/loadavg.h.svn-base deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/prop-base/loadavg.h.svn-base +++ /dev/null diff --git a/arch/linux/common/.svn/prop-base/memory.h.svn-base b/arch/linux/common/.svn/prop-base/memory.h.svn-base deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/prop-base/memory.h.svn-base +++ /dev/null diff --git a/arch/linux/common/.svn/prop-base/modules.h.svn-base b/arch/linux/common/.svn/prop-base/modules.h.svn-base deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/prop-base/modules.h.svn-base +++ /dev/null diff --git a/arch/linux/common/.svn/prop-base/net.h.svn-base b/arch/linux/common/.svn/prop-base/net.h.svn-base deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/prop-base/net.h.svn-base +++ /dev/null diff --git a/arch/linux/common/.svn/prop-base/os.h.svn-base b/arch/linux/common/.svn/prop-base/os.h.svn-base deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/prop-base/os.h.svn-base +++ /dev/null diff --git a/arch/linux/common/.svn/prop-base/pci.h.svn-base b/arch/linux/common/.svn/prop-base/pci.h.svn-base deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/prop-base/pci.h.svn-base +++ /dev/null diff --git a/arch/linux/common/.svn/prop-base/samba.h.svn-base b/arch/linux/common/.svn/prop-base/samba.h.svn-base deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/prop-base/samba.h.svn-base +++ /dev/null diff --git a/arch/linux/common/.svn/prop-base/sensors.h.svn-base b/arch/linux/common/.svn/prop-base/sensors.h.svn-base deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/prop-base/sensors.h.svn-base +++ /dev/null diff --git a/arch/linux/common/.svn/prop-base/storage.h.svn-base b/arch/linux/common/.svn/prop-base/storage.h.svn-base deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/prop-base/storage.h.svn-base +++ /dev/null diff --git a/arch/linux/common/.svn/prop-base/uptime.h.svn-base b/arch/linux/common/.svn/prop-base/uptime.h.svn-base deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/prop-base/uptime.h.svn-base +++ /dev/null diff --git a/arch/linux/common/.svn/prop-base/usb.h.svn-base b/arch/linux/common/.svn/prop-base/usb.h.svn-base deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/prop-base/usb.h.svn-base +++ /dev/null diff --git a/arch/linux/common/.svn/props/alsa.h.svn-work b/arch/linux/common/.svn/props/alsa.h.svn-work deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/props/alsa.h.svn-work +++ /dev/null diff --git a/arch/linux/common/.svn/props/filesystem.h.svn-work b/arch/linux/common/.svn/props/filesystem.h.svn-work deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/props/filesystem.h.svn-work +++ /dev/null diff --git a/arch/linux/common/.svn/props/inputdevices.h.svn-work b/arch/linux/common/.svn/props/inputdevices.h.svn-work deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/props/inputdevices.h.svn-work +++ /dev/null diff --git a/arch/linux/common/.svn/props/loadavg.h.svn-work b/arch/linux/common/.svn/props/loadavg.h.svn-work deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/props/loadavg.h.svn-work +++ /dev/null diff --git a/arch/linux/common/.svn/props/memory.h.svn-work b/arch/linux/common/.svn/props/memory.h.svn-work deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/props/memory.h.svn-work +++ /dev/null diff --git a/arch/linux/common/.svn/props/modules.h.svn-work b/arch/linux/common/.svn/props/modules.h.svn-work deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/props/modules.h.svn-work +++ /dev/null diff --git a/arch/linux/common/.svn/props/net.h.svn-work b/arch/linux/common/.svn/props/net.h.svn-work deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/props/net.h.svn-work +++ /dev/null diff --git a/arch/linux/common/.svn/props/os.h.svn-work b/arch/linux/common/.svn/props/os.h.svn-work deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/props/os.h.svn-work +++ /dev/null diff --git a/arch/linux/common/.svn/props/pci.h.svn-work b/arch/linux/common/.svn/props/pci.h.svn-work deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/props/pci.h.svn-work +++ /dev/null diff --git a/arch/linux/common/.svn/props/samba.h.svn-work b/arch/linux/common/.svn/props/samba.h.svn-work deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/props/samba.h.svn-work +++ /dev/null diff --git a/arch/linux/common/.svn/props/sensors.h.svn-work b/arch/linux/common/.svn/props/sensors.h.svn-work deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/props/sensors.h.svn-work +++ /dev/null diff --git a/arch/linux/common/.svn/props/storage.h.svn-work b/arch/linux/common/.svn/props/storage.h.svn-work deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/props/storage.h.svn-work +++ /dev/null diff --git a/arch/linux/common/.svn/props/uptime.h.svn-work b/arch/linux/common/.svn/props/uptime.h.svn-work deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/props/uptime.h.svn-work +++ /dev/null diff --git a/arch/linux/common/.svn/props/usb.h.svn-work b/arch/linux/common/.svn/props/usb.h.svn-work deleted file mode 100644 index e69de29b..00000000 --- a/arch/linux/common/.svn/props/usb.h.svn-work +++ /dev/null diff --git a/arch/linux/common/.svn/text-base/alsa.h.svn-base b/arch/linux/common/.svn/text-base/alsa.h.svn-base deleted file mode 100644 index 0c0744ae..00000000 --- a/arch/linux/common/.svn/text-base/alsa.h.svn-base +++ /dev/null @@ -1,69 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 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 - */ - -gchar * -computer_get_alsacards(Computer * computer) -{ -    GSList *p; -    gchar *tmp = ""; -    gint n = 0; - -    if (computer->alsa) { -	for (p = computer->alsa->cards; p; p = p->next) { -	    AlsaCard *ac = (AlsaCard *) p->data; - -	    tmp = -		g_strdup_printf("Audio Adapter#%d=%s\n%s", ++n, -				ac->friendly_name, tmp); -	} -    } - -    return tmp; -} - -static AlsaInfo * -computer_get_alsainfo(void) -{ -    AlsaInfo *ai; -    AlsaCard *ac; -    FILE *cards; -    gchar buffer[128]; - -    cards = fopen("/proc/asound/cards", "r"); -    if (!cards) -	return NULL; - -    ai = g_new0(AlsaInfo, 1); - -    while (fgets(buffer, 128, cards)) { -	gchar **tmp; - -	ac = g_new0(AlsaCard, 1); - -	tmp = g_strsplit(buffer, ":", 0); - -	ac->friendly_name = g_strdup(tmp[1]); -	ai->cards = g_slist_append(ai->cards, ac); - -	g_strfreev(tmp); -	fgets(buffer, 128, cards);	/* skip next line */ -    } -    fclose(cards); - -    return ai; -} diff --git a/arch/linux/common/.svn/text-base/filesystem.h.svn-base b/arch/linux/common/.svn/text-base/filesystem.h.svn-base deleted file mode 100644 index 79784c8f..00000000 --- a/arch/linux/common/.svn/text-base/filesystem.h.svn-base +++ /dev/null @@ -1,102 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 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 - * - * Some code from xfce4-mount-plugin, version 0.4.3 - *  Copyright (C) 2005 Jean-Baptiste jb_dul@yahoo.com  - *  Distributed under the terms of GNU GPL 2.  - */ -#include <sys/vfs.h> -#define KB 1024 -#define MB 1048576 -#define GB 1073741824 - -static gchar *fs_list = NULL; - -static gchar * -fs_human_readable(gfloat size) -{ -    if (size < KB) -	return g_strdup_printf("%.1f B", size); -    if (size < MB) -	return g_strdup_printf("%.1f KiB", size / KB); -    if (size < GB) -	return g_strdup_printf("%.1f MiB", size / MB); - -    return g_strdup_printf("%.1f GiB", size / GB); -} - -static void -scan_filesystems(void) -{ -    FILE *mtab; -    gchar buf[1024]; -    struct statfs sfs; - -    g_free(fs_list); -    fs_list = g_strdup(""); - -    mtab = fopen("/etc/mtab", "r"); -    if (!mtab) -	return; - -    while (fgets(buf, 1024, mtab)) { -	gfloat size, used, avail; -	gchar **tmp; - -	tmp = g_strsplit(buf, " ", 0); -	if (!statfs(tmp[1], &sfs)) { -		size = (float) sfs.f_bsize * (float) sfs.f_blocks; -		avail = (float) sfs.f_bsize * (float) sfs.f_bavail; -		used = size - avail; - -		gchar *strsize = fs_human_readable(size), -		      *stravail = fs_human_readable(avail), -	  	      *strused = fs_human_readable(used); - -		gchar *strhash; -		if ((strhash = g_hash_table_lookup(moreinfo, tmp[0]))) { -		    g_hash_table_remove(moreinfo, tmp[0]); -		    g_free(strhash); -		} - -		strhash = g_strdup_printf("[%s]\n" -					  "Filesystem=%s\n" -					  "Mounted As=%s\n" -					  "Mount Point=%s\n" -					  "Size=%s\n" -					  "Used=%s\n" -					  "Available=%s\n", -					  tmp[0], -					  tmp[2], -					  strstr(tmp[3], "rw") ? "Read-Write" : -					  "Read-Only", tmp[1], strsize, strused, -					  stravail); -		g_hash_table_insert(moreinfo, g_strdup(tmp[0]), strhash); - -		fs_list = g_strdup_printf("%s$%s$%s=%s total, %s free\n", -					  fs_list, -					  tmp[0], tmp[0], strsize, stravail); - -		g_free(strsize); -		g_free(stravail); -		g_free(strused); -	} -	g_strfreev(tmp); -    } - -    fclose(mtab); -} diff --git a/arch/linux/common/.svn/text-base/inputdevices.h.svn-base b/arch/linux/common/.svn/text-base/inputdevices.h.svn-base deleted file mode 100644 index 44a109ca..00000000 --- a/arch/linux/common/.svn/text-base/inputdevices.h.svn-base +++ /dev/null @@ -1,122 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 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 gchar *input_icons = NULL; - -static gboolean -remove_input_devices(gpointer key, gpointer value, gpointer data) -{ -    if (!strncmp((gchar *) key, "INP", 3)) { -	g_free((gchar *) key); -	g_free((GtkTreeIter *) value); -	return TRUE; -    } - -    return FALSE; -} - -static struct { -    char *name; -    char *icon; -} input_devices[] = { -    { "Keyboard", "keyboard.png" }, -    { "Joystick", "joystick.png" }, -    { "Mouse",    "mouse.png"    }, -    { "Speaker",  "audio.png"  }, -    { "Unknown",  "module.png"   }, -}; - -void -scan_inputdevices(void) -{ -    FILE *dev; -    gchar buffer[128]; -    gchar *tmp, *name = NULL, *phys = NULL; -    gint bus, vendor, product, version; -    int d = 0, n = 0; - -    dev = fopen("/proc/bus/input/devices", "r"); -    if (!dev) -	return; - -    if (input_list) { -	g_hash_table_foreach_remove(devices, remove_input_devices, NULL); -	g_free(input_list); -	g_free(input_icons); -    } -    input_list = g_strdup(""); -    input_icons = g_strdup(""); - -    while (fgets(buffer, 128, dev)) { -	tmp = buffer; - -	switch (*tmp) { -	case 'N': -	    name = g_strdup(tmp + strlen("N: Name=")); -	    remove_quotes(name); -	    break; -	case 'P': -	    phys = g_strdup(tmp + strlen("P: Phys=")); -	    break; -	case 'I': -	    sscanf(tmp, "I: Bus=%x Vendor=%x Product=%x Version=%x", -		   &bus, &vendor, &product, &version); -	    break; -	case 'H': -	    if (strstr(tmp, "kbd")) -		d = 0;		//INPUT_KEYBOARD; -	    else if (strstr(tmp, "js")) -		d = 1;		//INPUT_JOYSTICK; -	    else if (strstr(tmp, "mouse")) -		d = 2;		//INPUT_MOUSE; -	    else -		d = 4;		//INPUT_UNKNOWN; -	    break; -	case '\n': -	    if (strstr(name, "PC Speaker")) { -	      d = 3;		// INPUT_PCSPKR -	    } -	 -	    tmp = g_strdup_printf("INP%d", ++n); -	    input_list = g_strdup_printf("%s$%s$%s=\n", -					 input_list, -					 tmp, name); -	    input_icons = g_strdup_printf("%sIcon$%s$%s=%s\n", -				 	  input_icons, -					  tmp, name, -					  input_devices[d].icon); -	    gchar *strhash = g_strdup_printf("[Device Information]\n" -					     "Name=%s\n" -					     "Type=%s\n" -					     "Bus=0x%x\n" -					     "Vendor=0x%x\n" -					     "Product=0x%x\n" -					     "Version=0x%x\n" -					     "Connected to=%s\n", -					     name, input_devices[d].name, -					     bus, vendor, product, -					     version, phys); -	    g_hash_table_insert(devices, tmp, strhash); - -	    g_free(phys); -	    g_free(name); -	} -    } - -    fclose(dev); -} diff --git a/arch/linux/common/.svn/text-base/loadavg.h.svn-base b/arch/linux/common/.svn/text-base/loadavg.h.svn-base deleted file mode 100644 index 28132b5f..00000000 --- a/arch/linux/common/.svn/text-base/loadavg.h.svn-base +++ /dev/null @@ -1,47 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 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 LoadInfo * -computer_get_loadinfo(void) -{ -    LoadInfo *li = g_new0(LoadInfo, 1); -    FILE *procloadavg; - -    procloadavg = fopen("/proc/loadavg", "r"); -    fscanf(procloadavg, "%f %f %f", &(li->load1), &(li->load5), -	   &(li->load15)); -    fclose(procloadavg); - -    return li; -} - -static gchar * -computer_get_formatted_loadavg() -{ -    LoadInfo *li; -    gchar *tmp; - -    li = computer_get_loadinfo(); - -    tmp = -	g_strdup_printf("%.2f, %.2f, %.2f", li->load1, li->load5, -			li->load15); - -    g_free(li); -    return tmp; -} diff --git a/arch/linux/common/.svn/text-base/memory.h.svn-base b/arch/linux/common/.svn/text-base/memory.h.svn-base deleted file mode 100644 index def4cc1d..00000000 --- a/arch/linux/common/.svn/text-base/memory.h.svn-base +++ /dev/null @@ -1,56 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 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 MemoryInfo * -computer_get_memory(void) -{ -    MemoryInfo *mi; -    FILE *procmem; -    gchar buffer[128]; - -    procmem = fopen("/proc/meminfo", "r"); -    if (!procmem) -	return NULL; -    mi = g_new0(MemoryInfo, 1); - -    while (fgets(buffer, 128, procmem)) { -	gchar **tmp = g_strsplit(buffer, ":", 2); - -	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); - -	g_strfreev(tmp); -    } -    fclose(procmem); -     -    mi->used = mi->total - mi->free; - -    mi->total  /= 1000; -    mi->cached /= 1000; -    mi->used   /= 1000; -    mi->free   /= 1000; - -    mi->used -= mi->cached; -    mi->ratio = 1 - (gdouble) mi->used / mi->total; - -    return mi; -} diff --git a/arch/linux/common/.svn/text-base/modules.h.svn-base b/arch/linux/common/.svn/text-base/modules.h.svn-base deleted file mode 100644 index 69f7ebd6..00000000 --- a/arch/linux/common/.svn/text-base/modules.h.svn-base +++ /dev/null @@ -1,129 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 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 - */ - -void -scan_modules(void) -{ -    FILE *lsmod; -    gchar buffer[1024]; - -    lsmod = popen("/sbin/lsmod", "r"); -    if (!lsmod) -	return; - -    fgets(buffer, 1024, lsmod);	/* Discards the first line */ - -    while (fgets(buffer, 1024, lsmod)) { -	gchar *buf, *strmodule, *hashkey; -	gchar *author = NULL, -	    *description = NULL, -	    *license = NULL, -	    *deps = NULL, *vermagic = NULL, *filename = NULL, modname[64]; -	FILE *modi; -	glong memory; - -	shell_status_pulse(); - -	buf = buffer; - -	sscanf(buf, "%s %ld", modname, &memory); - -	hashkey = g_strdup_printf("MOD%s", modname); -	buf = g_strdup_printf("/sbin/modinfo %s", modname); - -	modi = popen(buf, "r"); -	while (fgets(buffer, 1024, modi)) { -	    gchar **tmp = g_strsplit(buffer, ":", 2); - -	    GET_STR("author", author); -	    GET_STR("description", description); -	    GET_STR("license", license); -	    GET_STR("depends", deps); -	    GET_STR("vermagic", vermagic); -	    GET_STR("filename", filename); - -	    g_strfreev(tmp); -	} -	pclose(modi); -	g_free(buf); - -	/* old modutils includes quotes in some strings; strip them */ -	/*remove_quotes(modname); -	   remove_quotes(description); -	   remove_quotes(vermagic); -	   remove_quotes(author); -	   remove_quotes(license); */ - -	/* old modutils displays <none> when there's no value for a -	   given field; this is not desirable in the module name  -	   display, so change it to an empty string */ -	if (description && !strcmp(description, "<none>")) { -	    g_free(description); -	    description = g_strdup(""); -	} - -	/* append this module to the list of modules */ -	module_list = g_strdup_printf("%s$%s$%s=%s\n", -				      module_list, -				      hashkey, -				      modname, -				      description ? description : ""); - -#define NONE_IF_NULL(var) (var) ? (var) : "N/A" - -	/* create the module information string */ -	strmodule = g_strdup_printf("[Module Information]\n" -				    "Path=%s\n" -				    "Used Memory=%.2fKiB\n" -				    "[Description]\n" -				    "Name=%s\n" -				    "Description=%s\n" -				    "Version Magic=%s\n" -				    "[Copyright]\n" -				    "Author=%s\n" -				    "License=%s\n", -				    NONE_IF_NULL(filename), -				    memory / 1024.0, -				    NONE_IF_NULL(modname), -				    NONE_IF_NULL(description), -				    NONE_IF_NULL(vermagic), -				    NONE_IF_NULL(author), -				    NONE_IF_NULL(license)); - -	/* if there are dependencies, append them to that string */ -	if (deps && strlen(deps)) { -	    gchar **tmp = g_strsplit(deps, ",", 0); - -	    strmodule = g_strconcat(strmodule, -                                    "\n[Dependencies]\n", -                                    g_strjoinv("=\n", tmp), -                                    "=\n", NULL); -	    g_strfreev(tmp); -	    g_free(deps); -	} - -	g_hash_table_insert(devices, hashkey, strmodule); - -	g_free(license); -	g_free(description); -	g_free(author); -	g_free(vermagic); -	g_free(filename); -    } -    pclose(lsmod); -} diff --git a/arch/linux/common/.svn/text-base/net.h.svn-base b/arch/linux/common/.svn/text-base/net.h.svn-base deleted file mode 100644 index 87e7e59b..00000000 --- a/arch/linux/common/.svn/text-base/net.h.svn-base +++ /dev/null @@ -1,203 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 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 gchar *network_interfaces = NULL; - -#include <sys/ioctl.h> -#include <net/if.h> -#include <netinet/in.h> -#include <linux/sockios.h> -#include <sys/socket.h> - -typedef struct _NetInfo NetInfo; -struct _NetInfo { -    char                name[16];  -    int                 mtu; -    unsigned char       mac[8]; -}; - - -void get_net_info(char *if_name, NetInfo *netinfo) -{ -    struct ifreq ifr; -    int fd; - -    fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); - -    strcpy(ifr.ifr_name, if_name); -    strcpy(netinfo->name, if_name); - -    if (ioctl(fd, SIOCGIFMTU, &ifr) < 0) { -        netinfo->mtu = 0; -    } else { -        netinfo->mtu = ifr.ifr_mtu; -    } -     -    strcpy(ifr.ifr_name, if_name); -    if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { -        memset(netinfo->mac, 0, 8); -    } else { -        memcpy(netinfo->mac, ifr.ifr_ifru.ifru_hwaddr.sa_data, 8); -    } - -    shutdown(fd, 0); -} - -static struct { -    char *type; -    char *label; -} netdev2type[] = { -    { "eth",	"Ethernet" }, -    { "lo",	"Loopback" }, -    { "ppp",	"Point-to-Point" }, -    { "ath",	"Wireless" }, -    { "wlan",	"Wireless" }, -    { "tun",    "Virtual Point-to-Point (TUN)" }, -    { "tap",    "Ethernet (TAP)" }, -    { "plip",   "Parallel Line Internet Protocol" }, -    { "irlan",  "Infrared" }, -    { "slip",   "Serial Line Internet Protocol" }, -    { "isdn",	"Integrated Services Digital Network" }, -    { "sit",	"IPv6-over-IPv4 Tunnel" }, -    { "vmnet8", "VMWare Virtual Network Interface (NAT)" }, -    { "vmnet",  "VMWare Virtual Network Interface" }, -    { NULL,	"Unknown" }, -}; - -static const gchar * -net_get_iface_type(gchar *name) -{ -    int i; -     -    for (i = 0; netdev2type[i].type; i++) { -        if (g_str_has_prefix(name, netdev2type[i].type)) -            break; -    } -     -    return netdev2type[i].label; -} - -static gboolean -remove_net_devices(gpointer key, gpointer value, gpointer data) -{ -    if (!strncmp((gchar *) key, "NET", 4)) { -	g_free((gchar *) key); -	g_free((GtkTreeIter *) value); -	return TRUE; -    } -    return FALSE; -} - -static void -scan_net_interfaces_24(void) -{ -    FILE *proc_net; -    NetInfo ni; -    gchar buffer[256]; -    gchar *devid, *detailed; -    gulong recv_bytes; -    gulong recv_errors; -    gulong recv_packets; -     -    gulong trans_bytes; -    gulong trans_errors; -    gulong trans_packets; -     -    if (!g_file_test("/proc/net/dev", G_FILE_TEST_EXISTS)) { -        if (network_interfaces) { -            g_free(network_interfaces); -            network_interfaces = g_strdup("[Network Interfaces]\n" -                                          "None found=\n"); -        } - -	return; -    } - -    if (network_interfaces) { -        g_free(network_interfaces); -    } -     -    network_interfaces = g_strdup("[Network Interfaces]\n"); - -    proc_net = fopen("/proc/net/dev", "r"); -    while (fgets(buffer, 256, proc_net)) { -	if (strchr(buffer, ':')) { -	    gint trash; -	    gchar ifacename[16]; -	    gchar *buf = buffer; -	    gint i; - -	    buf = g_strstrip(buf); - -	    memset(ifacename, 0, 16); - -	    for (i = 0; buffer[i] != ':' && i < 16; i++) { -		ifacename[i] = buffer[i]; -	    } - -	    buf = strchr(buf, ':') + 1; - -	    /* iface: bytes packets errs drop fifo frame compressed multicast */ -	    sscanf(buf, "%ld %ld %ld %d %d %d %d %d %ld %ld %ld", -		   &recv_bytes, &recv_packets, -		   &recv_errors, &trash, &trash, &trash, &trash, -		   &trash, &trans_bytes, &trans_packets, -		   &trans_errors); - -            gfloat recv_mb = recv_bytes / 1048576.0; -            gfloat trans_mb = trans_bytes / 1048576.0; -             -            devid = g_strdup_printf("NET%s", ifacename); -	    network_interfaces = g_strdup_printf("%s$%s$%s=Sent %.2fMiB, received %.2fMiB\n", -                                                  network_interfaces, -                                                  devid, -                                                  ifacename, -                                                  trans_mb, -                                                  recv_mb); -             -            get_net_info(ifacename, &ni); -            detailed = g_strdup_printf("[Network Adapter Properties]\n" -                                        "Interface Type=%s\n" -                                        "Hardware Address=%02x:%02x:%02x:%02x:%02x:%02x\n" -                                        "MTU=%d\n" -                                        "Bytes Sent=%ld (%.2fMiB)\n" -                                        "Bytes Received=%ld (%.2fMiB)\n", -                                        net_get_iface_type(ifacename), -                                        ni.mac[0], ni.mac[1], -                                        ni.mac[2], ni.mac[3], -                                        ni.mac[4], ni.mac[5], -                                        ni.mtu, -                                        recv_bytes, recv_mb, -                                        trans_bytes, trans_mb); -            g_hash_table_insert(moreinfo, devid, detailed); -	} -    } -    fclose(proc_net); -} - -static void -scan_net_interfaces(void) -{ -    /* FIXME: See if we're running Linux 2.6 and if /sys is mounted, then use -              that instead of /proc/net/dev */ - -    /* remove old devices from global device table */ -    g_hash_table_foreach_remove(moreinfo, remove_net_devices, NULL); - -    scan_net_interfaces_24(); -} diff --git a/arch/linux/common/.svn/text-base/nfs.h.svn-base b/arch/linux/common/.svn/text-base/nfs.h.svn-base deleted file mode 100644 index 5ae22797..00000000 --- a/arch/linux/common/.svn/text-base/nfs.h.svn-base +++ /dev/null @@ -1,29 +0,0 @@ -static gchar *nfs_shares_list = NULL; -void -scan_nfs_shared_directories(void) -{ -    FILE *exports; -    gchar buf[512]; -     -    if (nfs_shares_list) { -        g_free(nfs_shares_list); -    } - -    nfs_shares_list = g_strdup(""); -     -    exports = fopen("/etc/exports", "r"); -    if (!exports) -        return; -         -    while (fgets(buf, 512, exports)) { -        if (buf[0] != '/') -            continue; -         -        strend(buf, ' '); -        strend(buf, '\t'); - -        nfs_shares_list = g_strconcat(nfs_shares_list, buf, "=\n", NULL); -    } -    fclose(exports); -} - diff --git a/arch/linux/common/.svn/text-base/os.h.svn-base b/arch/linux/common/.svn/text-base/os.h.svn-base deleted file mode 100644 index 0f7b59e3..00000000 --- a/arch/linux/common/.svn/text-base/os.h.svn-base +++ /dev/null @@ -1,203 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 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 gchar * -get_libc_version(void) -{ -    FILE *libc; -    gchar buf[256], *tmp, *p; -     -    libc = popen("/lib/libc.so.6", "r"); -    if (!libc) goto err; -     -    fgets(buf, 256, libc); -    if (pclose(libc)) goto err; -     -    tmp = strstr(buf, "version "); -    if (!tmp) goto err; -     -    p = strchr(tmp, ','); -    if (p) *p = '\0'; -    else goto err; -     -    return g_strdup_printf("GNU C Library version %s (%sstable)", -                           strchr(tmp, ' ') + 1, -                           strstr(buf, " stable ") ? "" : "un"); -  err: -    return g_strdup("Unknown"); -} - -static gchar * -get_os_compiled_date(void) -{ -    FILE *procversion; -    gchar buf[512]; - -    procversion = fopen("/proc/sys/kernel/version", "r"); -    if (!procversion) -	return g_strdup("Unknown"); - -    fgets(buf, 512, procversion); -    fclose(procversion); - -    return g_strdup(buf); -} - - -#include <gdk/gdkx.h> - -void -detect_desktop_environment(OperatingSystem * os) -{ -    const gchar *tmp = g_getenv("GNOME_DESKTOP_SESSION_ID"); -    FILE *version; -    int maj, min; - -    if (tmp) { -	/* FIXME: this might not be true, as the gnome-panel in path -	   may not be the one that's running. -	   see where the user's running panel is and run *that* to -	   obtain the version. */ -	version = popen("gnome-panel --version", "r"); -	if (version) { -	    fscanf(version, "Gnome gnome-panel %d.%d", &maj, &min); -	    if (pclose(version)) -	        goto unknown; -	} else { -	    goto unknown; -	} - -	os->desktop = -	    g_strdup_printf("GNOME %d.%d (session name: %s)", maj, min, -			    tmp); -    } else if (g_getenv("KDE_FULL_SESSION")) { -	version = popen("kcontrol --version", "r"); -	if (version) { -	    char buf[32]; - -	    fgets(buf, 32, version); - -	    fscanf(version, "KDE: %d.%d", &maj, &min); -	    if (pclose(version)) -	        goto unknown; -	} else { -	    goto unknown; -	} - -	os->desktop = g_strdup_printf("KDE %d.%d", maj, min); -    } else { -      unknown: -	if (!g_getenv("DISPLAY")) { -	    os->desktop = g_strdup("Terminal"); -	} else { -            const gchar *windowman; -            GdkScreen *screen = gdk_screen_get_default(); - -            windowman = gdk_x11_screen_get_window_manager_name(screen); -             -            if (g_str_equal(windowman, "Xfwm4")) { -                /* FIXME: check if xprop -root | grep XFCE_DESKTOP_WINDOW -                   is defined */ -                os->desktop = g_strdup("XFCE 4"); -            } else { -  	        os->desktop = g_strdup_printf("Unknown (Window Manager: %s)", -  	                                      windowman); -            } -	} -    } -} - -static OperatingSystem * -computer_get_os(void) -{ -    struct utsname utsbuf; -    OperatingSystem *os; -    int i; - -    os = g_new0(OperatingSystem, 1); - -    os->compiled_date = get_os_compiled_date(); - -    /* Attempt to get the Distribution name; try using /etc/lsb-release first, -       then doing the legacy method (checking for /etc/$DISTRO-release files) */ -    if (g_file_test("/etc/lsb-release", G_FILE_TEST_EXISTS)) { -	FILE *release; -	gchar buffer[128]; - -	release = popen("lsb_release -d", "r"); -	fgets(buffer, 128, release); -	pclose(release); - -	os->distro = buffer; -	os->distro = g_strdup(os->distro + strlen("Description:\t")); -    } - -    for (i = 0;; i++) { -	if (distro_db[i].file == NULL) { -	    os->distrocode = g_strdup("unk"); -	    os->distro = g_strdup("Unknown distribution"); -	    break; -	} - -	if (g_file_test(distro_db[i].file, G_FILE_TEST_EXISTS)) { - - -	    FILE *distro_ver; -	    char buf[128]; - -	    distro_ver = fopen(distro_db[i].file, "r"); -	    fgets(buf, 128, distro_ver); -	    fclose(distro_ver); - -	    buf[strlen(buf) - 1] = 0; - -	    if (!os->distro) { -		/* -		 * HACK: Some Debian systems doesn't include -		 * the distribuition name in /etc/debian_release, -		 * so add them here.  -		 */ -		if (!strncmp(distro_db[i].codename, "deb", 3) && -		    ((buf[0] >= '0' && buf[0] <= '9') || buf[0] != 'D')) { -		    os->distro = g_strdup_printf -			("Debian GNU/Linux %s", buf); -		} else { -		    os->distro = g_strdup(buf); -		} -	    } -	    os->distrocode = g_strdup(distro_db[i].codename); - -	    break; -	} -    } - -    /* Kernel and hostname info */ -    uname(&utsbuf); -    os->kernel = g_strdup_printf("%s %s (%s)", utsbuf.sysname, -				 utsbuf.release, utsbuf.machine); -    os->hostname = g_strdup(utsbuf.nodename); -    os->language = g_strdup(g_getenv("LC_MESSAGES")); -    os->homedir = g_strdup(g_get_home_dir()); -    os->username = g_strdup_printf("%s (%s)", -				   g_get_user_name(), g_get_real_name()); -    os->libc = get_libc_version(); -    scan_languages(os); -    detect_desktop_environment(os); - -    return os; -} diff --git a/arch/linux/common/.svn/text-base/pci.h.svn-base b/arch/linux/common/.svn/text-base/pci.h.svn-base deleted file mode 100644 index f8c9d319..00000000 --- a/arch/linux/common/.svn/text-base/pci.h.svn-base +++ /dev/null @@ -1,190 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 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 - */ - -void -scan_pci(void) -{ -    FILE *lspci; -    gchar buffer[256], *buf, *strhash = NULL, *strdevice = NULL; -    gchar *category = NULL, *name = NULL; -    gint n = 0; - -    //if (g_file_test("/usr/bin/gksudo", G_FILE_TEST_EXISTS)) { -    //  lspci = popen("gksudo '/bin/lspci -v'", "r"); -    //} else { -    lspci = popen(LSPCI, "r"); -    //} - -    if (!lspci) { -	return; -    } - -    gchar *icon; -     -    int x = 0;			/* unique Memory, Capability and I/O port */ -    while (fgets(buffer, 256, lspci)) { -	buf = g_strstrip(buffer); - -	if (!strncmp(buf, "Flags", 5)) { -	    gint irq = 0, freq = 0, latency = 0, i; -	    gchar **list; -	    gboolean bus_master; - -	    buf += 7; - -	    bus_master = FALSE; - -	    list = g_strsplit(buf, ", ", 10); -	    for (i = 0; i <= 10; i++) { -		if (!list[i]) -		    break; - -		if (!strncmp(list[i], "IRQ", 3)) -		    sscanf(list[i], "IRQ %d", &irq); -		else if (strstr(list[i], "Mhz")) -		    sscanf(list[i], "%dMhz", &freq); -		else if (!strncmp(list[i], "bus master", 10)) -		    bus_master = TRUE; -		else if (!strncmp(list[i], "latency", 7)) -		    sscanf(list[i], "latency %d", &latency); -	    } -	    g_strfreev(list); - -	    if (irq) -		strdevice = g_strdup_printf("%sIRQ=%d\n", strdevice, irq); -	    if (freq) -		strdevice = -		    g_strdup_printf("%sFrequency=%dMHz\n", strdevice, -				    freq); -	    if (latency) -		strdevice = -		    g_strdup_printf("%sLatency=%d\n", strdevice, latency); - -	    strdevice = -		g_strdup_printf("%sBus Master=%s\n", strdevice, -				bus_master ? "Yes" : "No"); -	} else if (!strncmp(buf, "Subsystem", 9)) { -	    WALK_UNTIL(' '); -	    buf++; -	    strdevice = -		g_strdup_printf("%sOEM Vendor=%s\n", strdevice, buf); -	} else if (!strncmp(buf, "Capabilities", 12) -		   && !strstr(buf, "only to root") &&  -		      !strstr(buf, "access denied")) { -	    WALK_UNTIL(' '); -	    WALK_UNTIL(']'); -	    buf++; -	    strdevice = -		g_strdup_printf("%sCapability#%d=%s\n", strdevice, ++x, -				buf); -	} else if (!strncmp(buf, "Memory at", 9) && strstr(buf, "[size=")) { -	    gint mem; -	    gchar unit; -	    gboolean prefetch; -	    gboolean _32bit; - -	    prefetch = strstr(buf, "non-prefetchable") ? FALSE : TRUE; -	    _32bit = strstr(buf, "32-bit") ? TRUE : FALSE; - -	    WALK_UNTIL('['); -	    sscanf(buf, "[size=%d%c", &mem, &unit); - -	    strdevice = g_strdup_printf("%sMemory#%d=%d%cB (%s%s)\n", -					strdevice, ++x, -					mem, -					(unit == ']') ? ' ' : unit, -					_32bit ? "32-bit, " : "", -					prefetch ? "prefetchable" : -					"non-prefetchable"); - -	} else if (!strncmp(buf, "I/O", 3)) { -	    guint io_addr, io_size; - -	    sscanf(buf, "I/O ports at %x [size=%d]", &io_addr, &io_size); - -	    strdevice = -		g_strdup_printf("%sI/O ports at#%d=0x%x - 0x%x\n", -				strdevice, ++x, io_addr, -				io_addr + io_size); -	} else if ((buf[0] >= '0' && buf[0] <= '9') && (buf[4] == ':' || buf[2] == ':')) { -	    gint bus, device, function, domain; -	    gpointer start, end; - -	    if (strdevice != NULL && strhash != NULL) { -		g_hash_table_insert(devices, strhash, strdevice); -                g_free(category); -                g_free(name); -	    } - -	    if (buf[4] == ':') { -		sscanf(buf, "%x:%x:%x.%d", &domain, &bus, &device, &function); -	    } else { -	    	/* lspci without domain field */ -	    	sscanf(buf, "%x:%x.%x", &bus, &device, &function); -	    	domain = 0; -	    } - -	    WALK_UNTIL(' '); - -	    start = buf; - -	    WALK_UNTIL(':'); -	    end = buf + 1; -	    *buf = 0; - -	    buf = start + 1; -	    category = g_strdup(buf); - -	    buf = end; -	    start = buf; -	    WALK_UNTIL('('); -	    *buf = 0; -	    buf = start + 1; - -            if (strstr(category, "RAM memory")) icon = "mem"; -            else if (strstr(category, "Multimedia")) icon = "media"; -            else if (strstr(category, "USB")) icon = "usb"; -            else icon = "pci"; -             -	    name = g_strdup(buf); - -	    strhash = g_strdup_printf("PCI%d", n); -	    strdevice = g_strdup_printf("[Device Information]\n" -					"Name=%s\n" -					"Class=%s\n" -					"Domain=%d\n" -					"Bus, device, function=%d, %d, %d\n", -					name, category, domain, bus, -					device, function); -	    pci_list = g_strdup_printf("%s$PCI%d$%s=%s\n", pci_list, n, category, -				name); - -	    n++; -	} -    } -     -    if (pclose(lspci)) { -        /* error (no pci, perhaps?) */ -        pci_list = g_strconcat(pci_list, "No PCI devices found=\n", NULL); -    } else if (strhash) { -	/* insert the last device */ -        g_hash_table_insert(devices, strhash, strdevice); -        g_free(category); -        g_free(name); -    } -} diff --git a/arch/linux/common/.svn/text-base/samba.h.svn-base b/arch/linux/common/.svn/text-base/samba.h.svn-base deleted file mode 100644 index 5f5ecbe5..00000000 --- a/arch/linux/common/.svn/text-base/samba.h.svn-base +++ /dev/null @@ -1,80 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 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 gchar *smb_shares_list = NULL; -void -scan_samba_shared_directories(void) -{ -    GKeyFile *keyfile; -    GError *error = NULL; -    gchar **groups; -    gchar *smbconf; -    gsize length; -    gint i = 0; - -    if (smb_shares_list) { -        g_free(smb_shares_list); -    } -     -    keyfile = g_key_file_new(); -     -    if (!g_file_get_contents("/etc/samba/smb.conf", &smbconf, &length, &error)) { -        smb_shares_list = g_strdup("Cannot open /etc/samba/smb.conf=\n"); -        g_error_free(error); -        goto cleanup; -    } -     -    gchar *_smbconf = smbconf; -    for (; *_smbconf; _smbconf++) -        if (*_smbconf == ';') *_smbconf = '\0'; -     -    if (!g_key_file_load_from_data(keyfile, smbconf, length, 0, &error)) { -        smb_shares_list = g_strdup("Cannot parse smb.conf=\n"); -        g_error_free(error); -        goto cleanup; -    } - -    smb_shares_list = g_strdup(""); - -    groups = g_key_file_get_groups(keyfile, NULL); -    while (groups[i]) { -        if (g_key_file_has_key(keyfile, groups[i], "path", NULL) && -            g_key_file_has_key(keyfile, groups[i], "available", NULL)) { -             -            gchar *available = g_key_file_get_string(keyfile, groups[i], "available", NULL); -         -            if (g_str_equal(available, "yes")) { -                gchar *path = g_key_file_get_string(keyfile, groups[i], "path", NULL); -                smb_shares_list = g_strconcat(smb_shares_list, groups[i], "=", -                                          path, "\n", NULL); -                g_free(path); -            } -             -            g_free(available); -        } -         -        i++; -    } -     -    g_strfreev(groups); -   -  cleanup: -    g_key_file_free(keyfile); -    g_free(smbconf); -} - diff --git a/arch/linux/common/.svn/text-base/sensors.h.svn-base b/arch/linux/common/.svn/text-base/sensors.h.svn-base deleted file mode 100644 index ef834de2..00000000 --- a/arch/linux/common/.svn/text-base/sensors.h.svn-base +++ /dev/null @@ -1,237 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 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 gchar *sensors = NULL; -static GHashTable *sensor_labels = NULL; -static GHashTable *sensor_compute = NULL; - -static void -read_sensor_labels(gchar *driver) -{ -    FILE *conf; -    gchar buf[256], *line, *p; -    gboolean lock = FALSE; -    gint i; -     -    sensor_labels = g_hash_table_new_full(g_str_hash, g_str_equal, -                                          g_free, g_free); -    sensor_compute = g_hash_table_new(g_str_hash, g_str_equal); -     -    conf = fopen("/etc/sensors.conf", "r"); -    if (!conf) -        return; -         -    while (fgets(buf, 256, conf)) { -        line = buf; -         -        remove_linefeed(line); -        strend(line, '#'); -         -        if (*line == '\0') { -            continue; -        } else if (lock && strstr(line, "label")) {	/* label lines */ -            gchar **names = g_strsplit(strstr(line, "label") + 5, " ", 0); -            gchar *name = NULL, *value = NULL; -             -            for (i = 0; names[i]; i++) { -                if (names[i][0] == '\0') -                    continue; -                 -                if (!name) name = g_strdup(names[i]); -                else if (!value) value = g_strdup(names[i]); -                else value = g_strconcat(value, " ", names[i], NULL);             -            } -             -            remove_quotes(value); -            g_hash_table_insert(sensor_labels, name, value); -             -            g_strfreev(names);             -        } else if (lock && strstr(line, "ignore")) {	/* ignore lines */ -            p = strstr(line, "ignore") + 6; -            if (!strchr(p, ' ')) -                continue; -             -            while (*p == ' ') p++; -            g_hash_table_insert(sensor_labels, g_strdup(p), "ignore"); -        } else if (lock && strstr(line, "compute")) {	/* compute lines */ -            gchar **formulas = g_strsplit(strstr(line, "compute") + 7, " ", 0); -            gchar *name = NULL, *formula = NULL; -             -            for (i = 0; formulas[i]; i++) { -                if (formulas[i][0] == '\0') -                    continue; -                if (formulas[i][0] == ',') -                    break; -                 -                if (!name) name = g_strdup(formulas[i]); -                else if (!formula) formula = g_strdup(formulas[i]); -                else formula = g_strconcat(formula, formulas[i], NULL);             -            } -             -            g_strfreev(formulas); -            g_hash_table_insert(sensor_compute, name, math_string_to_postfix(formula)); -        } else if (g_str_has_prefix(line, "chip")) {	/* chip lines (delimiter) */ -            if (lock == FALSE) { -                gchar **chips = g_strsplit(line, " ", 0); -                 -                for (i = 1; chips[i]; i++) { -                    strend(chips[i], '*'); -                     -                    if (g_str_has_prefix(driver, chips[i] + 1)) { -                        lock = TRUE; -                        break; -                    } -                } -                 -                g_strfreev(chips); -            } else { -                break; -            } -        } -    } -     -    fclose(conf); -} - -static gchar * -get_sensor_label(gchar *sensor) -{ -    gchar *ret; -     -    ret = g_hash_table_lookup(sensor_labels, sensor); -    if (!ret) ret = g_strdup(sensor); -    else      ret = g_strdup(ret); - -    return ret; -} - -static float -adjust_sensor(gchar *name, float value) -{ -    GSList *postfix; -     -    postfix = g_hash_table_lookup(sensor_compute, name); -    if (!postfix) return value; -     -    return math_postfix_eval(postfix, value); -} - -static void -read_sensors(void) -{ -    gchar *path_hwmon, *path_sensor, *tmp, *driver, *name, *mon; -    int hwmon, count; -     -    if (sensors) -        g_free(sensors); -     -    hwmon = 0; -    sensors = g_strdup(""); -     -    path_hwmon = g_strdup_printf("/sys/class/hwmon/hwmon%d/device/", hwmon); -    while (g_file_test(path_hwmon, G_FILE_TEST_EXISTS)) { -        tmp = g_strdup_printf("%sdriver", path_hwmon); -        driver = g_file_read_link(tmp, NULL); -        g_free(tmp); - -        tmp = g_path_get_basename(driver); -        g_free(driver); -        driver = tmp; -         -        if (!sensor_labels) { -            read_sensor_labels(driver); -        } - -        sensors = g_strdup_printf("%s[Driver Info]\n" -                                  "Name=%s\n", sensors, driver); -     -        sensors = g_strconcat(sensors, "[Cooling Fans]\n", NULL); -        for (count = 1; ; count++) { -            path_sensor = g_strdup_printf("%sfan%d_input", path_hwmon, count); -            if (!g_file_get_contents(path_sensor, &tmp, NULL, NULL)) { -                g_free(path_sensor); -                break; -            } -             -            mon = g_strdup_printf("fan%d", count); -            name = get_sensor_label(mon); -            if (!g_str_equal(name, "ignore")) { -                sensors = g_strdup_printf("%s%s=%.0fRPM\n", -                                          sensors, name, -                                          adjust_sensor(mon, atof(tmp))); -            } -             -            g_free(name); -            g_free(mon); -            g_free(tmp); -            g_free(path_sensor); -        } - -        sensors = g_strconcat(sensors, "[Temperatures]\n", NULL); -        for (count = 1; ; count++) { -            path_sensor = g_strdup_printf("%stemp%d_input", path_hwmon, count); -            if (!g_file_get_contents(path_sensor, &tmp, NULL, NULL)) { -                g_free(path_sensor); -                break; -            } - -            mon = g_strdup_printf("temp%d", count); -            name = get_sensor_label(mon); -            if (!g_str_equal(name, "ignore")) { -                sensors = g_strdup_printf("%s%s=%.2f\302\260C\n", -                                          sensors, name, -                                          adjust_sensor(mon, atof(tmp) / 1000.0)); -            } -             -            g_free(tmp); -            g_free(name); -            g_free(path_sensor); -            g_free(mon); -        } - -        sensors = g_strconcat(sensors, "[Voltage Values]\n", NULL); -        for (count = 0; ; count++) { -            path_sensor = g_strdup_printf("%sin%d_input", path_hwmon, count); -            if (!g_file_get_contents(path_sensor, &tmp, NULL, NULL)) { -                g_free(path_sensor); -                break; -            } -             - -            mon = g_strdup_printf("in%d", count); -            name = get_sensor_label(mon); -            if (!g_str_equal(name, "ignore")) { -                sensors = g_strdup_printf("%s%s=%.3fV\n", -                                          sensors, name, -                                          adjust_sensor(mon, atof(tmp) / 1000.0)); -            } -             -            g_free(tmp); -            g_free(mon); -            g_free(name); -            g_free(path_sensor); -        } -     -        g_free(path_hwmon); -        g_free(driver); -        path_hwmon = g_strdup_printf("/sys/class/hwmon/hwmon%d/device/", ++hwmon); -    } -     -    g_free(path_hwmon);     -} - diff --git a/arch/linux/common/.svn/text-base/storage.h.svn-base b/arch/linux/common/.svn/text-base/storage.h.svn-base deleted file mode 100644 index 4fb682a9..00000000 --- a/arch/linux/common/.svn/text-base/storage.h.svn-base +++ /dev/null @@ -1,268 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 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 gchar *storage_icons = ""; - -static gboolean -remove_scsi_devices(gpointer key, gpointer value, gpointer data) -{ -    if (!strncmp((gchar *) key, "SCSI", 4)) { -	g_free((gchar *) key); -	g_free((GtkTreeIter *) value); -	return TRUE; -    } -    return FALSE; -} - -/* SCSI support by Pascal F.Martin <pascalmartin@earthlink.net> */ -void -scan_scsi(void) -{ -    FILE *proc_scsi; -    gchar buffer[256], *buf; -    gint n = 0; -    gint scsi_controller; -    gint scsi_channel; -    gint scsi_id; -    gint scsi_lun; -    gchar *vendor = NULL, *revision = NULL, *model = NULL; - -    /* remove old devices from global device table */ -    g_hash_table_foreach_remove(devices, remove_scsi_devices, NULL); - -    if (!g_file_test("/proc/scsi/scsi", G_FILE_TEST_EXISTS)) -	return; - -    storage_list = g_strconcat(storage_list, "\n[SCSI Disks]\n", NULL); - -    proc_scsi = fopen("/proc/scsi/scsi", "r"); -    while (fgets(buffer, 256, proc_scsi)) { -	buf = g_strstrip(buffer); -	if (!strncmp(buf, "Host: scsi", 10)) { -	    sscanf(buf, -		   "Host: scsi%d Channel: %d Id: %d Lun: %d", -		   &scsi_controller, &scsi_channel, &scsi_id, &scsi_lun); - -	    n++; -	} else if (!strncmp(buf, "Vendor: ", 8)) { -	    char *p; -	    char *rev = strstr(buf, "Rev: "); - -	    model = strstr(buf, "Model: "); - -	    if (model == NULL) { -		model = buf + strlen(buf); -	    } -	    p = model; -	    while (*(--p) == ' '); -	    *(++p) = 0; -	    vendor = g_strdup(buf + 8); - -	    if (rev != NULL) { -		revision = g_strdup(rev + 5); -	    } else { -		rev = model + strlen(model); -	    } -	    p = rev; -	    while (*(--p) == ' '); -	    *(++p) = 0; -	    model = g_strdup_printf("%s %s", vendor, model + 7); - -	} else if (!strncmp(buf, "Type:   ", 8)) { -	    char *p = strstr(buf, "ANSI SCSI revi"); -	    gchar *type = NULL, *icon = NULL; - -	    if (p != NULL) { -		while (*(--p) == ' '); -		*(++p) = 0; - -                static struct { -                    char *type; -                    char *label; -                    char *icon; -                } type2icon[] = { -                    { "Direct-Access", "Disk", "hdd"}, -                    { "Sequential-Access", "Tape", "tape"}, -                    { "Printer", "Printer", "lpr"}, -                    { "WORM", "CD-ROM", "cd"}, -                    { "CD-ROM", "CD-ROM", "cd"}, -                    { "Scanner", "Scanner", "scanner"}, -                    { NULL, "Generic", "scsi"}  -                }; -                int i; - -                for (i = 0; type2icon[i].type != NULL; i++) -                    if (!strcmp(buf + 8, type2icon[i].type)) -                        break; - -                type = type2icon[i].label; -                icon = type2icon[i].icon; -	    } -	     -	    gchar *devid = g_strdup_printf("SCSI%d", n); -	    storage_list = g_strdup_printf("%s$%s$%s=\n", storage_list, devid, model); -	    storage_icons = g_strdup_printf("%sIcon$%s$%s=%s.png\n", storage_icons, devid, model, icon); - -	    gchar *strhash = g_strdup_printf("[Device Information]\n" -					     "Model=%s\n" -					     "Type=%s\n" -					     "Revision=%s\n" -					     "[SCSI Controller]\n" -					     "Controller=scsi%d\n" -					     "Channel=%d\n" -					     "ID=%d\n" "LUN=%d\n", -					     model, -					     type, -					     revision, -					     scsi_controller, -					     scsi_channel, -					     scsi_id, -					     scsi_lun); -	    g_hash_table_insert(devices, devid, strhash); - -	    g_free(model); -	    g_free(revision); -	    g_free(vendor); -	} -    } -    fclose(proc_scsi); -} - -static gboolean -remove_ide_devices(gpointer key, gpointer value, gpointer data) -{ -    if (!strncmp((gchar *) key, "IDE", 3)) { -	g_free((gchar *) key); -	g_free((gchar *) value); - -	return TRUE; -    } -    return FALSE; -} - - -void -scan_ide(void) -{ -    FILE *proc_ide; -    gchar *device, iface, *model, *media, *pgeometry = NULL, *lgeometry = -	NULL; -    gint n = 0, i = 0, cache; - -    /* remove old devices from global device table */ -    g_hash_table_foreach_remove(devices, remove_ide_devices, NULL); - -    storage_list = g_strdup_printf("%s\n[IDE Disks]\n", storage_list); - -    iface = 'a'; -    for (i = 0; i <= 16; i++) { -	device = g_strdup_printf("/proc/ide/hd%c/model", iface); -	if (g_file_test(device, G_FILE_TEST_EXISTS)) { -	    gchar buf[64]; - -	    cache = 0; - -	    proc_ide = fopen(device, "r"); -	    fgets(buf, 64, proc_ide); -	    fclose(proc_ide); - -	    buf[strlen(buf) - 1] = 0; - -	    model = g_strdup(buf); - -	    g_free(device); - -	    device = g_strdup_printf("/proc/ide/hd%c/media", iface); -	    proc_ide = fopen(device, "r"); -	    fgets(buf, 64, proc_ide); -	    fclose(proc_ide); -	    buf[strlen(buf) - 1] = 0; - -	    media = g_strdup(buf); - -	    g_free(device); - -	    device = g_strdup_printf("/proc/ide/hd%c/cache", iface); -	    if (g_file_test(device, G_FILE_TEST_EXISTS)) { -		proc_ide = fopen(device, "r"); -		fscanf(proc_ide, "%d", &cache); -		fclose(proc_ide); -	    } -	    g_free(device); - -	    device = g_strdup_printf("/proc/ide/hd%c/geometry", iface); -	    if (g_file_test(device, G_FILE_TEST_EXISTS)) { -		gchar *tmp; - -		proc_ide = fopen(device, "r"); - -		fgets(buf, 64, proc_ide); -		for (tmp = buf; *tmp; tmp++) { -		    if (*tmp >= '0' && *tmp <= '9') -			break; -		} - -		pgeometry = g_strdup(g_strstrip(tmp)); - -		fgets(buf, 64, proc_ide); -		for (tmp = buf; *tmp; tmp++) { -		    if (*tmp >= '0' && *tmp <= '9') -			break; -		} -		lgeometry = g_strdup(g_strstrip(tmp)); - -		fclose(proc_ide); -	    } -	    g_free(device); - -	    n++; - -	    gchar *devid = g_strdup_printf("IDE%d", n); - -	    storage_list = g_strdup_printf("%s$%s$%s=\n", storage_list, -					 devid, model); -	    storage_icons = g_strdup_printf("%sIcon$%s$%s=%s.png\n", storage_icons, devid, -	                                  model, g_str_equal(media, "cdrom") ? \ -	                                         "cdrom" : "hdd"); - -	    gchar *strhash = g_strdup_printf("[Device Information]\n" -					     "Model=%s\n" -					     "Device Name=hd%c\n" -					     "Media=%s\n" "Cache=%dkb\n", -					     model, iface, media, cache); -	    if (pgeometry && lgeometry) -		strhash = g_strdup_printf("%s[Geometry]\n" -					  "Physical=%s\n" -					  "Logical=%s\n", -					  strhash, pgeometry, lgeometry); -             -	    g_hash_table_insert(devices, devid, strhash); - -	    g_free(model); -	    model = ""; - -	    g_free(pgeometry); -	    pgeometry = NULL; -	    g_free(lgeometry); -	    lgeometry = NULL; -	} else -	    g_free(device); - -	iface++; -    } -} diff --git a/arch/linux/common/.svn/text-base/uptime.h.svn-base b/arch/linux/common/.svn/text-base/uptime.h.svn-base deleted file mode 100644 index cf339bf3..00000000 --- a/arch/linux/common/.svn/text-base/uptime.h.svn-base +++ /dev/null @@ -1,75 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 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 UptimeInfo * -computer_get_uptime(void) -{ -    UptimeInfo *ui = g_new0(UptimeInfo, 1); -    FILE *procuptime; -    gulong minutes; - -    if ((procuptime = fopen("/proc/uptime", "r")) != NULL) { -	fscanf(procuptime, "%lu", &minutes); -	ui->minutes = minutes / 60; -	fclose(procuptime); -    } else { -	return NULL; -    } - -    ui->hours = ui->minutes / 60; -    ui->minutes %= 60; -    ui->days = ui->hours / 24; -    ui->hours %= 24; - -    return ui; -} - -static gchar * -computer_get_formatted_uptime() -{ -    UptimeInfo *ui; -    gchar *tmp; - -    ui = computer_get_uptime(); - -    /* FIXME: Use ngettext */ -#define plural(x) ((x > 1) ? "s" : "") - - -    if (ui->days < 1) { -	if (ui->hours < 1) { -	    tmp = -		g_strdup_printf("%d minute%s", ui->minutes, -				plural(ui->minutes)); -	} else { -	    tmp = -		g_strdup_printf("%d hour%s, %d minute%s", ui->hours, -				plural(ui->hours), ui->minutes, -				plural(ui->minutes)); -	} -    } else { -	tmp = -	    g_strdup_printf("%d day%s, %d hour%s and %d minute%s", -			    ui->days, plural(ui->days), ui->hours, -			    plural(ui->hours), ui->minutes, -			    plural(ui->minutes)); -    } - -    g_free(ui); -    return tmp; -} diff --git a/arch/linux/common/.svn/text-base/usb.h.svn-base b/arch/linux/common/.svn/text-base/usb.h.svn-base deleted file mode 100644 index a52be2cb..00000000 --- a/arch/linux/common/.svn/text-base/usb.h.svn-base +++ /dev/null @@ -1,132 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 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 gboolean -remove_usb_devices(gpointer key, gpointer value, gpointer data) -{ -    if (!strncmp((gchar *) key, "USB", 3)) { -	GtkTreeIter *iter = (GtkTreeIter *) data; - -	g_free((gchar *) value); -	g_free(iter); - -	return TRUE; -    } -    return FALSE; -} - -static gchar *usb_list = NULL; -void -scan_usb(void) -{ -    FILE *dev; -    gchar buffer[128]; -    gchar *tmp, *manuf = NULL, *product = NULL, *mxpwr; -    gint bus, level, port, classid, trash; -    gint vendor, prodid; -    gfloat ver, rev, speed; -    int n = 0; - -    dev = fopen("/proc/bus/usb/devices", "r"); -    if (!dev) -	return; - -    if (usb_list) { -	g_hash_table_foreach_remove(devices, remove_usb_devices, NULL); -	g_free(usb_list); -    } -    usb_list = g_strdup(""); - -    while (fgets(buffer, 128, dev)) { -	tmp = buffer; - -	switch (*tmp) { -	case 'T': -	    sscanf(tmp, -		   "T:  Bus=%d Lev=%d Prnt=%d Port=%d Cnt=%d Dev#=%d Spd=%f", -		   &bus, &level, &trash, &port, &trash, &trash, &speed); -	    break; -	case 'D': -	    sscanf(tmp, "D:  Ver=%f Cls=%x", &ver, &classid); -	    break; -	case 'P': -	    sscanf(tmp, "P:  Vendor=%x ProdID=%x Rev=%f", -		   &vendor, &prodid, &rev); -	    break; -	case 'S': -	    if (strstr(tmp, "Manufacturer=")) { -		manuf = g_strdup(strchr(tmp, '=') + 1); -		remove_linefeed(manuf); -	    } else if (strstr(tmp, "Product=")) { -		product = g_strdup(strchr(tmp, '=') + 1); -		remove_linefeed(product); -	    } -	    break; -	case 'C': -	    mxpwr = strstr(buffer, "MxPwr=") + 6; - -	    tmp = g_strdup_printf("USB%d", ++n); -	     -	    if (*product == '\0') { -	        g_free(product); -	        if (classid == 9) { -                    product = g_strdup_printf("USB %.2f Hub", ver); -                } else { -  	            product = g_strdup_printf("Unknown USB %.2f Device (class %d)", -                                              ver, classid); -                } -	    } -	     - -	    if (classid == 9) {	/* hub */ -    	        usb_list = g_strdup_printf("%s[%s#%d]\n", -		      		           usb_list, product, n); -            } else { /* everything else */ -    	        usb_list = g_strdup_printf("%s$%s$%s=\n", -		      		           usb_list, tmp, product); - -                gchar *strhash = g_strdup_printf("[Device Information]\n" -                                                 "Product=%s\n" -                                                 "Manufacturer=%s\n" -                                                 "[Port #%d]\n" -                                                 "Speed=%.2fMbit/s\n" -                                                 "Max Current=%s\n" -                                                 "[Misc]\n" -                                                 "USB Version=%.2f\n" -                                                 "Revision=%.2f\n" -                                                 "Class=0x%x\n" -                                                 "Vendor=0x%x\n" -                                                 "Product ID=0x%x\n" -                                                 "Bus=%d\n" "Level=%d\n", -                                                 product, manuf, -                                                 port, speed, mxpwr, -                                                 ver, rev, classid, -                                                 vendor, prodid, bus, level); - -                g_hash_table_insert(devices, tmp, strhash); -            } - -	    g_free(manuf); -	    g_free(product); -	    manuf = g_strdup(""); -	    product = g_strdup(""); -	} -    } - -    fclose(dev); -} diff --git a/arch/linux/common/battery.h b/arch/linux/common/battery.h new file mode 100644 index 00000000..20979e48 --- /dev/null +++ b/arch/linux/common/battery.h @@ -0,0 +1,212 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2006 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 <time.h> + +static void +__scan_battery_acpi(void) +{ +    gchar *acpi_path; + +    gchar *present = NULL; +    gchar *capacity = NULL; +    gchar *technology = NULL; +    gchar *voltage = NULL; +    gchar *model = NULL, *serial = NULL, *type = NULL; +    gchar *state = NULL, *rate = NULL; +    gchar *remaining = NULL; +     +    if (battery_list) { +      g_free(battery_list); +    } +    battery_list = g_strdup(""); +     +    acpi_path = g_strdup("/proc/acpi/battery"); +    if (g_file_test(acpi_path, G_FILE_TEST_EXISTS)) { +      GDir *acpi; +       +      if ((acpi = g_dir_open(acpi_path, 0, NULL))) { +        const gchar *entry; +         +        while ((entry = g_dir_read_name(acpi))) { +          gchar *path = g_strdup_printf("%s/%s/info", acpi_path, entry); +          FILE *f; +          gchar buffer[256]; +          gdouble charge_rate = 1.0; +           +          f = fopen(path, "r"); +          g_free(path); +           +          if (!f) +            goto cleanup; +           +          while (fgets(buffer, 256, f)) { +            gchar **tmp = g_strsplit(buffer, ":", 2); +             +            GET_STR("present", present); +            GET_STR("design capacity", capacity); +            GET_STR("battery technology", technology); +            GET_STR("design voltage", voltage); +            GET_STR("model number", model); +            GET_STR("serial number", serial); +            GET_STR("battery type", type); +             +            g_strfreev(tmp); +          }           +          fclose(f); +           +          path = g_strdup_printf("%s/%s/state", acpi_path, entry); +          f = fopen(path, "r"); +          g_free(path); +           +          if (!f) +            goto cleanup; +           +          while (fgets(buffer, 256, f)) { +            gchar **tmp = g_strsplit(buffer, ":", 2); +             +            GET_STR("charging state", state); +            GET_STR("present rate", rate); +            GET_STR("remaining capacity", remaining); +           +            g_strfreev(tmp); +          } +           +          fclose(f); +           +          if (g_str_equal(present, "yes")) { +            charge_rate = atof(remaining) / atof(capacity); +           +            battery_list = g_strdup_printf("%s\n[Battery: %s]\n" +                                           "State=%s (load: %s)\n" +                                           "Capacity=%s / %s (%.2f%%)\n" +                                           "Battery Technology=%s (%s)\n" +                                           "Model Number=%s\n" +                                           "Serial Number=%s\n", +                                           battery_list, +                                           entry, +                                           state, rate, +                                           remaining, capacity, charge_rate * 100.0, +                                           technology, type, +                                           model, +                                           serial); +          } +           +         cleanup: +          g_free(present); +          g_free(capacity); +          g_free(technology); +          g_free(type); +          g_free(model); +          g_free(serial); +          g_free(state); +          g_free(remaining); +          g_free(rate); + +          present = capacity = technology = type = \ +                model = serial = state = remaining = rate = NULL; +        } +       +        g_dir_close(acpi); +      } +    } +     +    g_free(acpi_path); +} + +static void +__scan_battery_apm(void) +{ +    FILE                *procapm; +    static char         *sremaining = NULL, *stotal = NULL; +    static unsigned int  last_time = 0; +    static int           percentage = 0; +    const  char         *ac_status[] = { "Battery", +                                         "AC Power", +                                         "Charging" }; +    int                  ac_bat; +    char                 apm_bios_ver[16], apm_drv_ver[16]; +    char                 trash[10]; +     +    if ((procapm = fopen("/proc/apm", "r"))) { +        int old_percentage = percentage; +         +        fscanf(procapm, "%s %s %s 0x%x %s %s %d%%", +               apm_drv_ver, apm_bios_ver, trash, +               &ac_bat, trash, trash, &percentage); +        fclose(procapm); +         +        if (last_time == 0) { +            last_time = time(NULL); +            sremaining = stotal = NULL; +        } + +        if (old_percentage - percentage > 0) { +            if (sremaining && stotal) { +                g_free(sremaining); +                g_free(stotal); +            } +                         +            int secs_remaining = (time(NULL) - last_time) * percentage / +                                 (old_percentage - percentage); +            sremaining = seconds_to_string(secs_remaining); +            stotal = seconds_to_string((secs_remaining * 100) / percentage); +             +            last_time = time(NULL); +        } +    } else { +        return; +    } + +    if (stotal && sremaining) { +        battery_list = g_strdup_printf("%s\n[Battery (APM)]\n" +                                       "Charge=%d%%\n" +                                       "Remaining Charge=%s of %s\n" +                                       "Using=%s\n" +                                       "APM driver version=%s\n" +                                       "APM BIOS version=%s\n", +                                       battery_list, +                                       percentage, +                                       sremaining, stotal, +                                       ac_status[ac_bat], +                                       apm_drv_ver, apm_bios_ver); +    } else { +        battery_list = g_strdup_printf("%s\n[Battery (APM)]\n" +                                       "Charge=%d%%\n" +                                       "Using=%s\n" +                                       "APM driver version=%s\n" +                                       "APM BIOS version=%s\n", +                                       battery_list, +                                       percentage, +                                       ac_status[ac_bat], +                                       apm_drv_ver, apm_bios_ver); +     +    } +} + +static void +__scan_battery(void) +{ +    if (battery_list) { +      g_free(battery_list); +    } +    battery_list = g_strdup(""); + +    __scan_battery_acpi(); +    __scan_battery_apm(); +} diff --git a/arch/linux/common/boots.h b/arch/linux/common/boots.h new file mode 100644 index 00000000..c95ba321 --- /dev/null +++ b/arch/linux/common/boots.h @@ -0,0 +1,61 @@ +/* + *    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 + */ + +void +scan_boots_real(void) +{ +    FILE *last; +    char buffer[256]; + +    scan_os(FALSE); + +    if (!computer->os->boots) +      computer->os->boots = "[Boots]\n"; +    else +      return; +     +    last = popen("last", "r"); +    if (last) { +      while (fgets(buffer, 256, last)) { +        if (strstr(buffer, "system boot")) { +          gchar **tmp, *buf = buffer; +           +          strend(buffer, '\n'); +           +          while (*buf) { +            if (*buf == ' ' && *(buf + 1) == ' ') { +              strcpy(buf, buf + 1); +               +              buf--; +            } else { +              buf++; +            } +          } + +          tmp = g_strsplit(buffer, " ", 5); +          computer->os->boots = g_strdup_printf("%s\n%s=Kernel %s", +                                                computer->os->boots, +                                                tmp[4], +                                                tmp[3]); +          g_strfreev(tmp); +        } +      } +       +      pclose(last); +    } +} diff --git a/arch/linux/common/devmemory.h b/arch/linux/common/devmemory.h new file mode 100644 index 00000000..780ab12f --- /dev/null +++ b/arch/linux/common/devmemory.h @@ -0,0 +1,99 @@ +/* + *    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 GHashTable *memlabels; + +static void __scan_memory() +{ +    gchar **keys, *tmp; +    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 */ +        offset = strstr(idle_free(module_call_method("computer::getOSKernel")), +                        "Linux 2.4") ? 3 : 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[1]); +         +        if ((tmp = g_hash_table_lookup(memlabels, newkeys[0]))) { +            g_free(newkeys[0]); +            newkeys[0] = g_strdup(tmp); +        } +         +        g_hash_table_replace(moreinfo, g_strdup(newkeys[0]), g_strdup(newkeys[1])); + +        tmp = g_strconcat(meminfo, newkeys[0], "=", newkeys[1], "\n", NULL); +        g_free(meminfo); +        meminfo = tmp; +         +        tmp = g_strconcat(lginterval, +                          "UpdateInterval$", newkeys[0], "=1000\n", NULL); +        g_free(lginterval); +        lginterval = tmp; + +        g_strfreev(newkeys); +    } +    g_strfreev(keys); +} + +static void __init_memory_labels(void) +{ +    static struct { +        char *proc_label; +        char *real_label; +    } proc2real[] = { +        { "MemTotal",	"Total Memory"        }, +        { "MemFree", 	"Free Memory"         }, +        { "SwapCached",	"Cached Swap"         }, +        { "HighTotal",	"High Memory"         }, +        { "HighFree",   "Free High Memory"    }, +        { "LowTotal",	"Low Memory"          }, +        { "LowFree",	"Free Low Memory"     }, +        { "SwapTotal",	"Virtual Memory"      }, +        { "SwapFree",   "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); +    } +} diff --git a/arch/linux/common/filesystem.h b/arch/linux/common/filesystem.h index 79784c8f..8300f278 100644 --- a/arch/linux/common/filesystem.h +++ b/arch/linux/common/filesystem.h @@ -20,25 +20,9 @@   *  Distributed under the terms of GNU GPL 2.    */  #include <sys/vfs.h> -#define KB 1024 -#define MB 1048576 -#define GB 1073741824  static gchar *fs_list = NULL; -static gchar * -fs_human_readable(gfloat size) -{ -    if (size < KB) -	return g_strdup_printf("%.1f B", size); -    if (size < MB) -	return g_strdup_printf("%.1f KiB", size / KB); -    if (size < GB) -	return g_strdup_printf("%.1f MiB", size / MB); - -    return g_strdup_printf("%.1f GiB", size / GB); -} -  static void  scan_filesystems(void)  { @@ -63,16 +47,18 @@ scan_filesystems(void)  		avail = (float) sfs.f_bsize * (float) sfs.f_bavail;  		used = size - avail; -		gchar *strsize = fs_human_readable(size), -		      *stravail = fs_human_readable(avail), -	  	      *strused = fs_human_readable(used); +		gchar *strsize = size_human_readable(size), +		      *stravail = size_human_readable(avail), +	  	      *strused = size_human_readable(used);  		gchar *strhash;  		if ((strhash = g_hash_table_lookup(moreinfo, tmp[0]))) {  		    g_hash_table_remove(moreinfo, tmp[0]);  		    g_free(strhash);  		} - +		 +		strreplace(tmp[0], "#", '_'); +		  		strhash = g_strdup_printf("[%s]\n"  					  "Filesystem=%s\n"  					  "Mounted As=%s\n" diff --git a/arch/linux/common/inputdevices.h b/arch/linux/common/inputdevices.h index 44a109ca..1a5baff8 100644 --- a/arch/linux/common/inputdevices.h +++ b/arch/linux/common/inputdevices.h @@ -22,8 +22,6 @@ static gboolean  remove_input_devices(gpointer key, gpointer value, gpointer data)  {      if (!strncmp((gchar *) key, "INP", 3)) { -	g_free((gchar *) key); -	g_free((GtkTreeIter *) value);  	return TRUE;      } @@ -42,7 +40,7 @@ static struct {  };  void -scan_inputdevices(void) +__scan_input_devices(void)  {      FILE *dev;      gchar buffer[128]; @@ -55,7 +53,7 @@ scan_inputdevices(void)  	return;      if (input_list) { -	g_hash_table_foreach_remove(devices, remove_input_devices, NULL); +	g_hash_table_foreach_remove(moreinfo, remove_input_devices, NULL);  	g_free(input_list);  	g_free(input_icons);      } @@ -103,15 +101,31 @@ scan_inputdevices(void)  	    gchar *strhash = g_strdup_printf("[Device Information]\n"  					     "Name=%s\n"  					     "Type=%s\n" -					     "Bus=0x%x\n" -					     "Vendor=0x%x\n" -					     "Product=0x%x\n" -					     "Version=0x%x\n" -					     "Connected to=%s\n", -					     name, input_devices[d].name, -					     bus, vendor, product, -					     version, phys); -	    g_hash_table_insert(devices, tmp, strhash); +					     "Bus=0x%x\n", +					     name, +					     input_devices[d].name, +					     bus); + +	    const gchar *url = vendor_get_url(name); +	    if (url) { +	    	strhash = g_strdup_printf("%s" +					  "Vendor=%s (%s)\n", +					  strhash, +					  vendor_get_name(name), +					  url); +	    } else { +	    	strhash = g_strdup_printf("%s" +					  "Vendor=%x\n", +					  strhash, +					  vendor); +	    } + +	    strhash = g_strdup_printf("%s" +				      "Product=0x%x\n" +				      "Version=0x%x\n" +				      "Connected to=%s\n", +				      strhash, product, version, phys); +	    g_hash_table_insert(moreinfo, tmp, strhash);  	    g_free(phys);  	    g_free(name); diff --git a/arch/linux/common/modules.h b/arch/linux/common/modules.h index 69f7ebd6..9b895ee8 100644 --- a/arch/linux/common/modules.h +++ b/arch/linux/common/modules.h @@ -16,12 +16,37 @@   *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA   */ -void -scan_modules(void) +#define GET_STR(field_name,ptr)      					\ +  if (!ptr && strstr(tmp[0], field_name)) {				\ +    ptr = g_markup_escape_text(g_strstrip(tmp[1]), strlen(tmp[1]));	\ +    g_strfreev(tmp);                 					\ +    continue;                        					\ +  } + +static gboolean +remove_module_devices(gpointer key, gpointer value, gpointer data) +{ +    if (!strncmp((gchar *) key, "MOD", 3)) { +	g_free((gchar *) key); +	g_free((GtkTreeIter *) value); +	return TRUE; +    } +    return FALSE; +} + +static void +scan_modules_do(void)  {      FILE *lsmod;      gchar buffer[1024]; +    if (module_list) { +        g_free(module_list); +        module_list = NULL; +    } + +    g_hash_table_foreach_remove(moreinfo, remove_module_devices, NULL); +      lsmod = popen("/sbin/lsmod", "r");      if (!lsmod)  	return; @@ -44,7 +69,7 @@ scan_modules(void)  	sscanf(buf, "%s %ld", modname, &memory);  	hashkey = g_strdup_printf("MOD%s", modname); -	buf = g_strdup_printf("/sbin/modinfo %s", modname); +	buf = g_strdup_printf("/sbin/modinfo %s 2>/dev/null", modname);  	modi = popen(buf, "r");  	while (fgets(buffer, 1024, modi)) { @@ -72,14 +97,14 @@ scan_modules(void)  	/* old modutils displays <none> when there's no value for a  	   given field; this is not desirable in the module name   	   display, so change it to an empty string */ -	if (description && !strcmp(description, "<none>")) { +	if (description && g_str_equal(description, "<none>")) {  	    g_free(description);  	    description = g_strdup("");  	}  	/* append this module to the list of modules */  	module_list = g_strdup_printf("%s$%s$%s=%s\n", -				      module_list, +				      module_list ? module_list : "",  				      hashkey,  				      modname,  				      description ? description : ""); @@ -117,7 +142,7 @@ scan_modules(void)  	    g_free(deps);  	} -	g_hash_table_insert(devices, hashkey, strmodule); +	g_hash_table_insert(moreinfo, hashkey, strmodule);  	g_free(license);  	g_free(description); diff --git a/arch/linux/common/net.h b/arch/linux/common/net.h index 87e7e59b..cd8b8706 100644 --- a/arch/linux/common/net.h +++ b/arch/linux/common/net.h @@ -24,14 +24,25 @@ static gchar *network_interfaces = NULL;  #include <linux/sockios.h>  #include <sys/socket.h> +#include <stdio.h> +#include <unistd.h> +#include <string.h> /* for strncpy */ +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> + +  typedef struct _NetInfo NetInfo;  struct _NetInfo { -    char                name[16];  -    int                 mtu; -    unsigned char       mac[8]; +    char name[16];  +    int  mtu; +    unsigned char mac[8]; +    char ip[16]; +    char mask[16]; +    char broadcast[16];  }; -  void get_net_info(char *if_name, NetInfo *netinfo)  {      struct ifreq ifr; @@ -39,21 +50,49 @@ void get_net_info(char *if_name, NetInfo *netinfo)      fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); -    strcpy(ifr.ifr_name, if_name); +    /* IPv4 */ +    ifr.ifr_addr.sa_family = AF_INET;      strcpy(netinfo->name, if_name); +    /* MTU */ +    strcpy(ifr.ifr_name, if_name);      if (ioctl(fd, SIOCGIFMTU, &ifr) < 0) {          netinfo->mtu = 0;      } else {          netinfo->mtu = ifr.ifr_mtu;      } -     + +    /* HW Address */      strcpy(ifr.ifr_name, if_name);      if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) {          memset(netinfo->mac, 0, 8);      } else {          memcpy(netinfo->mac, ifr.ifr_ifru.ifru_hwaddr.sa_data, 8);      } +     +    /* IP Address */ +    strcpy(ifr.ifr_name, if_name); +    if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) { +        netinfo->ip[0] = 0; +    } else { +        sprintf(netinfo->ip, "%s", inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));  +    } +     +    /* Mask Address */ +    strcpy(ifr.ifr_name, if_name); +    if (ioctl(fd, SIOCGIFNETMASK, &ifr) < 0) { +        netinfo->mask[0] = 0; +    } else { +        sprintf(netinfo->mask, "%s", inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr)); +    } + +    /* Broadcast Address */ +    strcpy(ifr.ifr_name, if_name); +    if (ioctl(fd, SIOCGIFBRDADDR, &ifr) < 0) { +        netinfo->broadcast[0] = 0; +    } else { +        sprintf(netinfo->broadcast, "%s", inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr)); +    }      shutdown(fd, 0);  } @@ -162,21 +201,25 @@ scan_net_interfaces_24(void)              gfloat recv_mb = recv_bytes / 1048576.0;              gfloat trans_mb = trans_bytes / 1048576.0; +            get_net_info(ifacename, &ni); +              devid = g_strdup_printf("NET%s", ifacename); -	    network_interfaces = g_strdup_printf("%s$%s$%s=Sent %.2fMiB, received %.2fMiB\n", +	    network_interfaces = g_strdup_printf("%s$%s$%s=Sent %.2fMiB, received %.2fMiB%s\n",                                                    network_interfaces,                                                    devid,                                                    ifacename,                                                    trans_mb, -                                                  recv_mb); +                                                  recv_mb, +						  ni.ip[0] ? +						  (gchar*)idle_free(g_strdup_printf(" (%s)", ni.ip)) : ""); -            get_net_info(ifacename, &ni);              detailed = g_strdup_printf("[Network Adapter Properties]\n"                                          "Interface Type=%s\n" -                                        "Hardware Address=%02x:%02x:%02x:%02x:%02x:%02x\n" +                                        "Hardware Address (MAC)=%02x:%02x:%02x:%02x:%02x:%02x\n"                                          "MTU=%d\n" -                                        "Bytes Sent=%ld (%.2fMiB)\n" -                                        "Bytes Received=%ld (%.2fMiB)\n", +                                        "[Transfer Details]\n" +                                        "Bytes Received=%ld (%.2fMiB)\n" +                                        "Bytes Sent=%ld (%.2fMiB)\n",                                          net_get_iface_type(ifacename),                                          ni.mac[0], ni.mac[1],                                          ni.mac[2], ni.mac[3], @@ -184,6 +227,19 @@ scan_net_interfaces_24(void)                                          ni.mtu,                                          recv_bytes, recv_mb,                                          trans_bytes, trans_mb); +                                         +            if (ni.ip[0] || ni.mask[0] || ni.broadcast[0]) { +                 detailed = g_strdup_printf("%s\n" +                                            "[Internet Protocol (IPv4)]\n" +                                            "IP Address=%s\n" +                                            "Mask=%s\n" +                                            "Broadcast Address=%s\n", +                                            detailed, +                                            ni.ip[0]        ? ni.ip        : "Not set", +                                            ni.mask[0]      ? ni.mask      : "Not set", +                                            ni.broadcast[0] ? ni.broadcast : "Not set"); +            } +                            g_hash_table_insert(moreinfo, devid, detailed);  	}      } diff --git a/arch/linux/common/os.h b/arch/linux/common/os.h index 0f7b59e3..d30146ef 100644 --- a/arch/linux/common/os.h +++ b/arch/linux/common/os.h @@ -75,7 +75,9 @@ detect_desktop_environment(OperatingSystem * os)  	   obtain the version. */  	version = popen("gnome-panel --version", "r");  	if (version) { -	    fscanf(version, "Gnome gnome-panel %d.%d", &maj, &min); +	    char gnome[10]; +	     +	    fscanf(version, "%s gnome-panel %d.%d", gnome, &maj, &min);  	    if (pclose(version))  	        goto unknown;  	} else { @@ -105,18 +107,23 @@ detect_desktop_environment(OperatingSystem * os)  	if (!g_getenv("DISPLAY")) {  	    os->desktop = g_strdup("Terminal");  	} else { -            const gchar *windowman;              GdkScreen *screen = gdk_screen_get_default(); - -            windowman = gdk_x11_screen_get_window_manager_name(screen); -            if (g_str_equal(windowman, "Xfwm4")) { -                /* FIXME: check if xprop -root | grep XFCE_DESKTOP_WINDOW -                   is defined */ -                os->desktop = g_strdup("XFCE 4"); +            if (screen && GDK_IS_SCREEN(screen)) { +              const gchar *windowman; + +              windowman = gdk_x11_screen_get_window_manager_name(screen); +               +              if (g_str_equal(windowman, "Xfwm4")) { +                  /* FIXME: check if xprop -root | grep XFCE_DESKTOP_WINDOW +                     is defined */ +                  os->desktop = g_strdup("XFCE 4"); +              } else { +                  os->desktop = g_strdup_printf("Unknown (Window Manager: %s)", +                                                windowman); +              }              } else { -  	        os->desktop = g_strdup_printf("Unknown (Window Manager: %s)", -  	                                      windowman); +              os->desktop = g_strdup("Unknown");              }  	}      } diff --git a/arch/linux/common/pci.h b/arch/linux/common/pci.h index f8c9d319..e50691d0 100644 --- a/arch/linux/common/pci.h +++ b/arch/linux/common/pci.h @@ -17,7 +17,7 @@   */  void -scan_pci(void) +__scan_pci(void)  {      FILE *lspci;      gchar buffer[256], *buf, *strhash = NULL, *strdevice = NULL; @@ -126,7 +126,7 @@ scan_pci(void)  	    gpointer start, end;  	    if (strdevice != NULL && strhash != NULL) { -		g_hash_table_insert(devices, strhash, strdevice); +		g_hash_table_insert(moreinfo, strhash, strdevice);                  g_free(category);                  g_free(name);  	    } @@ -171,6 +171,17 @@ scan_pci(void)  					"Bus, device, function=%d, %d, %d\n",  					name, category, domain, bus,  					device, function); +             +            const gchar *url = vendor_get_url(name); +            if (url) { +                strdevice = g_strdup_printf("%s" +                                            "Vendor=%s (%s)\n", +                                            strdevice, +                                            vendor_get_name(name), +                                            url); +            } +             +              	    pci_list = g_strdup_printf("%s$PCI%d$%s=%s\n", pci_list, n, category,  				name); @@ -183,7 +194,7 @@ scan_pci(void)          pci_list = g_strconcat(pci_list, "No PCI devices found=\n", NULL);      } else if (strhash) {  	/* insert the last device */ -        g_hash_table_insert(devices, strhash, strdevice); +        g_hash_table_insert(moreinfo, strhash, strdevice);          g_free(category);          g_free(name);      } diff --git a/arch/linux/common/samba.h b/arch/linux/common/samba.h index 5f5ecbe5..7c7d8bb7 100644 --- a/arch/linux/common/samba.h +++ b/arch/linux/common/samba.h @@ -24,7 +24,7 @@ scan_samba_shared_directories(void)      GError *error = NULL;      gchar **groups;      gchar *smbconf; -    gsize length; +    gsize length = -1;      gint i = 0;      if (smb_shares_list) { @@ -33,9 +33,10 @@ scan_samba_shared_directories(void)      keyfile = g_key_file_new(); -    if (!g_file_get_contents("/etc/samba/smb.conf", &smbconf, &length, &error)) { +    if (!g_file_get_contents("/etc/samba/smb.conf", &smbconf, &length, &error) || length == 0) {          smb_shares_list = g_strdup("Cannot open /etc/samba/smb.conf=\n"); -        g_error_free(error); +        if (error) +            g_error_free(error);          goto cleanup;      } @@ -45,7 +46,8 @@ scan_samba_shared_directories(void)      if (!g_key_file_load_from_data(keyfile, smbconf, length, 0, &error)) {          smb_shares_list = g_strdup("Cannot parse smb.conf=\n"); -        g_error_free(error); +        if (error) +            g_error_free(error);          goto cleanup;      } diff --git a/arch/linux/common/sensors.h b/arch/linux/common/sensors.h index ef834de2..3303d5d2 100644 --- a/arch/linux/common/sensors.h +++ b/arch/linux/common/sensors.h @@ -20,218 +20,352 @@ static gchar *sensors = NULL;  static GHashTable *sensor_labels = NULL;  static GHashTable *sensor_compute = NULL; -static void -read_sensor_labels(gchar *driver) +static void read_sensor_labels(gchar * driver)  {      FILE *conf;      gchar buf[256], *line, *p;      gboolean lock = FALSE;      gint i; -     +      sensor_labels = g_hash_table_new_full(g_str_hash, g_str_equal, -                                          g_free, g_free); +					  g_free, g_free);      sensor_compute = g_hash_table_new(g_str_hash, g_str_equal); -     +      conf = fopen("/etc/sensors.conf", "r");      if (!conf) -        return; -         +	return; +      while (fgets(buf, 256, conf)) { -        line = buf; -         -        remove_linefeed(line); -        strend(line, '#'); -         -        if (*line == '\0') { -            continue; -        } else if (lock && strstr(line, "label")) {	/* label lines */ -            gchar **names = g_strsplit(strstr(line, "label") + 5, " ", 0); -            gchar *name = NULL, *value = NULL; -             -            for (i = 0; names[i]; i++) { -                if (names[i][0] == '\0') -                    continue; -                 -                if (!name) name = g_strdup(names[i]); -                else if (!value) value = g_strdup(names[i]); -                else value = g_strconcat(value, " ", names[i], NULL);             -            } -             -            remove_quotes(value); -            g_hash_table_insert(sensor_labels, name, value); -             -            g_strfreev(names);             -        } else if (lock && strstr(line, "ignore")) {	/* ignore lines */ -            p = strstr(line, "ignore") + 6; -            if (!strchr(p, ' ')) -                continue; -             -            while (*p == ' ') p++; -            g_hash_table_insert(sensor_labels, g_strdup(p), "ignore"); -        } else if (lock && strstr(line, "compute")) {	/* compute lines */ -            gchar **formulas = g_strsplit(strstr(line, "compute") + 7, " ", 0); -            gchar *name = NULL, *formula = NULL; -             -            for (i = 0; formulas[i]; i++) { -                if (formulas[i][0] == '\0') -                    continue; -                if (formulas[i][0] == ',') -                    break; -                 -                if (!name) name = g_strdup(formulas[i]); -                else if (!formula) formula = g_strdup(formulas[i]); -                else formula = g_strconcat(formula, formulas[i], NULL);             -            } -             -            g_strfreev(formulas); -            g_hash_table_insert(sensor_compute, name, math_string_to_postfix(formula)); -        } else if (g_str_has_prefix(line, "chip")) {	/* chip lines (delimiter) */ -            if (lock == FALSE) { -                gchar **chips = g_strsplit(line, " ", 0); -                 -                for (i = 1; chips[i]; i++) { -                    strend(chips[i], '*'); -                     -                    if (g_str_has_prefix(driver, chips[i] + 1)) { -                        lock = TRUE; -                        break; -                    } -                } -                 -                g_strfreev(chips); -            } else { -                break; -            } -        } +	line = buf; + +	remove_linefeed(line); +	strend(line, '#'); + +	if (*line == '\0') { +	    continue; +	} else if (lock && strstr(line, "label")) {	/* label lines */ +	    gchar **names = g_strsplit(strstr(line, "label") + 5, " ", 0); +	    gchar *name = NULL, *value = NULL; + +	    for (i = 0; names[i]; i++) { +		if (names[i][0] == '\0') +		    continue; + +		if (!name) +		    name = g_strdup(names[i]); +		else if (!value) +		    value = g_strdup(names[i]); +		else +		    value = g_strconcat(value, " ", names[i], NULL); +	    } + +	    remove_quotes(value); +	    g_hash_table_insert(sensor_labels, name, value); + +	    g_strfreev(names); +	} else if (lock && strstr(line, "ignore")) {	/* ignore lines */ +	    p = strstr(line, "ignore") + 6; +	    if (!strchr(p, ' ')) +		continue; + +	    while (*p == ' ') +		p++; +	    g_hash_table_insert(sensor_labels, g_strdup(p), "ignore"); +	} else if (lock && strstr(line, "compute")) {	/* compute lines */ +	    gchar **formulas = +		g_strsplit(strstr(line, "compute") + 7, " ", 0); +	    gchar *name = NULL, *formula = NULL; + +	    for (i = 0; formulas[i]; i++) { +		if (formulas[i][0] == '\0') +		    continue; +		if (formulas[i][0] == ',') +		    break; + +		if (!name) +		    name = g_strdup(formulas[i]); +		else if (!formula) +		    formula = g_strdup(formulas[i]); +		else +		    formula = g_strconcat(formula, formulas[i], NULL); +	    } + +	    g_strfreev(formulas); +	    g_hash_table_insert(sensor_compute, name, +				math_string_to_postfix(formula)); +	} else if (g_str_has_prefix(line, "chip")) {	/* chip lines (delimiter) */ +	    if (lock == FALSE) { +		gchar **chips = g_strsplit(line, " ", 0); + +		for (i = 1; chips[i]; i++) { +		    strend(chips[i], '*'); + +		    if (g_str_has_prefix(driver, chips[i] + 1)) { +			lock = TRUE; +			break; +		    } +		} + +		g_strfreev(chips); +	    } else { +		break; +	    } +	}      } -     +      fclose(conf);  } -static gchar * -get_sensor_label(gchar *sensor) +static gchar *get_sensor_label(gchar * sensor)  {      gchar *ret; -     +      ret = g_hash_table_lookup(sensor_labels, sensor); -    if (!ret) ret = g_strdup(sensor); -    else      ret = g_strdup(ret); +    if (!ret) +	ret = g_strdup(sensor); +    else +	ret = g_strdup(ret);      return ret;  } -static float -adjust_sensor(gchar *name, float value) +static float adjust_sensor(gchar * name, float value)  {      GSList *postfix; -     +      postfix = g_hash_table_lookup(sensor_compute, name); -    if (!postfix) return value; -     +    if (!postfix) +	return value; +      return math_postfix_eval(postfix, value);  } -static void -read_sensors(void) + +static void read_sensors_hwmon(void)  { -    gchar *path_hwmon, *path_sensor, *tmp, *driver, *name, *mon;      int hwmon, count; -     -    if (sensors) -        g_free(sensors); -     +    gchar *path_hwmon, *path_sensor, *tmp, *driver, *name, *mon;      hwmon = 0; -    sensors = g_strdup(""); -     -    path_hwmon = g_strdup_printf("/sys/class/hwmon/hwmon%d/device/", hwmon); + +    path_hwmon = +	g_strdup_printf("/sys/class/hwmon/hwmon%d/device/", hwmon);      while (g_file_test(path_hwmon, G_FILE_TEST_EXISTS)) { -        tmp = g_strdup_printf("%sdriver", path_hwmon); -        driver = g_file_read_link(tmp, NULL); -        g_free(tmp); - -        tmp = g_path_get_basename(driver); -        g_free(driver); -        driver = tmp; -         -        if (!sensor_labels) { -            read_sensor_labels(driver); -        } - -        sensors = g_strdup_printf("%s[Driver Info]\n" -                                  "Name=%s\n", sensors, driver); -     -        sensors = g_strconcat(sensors, "[Cooling Fans]\n", NULL); -        for (count = 1; ; count++) { -            path_sensor = g_strdup_printf("%sfan%d_input", path_hwmon, count); -            if (!g_file_get_contents(path_sensor, &tmp, NULL, NULL)) { -                g_free(path_sensor); -                break; -            } -             -            mon = g_strdup_printf("fan%d", count); -            name = get_sensor_label(mon); -            if (!g_str_equal(name, "ignore")) { -                sensors = g_strdup_printf("%s%s=%.0fRPM\n", -                                          sensors, name, -                                          adjust_sensor(mon, atof(tmp))); -            } -             -            g_free(name); -            g_free(mon); -            g_free(tmp); -            g_free(path_sensor); -        } - -        sensors = g_strconcat(sensors, "[Temperatures]\n", NULL); -        for (count = 1; ; count++) { -            path_sensor = g_strdup_printf("%stemp%d_input", path_hwmon, count); -            if (!g_file_get_contents(path_sensor, &tmp, NULL, NULL)) { -                g_free(path_sensor); -                break; -            } - -            mon = g_strdup_printf("temp%d", count); -            name = get_sensor_label(mon); -            if (!g_str_equal(name, "ignore")) { -                sensors = g_strdup_printf("%s%s=%.2f\302\260C\n", -                                          sensors, name, -                                          adjust_sensor(mon, atof(tmp) / 1000.0)); -            } -             -            g_free(tmp); -            g_free(name); -            g_free(path_sensor); -            g_free(mon); -        } - -        sensors = g_strconcat(sensors, "[Voltage Values]\n", NULL); -        for (count = 0; ; count++) { -            path_sensor = g_strdup_printf("%sin%d_input", path_hwmon, count); -            if (!g_file_get_contents(path_sensor, &tmp, NULL, NULL)) { -                g_free(path_sensor); -                break; -            } -             - -            mon = g_strdup_printf("in%d", count); -            name = get_sensor_label(mon); -            if (!g_str_equal(name, "ignore")) { -                sensors = g_strdup_printf("%s%s=%.3fV\n", -                                          sensors, name, -                                          adjust_sensor(mon, atof(tmp) / 1000.0)); -            } -             -            g_free(tmp); -            g_free(mon); -            g_free(name); -            g_free(path_sensor); -        } -     -        g_free(path_hwmon); -        g_free(driver); -        path_hwmon = g_strdup_printf("/sys/class/hwmon/hwmon%d/device/", ++hwmon); +	tmp = g_strdup_printf("%sdriver", path_hwmon); +	driver = g_file_read_link(tmp, NULL); +	g_free(tmp); + +	tmp = g_path_get_basename(driver); +	g_free(driver); +	driver = tmp; + +	if (!sensor_labels) { +	    read_sensor_labels(driver); +	} + +	sensors = g_strdup_printf("%s[Driver Info]\n" +				  "Name=%s\n", sensors, driver); + +	sensors = g_strconcat(sensors, "[Cooling Fans]\n", NULL); +	for (count = 1;; count++) { +	    path_sensor = +		g_strdup_printf("%sfan%d_input", path_hwmon, count); +	    if (!g_file_get_contents(path_sensor, &tmp, NULL, NULL)) { +		g_free(path_sensor); +		break; +	    } + +	    mon = g_strdup_printf("fan%d", count); +	    name = get_sensor_label(mon); +	    if (!g_str_equal(name, "ignore")) { +		sensors = g_strdup_printf("%s%s=%.0fRPM\n", +					  sensors, name, +					  adjust_sensor(mon, atof(tmp))); +	    } + +	    g_free(name); +	    g_free(mon); +	    g_free(tmp); +	    g_free(path_sensor); +	} + +	sensors = g_strconcat(sensors, "[Temperatures]\n", NULL); +	for (count = 1;; count++) { +	    path_sensor = +		g_strdup_printf("%stemp%d_input", path_hwmon, count); +	    if (!g_file_get_contents(path_sensor, &tmp, NULL, NULL)) { +		g_free(path_sensor); +		break; +	    } + +	    mon = g_strdup_printf("temp%d", count); +	    name = get_sensor_label(mon); +	    if (!g_str_equal(name, "ignore")) { +		sensors = g_strdup_printf("%s%s=%.2f\302\260C\n", +					  sensors, name, +					  adjust_sensor(mon, +							atof(tmp) / +							1000.0)); +	    } + +	    g_free(tmp); +	    g_free(name); +	    g_free(path_sensor); +	    g_free(mon); +	} + +	sensors = g_strconcat(sensors, "[Voltage Values]\n", NULL); +	for (count = 0;; count++) { +	    path_sensor = +		g_strdup_printf("%sin%d_input", path_hwmon, count); +	    if (!g_file_get_contents(path_sensor, &tmp, NULL, NULL)) { +		g_free(path_sensor); +		break; +	    } + + +	    mon = g_strdup_printf("in%d", count); +	    name = get_sensor_label(mon); +	    if (!g_str_equal(name, "ignore")) { +		sensors = g_strdup_printf("%s%s=%.3fV\n", +					  sensors, name, +					  adjust_sensor(mon, +							atof(tmp) / +							1000.0)); +	    } + +	    g_free(tmp); +	    g_free(mon); +	    g_free(name); +	    g_free(path_sensor); +	} + +	g_free(path_hwmon); +	g_free(driver); +	path_hwmon = +	    g_strdup_printf("/sys/class/hwmon/hwmon%d/device/", ++hwmon);      } -     -    g_free(path_hwmon);     + +    g_free(path_hwmon); +  } +static void read_sensors_acpi(void) +{ +    const gchar *path_tz = "/proc/acpi/thermal_zone"; + +    if (g_file_test(path_tz, G_FILE_TEST_EXISTS)) { +	GDir *tz; + +	if ((tz = g_dir_open(path_tz, 0, NULL))) { +	    const gchar *entry; + +	    sensors = +		g_strdup_printf("%s\n[ACPI Thermal Zone]\n", sensors); + +	    while ((entry = g_dir_read_name(tz))) { +		gchar *path = +		    g_strdup_printf("%s/%s/temperature", path_tz, entry); +		gchar *contents; + +		if (g_file_get_contents(path, &contents, NULL, NULL)) { +		    int temperature; + +		    sscanf(contents, "temperature: %d C", &temperature); + +		    sensors = g_strdup_printf("%s\n%s=%d\302\260C\n", +					      sensors, entry, temperature); + +		    g_free(contents); +		} +	    } + +	    g_dir_close(tz); +	} +    } + +} + +static void read_sensors_omnibook(void) +{ +    const gchar *path_ob = "/proc/omnibook/temperature"; +    gchar *contents; + +    if (g_file_get_contents(path_ob, &contents, NULL, NULL)) { +        int temperature; + +        sscanf(contents, "CPU temperature: %d C", &temperature); + +        sensors = g_strdup_printf("%s\n[Omnibook]\n" +                                  "CPU temperature=%d\302\260C\n", +                                  sensors, temperature); + +        g_free(contents); +    } +} + +static void read_sensors_hddtemp(void) +{ +    Socket *s; +    static gchar *old = NULL; +    gchar buffer[1024]; +    gint len = 0; + +    if ((s = sock_connect("127.0.0.1", 7634))) { +	while (!len) +	    len = sock_read(s, buffer, sizeof(buffer)); +	sock_close(s); + +	if (len > 2 && buffer[0] == '|' && buffer[1] == '/') { +	    gchar **disks; +	    int i; + +	    if (old) +		g_free(old); + +	    old = g_strdup("[Hard Disk Temperature]\n"); + +	    disks = g_strsplit(buffer, "\n", 0); +	    for (i = 0; disks[i]; i++) { +		gchar **fields = g_strsplit(disks[i] + 1, "|", 5); + +		/* +		 * 0 -> /dev/hda +		 * 1 -> FUJITSU MHV2080AH +		 * 2 -> 41 +		 * 3 -> C +		 */ +		old = g_strdup_printf("%s\n" +				      "%s (%s)=%s\302\260%s\n", +				      old, +				      fields[1], fields[0], +				      fields[2], fields[3]); + +		g_strfreev(fields); +	    } + +	    g_strfreev(disks); +	} +    } else { +	g_free(old); +	old = NULL; +    } + +    if (old) { +	sensors = g_strconcat(sensors, "\n", old, NULL); +    } +} + +static void __scan_sensors(void) +{ +    if (sensors) +	g_free(sensors); + +    sensors = g_strdup(""); + +    read_sensors_hwmon(); +    read_sensors_acpi(); +    read_sensors_omnibook(); +    read_sensors_hddtemp(); + +    /* FIXME: Add support for  ibm acpi and more sensors */ +} diff --git a/arch/linux/common/storage.h b/arch/linux/common/storage.h index 4fb682a9..836ba7ea 100644 --- a/arch/linux/common/storage.h +++ b/arch/linux/common/storage.h @@ -22,8 +22,6 @@ static gboolean  remove_scsi_devices(gpointer key, gpointer value, gpointer data)  {      if (!strncmp((gchar *) key, "SCSI", 4)) { -	g_free((gchar *) key); -	g_free((GtkTreeIter *) value);  	return TRUE;      }      return FALSE; @@ -31,7 +29,7 @@ remove_scsi_devices(gpointer key, gpointer value, gpointer data)  /* SCSI support by Pascal F.Martin <pascalmartin@earthlink.net> */  void -scan_scsi(void) +__scan_scsi_devices(void)  {      FILE *proc_scsi;      gchar buffer[256], *buf; @@ -43,7 +41,7 @@ scan_scsi(void)      gchar *vendor = NULL, *revision = NULL, *model = NULL;      /* remove old devices from global device table */ -    g_hash_table_foreach_remove(devices, remove_scsi_devices, NULL); +    g_hash_table_foreach_remove(moreinfo, remove_scsi_devices, NULL);      if (!g_file_test("/proc/scsi/scsi", G_FILE_TEST_EXISTS))  	return; @@ -107,7 +105,7 @@ scan_scsi(void)                  int i;                  for (i = 0; type2icon[i].type != NULL; i++) -                    if (!strcmp(buf + 8, type2icon[i].type)) +                    if (g_str_equal(buf + 8, type2icon[i].type))                          break;                  type = type2icon[i].label; @@ -120,6 +118,7 @@ scan_scsi(void)  	    gchar *strhash = g_strdup_printf("[Device Information]\n"  					     "Model=%s\n" +					     "Vendor=%s (%s)\n"  					     "Type=%s\n"  					     "Revision=%s\n"  					     "[SCSI Controller]\n" @@ -127,13 +126,15 @@ scan_scsi(void)  					     "Channel=%d\n"  					     "ID=%d\n" "LUN=%d\n",  					     model, +					     vendor_get_name(model), +					     vendor_get_url(model),  					     type,  					     revision,  					     scsi_controller,  					     scsi_channel,  					     scsi_id,  					     scsi_lun); -	    g_hash_table_insert(devices, devid, strhash); +	    g_hash_table_insert(moreinfo, devid, strhash);  	    g_free(model);  	    g_free(revision); @@ -147,25 +148,22 @@ static gboolean  remove_ide_devices(gpointer key, gpointer value, gpointer data)  {      if (!strncmp((gchar *) key, "IDE", 3)) { -	g_free((gchar *) key); -	g_free((gchar *) value); -  	return TRUE;      }      return FALSE;  } -  void -scan_ide(void) +__scan_ide_devices(void)  {      FILE *proc_ide;      gchar *device, iface, *model, *media, *pgeometry = NULL, *lgeometry =  	NULL; -    gint n = 0, i = 0, cache; +    gint n = 0, i = 0, cache, nn = 0; +    gchar *capab = NULL, *speed = NULL, *driver = NULL;      /* remove old devices from global device table */ -    g_hash_table_foreach_remove(devices, remove_ide_devices, NULL); +    g_hash_table_foreach_remove(moreinfo, remove_ide_devices, NULL);      storage_list = g_strdup_printf("%s\n[IDE Disks]\n", storage_list); @@ -173,12 +171,12 @@ scan_ide(void)      for (i = 0; i <= 16; i++) {  	device = g_strdup_printf("/proc/ide/hd%c/model", iface);  	if (g_file_test(device, G_FILE_TEST_EXISTS)) { -	    gchar buf[64]; +	    gchar buf[128];  	    cache = 0;  	    proc_ide = fopen(device, "r"); -	    fgets(buf, 64, proc_ide); +	    fgets(buf, 128, proc_ide);  	    fclose(proc_ide);  	    buf[strlen(buf) - 1] = 0; @@ -189,11 +187,67 @@ scan_ide(void)  	    device = g_strdup_printf("/proc/ide/hd%c/media", iface);  	    proc_ide = fopen(device, "r"); -	    fgets(buf, 64, proc_ide); +	    fgets(buf, 128, proc_ide);  	    fclose(proc_ide);  	    buf[strlen(buf) - 1] = 0;  	    media = g_strdup(buf); +	    if (g_str_equal(media, "cdrom")) { +	        /* obtain cd-rom drive information from cdrecord */ +	        GTimer *timer; +	        gchar *tmp = g_strdup_printf("cdrecord dev=/dev/hd%c -prcap 2>/dev/stdout", iface); +	        FILE *prcap; +	         +	        if ((prcap = popen(tmp, "r"))) { +                    /* we need a timeout so cdrecord does not try to get information on cd drives +                       with inserted media, which is not possible currently. half second should be +                       enough. */ +                    timer = g_timer_new(); +                    g_timer_start(timer); + +  	            while (fgets(buf, 128, prcap) && g_timer_elapsed(timer, NULL) < 0.5) { +  	               if (g_str_has_prefix(buf, "  Does")) { +  	                   if (g_str_has_suffix(buf, "media\n") && !strstr(buf, "speed")) { +      	                       gchar *media_type = g_strstrip(strstr(buf, "Does ")); +      	                       gchar **ttmp = g_strsplit(media_type, " ", 0); +  	                    +      	                       capab = g_strdup_printf("%s\nCan %s#%d=%s\n", +  	                                               capab ? capab : "", +  	                                               ttmp[1], ++nn, ttmp[2]); +  	                                            +                               g_strfreev(ttmp); +                           } else if (strstr(buf, "Buffer-Underrun-Free")) { +                               capab = g_strdup_printf("%s\nSupports BurnProof=%s\n", +                                                       capab ? capab : "", +                                                       strstr(buf, "Does not") ? "No" : "Yes"); +                           } else if (strstr(buf, "multi-session")) { +                               capab = g_strdup_printf("%s\nCan read multi-session CDs=%s\n", +                                                       capab ? capab : "", +                                                       strstr(buf, "Does not") ? "No" : "Yes"); +                           } else if (strstr(buf, "audio CDs")) { +                               capab = g_strdup_printf("%s\nCan play audio CDs=%s\n", +                                                       capab ? capab : "", +                                                       strstr(buf, "Does not") ? "No" : "Yes"); +                           } else if (strstr(buf, "PREVENT/ALLOW")) { +                               capab = g_strdup_printf("%s\nCan lock media=%s\n", +                                                       capab ? capab : "", +                                                       strstr(buf, "Does not") ? "No" : "Yes"); +                           } +  	               } else if ((strstr(buf, "read") || strstr(buf, "write")) && strstr(buf, "kB/s")) { +  	                   speed = g_strconcat(speed ? speed : "", +  	                                       strreplace(g_strstrip(buf), ":", '='), +  	                                       "\n", NULL); +  	               } else if (strstr(buf, "Device seems to be")) { +  	                   driver = g_strdup_printf("Driver=%s\n", strchr(buf, ':') + 1); +  	               } +  	            } + +  	            pclose(prcap); +                    g_timer_destroy(timer); +                } +	         +	        g_free(tmp); +	    }  	    g_free(device); @@ -242,24 +296,53 @@ scan_ide(void)  	    gchar *strhash = g_strdup_printf("[Device Information]\n"  					     "Model=%s\n" +					     "Vendor=%s (%s)\n"  					     "Device Name=hd%c\n" -					     "Media=%s\n" "Cache=%dkb\n", -					     model, iface, media, cache); -	    if (pgeometry && lgeometry) +					     "Media=%s\n" +					     "Cache=%dkb\n", +					     model, +					     vendor_get_name(model), +					     vendor_get_url(model), +					     iface, +					     media, +					     cache); +            if (driver) { +                strhash = g_strdup_printf("%s%s\n", strhash, driver); +                 +                g_free(driver); +                driver = NULL; +            } +             +	    if (pgeometry && lgeometry) {  		strhash = g_strdup_printf("%s[Geometry]\n"  					  "Physical=%s\n"  					  "Logical=%s\n",  					  strhash, pgeometry, lgeometry); + +                g_free(pgeometry); +                pgeometry = NULL; +                g_free(lgeometry); +                lgeometry = NULL; +            } +             +            if (capab) { +                strhash = g_strdup_printf("%s[Capabilities]\n%s", strhash, capab); +                 +                g_free(capab); +                capab = NULL; +            } -	    g_hash_table_insert(devices, devid, strhash); +            if (speed) { +                strhash = g_strdup_printf("%s[Speeds]\n%s", strhash, speed); +                 +                g_free(speed); +                speed = NULL; +            } +             +	    g_hash_table_insert(moreinfo, devid, strhash);  	    g_free(model);  	    model = ""; - -	    g_free(pgeometry); -	    pgeometry = NULL; -	    g_free(lgeometry); -	    lgeometry = NULL;  	} else  	    g_free(device); diff --git a/arch/linux/common/uptime.h b/arch/linux/common/uptime.h index cf339bf3..9225c85c 100644 --- a/arch/linux/common/uptime.h +++ b/arch/linux/common/uptime.h @@ -50,7 +50,6 @@ computer_get_formatted_uptime()      /* FIXME: Use ngettext */  #define plural(x) ((x > 1) ? "s" : "") -      if (ui->days < 1) {  	if (ui->hours < 1) {  	    tmp = diff --git a/arch/linux/common/usb.h b/arch/linux/common/usb.h index a52be2cb..d59f5f01 100644 --- a/arch/linux/common/usb.h +++ b/arch/linux/common/usb.h @@ -20,11 +20,6 @@ static gboolean  remove_usb_devices(gpointer key, gpointer value, gpointer data)  {      if (!strncmp((gchar *) key, "USB", 3)) { -	GtkTreeIter *iter = (GtkTreeIter *) data; - -	g_free((gchar *) value); -	g_free(iter); -  	return TRUE;      }      return FALSE; @@ -32,7 +27,7 @@ remove_usb_devices(gpointer key, gpointer value, gpointer data)  static gchar *usb_list = NULL;  void -scan_usb(void) +__scan_usb(void)  {      FILE *dev;      gchar buffer[128]; @@ -47,7 +42,7 @@ scan_usb(void)  	return;      if (usb_list) { -	g_hash_table_foreach_remove(devices, remove_usb_devices, NULL); +	g_hash_table_foreach_remove(moreinfo, remove_usb_devices, NULL);  	g_free(usb_list);      }      usb_list = g_strdup(""); @@ -100,6 +95,13 @@ scan_usb(void)      	        usb_list = g_strdup_printf("%s$%s$%s=\n",  		      		           usb_list, tmp, product); +                const gchar *url = vendor_get_url(manuf); +                if (url) { +                    gchar *tmp = g_strdup_printf("%s (%s)", manuf, url); +                    g_free(manuf); +                    manuf = tmp; +                } +                  gchar *strhash = g_strdup_printf("[Device Information]\n"                                                   "Product=%s\n"                                                   "Manufacturer=%s\n" @@ -118,7 +120,7 @@ scan_usb(void)                                                   ver, rev, classid,                                                   vendor, prodid, bus, level); -                g_hash_table_insert(devices, tmp, strhash); +                g_hash_table_insert(moreinfo, tmp, strhash);              }  	    g_free(manuf); | 
