summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2005-03-29 16:25:21 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2005-03-29 16:25:21 +0000
commiteef7068a6de10b8f1c78351ad85efa001012c7a2 (patch)
tree44899415f4c2824bf109d60b321c873a612dc482
parentdec77e5fce736cb179c5aa83c50bb9e4e31b7f7a (diff)
Allow an apm implementation to return -1 in the minutes_left field of the
apm_power_info struct, if it has no reasonable value to provide. ok deraadt@ mickey@
-rw-r--r--usr.sbin/apm/apm.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c
index 49ab37ba77b..ec0a8bd5d71 100644
--- a/usr.sbin/apm/apm.c
+++ b/usr.sbin/apm/apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apm.c,v 1.9 2003/07/30 21:44:32 deraadt Exp $ */
+/* $OpenBSD: apm.c,v 1.10 2005/03/29 16:25:20 miod Exp $ */
/*
* Copyright (c) 1996 John T. Kohl
@@ -244,9 +244,14 @@ main(int argc, char *argv[])
if (dopct)
printf("%d\n",
reply.batterystate.battery_life);
- if (domin)
- printf("%d\n",
- reply.batterystate.minutes_left);
+ if (domin) {
+ if (reply.batterystate.minutes_left ==
+ (u_int)-1)
+ printf("unknown\n");
+ else
+ printf("%d\n",
+ reply.batterystate.minutes_left);
+ }
if (doac)
printf("%d\n",
reply.batterystate.ac_state);
@@ -273,8 +278,15 @@ main(int argc, char *argv[])
"not available\n");
else
#endif
- printf("Battery life estimate: %d minutes\n",
- reply.batterystate.minutes_left);
+ {
+ printf("Battery life estimate: ");
+ if (reply.batterystate.minutes_left ==
+ (u_int)-1)
+ printf("unknown\n");
+ else
+ printf("%d minutes\n",
+ reply.batterystate.minutes_left);
+ }
}
if (doac)
printf("A/C adapter state: %s\n",