aboutsummaryrefslogtreecommitdiff
path: root/hardinfo2/arch/linux
diff options
context:
space:
mode:
authorLeandro A. F. Pereira <leandro@hardinfo.org>2007-03-21 10:54:54 +0000
committerLeandro A. F. Pereira <leandro@hardinfo.org>2007-03-21 10:54:54 +0000
commit71a591195618271973a12ae7ffaf288909481cbc (patch)
tree68ea841f948f1351099dd470ba966edf42125047 /hardinfo2/arch/linux
parentf7ab0cb977df0d6eba533a245c93da582b9f5f84 (diff)
Cleanups. APM battery info fixes for Linux 2.6.
Diffstat (limited to 'hardinfo2/arch/linux')
-rw-r--r--hardinfo2/arch/linux/common/battery.h63
-rw-r--r--hardinfo2/arch/linux/common/os.h4
-rw-r--r--hardinfo2/arch/linux/x86/processor.h102
3 files changed, 95 insertions, 74 deletions
diff --git a/hardinfo2/arch/linux/common/battery.h b/hardinfo2/arch/linux/common/battery.h
index 919dc65d..20979e48 100644
--- a/hardinfo2/arch/linux/common/battery.h
+++ b/hardinfo2/arch/linux/common/battery.h
@@ -136,27 +136,31 @@ __scan_battery_apm(void)
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;
- float apm_bios_ver, apm_drv_ver;
+ char apm_bios_ver[16], apm_drv_ver[16];
char trash[10];
- if (last_time == 0) {
- last_time = time(NULL);
- sremaining = g_strdup("Estimating");
- stotal = g_strdup("Estimating");
- }
-
if ((procapm = fopen("/proc/apm", "r"))) {
int old_percentage = percentage;
- fscanf(procapm, "%f %f %s 0x%x %s %s %d%%",
- &apm_drv_ver, &apm_bios_ver, trash,
+ 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) {
- g_free(sremaining);
- g_free(stotal);
+ if (sremaining && stotal) {
+ g_free(sremaining);
+ g_free(stotal);
+ }
int secs_remaining = (time(NULL) - last_time) * percentage /
(old_percentage - percentage);
@@ -165,19 +169,34 @@ __scan_battery_apm(void)
last_time = time(NULL);
}
+ } else {
+ return;
}
- 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=%.2f\n"
- "APM BIOS version=%.2f\n",
- battery_list,
- percentage,
- sremaining, stotal,
- ac_bat ? "AC Power" : "Battery",
- apm_drv_ver, apm_bios_ver);
+ 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
diff --git a/hardinfo2/arch/linux/common/os.h b/hardinfo2/arch/linux/common/os.h
index b4404925..d30146ef 100644
--- a/hardinfo2/arch/linux/common/os.h
+++ b/hardinfo2/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 {
diff --git a/hardinfo2/arch/linux/x86/processor.h b/hardinfo2/arch/linux/x86/processor.h
index e9985d2c..918bac7c 100644
--- a/hardinfo2/arch/linux/x86/processor.h
+++ b/hardinfo2/arch/linux/x86/processor.h
@@ -86,7 +86,7 @@ static void get_processor_strfamily(Processor * processor)
}
} else if (family == 6) {
if (model == 1) {
- processor->strmodel = g_strdup("AMD Athlon (K7");
+ processor->strmodel = g_strdup("AMD Athlon (K7)");
} else if (model == 2) {
processor->strmodel = g_strdup("AMD Athlon (K75)");
} else if (model == 3) {
@@ -211,51 +211,50 @@ static GSList *__scan_processors(void)
static struct {
char *name, *meaning;
} flag_meaning[] = {
- {
- "3dnow", "3DNow! Technology"}, {
- "3dnowext", "Extended 3DNow! Technology"}, {
- "fpu", "Floating Point Unit"}, {
- "vme", "Virtual 86 Mode Extension"}, {
- "de", "Debug Extensions - I/O breakpoints"}, {
- "pse", "Page Size Extensions (4MB pages)"}, {
- "tsc", "Time Stamp Counter and RDTSC instruction"}, {
- "msr", "Model Specific Registers"}, {
- "pae", "Physical Address Extensions (36-bit address, 2MB pages)"}, {
- "mce", "Machine Check Architeture"}, {
- "cx8", "CMPXCHG8 instruction"}, {
- "apic", "Advanced Programmable Interrupt Controller"}, {
- "sep", "Fast System Call (SYSENTER/SYSEXIT instructions)"}, {
- "mtrr", "Memory Type Range Registers"}, {
- "pge", "Page Global Enable"}, {
- "mca", "Machine Check Architecture"}, {
- "cmov", "Conditional Move instruction"}, {
- "pat", "Page Attribute Table"}, {
- "pse36", "36bit Page Size Extensions"}, {
- "psn", "96 bit Processor Serial Number"}, {
- "mmx", "MMX technology"}, {
- "mmxext", "Extended MMX Technology"}, {
- "cflush", "Cache Flush"}, {
- "dtes", "Debug Trace Store"}, {
- "fxsr", "FXSAVE and FXRSTOR instructions"}, {
- "kni", "Streaming SIMD instructions"}, {
- "xmm", "Streaming SIMD instructions"}, {
- "ht", "HyperThreading"}, {
- "mp", "Multiprocessing Capable"}, {
- "sse", "SSE instructions"}, {
- "sse2", "SSE2 (WNI) instructions"}, {
- "acc", "Automatic Clock Control"}, {
- "ia64", "IA64 Instructions"}, {
- "syscall", "SYSCALL and SYSEXIT instructions"}, {
- "nx", "No-execute Page Protection"}, {
- "xd", "Execute Disable"}, {
- "clflush", "Cache Line Flush instruction"}, {
- "acpi", "Thermal Monitor and Software Controlled Clock Facilities"}, {
- "dts", "Debug Store"}, {
- "ss", "Self Snoop"}, {
- "tm", "Thermal Monitor"}, {
- "pbe", "Pending Break Enable"}, {
- "pb", "Pending Break Enable"}, {
- NULL, NULL}
+ { "3dnow", "3DNow! Technology" },
+ { "3dnowext", "Extended 3DNow! Technology" },
+ { "fpu", "Floating Point Unit" },
+ { "vme", "Virtual 86 Mode Extension" },
+ { "de", "Debug Extensions - I/O breakpoints" },
+ { "pse", "Page Size Extensions (4MB pages)" },
+ { "tsc", "Time Stamp Counter and RDTSC instruction" },
+ { "msr", "Model Specific Registers" },
+ { "pae", "Physical Address Extensions" },
+ { "mce", "Machine Check Architeture" },
+ { "cx8", "CMPXCHG8 instruction" },
+ { "apic", "Advanced Programmable Interrupt Controller" },
+ { "sep", "Fast System Call (SYSENTER/SYSEXIT)" },
+ { "mtrr", "Memory Type Range Registers" },
+ { "pge", "Page Global Enable" },
+ { "mca", "Machine Check Architecture" },
+ { "cmov", "Conditional Move instruction" },
+ { "pat", "Page Attribute Table" },
+ { "pse36", "36bit Page Size Extensions" },
+ { "psn", "96 bit Processor Serial Number" },
+ { "mmx", "MMX technology" },
+ { "mmxext", "Extended MMX Technology" },
+ { "cflush", "Cache Flush" },
+ { "dtes", "Debug Trace Store" },
+ { "fxsr", "FXSAVE and FXRSTOR instructions" },
+ { "kni", "Streaming SIMD instructions" },
+ { "xmm", "Streaming SIMD instructions" },
+ { "ht", "HyperThreading" },
+ { "mp", "Multiprocessing Capable" },
+ { "sse", "SSE instructions" },
+ { "sse2", "SSE2 (WNI) instructions" },
+ { "acc", "Automatic Clock Control" },
+ { "ia64", "IA64 Instructions" },
+ { "syscall", "SYSCALL and SYSEXIT instructions" },
+ { "nx", "No-execute Page Protection" },
+ { "xd", "Execute Disable" },
+ { "clflush", "Cache Line Flush instruction" },
+ { "acpi", "Thermal Monitor and Software Controlled Clock" },
+ { "dts", "Debug Store" },
+ { "ss", "Self Snoop" },
+ { "tm", "Thermal Monitor" },
+ { "pbe", "Pending Break Enable" },
+ { "pb", "Pending Break Enable" },
+ { NULL, NULL },
};
gchar *processor_get_capabilities_from_flags(gchar * strflags)
@@ -295,12 +294,12 @@ static gchar *processor_get_detailed_info(Processor * processor)
tmp = processor_get_capabilities_from_flags(processor->flags);
ret = g_strdup_printf("[Processor]\n"
"Name=%s\n"
- "Specification=%s\n"
- "Family, model, stepping=%d, %d, %d\n"
+ "Family, model, stepping=%d, %d, %d (%s)\n"
"Vendor=%s\n"
+ "[Configuration]\n"
"Cache Size=%dkb\n"
"Frequency=%.2fMHz\n"
- "BogoMips=%.2f\n"
+ "BogoMIPS=%.2f\n"
"Byte Order=%s\n"
"[Features]\n"
"FDIV Bug=%s\n"
@@ -308,12 +307,13 @@ static gchar *processor_get_detailed_info(Processor * processor)
"F00F Bug=%s\n"
"Coma Bug=%s\n"
"Has FPU=%s\n"
- "[Capabilities]\n" "%s",
- processor->strmodel,
+ "[Capabilities]\n"
+ "%s",
processor->model_name,
processor->family,
processor->model,
processor->stepping,
+ processor->strmodel,
vendor_get_name(processor->vendor_id),
processor->cache_size,
processor->cpu_mhz, processor->bogomips,