2 // C++ Implementation: common
4 // Author: Oliver Groß <z.o.gross@gmx.de>, (C) 2008
6 // Copyright: See COPYING file that comes with this distribution
15 bool readStringFromFile(char * buffer
, const char * fileName
) {
17 f
= fopen(fileName
, "r");
19 fgets(buffer
, BUF_SIZE
, f
);
23 for (int i
= 0; i
< BUF_SIZE
; i
++) {
24 if (buffer
[i
] == '\n')
36 int readIntSysFile(const char * fileName
) {
37 char buffer
[BUF_SIZE
];
38 readStringFromFile(buffer
, fileName
);
42 int toStatusInt(const char * status
) {
43 if (strcmp(status
, "Discharging") == 0)
44 return UI_BATTERY_DISCHARGING
;
45 else if (strcmp(status
, "Charging") == 0)
46 return UI_BATTERY_CHARGING
;
47 else if (strcmp(status
, "Full") == 0)
48 return UI_BATTERY_FULL
;