|
Greenbone Vulnerability Management Libraries 22.32.0
|


Go to the source code of this file.
Macros | |
| #define | GVM_JSON_CHAR_EOF -1 |
| End of file. | |
| #define | GVM_JSON_CHAR_ERROR -2 |
| Error reading file. | |
| #define | GVM_JSON_CHAR_UNDEFINED -3 |
| Undefined state. | |
Functions | |
| gvm_json_path_elem_t * | gvm_json_pull_path_elem_new (gvm_json_pull_container_type_t parent_type, int depth) |
| Creates a new JSON path element. | |
| void | gvm_json_pull_path_elem_free (gvm_json_path_elem_t *elem) |
| Frees a JSON path element. | |
| void | gvm_json_pull_event_init (gvm_json_pull_event_t *event) |
| Initializes a JSON pull event data structure. | |
| void | gvm_json_pull_event_cleanup (gvm_json_pull_event_t *event) |
| Frees all data of JSON pull event data structure. | |
| void | gvm_json_pull_parser_init_full (gvm_json_pull_parser_t *parser, FILE *input_stream, size_t parse_buffer_limit, size_t read_buffer_size) |
| Initializes a JSON pull parser. | |
| void | gvm_json_pull_parser_init (gvm_json_pull_parser_t *parser, FILE *input_stream) |
| Initializes a JSON pull parser with default buffer sizes. | |
| void | gvm_json_pull_parser_cleanup (gvm_json_pull_parser_t *parser) |
| Frees the data of a JSON pull parser. | |
| static gchar * | gvm_json_read_stream_error_str () |
| Generates message for an error that occurred reading the JSON stream. | |
| static int | gvm_json_pull_check_parse_buffer_size (const char *value_type, gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event) |
| Checks if the parse buffer limit of a JSON pull parser is reached. | |
| static int | gvm_json_pull_parser_next_char (gvm_json_pull_parser_t *parser) |
| Reads the next character in a pull parser input stream. | |
| static int | gvm_json_pull_parse_buffered (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event, const char *value_name, cJSON_bool(*validate_func)(const cJSON *const), cJSON **cjson_value) |
| Tries to parse the buffer content of a JSON pull parser. | |
| static void | gvm_json_pull_handle_read_end (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event, gboolean allow_eof) |
| Handles error or EOF after reading a character in JSON pull parser. | |
| static int | gvm_json_pull_skip_space (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event, gboolean allow_eof) |
| Skips whitespaces in the input stream of a JSON pull parser. | |
| static int | gvm_json_pull_parse_string (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event, cJSON **cjson_value) |
| Parses a string in a JSON pull parser. | |
| static int | gvm_json_pull_parse_number (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event, cJSON **cjson_value) |
| Parses a number in a JSON pull parser. | |
| static int | gvm_json_pull_parse_keyword (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event, const char *keyword) |
| Parses a keyword value in a JSON pull parser. | |
| static void | parse_value_next_expect (gvm_json_pull_parser_t *parser) |
| Updates the expectation for a JSON pull parser according to the path. | |
| static int | gvm_json_pull_parse_key (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event) |
| Handles the case that an object key is expected in a JSON pull parser. | |
| static int | gvm_json_pull_parse_comma (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event) |
| Handles the case that a comma is expected in a JSON pull parser. | |
| static int | gvm_json_pull_parse_value (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event) |
| Handles the case that a value is expected in a JSON pull parser. | |
| void | gvm_json_pull_parser_next (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event) |
| Get the next event from a JSON pull parser. | |
| cJSON * | gvm_json_pull_expand_container (gvm_json_pull_parser_t *parser, gchar **error_message) |
| Expands the current array or object of a JSON pull parser. | |
| static void | gvm_json_path_string_add_elem (gvm_json_path_elem_t *path_elem, GString *path_string) |
| Appends a string path element to a JSONPath string. | |
| gchar * | gvm_json_path_to_string (GQueue *path) |
| Converts a path as used by a JSON pull parser to a JSONPath string. | |
| #define GVM_JSON_CHAR_EOF -1 |
End of file.
Definition at line 10 of file jsonpull.c.
Referenced by gvm_json_pull_expand_container(), gvm_json_pull_parser_next(), and gvm_json_pull_parser_next_char().
| #define GVM_JSON_CHAR_ERROR -2 |
Error reading file.
Definition at line 11 of file jsonpull.c.
Referenced by gvm_json_pull_expand_container(), gvm_json_pull_handle_read_end(), gvm_json_pull_parse_number(), and gvm_json_pull_parser_next_char().
| #define GVM_JSON_CHAR_UNDEFINED -3 |
Undefined state.
Definition at line 12 of file jsonpull.c.
Referenced by gvm_json_pull_parser_init_full(), and gvm_json_pull_parser_next().
|
static |
Appends a string path element to a JSONPath string.
| [in] | path_elem | The path element to append |
| [in] | path_string | The path string to append to |
Definition at line 889 of file jsonpull.c.
References GVM_JSON_PULL_CONTAINER_OBJECT, gvm_json_string_escape(), gvm_json_path_elem::index, gvm_json_path_elem::key, and gvm_json_path_elem::parent_type.
Referenced by gvm_json_path_to_string().


