summaryrefslogtreecommitdiffstats
path: root/usr.sbin/apm
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-09-02 06:36:39 +0000
committercharnier <charnier@FreeBSD.org>1997-09-02 06:36:39 +0000
commite155880d06561d7abdc6c270121e233ee0bd5632 (patch)
treee745743bddf583e7d19d5be76d48d46f208b4cc0 /usr.sbin/apm
parente462c7e2d2b251f784226c19805bfb673f8250a5 (diff)
downloadFreeBSD-src-e155880d06561d7abdc6c270121e233ee0bd5632.zip
FreeBSD-src-e155880d06561d7abdc6c270121e233ee0bd5632.tar.gz
Use err(3). Typo in man page.
Diffstat (limited to 'usr.sbin/apm')
-rw-r--r--usr.sbin/apm/apm.810
-rw-r--r--usr.sbin/apm/apm.c39
2 files changed, 24 insertions, 25 deletions
diff --git a/usr.sbin/apm/apm.8 b/usr.sbin/apm/apm.8
index f30cd23..dbc7550 100644
--- a/usr.sbin/apm/apm.8
+++ b/usr.sbin/apm/apm.8
@@ -21,17 +21,17 @@
.Pp
.Nm zzz
.Sh DESCRIPTION
-.Nm apm
+.Nm Apm
controls the Intel / Microsoft APM (Advanced Power Management) BIOS and
displays the current status of APM on laptop PCs.
-.Nm zzz
+.Nm Zzz
suspends the system by controlling APM.
.Pp
The following options are available for
.Nm apm
(no options are available for
-.Nm zzz.
-)
+.Nm zzz
+).
If no options are specified,
.Nm apm
displays information and current status of APM in verbose mode.
@@ -70,7 +70,7 @@ Display the status of the APM support as an integer value. The values
.Dq enabled
state or
.Dq disabled
-state respecitively
+state respectively.
.It Fl z
Suspend the system. It is equivalent to
.Nm zzz.
diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c
index 0e3847d..5c8b1dd 100644
--- a/usr.sbin/apm/apm.c
+++ b/usr.sbin/apm/apm.c
@@ -13,6 +13,12 @@
* Sep., 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -23,31 +29,27 @@
#define APMDEV "/dev/apm"
-static char *cmdname;
-
void
usage()
{
- fprintf(stderr, "usage: %s [-ablsz] [-d 1|0]\n", cmdname);
+ fprintf(stderr, "%s\n%s\n",
+ "usage: apm [-ablsz] [-d 1|0]",
+ " zzz");
exit(1);
}
void
apm_suspend(int fd)
{
- if (ioctl(fd, APMIO_SUSPEND, NULL) == -1) {
- perror(cmdname);
- exit(1);
- }
+ if (ioctl(fd, APMIO_SUSPEND, NULL) == -1)
+ err(1, NULL);
}
void
apm_getinfo(int fd, apm_info_t aip)
{
- if (ioctl(fd, APMIO_GETINFO, aip) == -1) {
- perror(cmdname);
- exit(1);
- }
+ if (ioctl(fd, APMIO_GETINFO, aip) == -1)
+ err(1, NULL);
}
void
@@ -93,22 +95,19 @@ print_all_info(apm_info_t aip)
void
apm_display(int fd, int newstate)
{
- if (ioctl(fd, APMIO_DISPLAY, &newstate) == -1) {
- perror(cmdname);
- exit(1);
- }
+ if (ioctl(fd, APMIO_DISPLAY, &newstate) == -1)
+ err(1, NULL);
}
-extern char *optarg;
-extern int optind;
-
int
main(int argc, char *argv[])
{
int c, fd;
int sleep = 0, all_info = 1, apm_status = 0, batt_status = 0;
int display = 0, batt_life = 0, ac_status = 0;
+ char *cmdname;
+
if ((cmdname = strrchr(argv[0], '/')) != NULL)
cmdname++;
@@ -133,7 +132,7 @@ main(int argc, char *argv[])
case 'd':
display = *optarg - '0';
if (display < 0 || display > 1) {
- fprintf(stderr, "%s: Argument of option '-%c' is invalid.\n", cmdname, c);
+ warnx("argument of option '-%c' is invalid", c);
usage();
}
display++;
@@ -161,7 +160,7 @@ main(int argc, char *argv[])
finish_option:
fd = open(APMDEV, O_RDWR);
if (fd == -1) {
- fprintf(stderr, "%s: Can't open %s.\n", cmdname, APMDEV);
+ warnx("can't open %s", APMDEV);
return 1;
}
if (sleep)
OpenPOWER on IntegriCloud