Browse Source

lib/jsonwrt: check if JSON handler is initialized

Signed-off-by: Karel Zak <kzak@redhat.com>
pull/1503/head
Karel Zak 9 months ago
parent
commit
195993d504
  1. 1
      include/jsonwrt.h
  2. 5
      lib/jsonwrt.c

1
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);

5
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;

Loading…
Cancel
Save