| gchar * gvm_json_path_to_string | ( | GQueue * | path | ) |
Converts a path as used by a JSON pull parser to a JSONPath string.
| [in] | path | The path to convert |
Definition at line 910 of file jsonpull.c.
References gvm_json_path_string_add_elem().
Referenced by parse_vt_json().


|
static |
Checks if the parse buffer limit of a JSON pull parser is reached.
| [in] | value_type | The value type to include in the error message |
| [in] | parser | The parser to check the parse buffer of |
| [in] | event | Event data for error status and message if needed |
Definition at line 151 of file jsonpull.c.
References GVM_JSON_PULL_EVENT_ERROR, gvm_json_pull_parser_t::parse_buffer, and gvm_json_pull_parser_t::parse_buffer_limit.
Referenced by gvm_json_pull_parse_number(), and gvm_json_pull_parse_string().

| void gvm_json_pull_event_cleanup | ( | gvm_json_pull_event_t * | event | ) |
Frees all data of JSON pull event data structure.
| [in] | event | The event structure to clean up |
Definition at line 61 of file jsonpull.c.
References gvm_json_pull_event_t::error_message, and gvm_json_pull_event_t::value.
Referenced by Ensure(), Ensure(), and gvm_json_pull_parser_next().

| void gvm_json_pull_event_init | ( | gvm_json_pull_event_t * | event | ) |
Initializes a JSON pull event data structure.
| [in] | event | The event structure to initialize |
Definition at line 50 of file jsonpull.c.
Referenced by Ensure().

| cJSON * gvm_json_pull_expand_container | ( | gvm_json_pull_parser_t * | parser, |
| gchar ** | error_message ) |
Expands the current array or object of a JSON pull parser.
This should be called after an array or object start event.
| [in] | parser | Parser to get the current container element from |
| [out] | error_message | Error message output |
Definition at line 746 of file jsonpull.c.
References gvm_json_path_elem::depth, GVM_JSON_CHAR_EOF, GVM_JSON_CHAR_ERROR, GVM_JSON_PULL_CONTAINER_ARRAY, GVM_JSON_PULL_CONTAINER_OBJECT, gvm_json_pull_parser_next_char(), gvm_json_pull_path_elem_free(), gvm_json_pull_path_elem_new(), gvm_json_read_stream_error_str(), gvm_json_pull_parser_t::last_read_char, gvm_json_path_elem::parent_type, gvm_json_pull_parser_t::parse_buffer, gvm_json_pull_parser_t::parse_buffer_limit, parse_value_next_expect(), gvm_json_pull_parser_t::path, and gvm_json_pull_parser_t::path_add.
Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), and parse_vt_json().


|
static |
Handles error or EOF after reading a character in JSON pull parser.
| [in] | parser | Parser to get the last read character from |
| [in] | event | Event data to set EOF or error status in |
| [in] | allow_eof | Whether to allow EOF, generate error on EOF if FALSE |
Definition at line 238 of file jsonpull.c.
References GVM_JSON_CHAR_ERROR, GVM_JSON_PULL_EVENT_EOF, GVM_JSON_PULL_EVENT_ERROR, gvm_json_read_stream_error_str(), and gvm_json_pull_parser_t::last_read_char.
Referenced by gvm_json_pull_parse_keyword(), gvm_json_pull_parse_string(), gvm_json_pull_parser_next(), and gvm_json_pull_skip_space().


