1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
diff -Naurp matchbox-panel-0.9.3.orig/applets/mb-applet-battery.c matchbox-panel-0.9.3/applets/mb-applet-battery.c
--- matchbox-panel-0.9.3.orig/applets/mb-applet-battery.c 2006-02-07 22:27:24.000000000 +0000
+++ matchbox-panel-0.9.3/applets/mb-applet-battery.c 2006-06-20 18:12:00.000000000 +0000
@@ -157,50 +157,50 @@ struct avg_consumption {
static struct avg_consumption a;
+enum ac_state { AC_UNKNOWN = -1, AC_OFFLINE = 0, AC_ONLINE = 1 };
+enum bat_state { BAT_UNKNOWN = -1, BAT_CHARGING = 1, BAT_DISCHARGING = 2 };
+
+struct entry {
+ char *key;
+ char *value;
+ char *unit;
+};
+
+struct acpi_status {
+ enum ac_state ac_state;
+ enum bat_state bat_state;
+ unsigned long design_capacity;
+ unsigned long remaining_capacity;
+ unsigned long present_rate;
+};
+
static int
-read_apm(int *values)
+line_parse(char *line, struct entry *e)
{
- enum ac_state { AC_UNKNOWN = -1, AC_OFFLINE = 0, AC_ONLINE = 1 };
- enum bat_state { BAT_UNKNOWN = -1, BAT_CHARGING = 1, BAT_DISCHARGING = 2 };
-
- struct entry {
- char *key;
- char *value;
- char *unit;
- };
-
- struct acpi_status {
- enum ac_state ac_state;
- enum bat_state bat_state;
- unsigned long design_capacity;
- unsigned long remaining_capacity;
- unsigned long present_rate;
- };
+ char *ptr;
- static int
- line_parse(char *line, struct entry *e)
- {
- char *ptr;
-
- ptr = strchr(line, ':');
- if (!ptr)
- return -1;
- e->key = line;
- *ptr = 0;
- while (*++ptr && *ptr == ' ');
- e->value = ptr;
- while (*++ptr && *ptr != '\n' && *ptr != ' ');
+ ptr = strchr(line, ':');
+ if (!ptr)
+ return -1;
+ e->key = line;
+ *ptr = 0;
+ while (*++ptr && *ptr == ' ');
+ e->value = ptr;
+ while (*++ptr && *ptr != '\n' && *ptr != ' ');
+ *ptr = 0;
+ if (*++ptr) {
+ e->unit = ptr;
+ while (*++ptr && *ptr != '\n');
*ptr = 0;
- if (*++ptr) {
- e->unit = ptr;
- while (*++ptr && *ptr != '\n');
- *ptr = 0;
- } else
- e->unit = 0;
-
- return 0;
- }
+ } else
+ e->unit = 0;
+
+ return 0;
+}
+static int
+read_apm(int *values)
+{
FILE *f;
char line[1024];
struct entry e;
|