mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
sleep: define main through macro
This commit is contained in:
parent
6e61c701f2
commit
7caefb8140
@ -351,7 +351,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
return 1 /* work to do */;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
static int run(int argc, char *argv[]) {
|
||||
bool allow;
|
||||
_cleanup_strv_free_ char **modes = NULL, **states = NULL;
|
||||
usec_t delay = 0;
|
||||
@ -363,22 +363,21 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
r = parse_argv(argc, argv);
|
||||
if (r <= 0)
|
||||
goto finish;
|
||||
return r;
|
||||
|
||||
r = parse_sleep_config(arg_verb, &allow, &modes, &states, &delay);
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
return r;
|
||||
|
||||
if (!allow) {
|
||||
log_error("Sleep mode \"%s\" is disabled by configuration, refusing.", arg_verb);
|
||||
return EXIT_FAILURE;
|
||||
return -EACCES;
|
||||
}
|
||||
|
||||
if (streq(arg_verb, "suspend-then-hibernate"))
|
||||
r = execute_s2h(delay);
|
||||
return execute_s2h(delay);
|
||||
else
|
||||
r = execute(modes, states);
|
||||
|
||||
finish:
|
||||
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
return execute(modes, states);
|
||||
}
|
||||
|
||||
DEFINE_MAIN_FUNCTION(run);
|
||||
|
Loading…
Reference in New Issue
Block a user