48 lines
859 B
C
48 lines
859 B
C
#ifndef JSH_H
|
|
#define JSH_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <jansson.h>
|
|
|
|
|
|
struct stream {
|
|
char *name;
|
|
FILE *out;
|
|
size_t buf_size;
|
|
size_t counter;
|
|
struct stream *root;
|
|
json_t *data;
|
|
struct stream *next;
|
|
struct stream *first_child;
|
|
bool first;
|
|
};
|
|
|
|
|
|
/*
|
|
* Creates a new root stream. If buf_size is <= 0, uses the default value of 10.
|
|
*/
|
|
struct stream *jsh_new_stream(char *name, FILE *out_file, size_t buf_size);
|
|
|
|
|
|
void jsh_close_stream(struct stream *s);
|
|
|
|
void jsh_start_stream(struct stream *s);
|
|
|
|
void jsh_end_stream(struct stream *s);
|
|
|
|
struct stream *jsh_new_substream(struct stream *s, char * name);
|
|
|
|
/*
|
|
* Outputs the given object to the top level stream.
|
|
*/
|
|
void jsh_output(struct stream *s, char *key, json_t *value);
|
|
|
|
|
|
/*
|
|
* Flushes the output for the entire tree of substreams.
|
|
*/
|
|
void jsh_flush(struct stream *s);
|
|
|
|
|
|
#endif |