История изменений
Исправление ttnl, (текущая версия) :
#define BATTERY_FILE_NAME "/sys/class/power_supply/battery/online"
static int
battery_online () {
int status = 0;
char c;
int fd;
fd = open (BATTERY_FILE_NAME, O_RDONLY);
if (fd < 0) {
perrmsg ("open: " BATTERY_FILE_NAME);
return -1;
}
if (read(fd, &c, 1) != 1) {
perrmsg ("fail on read " BATTERY_FILE_NAME);
c = -1;
} else {
c -= '0';
if (c != 0 && c != 1)
c = -1;
}
close(fd);
return c;
}
Исправление ttnl, :
#define BATTERY_FILE_NAME "/sys/class/power_supply/battery/online"
static int
battery_online () {
int status = 0;
char c;
int fd;
fd = open (BATTERY_FILE_NAME, O_RDONLY);
if (fd < 0) {
perrmsg ("open: " BATTERY_FILE_NAME);
return -1;
}
if (read(fd, &c, 1) != 1) {
perrmsg ("fail on read " BATTERY_FILE_NAME);
c = -1;
} else {
c -= '0';
}
close(fd);
return c;
}
Исправление ttnl, :
#define BATTERY_FILE_NAME "/sys/class/power_supply/battery/online"
static int
battery_online () {
int status = 0;
char c;
int fd;
fd = open (BATTERY_FILE_NAME, O_RDONLY);
if (fd < 0) {
perrmsg ("open: " BATTERY_FILE_NAME);
return -1;
}
if (read(fd, &c, 1) != 1) {
perrmsg ("fail on read " BATTERY_FILE_NAME);
return -1;
}
return (c == '1');
}
Исходная версия ttnl, :
#define BATTERY_FILE_NAME «/sys/class/power_supply/battery/online»
static int battery_online () { int status = 0; char c; int fd;
fd = open (BATTERY_FILE_NAME, O_RDONLY); if (fd < 0) { perrmsg («open: » BATTERY_FILE_NAME); return -1; }
if (read(fd, &c, 1) != 1) { perrmsg («fail on read » BATTERY_FILE_NAME); return -1; }
return (c == '1'); }