|
static |
Tries to parse the buffer content of a JSON pull parser.
| [in] | parser | The parser to use the parse buffer of |
| [in] | event | Event set error of if necessary |
| [in] | value_name | Name of the value for error message if needed |
| [in] | validate_func | Function for validating the parsed value |
| [out] | cjson_value | Return of the parsed cJSON object on success |
Definition at line 211 of file jsonpull.c.
References GVM_JSON_PULL_EVENT_ERROR, and gvm_json_pull_parser_t::parse_buffer.
Referenced by gvm_json_pull_parse_number(), and gvm_json_pull_parse_string().

|
static |
Handles the case that a comma is expected in a JSON pull parser.
This will continue the parsing until a comma or the end of the current array/object was reached or an error occurred.
| [in] | parser | Parser to process |
| [in] | event | Event data to set error or end of object status in |
Definition at line 497 of file jsonpull.c.
References gvm_json_pull_parser_t::expect, GVM_JSON_PULL_CONTAINER_ARRAY, GVM_JSON_PULL_CONTAINER_OBJECT, GVM_JSON_PULL_EVENT_ARRAY_END, GVM_JSON_PULL_EVENT_ERROR, GVM_JSON_PULL_EVENT_OBJECT_END, GVM_JSON_PULL_EXPECT_KEY, GVM_JSON_PULL_EXPECT_VALUE, gvm_json_pull_parser_next_char(), gvm_json_pull_path_elem_free(), gvm_json_pull_skip_space(), gvm_json_path_elem::index, gvm_json_pull_parser_t::last_read_char, gvm_json_path_elem::parent_type, parse_value_next_expect(), and gvm_json_pull_parser_t::path.
Referenced by gvm_json_pull_parser_next().


|
static |
Handles the case that an object key is expected in a JSON pull parser.
This will continue the parsing until the value is expected, the end of the current object was reached or an error occurred.
| [in] | parser | Parser to process |
| [in] | event | Event data to set error or end of object status in |
Definition at line 426 of file jsonpull.c.
References gvm_json_pull_parser_t::expect, GVM_JSON_PULL_EVENT_ERROR, GVM_JSON_PULL_EVENT_OBJECT_END, GVM_JSON_PULL_EXPECT_VALUE, gvm_json_pull_parse_string(), gvm_json_pull_parser_next_char(), gvm_json_pull_path_elem_free(), gvm_json_pull_skip_space(), gvm_json_path_elem::key, gvm_json_pull_parser_t::last_read_char, parse_value_next_expect(), and gvm_json_pull_parser_t::path.
Referenced by gvm_json_pull_parser_next().


|
static |
Parses a keyword value in a JSON pull parser.
The parser is expected to be at the first character of the keyword and will be at the first character after the keyword on success.
| [in] | parser | Parser to handle the keyword value in |
| [in] | event | Event data to set EOF or error status in |
| [in] | keyword | The expected keyword, e.g. "null", "true", "false". |
Definition at line 378 of file jsonpull.c.
References GVM_JSON_PULL_EVENT_ERROR, gvm_json_pull_handle_read_end(), gvm_json_pull_parser_next_char(), and gvm_json_pull_parser_t::last_read_char.
Referenced by gvm_json_pull_parse_value().


|
static |
Parses a number in a JSON pull parser.
The parser is expected to be at the first character of the number and will be at the first non-number character on success.
| [in] | parser | Parser to handle the number value in |
| [in] | event | Event data to set EOF or error status in |
| [out] | cjson_value | The cJSON value for the number on success. |
Definition at line 337 of file jsonpull.c.
References GVM_JSON_CHAR_ERROR, gvm_json_pull_check_parse_buffer_size(), GVM_JSON_PULL_EVENT_ERROR, gvm_json_pull_parse_buffered(), gvm_json_pull_parser_next_char(), gvm_json_read_stream_error_str(), gvm_json_pull_parser_t::last_read_char, and gvm_json_pull_parser_t::parse_buffer.
Referenced by gvm_json_pull_parse_value().


|
static |
Parses a string in a JSON pull parser.
The parser is expected to be at the opening quote mark and will be at the character after the closing quote mark on success.
| [in] | parser | Parser to handle the string value in |
| [in] | event | Event data to set EOF or error status in |
| [out] | cjson_value | The cJSON value for the string on success |
Definition at line 293 of file jsonpull.c.
References gvm_json_pull_check_parse_buffer_size(), gvm_json_pull_handle_read_end(), gvm_json_pull_parse_buffered(), gvm_json_pull_parser_next_char(), gvm_json_pull_parser_t::last_read_char, and gvm_json_pull_parser_t::parse_buffer.
Referenced by gvm_json_pull_parse_key(), and gvm_json_pull_parse_value().


