1 diff -Naur apmd-orig/Makefile apmd/Makefile
2 --- apmd-orig/Makefile 2001-11-25 14:46:16.000000000 -0800
3 +++ apmd/Makefile 2004-10-27 22:09:11.000000000 -0700
8 -XTRACFLAGS=-Wall -pipe -I. -I/usr/src/linux/include \
9 - -I/usr/src/linux-2.2/include -I /usr/src/linux-2.0/include \
10 +XTRACFLAGS=-Wall -pipe -I. -I/usr/linux/include \
11 -DVERSION=\"$(VERSION)\" \
12 -DAPMD_PROXY_NAME=\"$(APMD_PROXY_DIR)/apmd_proxy\"
14 diff -Naur apmd-orig/apmd.c apmd/apmd.c
15 --- apmd-orig/apmd.c 2001-11-25 14:43:32.000000000 -0800
16 +++ apmd/apmd.c 2004-10-27 22:09:11.000000000 -0700
21 -#define APM_TRACE 1 /* enable to compile in debug tracing */
25 -#define ADEBUG(lev,args...) \
26 - if (APM_TRACE>=lev) syslog(LOG_DEBUG, __FUNCTION__ ": " args)
28 -#define ADEBUG(args...)
30 +#define APM_TRACE 0 /* enable to compile in debug tracing */
32 #define PID_FILE _PATH_VARRUN "apmd.pid"
38 - ADEBUG(4, "0x%04x\n", event);
39 /* If the proxy flag is not set, then return 0 indicating that
40 * the event is acceptable
46 - ADEBUG(0, "can't open fds for apmd_proxy: %s", strerror(errno));
50 - ADEBUG(1, "executing: '%s' '%s'", argv[0], argv[1]);
53 if (pid == 0) /* child */
56 else if (pid < 0) /* can't fork */
58 - ADEBUG(0, "can't fork for apmd_proxy: %s", strerror(errno));
61 else if (pid > 0) /* parent */
63 while ((len = read(fds[0], line, sizeof(line)-1)) > 0)
66 - ADEBUG(1, "+ %s", line);
69 retval = waitpid(pid, &status, WNOHANG);
71 break; // finished okay
72 if (retval == -1 && errno != EINTR)
74 - ADEBUG(0, "waitpid failed: %s", strerror(errno));
79 while ((len = read(fds[0], line, sizeof(line)-1)) > 0)
82 - ADEBUG(1, "+ %s", line);
87 /* Collect the exit code */
88 if (WIFEXITED(status))
90 - ADEBUG(3, "%s exited with status %d", apmd_proxy,
91 - WEXITSTATUS(status));
92 + WEXITSTATUS(status);
93 /* Return the exit status of the program */
94 return WEXITSTATUS(status);
97 - ADEBUG(3, "%s exited on signal %d", apmd_proxy, WTERMSIG(status));
105 - ADEBUG(4, "0x%04x\n", event);
106 if (last_charging_status == apmi->battery_status)
111 static int apmd_suspend(apm_event_t event, apm_info * apmi)
113 - ADEBUG(4, "0x%04x\n", event);
114 if (apmd_call_proxy(event, apmi))
116 #ifdef APM_REJECT_ENABLED /* If kernel rejection enabled */
117 - ADEBUG(5, "Suspend rejected\n");
118 return apm_reject(apmd_fd);
123 static int apmd_standby(apm_event_t event, apm_info * apmi)
125 - ADEBUG(4, "0x%04x\n", event);
126 if (apmd_call_proxy(event, apmi))
128 #ifdef APM_REJECT_ENABLED
129 - ADEBUG(5, "Standby rejected\n");
130 return apm_reject(apmd_fd);
137 - ADEBUG(4, "0x%04x\n", event);
138 apmd_call_proxy(event, apmi);
142 static void apmd_low_battery(apm_event_t event, apm_info * apmi)
145 - ADEBUG(4, "0x%04x\n", event);
146 sprintf(msg, "Battery Low Notification from %s (%d%% %s)",
147 (event == APM_LOW_BATTERY ? "APM BIOS" : "apmd"),
148 apmi->battery_percentage, apm_time_nosec(apmd_time(apmi)));
150 static int last_battery_status = 0;
151 static int last_ac_status = -1;
153 - ADEBUG(4, "0x%04x\n", event);
155 /* Call proxy and perform special logging as needed */
158 if (apm_read(&apminfo))
161 - ADEBUG(4, " [event loop] 0x%04x\n", events[i]);
163 syslog(LOG_INFO, "Event 0x%04x: %s",
164 events[i], apm_event_name(events[i]));
165 diff -Naur apmd-orig/apmsleep.c apmd/apmsleep.c
166 --- apmd-orig/apmsleep.c 2001-05-11 13:30:08.000000000 -0700
167 +++ apmd/apmsleep.c 2004-10-27 22:09:11.000000000 -0700
172 +typedef unsigned char u8;
173 +typedef unsigned short u16;
174 +typedef unsigned int u32;
177 #include <linux/version.h>
179 -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,2,0)
180 -#include <asm/spinlock.h>
183 -#include <linux/mc146818rtc.h>
184 +#include <linux/rtc.h>
185 #include <sys/ioctl.h>
186 #include <sys/time.h>
187 #include <sys/types.h>
188 diff -Naur apmd-orig/on_ac_power apmd/on_ac_power
189 --- apmd-orig/on_ac_power 1999-06-05 15:10:00.000000000 -0700
190 +++ apmd/on_ac_power 2004-10-27 22:09:24.000000000 -0700
192 [ ! -f /proc/apm ] && exit 0;
194 exec awk </proc/apm '
195 - /^[0-9.]* [0-9.]* 0x.. 0x../ {
196 + /^[0-9a-z.]* [0-9a-z.]* 0x.. 0x../ {