int perc;
char path[PATH_MAX];
snprintf(path, sizeof(path), "%s%s%s", "/sys/class/power_supply/", bat, "/capacity");
return (pscanf(path, "%i", &perc) == 1) ?
bprintf("%d", perc) : NULL;
int perc;
char path[PATH_MAX];
snprintf(path, sizeof(path), "%s%s%s", "/sys/class/power_supply/", bat, "/capacity");
return (pscanf(path, "%i", &perc) == 1) ?
bprintf("%d", perc) : NULL;
struct apm_power_info apm_info;
int fd;
fd = open("/dev/apm", O_RDONLY);
if (fd < 0) {
struct apm_power_info apm_info;
int fd;
fd = open("/dev/apm", O_RDONLY);
if (fd < 0) {