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 QString
readStringSysFile(const char * fileName
) {
39 f
= fopen(fileName
, "r");
41 fgets(buf
, BUF_SIZE
, f
);
52 inFile.open(fileName);
58 int readIntSysFile(const char * fileName
) {
59 char buffer
[BUF_SIZE
];
60 readStringFromFile(buffer
, fileName
);
66 inFile.open(fileName);
73 int toStatusInt(/*std::string*/ QString status
) {
74 if (status
== "Discharging")
75 return UI_BATTERY_DISCHARGING
;
76 else if (status
== "Charging")
77 return UI_BATTERY_CHARGING
;
78 else if (status
== "Full")
79 return UI_BATTERY_FULL
;
84 int toStatusInt(const char * status
) {
85 if (strcmp(status
, "Discharging") == 0)
86 return UI_BATTERY_DISCHARGING
;
87 else if (strcmp(status
, "Charging") == 0)
88 return UI_BATTERY_CHARGING
;
89 else if (strcmp(status
, "Full") == 0)
90 return UI_BATTERY_FULL
;