mirror of
git://git.suckless.org/ubase
synced 2024-12-18 04:34:43 +00:00
2d38b7cb9e
1) Rewrite the manpage, don't just copy the util-linux manpage. 2) Fix usage() to reflect exclusivity of flags 3) Style changes.
43 lines
655 B
C
43 lines
655 B
C
/* See LICENSE file for copyright and license details. */
|
|
#include <sys/syscall.h>
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
#include "reboot.h"
|
|
#include "util.h"
|
|
|
|
static void
|
|
usage(void)
|
|
{
|
|
eprintf("usage: %s -h | -s\n", argv0);
|
|
}
|
|
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
int hflag = 0, sflag = 0, cmd;
|
|
|
|
ARGBEGIN {
|
|
case 'h':
|
|
hflag = 1;
|
|
break;
|
|
case 's':
|
|
sflag = 1;
|
|
break;
|
|
default:
|
|
usage();
|
|
} ARGEND;
|
|
|
|
if (argc || !(hflag ^ sflag))
|
|
usage();
|
|
|
|
cmd = hflag ? LINUX_REBOOT_CMD_CAD_ON : LINUX_REBOOT_CMD_CAD_OFF;
|
|
|
|
if (syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
|
|
cmd, NULL) < 0)
|
|
eprintf("reboot:");
|
|
|
|
return 0;
|
|
}
|