Use err(3). Typo in man page.
This commit is contained in:
parent
8a919505e4
commit
6039519c78
@ -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.
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user