2
* Copyright (C) 2002,2003,2004 Mattia Dongili<dongili@supereva.it>
3
* George Staikos <staikos@0wned.org>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
int libsys_init(void) {
26
rc = stat(APM_PROC_FILE, &sb);
28
cp_log(LOG_ERR, "libsys_init(): %s: %s\n", APM_PROC_FILE, strerror(errno));
34
void libsys_fini (void) {}
36
/* int scan_system_info(sys_info *s)
38
* Reads APM info and fills the input sys_info struct.
39
* Implements the prototype needed by cpufreqd to get
40
* info from the PM layer.
42
* Returns 0 on success, -1 otherwise
45
int scan_system_info(sys_info *s) {
50
/***** APM SCAN *****/
54
unsigned int batt_flag;
56
fp = fopen(APM_PROC_FILE , "r");
58
cp_log(LOG_ERR, "scan_system_info(): %s: %s\n", APM_PROC_FILE, strerror(errno));
62
if (!fgets(buf, 100, fp)) {
64
cp_log(LOG_ERR, "scan_system_info(): %s: %s\n", APM_PROC_FILE, strerror(errno));
68
sscanf(buf, "%s %d.%d %x %x %x %x %d%% %d %s\n",
69
s->version, &ignore, &ignore, &s->flags, &s->ac, &ignore2,
70
&batt_flag, &s->battery_percent, &s->battery_time, ignore3);
72
if (!strncmp(ignore3, "sec", 3)) {
73
s->battery_time /= 60;
76
if (s->battery_percent > 100) {
77
s->battery_percent = -1;
80
s->has_battery = batt_flag < 128;
84
cp_log(LOG_INFO, "scan_system_info(): battery %s - %d - %s cpu %d\n",
85
s->has_battery?"present":"absent",
87
s->ac?"on-line":"off-line",