[Pkg-wmaker-commits] [wmbattery] 26/241: * Converted to use libapm, instead of the hacked up old version of it used before. This probably breaks wmbattery on the BSD's, for now. The correct fix for the BSD's will be to get support for their apm implementations into libapm. To that end, I have filed a bug with all the code I ripped out. * The -f option also had to be removed. If libapm does not work right on systems that needed that flag it's probably a bug in the library. * Closes: #100027

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 24 23:37:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmbattery.

commit 6ad87bd9acf3023e96261f98d8b154e4f971aefe
Author: joey <joey at a4a2c43b-8ac3-0310-8836-e0e880c912e2>
Date:   Sun Feb 24 18:22:25 2002 +0000

       * Converted to use libapm, instead of the hacked up old version of it
         used before. This probably breaks wmbattery on the BSD's, for now. The
         correct fix for the BSD's will be to get support for their apm
         implementations into libapm. To that end, I have filed a bug with all the
         code I ripped out.
       * The -f option also had to be removed. If libapm does not work right on
         systems that needed that flag it's probably a bug in the library.
       * Closes: #100027
---
 config.h.in      |   7 ---
 configure.in     |  14 +----
 debian/changelog |  13 +++++
 debian/control   |   2 +-
 debian/copyright |   3 +-
 wmbattery.1x     |   6 +-
 wmbattery.c      | 166 ++-----------------------------------------------------
 wmbattery.h      |  17 ------
 8 files changed, 22 insertions(+), 206 deletions(-)

diff --git a/config.h.in b/config.h.in
index 756d324..dd5a6b3 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,13 +1,6 @@
 #ifndef CONFIG_H
 #define CONFIG_H
 
-/* Where is the apm device? */
-#undef HAVE__DEV_APM
-
-/* What apm header file should I use? */
-#undef HAVE_I386_APMVAR_H
-#undef HAVE_MACHINE_APM_BIOS_H
-
 /* What system header files can I use? */
 #undef HAVE_GETOPT_H
 #undef HAVE_SYS_FILE_H
diff --git a/configure.in b/configure.in
index 4a9721b..4d2163e 100644
--- a/configure.in
+++ b/configure.in
@@ -4,9 +4,6 @@ AC_CONFIG_HEADER(config.h)
 
 AC_CONFIG_AUX_DIR(autoconf)
 
-dnl Checks for the apm device other than /proc/apm.
-AC_CHECK_FILES(/dev/apm)
-
 dnl Checks for programs.
 AC_PROG_CC
 AC_PROG_INSTALL
@@ -27,21 +24,14 @@ dnl Checks for libraries.
 AC_CHECK_LIB(X11, XOpenDisplay)
 AC_CHECK_LIB(Xext, XShapeCombineMask)
 AC_CHECK_LIB(Xpm, XpmReadFileToPixmap)
+AC_CHECK_LIB(apm, apm_read)
 
 dnl Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS(unistd.h)
 AC_CHECK_HEADERS(X11/xpm.h)
 AC_CHECK_HEADERS(X11/extensions/shape.h)
-AC_CHECK_HEADERS(sys/file.h)
-AC_CHECK_HEADERS(sys/ioctl.h)
 AC_CHECK_HEADERS(getopt.h)
