#include "string-table.h"
#include "string-util.h"
-/* All functions in this file emit warnigs. */
+/* All functions in this file emit warnings. */
+
+int parse_boolean_argument(const char *optname, const char *s, bool *ret) {
+ int r;
+
+ /* Returns the result through *ret and the return value. */
+
+ if (s) {
+ r = parse_boolean(s);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse boolean argument to %s: %s.", optname, s);
+
+ if (ret)
+ *ret = r;
+ return r;
+ } else {
+ /* s may be NULL. This is controlled by getopt_long() parameters. */
+ if (ret)
+ *ret = true;
+ return true;
+ }
+}
int parse_json_argument(const char *s, JsonFormatFlags *ret) {
assert(s);
if (r < 0)
return log_error_errno(r, "Failed to parse path \"%s\" and make it absolute: %m", path);
- path_simplify(p, false);
+ path_simplify(p);
if (suppress_root && empty_or_root(p))
p = mfree(p);