/*
 * bbapm-0.0.1 patch-1 for FreeBSD-3.x and FreeBSD-4.x
 *
 * Copyright (c) 2000 by ISHIKAWA, Hidenori <hideishi@ops.dti.ne.jp>
 *
 * This patch may be used, modified, copied or distributed in both
 * source and binary as long as the above copyright and these terms
 * are retained. 
 *
 * Although the author has debugged this patch with great care,
 * under no circumstances is the author responsible for any damage
 * incurred with its use.
 *
 * In case if this patch is merged to the original bbapm-0.0.1,
 * this patch will also obey the license of the original bbapm-0.0.1,
 * i.e. GNU General Public License.
 *
 * patch-1 : Apr, 2000  Tested on FreeBSD-3.4-STABLE + PAO3
 */

#include <stdio.h>
#include <sys/file.h>
#include <sys/ioctl.h>

#include <machine/apm_bios.h>
#define APMDEV  "/dev/apm"

static	int	apmfd = 0;

void
apm_exists(void)
{
	if ((apmfd = open(APMDEV, O_RDWR)) == -1){
		printf("cannot open APM device\n");
		exit(1);
	}
}

int
apm_read(apm_info_t info)
{
	if (ioctl(apmfd, APMIO_GETINFO, info) == -1)
		return -1;
	else
		return 0;

}


syntax highlighted by Code2HTML, v. 0.9.1