diff --git a/include/jsonwrt.h b/include/jsonwrt.h index 4587b60a9..396765c24 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 9331dec0e..8ca1d4d9a 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;