|
static |
Handles the case that a value is expected in a JSON pull parser.
This will continue the parsing until a value or the end of the current array/object was parsed or an error occurred.
| [in] | parser | Parser to process |
| [in] | event | Event data to set error or end of object status in |
Definition at line 565 of file jsonpull.c.
References gvm_json_pull_parser_t::expect, GVM_JSON_PULL_CONTAINER_ARRAY, GVM_JSON_PULL_CONTAINER_OBJECT, GVM_JSON_PULL_EVENT_ARRAY_END, GVM_JSON_PULL_EVENT_ARRAY_START, GVM_JSON_PULL_EVENT_BOOLEAN, GVM_JSON_PULL_EVENT_ERROR, GVM_JSON_PULL_EVENT_NULL, GVM_JSON_PULL_EVENT_NUMBER, GVM_JSON_PULL_EVENT_OBJECT_START, GVM_JSON_PULL_EVENT_STRING, GVM_JSON_PULL_EXPECT_KEY, GVM_JSON_PULL_EXPECT_VALUE, gvm_json_pull_parse_keyword(), gvm_json_pull_parse_number(), gvm_json_pull_parse_string(), gvm_json_pull_parser_next_char(), gvm_json_pull_path_elem_free(), gvm_json_pull_path_elem_new(), gvm_json_pull_skip_space(), gvm_json_pull_parser_t::last_read_char, gvm_json_path_elem::parent_type, parse_value_next_expect(), gvm_json_pull_parser_t::path, and gvm_json_pull_parser_t::path_add.
Referenced by gvm_json_pull_parser_next().


| void gvm_json_pull_parser_cleanup | ( | gvm_json_pull_parser_t * | parser | ) |
Frees the data of a JSON pull parser.
| [in] | parser | The parser data structure to free the data of |
Definition at line 120 of file jsonpull.c.
References gvm_json_pull_path_elem_free(), gvm_json_pull_parser_t::parse_buffer, gvm_json_pull_parser_t::path, and gvm_json_pull_parser_t::read_buffer.
Referenced by Ensure(), Ensure(), and Ensure().


| void gvm_json_pull_parser_init | ( | gvm_json_pull_parser_t * | parser, |
| FILE * | input_stream ) |
Initializes a JSON pull parser with default buffer sizes.
| [in] | parser | The parser data structure to initialize |
| [in] | input_stream | The JSON input stream |
Definition at line 109 of file jsonpull.c.
References gvm_json_pull_parser_init_full().
Referenced by Ensure(), and Ensure().


| void gvm_json_pull_parser_init_full | ( | gvm_json_pull_parser_t * | parser, |
| FILE * | input_stream, | ||
| size_t | parse_buffer_limit, | ||
| size_t | read_buffer_size ) |
Initializes a JSON pull parser.
| [in] | parser | The parser data structure to initialize |
| [in] | input_stream | The JSON input stream |
| [in] | parse_buffer_limit | Maximum buffer size for parsing values |
| [in] | read_buffer_size | Buffer size for reading from the stream |
Definition at line 78 of file jsonpull.c.
References gvm_json_pull_parser_t::expect, GVM_JSON_CHAR_UNDEFINED, GVM_JSON_PULL_EXPECT_VALUE, GVM_JSON_PULL_PARSE_BUFFER_LIMIT, GVM_JSON_PULL_READ_BUFFER_SIZE, gvm_json_pull_parser_t::input_stream, gvm_json_pull_parser_t::last_read_char, gvm_json_pull_parser_t::parse_buffer, gvm_json_pull_parser_t::parse_buffer_limit, gvm_json_pull_parser_t::path, gvm_json_pull_parser_t::read_buffer, and gvm_json_pull_parser_t::read_buffer_size.
Referenced by gvm_json_pull_parser_init().

