From: Karel Zak Date: Mon, 8 Nov 2021 14:43:30 +0000 (+0100) Subject: lib/jsonwrt: check if JSON handler is initialized X-Git-Tag: v2.38-rc1~180 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=195993d504de1697923451289bf86feed009b29e;p=thirdparty%2Futil-linux.git lib/jsonwrt: check if JSON handler is initialized Signed-off-by: Karel Zak --- diff --git a/include/jsonwrt.h b/include/jsonwrt.h index 4587b60a9c..396765c245 100644 --- a/include/jsonwrt.h +++ b/include/jsonwrt.h @@ -15,6 +15,7 @@ struct ul_jsonwrt { }; void ul_jsonwrt_init(struct ul_jsonwrt *fmt, FILE *out, int indent); +int ul_jsonwrt_is_ready(struct ul_jsonwrt *fmt); void ul_jsonwrt_indent(struct ul_jsonwrt *fmt); void ul_jsonwrt_open(struct ul_jsonwrt *fmt, const char *name, int type); void ul_jsonwrt_close(struct ul_jsonwrt *fmt, int type); diff --git a/lib/jsonwrt.c b/lib/jsonwrt.c index 9331dec0e7..8ca1d4d9a3 100644 --- a/lib/jsonwrt.c +++ b/lib/jsonwrt.c @@ -109,6 +109,11 @@ void ul_jsonwrt_init(struct ul_jsonwrt *fmt, FILE *out, int indent) fmt->after_close = 0; } +int ul_jsonwrt_is_ready(struct ul_jsonwrt *fmt) +{ + return fmt->out == NULL ? 0 : 1; +} + void ul_jsonwrt_indent(struct ul_jsonwrt *fmt) { int i;