diff --git a/src/shared/json.c b/src/shared/json.c index 420555ae544..75795c28503 100644 --- a/src/shared/json.c +++ b/src/shared/json.c @@ -1236,7 +1236,7 @@ int json_variant_get_source(JsonVariant *v, const char **ret_source, unsigned *r return 0; } -static int print_source(FILE *f, JsonVariant *v, unsigned flags, bool whitespace) { +static int print_source(FILE *f, JsonVariant *v, JsonFormatFlags flags, bool whitespace) { size_t w, k; if (!FLAGS_SET(flags, JSON_FORMAT_SOURCE|JSON_FORMAT_PRETTY)) @@ -1289,7 +1289,7 @@ static int print_source(FILE *f, JsonVariant *v, unsigned flags, bool whitespace return 0; } -static int json_format(FILE *f, JsonVariant *v, unsigned flags, const char *prefix) { +static int json_format(FILE *f, JsonVariant *v, JsonFormatFlags flags, const char *prefix) { int r; assert(f); @@ -1546,7 +1546,7 @@ static int json_format(FILE *f, JsonVariant *v, unsigned flags, const char *pref return 0; } -int json_variant_format(JsonVariant *v, unsigned flags, char **ret) { +int json_variant_format(JsonVariant *v, JsonFormatFlags flags, char **ret) { _cleanup_free_ char *s = NULL; size_t sz = 0; int r; @@ -1576,7 +1576,7 @@ int json_variant_format(JsonVariant *v, unsigned flags, char **ret) { return (int) sz; } -void json_variant_dump(JsonVariant *v, unsigned flags, FILE *f, const char *prefix) { +void json_variant_dump(JsonVariant *v, JsonFormatFlags flags, FILE *f, const char *prefix) { if (!v) return; diff --git a/src/shared/json.h b/src/shared/json.h index 4a21a411acd..04687d41359 100644 --- a/src/shared/json.h +++ b/src/shared/json.h @@ -150,17 +150,17 @@ struct json_variant_foreach_state { int json_variant_get_source(JsonVariant *v, const char **ret_source, unsigned *ret_line, unsigned *ret_column); -enum { +typedef enum JsonFormatFlags { JSON_FORMAT_NEWLINE = 1 << 0, /* suffix with newline */ JSON_FORMAT_PRETTY = 1 << 1, /* add internal whitespace to appeal to human readers */ JSON_FORMAT_COLOR = 1 << 2, /* insert ANSI color sequences */ JSON_FORMAT_SOURCE = 1 << 3, /* prefix with source filename/line/column */ JSON_FORMAT_SSE = 1 << 4, /* prefix/suffix with W3C server-sent events */ JSON_FORMAT_SEQ = 1 << 5, /* prefix/suffix with RFC 7464 application/json-seq */ -}; +} JsonFormatFlags; -int json_variant_format(JsonVariant *v, unsigned flags, char **ret); -void json_variant_dump(JsonVariant *v, unsigned flags, FILE *f, const char *prefix); +int json_variant_format(JsonVariant *v, JsonFormatFlags flags, char **ret); +void json_variant_dump(JsonVariant *v, JsonFormatFlags flags, FILE *f, const char *prefix); int json_parse(const char *string, JsonVariant **ret, unsigned *ret_line, unsigned *ret_column); int json_parse_continue(const char **p, JsonVariant **ret, unsigned *ret_line, unsigned *ret_column);