| void gvm_json_pull_parser_next | ( | gvm_json_pull_parser_t * | parser, |
| gvm_json_pull_event_t * | event ) |
Get the next event from a JSON pull parser.
Note: This invalidates previous event data like the cJSON value.
| [in] | parser | The JSON pull parser to process until the next event |
| [in] | event | Structure to store event data in. |
Definition at line 669 of file jsonpull.c.
References gvm_json_pull_parser_t::expect, GVM_JSON_CHAR_EOF, GVM_JSON_CHAR_UNDEFINED, gvm_json_pull_event_cleanup(), GVM_JSON_PULL_EVENT_ERROR, GVM_JSON_PULL_EXPECT_COMMA, GVM_JSON_PULL_EXPECT_EOF, GVM_JSON_PULL_EXPECT_KEY, GVM_JSON_PULL_EXPECT_VALUE, gvm_json_pull_handle_read_end(), gvm_json_pull_parse_comma(), gvm_json_pull_parse_key(), gvm_json_pull_parse_value(), gvm_json_pull_parser_next_char(), gvm_json_pull_skip_space(), gvm_json_pull_parser_t::last_read_char, gvm_json_pull_parser_t::path, and gvm_json_pull_parser_t::path_add.
Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), and parse_vt_json().

|
static |
Reads the next character in a pull parser input stream.
| [in] | parser | The parser to read the next character from |
Definition at line 174 of file jsonpull.c.
References GVM_JSON_CHAR_EOF, GVM_JSON_CHAR_ERROR, gvm_json_pull_parser_t::input_stream, gvm_json_pull_parser_t::last_read_char, gvm_json_pull_parser_t::last_read_size, gvm_json_pull_parser_t::read_buffer, gvm_json_pull_parser_t::read_buffer_size, and gvm_json_pull_parser_t::read_pos.
Referenced by gvm_json_pull_expand_container(), gvm_json_pull_parse_comma(), gvm_json_pull_parse_key(), gvm_json_pull_parse_keyword(), gvm_json_pull_parse_number(), gvm_json_pull_parse_string(), gvm_json_pull_parse_value(), gvm_json_pull_parser_next(), and gvm_json_pull_skip_space().

| void gvm_json_pull_path_elem_free | ( | gvm_json_path_elem_t * | elem | ) |
Frees a JSON path element.
| [in] | elem | The element to free |
Definition at line 38 of file jsonpull.c.
References gvm_json_path_elem::key.
Referenced by gvm_json_pull_expand_container(), gvm_json_pull_parse_comma(), gvm_json_pull_parse_key(), gvm_json_pull_parse_value(), and gvm_json_pull_parser_cleanup().

| gvm_json_path_elem_t * gvm_json_pull_path_elem_new | ( | gvm_json_pull_container_type_t | parent_type, |
| int | depth ) |
Creates a new JSON path element.
| [in] | parent_type | Type of the parent (array, object, none/root) |
| [in] | depth | The depth in the document tree |
Definition at line 23 of file jsonpull.c.
References gvm_json_path_elem::depth, and gvm_json_path_elem::parent_type.
Referenced by gvm_json_pull_expand_container(), and gvm_json_pull_parse_value().

|
static |
Skips whitespaces in the input stream of a JSON pull parser.
The parser will be at the first non-whitespace character on success.
| [in] | parser | Parser to skip the whitespaces in |
| [in] | event | Event data to set EOF or error status in |
| [in] | allow_eof | Whether to allow EOF, generate error on EOF if FALSE |
Definition at line 267 of file jsonpull.c.
References gvm_json_pull_handle_read_end(), gvm_json_pull_parser_next_char(), and gvm_json_pull_parser_t::last_read_char.
Referenced by gvm_json_pull_parse_comma(), gvm_json_pull_parse_key(), gvm_json_pull_parse_value(), and gvm_json_pull_parser_next().


|
static |
Generates message for an error that occurred reading the JSON stream.
Definition at line 136 of file jsonpull.c.
Referenced by gvm_json_pull_expand_container(), gvm_json_pull_handle_read_end(), and gvm_json_pull_parse_number().

|
static |
Updates the expectation for a JSON pull parser according to the path.
| [in] | parser | The parser to update. |
Definition at line 406 of file jsonpull.c.
References gvm_json_pull_parser_t::expect, GVM_JSON_PULL_EXPECT_COMMA, GVM_JSON_PULL_EXPECT_EOF, and gvm_json_pull_parser_t::path.
Referenced by gvm_json_pull_expand_container(), gvm_json_pull_parse_comma(), gvm_json_pull_parse_key(), and gvm_json_pull_parse_value().
