bootctl.c | bootctl.c | |||
---|---|---|---|---|
skipping to change at line 35 | skipping to change at line 35 | |||
#include <getopt.h> | #include <getopt.h> | |||
#include <locale.h> | #include <locale.h> | |||
#include <string.h> | #include <string.h> | |||
#include <sys/timex.h> | #include <sys/timex.h> | |||
#include "boot.h" | #include "boot.h" | |||
#include "build.h" | #include "build.h" | |||
#include "util.h" | #include "util.h" | |||
#include "utf8.h" | #include "utf8.h" | |||
static int help(void) { | static void help(void) { | |||
printf("%s [OPTIONS...] COMMAND ...\n\n" | printf("%s [OPTIONS...] COMMAND ...\n\n" | |||
"Query or change firmware and boot manager settings.\n\n" | "Query or change firmware and boot manager settings.\n\n" | |||
" -h --help Show this help\n" | " -h --help Show this help\n" | |||
" --version Show package version\n" | " --version Show package version\n" | |||
"Commands:\n" | "Commands:\n" | |||
" status Show current boot settings\n", | " status Show current boot settings\n" | |||
program_invocation_short_name); | , program_invocation_short_name); | |||
return 0; | ||||
} | } | |||
static int parse_argv(int argc, char *argv[]) { | static int parse_argv(int argc, char *argv[]) { | |||
enum { | enum { | |||
ARG_VERSION = 0x100, | ARG_VERSION = 0x100, | |||
}; | }; | |||
static const struct option options[] = { | static const struct option options[] = { | |||
{ "help", no_argument, NULL, 'h' | { "help", no_argument, NULL, 'h' }, | |||
}, | { "version", no_argument, NULL, ARG_VERSION }, | |||
{ "version", no_argument, NULL, ARG_VERSI | ||||
ON }, | ||||
{} | {} | |||
}; | }; | |||
int c; | int c; | |||
assert(argc >= 0); | assert(argc >= 0); | |||
assert(argv); | assert(argv); | |||
while ((c = getopt_long(argc, argv, "+h", options, NULL)) >= 0) { | while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0) | |||
switch (c) { | switch (c) { | |||
case 'h': | case 'h': | |||
return help(); | help(); | |||
return 0; | ||||
case ARG_VERSION: | case ARG_VERSION: | |||
puts(PACKAGE_STRING); | puts(PACKAGE_STRING); | |||
puts(SYSTEMD_FEATURES); | puts(SYSTEMD_FEATURES); | |||
return 0; | return 0; | |||
case '?': | case '?': | |||
return -EINVAL; | return -EINVAL; | |||
default: | default: | |||
assert_not_reached("Unhandled option"); | assert_not_reached("Unhandled option"); | |||
} | } | |||
} | ||||
return 1; | return 1; | |||
} | } | |||
static int boot_info_new(struct boot_info **info) { | static int boot_info_new(struct boot_info **info) { | |||
struct boot_info *in; | struct boot_info *in; | |||
int err; | int err; | |||
in = new0(struct boot_info, 1); | in = new0(struct boot_info, 1); | |||
if (!in) | if (!in) | |||
skipping to change at line 271 | skipping to change at line 268 | |||
break; | break; | |||
default: | default: | |||
assert_not_reached("Unknown comparison operator."); | assert_not_reached("Unknown comparison operator."); | |||
} | } | |||
return verbs[i].dispatch(argv + optind, left); | return verbs[i].dispatch(argv + optind, left); | |||
} | } | |||
int main(int argc, char *argv[]) { | int main(int argc, char *argv[]) { | |||
int r, retval = EXIT_FAILURE; | int r; | |||
log_parse_environment(); | log_parse_environment(); | |||
log_open(); | log_open(); | |||
r = parse_argv(argc, argv); | r = parse_argv(argc, argv); | |||
if (r < 0) | if (r <= 0) | |||
goto finish; | ||||
else if (r == 0) { | ||||
retval = EXIT_SUCCESS; | ||||
goto finish; | goto finish; | |||
} | ||||
r = bootctl_main(argc, argv); | r = bootctl_main(argc, argv); | |||
retval = r < 0 ? EXIT_FAILURE : r; | ||||
finish: | finish: | |||
return retval; | return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; | |||
} | } | |||
End of changes. 10 change blocks. | ||||
22 lines changed or deleted | 13 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |