]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/jsonwrt: check if JSON handler is initialized
authorKarel Zak <kzak@redhat.com>
Mon, 8 Nov 2021 14:43:30 +0000 (15:43 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 8 Nov 2021 14:43:30 +0000 (15:43 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/jsonwrt.h
lib/jsonwrt.c

index 4587b60a9c300f54f3b53ac22c7bc3b4ebd53a9d..396765c245c63f7e9642031f451b2faabe416c9d 100644 (file)
@@ -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);
index 9331dec0e77a67eb6cc17863361dcdb460634c10..8ca1d4d9a3b2e687940c448d35d8b0c0d042d15a 100644 (file)
@@ -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;