tree-wide: add a helper to parse boolean optarg

This nicely covers the case when optarg is optional. The same parser can be
used when the option string passed to getopt_long() requires a parameter and
when it doesn't.

The error messages are made consistent.
Also fixes a log error c&p in --crash-reboot message.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-02-17 21:06:31 +01:00
parent 79dbbb261d
commit 599c7c545f
10 changed files with 72 additions and 106 deletions
+1
View File
@@ -3,6 +3,7 @@
#include "json.h"
int parse_boolean_argument(const char *optname, const char *s, bool *ret);
int parse_json_argument(const char *s, JsonFormatFlags *ret);
int parse_path_argument(const char *path, bool suppress_root, char **arg);
int parse_signal_argument(const char *s, int *ret);