blob: cf887bf931e7c7862de933d96368d941ba8f9ee9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "../lib/sys/reboot.h"
#include "../lib/cstr/cstr.h"
#include "../lib/io/io.h"
#include "../lib/sys/sync.h"
int main(int argc, char **argv) {
if (argc != 2) {
wf(STDERR_FD, "powerctl [poweroff|reboot|halt|hard-reset|suspend]\n");
return -1;
}
char *command = argv[1];
sync();
if (cstr_compare(command, "poweroff")) {
reboot(REBOOT_POWEROFF);
} else if (cstr_compare(command, "reboot")) {
reboot(REBOOT_RESTART);
} else if (cstr_compare(command, "halt")) {
reboot(REBOOT_HALT_SYSTEM);
} else if (cstr_compare(command, "hard-reset")) {
reboot(REBOOT_HARD_RESET);
} else if (cstr_compare(command, "suspend")) {
reboot(REBOOT_SUSPEND);
}
return -1;
}
|