summaryrefslogtreecommitdiff
path: root/multibatt.c
blob: 48d27c49b95349cacb8ea8ac508831f7a5cb381e (plain)
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
#include <u.h>
#include <libc.h>

char f[] = "/mnt/acpi/battery";
char buf[512];
char *s;
int nb = 0;

void
main(void)
{
	int fd;

	fd = open(f, OREAD);
	if(fd < 0)
		sysfatal("open: %r");

	read(fd, buf, sizeof buf);

	buf[strlen(buf)-1] = '\0';

	print("%d\n", atoi(buf)); nb++;
	for(s = buf; *s != '\0'; s++)
		if(*s == '\n'){
			nb++;
			print("%d\n", atoi(++s));
		}
	print("batteries: %d\n", nb);
	exits("done");
}