View Single Post
  #5   (View Single Post)  
Old 11th January 2009
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

What about the following?

Code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/sysctl.h>

int main(void) {
	int mib[4];
	size_t len;
	char buf[BUFSIZ];
	int buflen = BUFSIZ;

	len = sizeof(mib);

	if(sysctlnametomib("hw.acpi.battery.life", mib, &len) == -1) {
		return 1;
	}

	if(sysctl(mib, len, buf, &buflen, NULL, 0) == -1) {
		return 1;
	}
	
	printf("%s\n", buf);
}
I can't confirm it'll compile, OpenBSD lacks this function..
Reply With Quote