11#include <cjson/cJSON.h>
77#define GVM_JSON_PULL_PARSE_BUFFER_LIMIT 10485760
79#define GVM_JSON_PULL_READ_BUFFER_SIZE 4096
void gvm_json_pull_event_reset(gvm_json_pull_event_t *)
Resets a JSON pull event data structure for reuse.
Definition jsonpull.c:119
cJSON * gvm_json_pull_expand_container(gvm_json_pull_parser_t *, gchar **)
Expands the current array or object of a JSON pull parser.
Definition jsonpull.c:815
void gvm_json_pull_parser_next(gvm_json_pull_parser_t *, gvm_json_pull_event_t *)
Get the next event from a JSON pull parser.
Definition jsonpull.c:741
void gvm_json_pull_path_elem_free(gvm_json_path_elem_t *)
Frees a JSON path element.
Definition jsonpull.c:96
void gvm_json_pull_parser_init_full(gvm_json_pull_parser_t *, FILE *, size_t, size_t)
Initializes a JSON pull parser.
Definition jsonpull.c:150
gvm_json_path_elem_t * gvm_json_pull_path_elem_new(gvm_json_pull_container_type_t, int)
Creates a new JSON path element.
Definition jsonpull.c:81
gvm_json_pull_container_type_t
Type of container the parser is currently in.
Definition jsonpull.h:19
@ GVM_JSON_PULL_CONTAINER_NONE
No container / document root.
Definition jsonpull.h:20
@ GVM_JSON_PULL_CONTAINER_OBJECT
Object.
Definition jsonpull.h:22
@ GVM_JSON_PULL_CONTAINER_ARRAY
Array.
Definition jsonpull.h:21
gchar * gvm_json_string_escape(const char *, gboolean)
Escapes a string according to the JSON or JSONPath standard.
Definition jsonpull.c:23
gchar * gvm_json_path_to_string(GQueue *path)
Converts a path as used by a JSON pull parser to a JSONPath string.
Definition jsonpull.c:973
void gvm_json_pull_parser_cleanup(gvm_json_pull_parser_t *)
Frees the data of a JSON pull parser.
Definition jsonpull.c:192
void gvm_json_pull_parser_init(gvm_json_pull_parser_t *, FILE *)
Initializes a JSON pull parser with default buffer sizes.
Definition jsonpull.c:181
gvm_json_pull_expect_t
Expected token state for the JSON pull parser.
Definition jsonpull.h:69
@ GVM_JSON_PULL_EXPECT_UNDEFINED
Undefined state.
Definition jsonpull.h:70
@ GVM_JSON_PULL_EXPECT_VALUE
Expect start of a value.
Definition jsonpull.h:71
@ GVM_JSON_PULL_EXPECT_KEY
Expect start of a key.
Definition jsonpull.h:72
@ GVM_JSON_PULL_EXPECT_EOF
Expect end of file.
Definition jsonpull.h:74
@ GVM_JSON_PULL_EXPECT_COMMA
Expect comma or container end brace.
Definition jsonpull.h:73
void gvm_json_pull_event_init(gvm_json_pull_event_t *)
Initializes a JSON pull event data structure.
Definition jsonpull.c:108
void gvm_json_pull_event_cleanup(gvm_json_pull_event_t *)
Frees all data of JSON pull event data structure.
Definition jsonpull.c:133
gvm_json_pull_event_type_t
Event types for the JSON pull parser.
Definition jsonpull.h:40
@ GVM_JSON_PULL_EVENT_STRING
Definition jsonpull.h:46
@ GVM_JSON_PULL_EVENT_OBJECT_START
Definition jsonpull.h:44
@ GVM_JSON_PULL_EVENT_ERROR
Definition jsonpull.h:51
@ GVM_JSON_PULL_EVENT_NULL
Definition jsonpull.h:49
@ GVM_JSON_PULL_EVENT_EOF
Definition jsonpull.h:50
@ GVM_JSON_PULL_EVENT_NUMBER
Definition jsonpull.h:47
@ GVM_JSON_PULL_EVENT_ARRAY_END
Definition jsonpull.h:43
@ GVM_JSON_PULL_EVENT_OBJECT_END
Definition jsonpull.h:45
@ GVM_JSON_PULL_EVENT_ARRAY_START
Definition jsonpull.h:42
@ GVM_JSON_PULL_EVENT_BOOLEAN
Definition jsonpull.h:48
@ GVM_JSON_PULL_EVENT_UNDEFINED
Definition jsonpull.h:41
struct gvm_json_path_elem gvm_json_path_elem_t
Path element types for the JSON pull parser.
Path element types for the JSON pull parser.
Definition jsonpull.h:29
int depth
Number of ancestor elements.
Definition jsonpull.h:33
int index
Index of the element within the parent.
Definition jsonpull.h:31
char * key
Key if element is in an object.
Definition jsonpull.h:32
gvm_json_pull_container_type_t parent_type
parent container type
Definition jsonpull.h:30
Event generated by the JSON pull parser.
Definition jsonpull.h:58
gchar * error_message
Error message, NULL on success.
Definition jsonpull.h:62
cJSON * value
Value for non-container value events.
Definition jsonpull.h:61
GQueue * path
Path to the event value.
Definition jsonpull.h:60
gvm_json_pull_event_type_t type
Type of event.
Definition jsonpull.h:59
A json pull parser.
Definition jsonpull.h:85
char * read_buffer
Stream reading buffer.
Definition jsonpull.h:91
size_t read_buffer_size
Size of the stream reading buffer.
Definition jsonpull.h:92
gvm_json_pull_expect_t expect
Current expected token.
Definition jsonpull.h:88
size_t last_read_size
Size of last stream read.
Definition jsonpull.h:93
int keyword_pos
Position in a keyword like "true" or "null".
Definition jsonpull.h:89
GString * parse_buffer
Buffer for parsing values and object keys.
Definition jsonpull.h:96
size_t parse_buffer_limit
Maximum parse buffer size.
Definition jsonpull.h:97
gvm_json_path_elem_t * path_add
Path elem to add in next step.
Definition jsonpull.h:87
size_t read_pos
Position in current read.
Definition jsonpull.h:95
GQueue * path
Path to the current value.
Definition jsonpull.h:86
int last_read_char
Character last read from stream.
Definition jsonpull.h:94
FILE * input_stream
Input stream.
Definition jsonpull.h:90