-
-dnl FreeBSD needs apm_bios.h
-AC_CHECK_HEADERS(machine/apm_bios.h)
-
-dnl NetBSD and OpenBSD need apmvar.h
-AC_CHECK_HEADERS(i386/apmvar.h)
+AC_CHECK_HEADERS(apm.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
diff --git a/debian/changelog b/debian/changelog
index 5948cb8..97e70de 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,16 @@
+wmbattery (1.22) unstable; urgency=low
+
+  * Converted to use libapm, instead of the hacked up old version of it
+    used before. This probably breaks wmbattery on the BSD's, for now. The
+    correct fix for the BSD's will be to get support for their apm
+    implementations into libapm. To that end, I have filed a bug with all the
+    code I ripped out.
+  * The -f option also had to be removed. If libapm does not work right on
+    systems that needed that flag it's probably a bug in the library.
+  * Closes: #100027
+
+ -- Joey Hess <joeyh at debian.org>  Sun, 24 Feb 2002 12:47:53 -0500
+
 wmbattery (1.21) unstable; urgency=low
 
   * Typo, Closes: #125485
diff --git a/debian/control b/debian/control
index 6541cca..13fda7e 100644
--- a/debian/control
+++ b/debian/control
@@ -1,7 +1,7 @@
 Source: wmbattery
 Section: x11
 Priority: extra
-Build-Depends: debhelper (>= 3), xlibs-dev, autoconf
+Build-Depends: debhelper (>= 3), xlibs-dev, autoconf, libapm-dev
 Maintainer: Joey Hess <joeyh at debian.org>
 Standards-Version: 3.5.6.0
 
diff --git a/debian/copyright b/debian/copyright
index f0a085a..04da2f4 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,9 +1,8 @@
-Wmbattery is copyright (C) 1998, 2001 by Joey Hess <joey at kitenet.net>
+Wmbattery is copyright (C) 1998, 2001, 2002 by Joey Hess <joey at kitenet.net>
 
 Wmbattery uses code and images from the following sources:
 
   wmapm	 - (C) 1998 Chris D. Faulhaber <jedgar at speck.ml.org>
-  libapm - Rik Faith <faith at cs.unc.edu>
   wmmon and wmgeneral - Martijm Pieterse <pieterse at xs4all.nl> and
   			Antoine Nulle <warp at xs4all.nl> 
 
diff --git a/wmbattery.1x b/wmbattery.1x
index c04f7f7..21fe1d4 100644
--- a/wmbattery.1x
+++ b/wmbattery.1x
@@ -3,7 +3,7 @@
 WMBATTERY \- Dockable APM/Battery Monitor
 .SH SYNOPSIS
 .B wmbattery
-[-h] [-d display] [-f apmfile]
+[-h] [-d display]
 .SH DESCRIPTION
 .PP
 .B wmbattery
@@ -64,10 +64,6 @@ Use the designated X display.
 .TP
 .B \-g +x+y
 Specify geometry. This specifies position, not size.
-.TP
-.B \-f [apmfile]
-Use the specified file instead of /proc/apm (or /dev/apm on BSD systems).
-Useful on Apple Macintosh powerbooks which use the pmud for apm handling.
 .SH AUTHOR
 Joey Hess <joey at kitenet.net>, based on wmapm by
 Chris D. Faulhaber <jedgar at speck.ml.org>
diff --git a/wmbattery.c b/wmbattery.c
index 623f19d..4dd7cac 100644
--- a/wmbattery.c
+++ b/wmbattery.c
@@ -7,22 +7,7 @@
 #include <X11/extensions/shape.h>
 #include <stdarg.h>
 #include <signal.h>
-
-#ifdef HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-
-#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-
-#ifdef HAVE_MACHINE_APM_BIOS_H	/* for FreeBSD */
-#include <machine/apm_bios.h>
-#endif
-
-#ifdef HAVE_I386_APMVAR_H	/* for NetBSD and OpenBSD */
-#include <i386/apmvar.h>
-#endif
+#include <apm.h>
 
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
@@ -39,14 +24,6 @@ Display *display;
 GC NormalGC;
 int pos[2] = {0, 0};
 
-#ifdef HAVE__DEV_APM
-#define APM_STATUS_FILE "/dev/apm"
-#else
-#define APM_STATUS_FILE "/proc/apm"
-#endif
-
-char *apm_status_file = APM_STATUS_FILE;
-
 void error(const char *fmt, ...) {
   	va_list arglist;
   
@@ -59,129 +36,6 @@ void error(const char *fmt, ...) {
   	exit(1);
 }
 
-#if defined (HAVE_MACHINE_APM_BIOS_H) || defined (HAVE_I386_APMVAR_H) /* BSD */
-
-int apm_read(apm_info *i) {
-	int fd;
-#ifdef HAVE_MACHINE_APM_BIOS_H /* FreeBSD */
-	unsigned long request = APMIO_GETINFO;
-	struct apm_info info;
-#else /* NetBSD or OpenBSD */
-	unsigned long request= APM_IOC_GETPOWER;
-	struct apm_power_info info;
-#endif
-
-	if ((fd = open(apm_status_file, O_RDONLY)) == -1) {
-    		return 0;
-	}
-	if (ioctl(fd, request, &info) == -1) {
-		return 0;
-	}
-	close(fd);
-
-#ifdef HAVE_MACHINE_APM_BIOS_H /* FreeBSD */
-	i->ac_line_status = info.ai_acline;
-	i->battery_status = info.ai_batt_stat;
-	i->battery_flags = (info.ai_batt_stat == 3) ? 8: 0;
-	i->battery_percentage = info.ai_batt_life;
-	i->battery_time = info.ai_batt_time;
-	i->using_minutes = 0;
-#else /* NetBSD or OpenBSD */
-	i->ac_line_status = info.ac_state;
-	i->battery_status = info.battery_state;
-	i->battery_flags = (info.battery_state == 3) ? 8: 0;
-	i->battery_percentage = info.battery_life;
-	i->battery_time = info.minutes_left;
-	i->using_minutes = 1;
-#endif
-	
-	return 1;
-}
-
-#else /* Linux */
-
-int apm_read(apm_info *i) {
-	FILE *str;
-  	char units[10];
-	char buffer[100];
-
-	if (!(str = fopen(apm_status_file, "r")))
-    		return 0;
-	fgets(buffer, sizeof(buffer) - 1, str);
-	buffer[sizeof(buffer) - 1] = '\0';
-	sscanf(buffer, "%s %d.%d %x %x %x %x %d%% %d %s\n",
-	       (char *)i->driver_version,
-	       &i->apm_version_major,
-	       &i->apm_version_minor,
-	       &i->apm_flags,
-	       &i->ac_line_status,
-	       &i->battery_status,
-		       &i->battery_flags,
-	       &i->battery_percentage,
-	       &i->battery_time,
-	       units);
-	i->using_minutes = !strncmp(units, "min", 3) ? 1 : 0;
-	if (i->driver_version[0] == 'B') { /* old style.  argh. */
-		strcpy((char *)i->driver_version, "pre-0.7");
-		i->apm_version_major  = 0;
-		i->apm_version_minor  = 0;
-		i->apm_flags          = 0;
-		i->ac_line_status     = 0xff;
-		i->battery_status     = 0xff;
-		i->battery_flags      = 0xff;
-		i->battery_percentage = -1;
-		i->battery_time       = -1;
-		i->using_minutes      = 1;
-		sscanf(buffer, "BIOS version: %d.%d",
-			&i->apm_version_major, &i->apm_version_minor);
-		fgets(buffer, sizeof(buffer) - 1, str);
-		sscanf(buffer, "Flags: 0x%02x", &i->apm_flags);
-		if (i->apm_flags & APM_32_BIT_SUPPORT) {
-			fgets(buffer, sizeof(buffer) - 1, str);
-			fgets(buffer, sizeof(buffer) - 1, str);
-			if (buffer[0] != 'P') {
-				if (!strncmp(buffer+4, "off line", 8))
-					i->ac_line_status = 0;
-				else if (!strncmp(buffer+4, "on line", 7))
-	  				i->ac_line_status = 1;
-				else if (!strncmp(buffer+4, "on back", 7))
-	  				i->ac_line_status = 2;
-				fgets(buffer, sizeof(buffer) - 1, str);
-				if (!strncmp(buffer+16, "high", 4))
-	  				i->battery_status = 0;
-				else if (!strncmp(buffer+16, "low", 3))
-	  				i->battery_status = 1;
-				else if (!strncmp(buffer+16, "crit", 4))
-	  				i->battery_status = 2;
-				else if (!strncmp(buffer+16, "charg", 5))
-	  				i->battery_status = 3;
-				fgets(buffer, sizeof(buffer) - 1, str);
-				if (strncmp(buffer+14, "unknown", 7))
-	  				i->battery_percentage = atoi(buffer + 14);
-				if (i->apm_version_major >= 1 && i->apm_version_minor >= 1) {
-	  				fgets(buffer, sizeof(buffer) - 1, str);
-	  				sscanf(buffer, "Battery flag: 0x%02x", &i->battery_flags);
-	  				fgets(buffer, sizeof(buffer) - 1, str);
-	  				if (strncmp(buffer+14, "unknown", 7))
-	    					i->battery_time = atoi(buffer + 14);
-				}
-      			}
-    		}
-	}
-
-       	/*
-	 * Fix possible kernel bug -- percentage
-         * set to 0xff (==255) instead of -1.
-	 */
-  	if (i->battery_percentage > 100)
-    		i->battery_percentage = -1;
-  
-  	fclose(str);
-  	return 1;
-}
-
-#endif /* linux */
-
 int apm_change(apm_info *cur) {
 	static int ac_line_status = 0, battery_status = 0, battery_flags = 0,
 		battery_percentage = 0, battery_time = 0, using_minutes = 0;
@@ -203,14 +57,6 @@ int apm_change(apm_info *cur) {
 	return i;
 }
 
-int apm_exists() {
-	apm_info i;
-  
-        if (access(apm_status_file, R_OK))
-        	return 0;
-	return apm_read(&i);
-}
-
 /* Load up the images this program uses. */
 void load_images() {
   	int x;
@@ -243,7 +89,6 @@ char *parse_commandline(int argc, char *argv[]) {
               		printf("\t-d <display>\tselects target display\n");
                		printf("\t-h\t\tdisplay this help\n");
                         printf("\t-g +x+y\t\tposition of the window\n");
-			printf("\t-f file\t\tapm status file to use instead of " APM_STATUS_FILE "\n\n");
                		exit(0);
 		 	break;
 		  case 'd':
@@ -261,9 +106,6 @@ char *parse_commandline(int argc, char *argv[]) {
                           }
                         }
                         break;
-		  case 'f':
-			apm_status_file = strdup(optarg);
-			break;
       		}
     	}
   
@@ -499,7 +341,7 @@ void recalc_window(apm_info cur_info) {
 void alarmhandler(int sig) {
 	apm_info cur_info;
 	
-	if (! apm_read(&cur_info))
+	if (apm_read(&cur_info) != 0)
 		error("Cannot read APM information.");
 	
 	/* If APM data changes redraw and wait for next update */
@@ -513,8 +355,8 @@ void alarmhandler(int sig) {
 int main(int argc, char *argv[]) {
 	make_window(parse_commandline(argc, argv), argc ,argv);
 
-	/*  Check for APM support */
-	if (! apm_exists())
+	/*  Check for APM support (returns 0 on success). */
+	if (apm_exists() != 0)
 		error("No APM support in kernel.");
 	
 	load_images();
diff --git a/wmbattery.h b/wmbattery.h
index 0937c6f..bf59f61 100644
--- a/wmbattery.h
+++ b/wmbattery.h
@@ -6,19 +6,6 @@ typedef struct {
   	XpmAttributes attributes;
 } XpmIcon;
 
-typedef struct {
-	const char driver_version[10];
-	int apm_version_major;
-   	int apm_version_minor;
-   	int apm_flags;
-   	int ac_line_status;
-   	int battery_status;
-   	int battery_flags;
-   	int battery_percentage;
-   	int battery_time;
-   	int using_minutes;
-} apm_info;
-
 typedef struct image_info_type {
   	const char* filename;
   	const int width;
@@ -28,10 +15,6 @@ typedef struct image_info_type {
   	const int charwidth;
 } image_info_type;
 
-#ifndef APM_32_BIT_SUPPORT
-#define APM_32_BIT_SUPPORT      0x0002
-#endif
-
 /* Assign reference numbers to all images that are loaded. */
 #define SMALLFONT 0
 #define BIGFONT 1

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbattery.git



More information about the Pkg-wmaker-commits mailing list