Greenbone Vulnerability Management Libraries 22.18.1
|
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.
#define GVM_JSON_CHAR_ERROR -2 |
Error reading file.
#define GVM_JSON_CHAR_UNDEFINED -3 |
Undefined state.
|
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 |
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 |
|
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 |
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 |
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 |
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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". |
|
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. |
|
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 |
|
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 |
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 |
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 |
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 |
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. |
|
static |
Reads the next character in a pull parser input stream.
[in] | parser | The parser to read the next character from |
void gvm_json_pull_path_elem_free | ( | gvm_json_path_elem_t * | elem | ) |
Frees a JSON path element.
[in] | elem | The element to free |
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 |
|
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 |
|
static |
Generates message for an error that occurred reading the JSON stream.
|
static |
Updates the expectation for a JSON pull parser according to the path.
[in] | parser | The parser to update. |