1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-10-31 21:57:12 +00:00
freebsd-ports/x11-wm/icewm/files/patch-ak
Yukihiro Nakai 1695850316 Add Brian Scott's apm patch.
Submitted by:	Brian Scott <bscott@bunyatech.com.au>
1999-12-01 07:58:13 +00:00

74 lines
1.5 KiB
Plaintext

--- src/aapm.cc.orig Mon Nov 8 20:45:52 1999
+++ src/aapm.cc Wed Dec 1 16:42:31 1999
@@ -20,15 +20,32 @@
#include <string.h>
#include <stdio.h>
+#ifdef __FreeBSD__
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <machine/apm_bios.h>
+#endif
+
#ifdef CONFIG_APM
YColor *YApm::apmBg = 0;
YColor *YApm::apmFg = 0;
YFont *YApm::apmFont = 0;
+#ifdef __FreeBSD__
+#define APMDEV "/dev/apm"
+#else
+#define APMDEV "/proc/apm"
+#endif
+
void ApmStr(char *s, bool Tool) {
+#ifdef __FreeBSD__
+ struct apm_info ai;
+#else
char buf[45];
- int len, i, fd = open("/proc/apm", O_RDONLY);
+#endif
+ int len, i, fd = open(APMDEV, O_RDONLY);
char driver[16];
char apmver[16];
int apmflags;
@@ -40,9 +57,27 @@
char units[16];
if (fd == -1) {
+ static int error = 0;
+ if (!error)
+ perror("Can't open the apm device");
+ error = 1;
return ;
}
-
+#ifdef __FreeBSD__
+ if (ioctl(fd,APMIO_GETINFO, &ai) == -1)
+ {
+ static int error = 0;
+ if (!error)
+ perror("Can't ioctl the apm device");
+ error = 1;
+ close(fd);
+ return;
+ }
+ close(fd);
+ BATlife = ai.ai_batt_life;
+ ACstatus = ai.ai_acline ;
+ BATflag = ai.ai_batt_stat == 3 ? 8 : 0;
+#else
len = read(fd, buf, sizeof(buf) - 1);
close(fd);
@@ -60,6 +95,7 @@
}
return ;
}
+#endif
if (BATlife == -1)
BATlife = 0;