Greenbone Vulnerability Management Libraries 22.35.9
jsonpull.h File Reference
#include "json.h"
#include <glib.h>
#include <stdio.h>
Include dependency graph for jsonpull.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  gvm_json_path_elem
 Path element types for the JSON pull parser. More...
struct  gvm_json_pull_event_t
 Event generated by the JSON pull parser. More...
struct  gvm_json_pull_parser_t
 A json pull parser. More...

Macros

#define _GNU_SOURCE
#define GVM_JSON_PULL_PARSE_BUFFER_LIMIT   10485760
#define GVM_JSON_PULL_READ_BUFFER_SIZE   4096

Typedefs

typedef struct gvm_json_path_elem gvm_json_path_elem_t
 Path element types for the JSON pull parser.

Enumerations

enum  gvm_json_pull_container_type_t { GVM_JSON_PULL_CONTAINER_NONE = 0 , GVM_JSON_PULL_CONTAINER_ARRAY , GVM_JSON_PULL_CONTAINER_OBJECT }
 Type of container the parser is currently in. More...
enum  gvm_json_pull_event_type_t {
  GVM_JSON_PULL_EVENT_UNDEFINED = 0 , GVM_JSON_PULL_EVENT_ARRAY_START , GVM_JSON_PULL_EVENT_ARRAY_END , GVM_JSON_PULL_EVENT_OBJECT_START ,
  GVM_JSON_PULL_EVENT_OBJECT_END , GVM_JSON_PULL_EVENT_STRING , GVM_JSON_PULL_EVENT_NUMBER , GVM_JSON_PULL_EVENT_BOOLEAN ,
  GVM_JSON_PULL_EVENT_NULL , GVM_JSON_PULL_EVENT_EOF , GVM_JSON_PULL_EVENT_ERROR
}
 Event types for the JSON pull parser. More...
enum  gvm_json_pull_expect_t {
  GVM_JSON_PULL_EXPECT_UNDEFINED = 0 , GVM_JSON_PULL_EXPECT_VALUE , GVM_JSON_PULL_EXPECT_KEY , GVM_JSON_PULL_EXPECT_COMMA ,
  GVM_JSON_PULL_EXPECT_EOF
}
 Expected token state for the JSON pull parser. More...

Functions

gvm_json_path_elem_tgvm_json_pull_path_elem_new (gvm_json_pull_container_type_t, int)
 Creates a new JSON path element.
void gvm_json_pull_path_elem_free (gvm_json_path_elem_t *)
 Frees a JSON path element.
void gvm_json_pull_event_init (gvm_json_pull_event_t *)
 Initializes a JSON pull event data structure.
void gvm_json_pull_event_cleanup (gvm_json_pull_event_t *)
 Frees all data of JSON pull event data structure.
void gvm_json_pull_parser_init_full (gvm_json_pull_parser_t *, FILE *, size_t, size_t)
 Initializes a JSON pull parser.
void gvm_json_pull_parser_init (gvm_json_pull_parser_t *, FILE *)
 Initializes a JSON pull parser with default buffer sizes.
void gvm_json_pull_parser_cleanup (gvm_json_pull_parser_t *)
 Frees the data of a JSON pull parser.
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.
cJSON * gvm_json_pull_expand_container (gvm_json_pull_parser_t *, gchar **)
 Expands the current array or object of a JSON pull parser.
gchar * gvm_json_path_to_string (GQueue *path)
 Converts a path as used by a JSON pull parser to a JSONPath string.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 9 of file jsonpull.h.

◆ GVM_JSON_PULL_PARSE_BUFFER_LIMIT

#define GVM_JSON_PULL_PARSE_BUFFER_LIMIT   10485760

Definition at line 78 of file jsonpull.h.

Referenced by Ensure(), and gvm_json_pull_parser_init_full().

◆ GVM_JSON_PULL_READ_BUFFER_SIZE

#define GVM_JSON_PULL_READ_BUFFER_SIZE   4096

Definition at line 80 of file jsonpull.h.

Referenced by Ensure(), and gvm_json_pull_parser_init_full().

Typedef Documentation

◆ gvm_json_path_elem_t

Path element types for the JSON pull parser.

Enumeration Type Documentation

◆ gvm_json_pull_container_type_t

Type of container the parser is currently in.

Enumerator
GVM_JSON_PULL_CONTAINER_NONE 

No container / document root.

GVM_JSON_PULL_CONTAINER_ARRAY 

Array.

GVM_JSON_PULL_CONTAINER_OBJECT 

Object.

Definition at line 19 of file jsonpull.h.

20{
gvm_json_pull_container_type_t
Type of container the parser is currently in.
Definition jsonpull.h:20
@ GVM_JSON_PULL_CONTAINER_NONE
No container / document root.
Definition jsonpull.h:21
@ GVM_JSON_PULL_CONTAINER_OBJECT
Object.
Definition jsonpull.h:23
@ GVM_JSON_PULL_CONTAINER_ARRAY
Array.
Definition jsonpull.h:22

◆ gvm_json_pull_event_type_t

Event types for the JSON pull parser.

Enumerator
GVM_JSON_PULL_EVENT_UNDEFINED 
GVM_JSON_PULL_EVENT_ARRAY_START 
GVM_JSON_PULL_EVENT_ARRAY_END 
GVM_JSON_PULL_EVENT_OBJECT_START 
GVM_JSON_PULL_EVENT_OBJECT_END 
GVM_JSON_PULL_EVENT_STRING 
GVM_JSON_PULL_EVENT_NUMBER 
GVM_JSON_PULL_EVENT_BOOLEAN 
GVM_JSON_PULL_EVENT_NULL 
GVM_JSON_PULL_EVENT_EOF 
GVM_JSON_PULL_EVENT_ERROR 

Definition at line 40 of file jsonpull.h.

41{
gvm_json_pull_event_type_t
Event types for the JSON pull parser.
Definition jsonpull.h:41
@ GVM_JSON_PULL_EVENT_STRING
Definition jsonpull.h:47
@ GVM_JSON_PULL_EVENT_OBJECT_START
Definition jsonpull.h:45
@ GVM_JSON_PULL_EVENT_ERROR
Definition jsonpull.h:52
@ GVM_JSON_PULL_EVENT_NULL
Definition jsonpull.h:50
@ GVM_JSON_PULL_EVENT_EOF
Definition jsonpull.h:51
@ GVM_JSON_PULL_EVENT_NUMBER
Definition jsonpull.h:48
@ GVM_JSON_PULL_EVENT_ARRAY_END
Definition jsonpull.h:44
@ GVM_JSON_PULL_EVENT_OBJECT_END
Definition jsonpull.h:46
@ GVM_JSON_PULL_EVENT_ARRAY_START
Definition jsonpull.h:43
@ GVM_JSON_PULL_EVENT_BOOLEAN
Definition jsonpull.h:49
@ GVM_JSON_PULL_EVENT_UNDEFINED
Definition jsonpull.h:42

◆ gvm_json_pull_expect_t

Expected token state for the JSON pull parser.

Enumerator
GVM_JSON_PULL_EXPECT_UNDEFINED 

Undefined state.

GVM_JSON_PULL_EXPECT_VALUE 

Expect start of a value.

GVM_JSON_PULL_EXPECT_KEY 

Expect start of a key.

GVM_JSON_PULL_EXPECT_COMMA 

Expect comma or container end brace.

GVM_JSON_PULL_EXPECT_EOF 

Expect end of file.

Definition at line 69 of file jsonpull.h.

70{
gvm_json_pull_expect_t
Expected token state for the JSON pull parser.
Definition jsonpull.h:70
@ GVM_JSON_PULL_EXPECT_UNDEFINED
Undefined state.
Definition jsonpull.h:71
@ GVM_JSON_PULL_EXPECT_VALUE
Expect start of a value.
Definition jsonpull.h:72
@ GVM_JSON_PULL_EXPECT_KEY
Expect start of a key.
Definition jsonpull.h:73
@ GVM_JSON_PULL_EXPECT_EOF
Expect end of file.
Definition jsonpull.h:75
@ GVM_JSON_PULL_EXPECT_COMMA
Expect comma or container end brace.
Definition jsonpull.h:74

Function Documentation

◆ 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.

Parameters
[in]pathThe path to convert
Returns
Newly allocated string of the path in JSONPath bracket notation

Definition at line 909 of file jsonpull.c.

910{
911 GString *path_string = g_string_new ("$");
912 g_queue_foreach (path, (GFunc) gvm_json_path_string_add_elem, path_string);
913 return g_string_free (path_string, FALSE);
914}
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.
Definition jsonpull.c:888

References gvm_json_path_string_add_elem().

Referenced by parse_vt_json().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gvm_json_pull_event_cleanup()

void gvm_json_pull_event_cleanup ( gvm_json_pull_event_t * event)

Frees all data of JSON pull event data structure.

Parameters
[in]eventThe event structure to clean up

Definition at line 61 of file jsonpull.c.

62{
63 cJSON_Delete (event->value);
64 g_free (event->error_message);
65 memset (event, 0, sizeof (gvm_json_pull_event_t));
66}
Event generated by the JSON pull parser.
Definition jsonpull.h:59
gchar * error_message
Error message, NULL on success.
Definition jsonpull.h:63
cJSON * value
Value for non-container value events.
Definition jsonpull.h:62

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().

Here is the caller graph for this function:

◆ gvm_json_pull_event_init()

void gvm_json_pull_event_init ( gvm_json_pull_event_t * event)

Initializes a JSON pull event data structure.

Parameters
[in]eventThe event structure to initialize

Definition at line 50 of file jsonpull.c.

51{
52 memset (event, 0, sizeof (gvm_json_pull_event_t));
53}

Referenced by Ensure().

Here is the caller graph for this function:

◆ gvm_json_pull_expand_container()

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.

Parameters
[in]parserParser to get the current container element from
[out]error_messageError message output
Returns
The expanded container as a cJSON object if successful, else NULL

Definition at line 745 of file jsonpull.c.

747{
748 gvm_json_path_elem_t *path_tail = NULL;
749
750 int start_depth;
751 gboolean in_string, escape_next_char, in_expanded_container;
752 cJSON *expanded;
753
754 g_string_truncate (parser->parse_buffer, 0);
755
756 if (error_message)
757 *error_message = NULL;
758
759 // require "path_add" to only allow expansion at start of container
760 if (parser->path_add)
761 {
762 path_tail = parser->path_add;
763 g_queue_push_tail (parser->path, path_tail);
764 parser->path_add = NULL;
765 }
766
767 if (path_tail && path_tail->parent_type == GVM_JSON_PULL_CONTAINER_ARRAY)
768 g_string_append_c (parser->parse_buffer, '[');
769 else if (path_tail
771 g_string_append_c (parser->parse_buffer, '{');
772 else
773 {
774 if (error_message)
775 *error_message =
776 g_strdup ("can only expand after array or object start");
777 return NULL;
778 }
779
780 start_depth = path_tail->depth;
781 in_string = escape_next_char = FALSE;
782 in_expanded_container = TRUE;
783
784 while (parser->last_read_char >= 0 && in_expanded_container)
785 {
786 if (parser->parse_buffer->len >= parser->parse_buffer_limit)
787 {
788 if (error_message)
789 *error_message =
790 g_strdup_printf ("container exceeds size limit of %zu bytes",
791 parser->parse_buffer_limit);
792 return NULL;
793 }
794
795 g_string_append_c (parser->parse_buffer, parser->last_read_char);
796
797 if (escape_next_char)
798 {
799 escape_next_char = FALSE;
800 }
801 else if (in_string)
802 {
803 escape_next_char = (parser->last_read_char == '\\');
804 in_string = (parser->last_read_char != '"');
805 }
806 else
807 {
808 switch (parser->last_read_char)
809 {
810 case '"':
811 in_string = TRUE;
812 break;
813 case '[':
814 path_tail = gvm_json_pull_path_elem_new (
815 GVM_JSON_PULL_CONTAINER_ARRAY, parser->path->length);
816 g_queue_push_tail (parser->path, path_tail);
817 break;
818 case '{':
819 path_tail = gvm_json_pull_path_elem_new (
820 GVM_JSON_PULL_CONTAINER_OBJECT, parser->path->length);
821 g_queue_push_tail (parser->path, path_tail);
822 break;
823 case ']':
824 path_tail = g_queue_pop_tail (parser->path);
826 {
827 if (error_message)
828 *error_message =
829 g_strdup ("unexpected closing square bracket");
831 return NULL;
832 }
833 if (path_tail->depth == start_depth)
834 in_expanded_container = FALSE;
835
837 break;
838 case '}':
839 path_tail = g_queue_pop_tail (parser->path);
841 {
842 if (error_message)
843 *error_message =
844 g_strdup ("unexpected closing curly brace");
846 return NULL;
847 }
848 if (path_tail->depth == start_depth)
849 in_expanded_container = FALSE;
850
852 break;
853 }
854 }
856 }
857
858 if (parser->last_read_char == GVM_JSON_CHAR_ERROR)
859 {
860 if (error_message)
861 *error_message = gvm_json_read_stream_error_str ();
862 return NULL;
863 }
864 else if (in_expanded_container && parser->last_read_char == GVM_JSON_CHAR_EOF)
865 {
866 if (error_message)
867 *error_message = g_strdup ("unexpected EOF");
868 return NULL;
869 }
870
871 expanded = cJSON_Parse (parser->parse_buffer->str);
872 g_string_truncate (parser->parse_buffer, 0);
874
875 if (expanded == NULL && error_message)
876 *error_message = g_strdup ("could not parse expanded container");
877
878 return expanded;
879}
static int gvm_json_pull_parser_next_char(gvm_json_pull_parser_t *parser)
Reads the next character in a pull parser input stream.
Definition jsonpull.c:173
#define GVM_JSON_CHAR_ERROR
Error reading file.
Definition jsonpull.c:11
static void parse_value_next_expect(gvm_json_pull_parser_t *parser)
Updates the expectation for a JSON pull parser according to the path.
Definition jsonpull.c:405
#define GVM_JSON_CHAR_EOF
End of file.
Definition jsonpull.c:10
void gvm_json_pull_path_elem_free(gvm_json_path_elem_t *elem)
Frees a JSON path element.
Definition jsonpull.c:38
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.
Definition jsonpull.c:23
static gchar * gvm_json_read_stream_error_str()
Generates message for an error that occurred reading the JSON stream.
Definition jsonpull.c:135
struct gvm_json_path_elem gvm_json_path_elem_t
Path element types for the JSON pull parser.
int depth
Number of ancestor elements.
Definition jsonpull.h:34
gvm_json_pull_container_type_t parent_type
parent container type
Definition jsonpull.h:31
GString * parse_buffer
Buffer for parsing values and object keys.
Definition jsonpull.h:97
size_t parse_buffer_limit
Maximum parse buffer size.
Definition jsonpull.h:98
gvm_json_path_elem_t * path_add
Path elem to add in next step.
Definition jsonpull.h:88
GQueue * path
Path to the current value.
Definition jsonpull.h:87
int last_read_char
Character last read from stream.
Definition jsonpull.h:95

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gvm_json_pull_parser_cleanup()

void gvm_json_pull_parser_cleanup ( gvm_json_pull_parser_t * parser)

Frees the data of a JSON pull parser.

Parameters
[in]parserThe parser data structure to free the data of

Definition at line 119 of file jsonpull.c.

120{
121 assert (parser);
122 g_queue_free_full (parser->path,
123 (GDestroyNotify) gvm_json_pull_path_elem_free);
124 g_string_free (parser->parse_buffer, TRUE);
125 g_free (parser->read_buffer);
126 memset (parser, 0, sizeof (gvm_json_pull_parser_t));
127}
A json pull parser.
Definition jsonpull.h:86
char * read_buffer
Stream reading buffer.
Definition jsonpull.h:92

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gvm_json_pull_parser_init()

void gvm_json_pull_parser_init ( gvm_json_pull_parser_t * parser,
FILE * input_stream )

Initializes a JSON pull parser with default buffer sizes.

Parameters
[in]parserThe parser data structure to initialize
[in]input_streamThe JSON input stream

Definition at line 108 of file jsonpull.c.

109{
110 gvm_json_pull_parser_init_full (parser, input_stream, 0, 0);
111}
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.
Definition jsonpull.c:77

References gvm_json_pull_parser_init_full().

Referenced by Ensure(), and Ensure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gvm_json_pull_parser_init_full()

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.

Parameters
[in]parserThe parser data structure to initialize
[in]input_streamThe JSON input stream
[in]parse_buffer_limitMaximum buffer size for parsing values
[in]read_buffer_sizeBuffer size for reading from the stream

Definition at line 77 of file jsonpull.c.

80{
81 assert (parser);
82 assert (input_stream);
83 memset (parser, 0, sizeof (gvm_json_pull_parser_t));
84
85 if (parse_buffer_limit <= 0)
86 parse_buffer_limit = GVM_JSON_PULL_PARSE_BUFFER_LIMIT;
87
88 if (read_buffer_size <= 0)
89 read_buffer_size = GVM_JSON_PULL_READ_BUFFER_SIZE;
90
91 parser->input_stream = input_stream;
92 parser->path = g_queue_new ();
94 parser->parse_buffer_limit = parse_buffer_limit;
95 parser->parse_buffer = g_string_new ("");
96 parser->read_buffer_size = read_buffer_size;
97 parser->read_buffer = g_malloc0 (read_buffer_size);
99}
#define GVM_JSON_CHAR_UNDEFINED
Undefined state.
Definition jsonpull.c:12
#define GVM_JSON_PULL_READ_BUFFER_SIZE
Definition jsonpull.h:80
#define GVM_JSON_PULL_PARSE_BUFFER_LIMIT
Definition jsonpull.h:78
size_t read_buffer_size
Size of the stream reading buffer.
Definition jsonpull.h:93
gvm_json_pull_expect_t expect
Current expected token.
Definition jsonpull.h:89
FILE * input_stream
Input stream.
Definition jsonpull.h:91

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().

Here is the caller graph for this function:

◆ gvm_json_pull_parser_next()

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.

Parameters
[in]parserThe JSON pull parser to process until the next event
[in]eventStructure to store event data in.

Definition at line 668 of file jsonpull.c.

670{
671 assert (parser);
672 assert (event);
673
676 {
677 // Handle first read of the stream
678 if (gvm_json_pull_parser_next_char (parser) < 0)
679 {
680 gvm_json_pull_handle_read_end (parser, event, TRUE);
681 return;
682 }
683 }
684
685 event->path = parser->path;
686
687 // Delayed addition to path after a container start element
688 if (parser->path_add)
689 {
690 g_queue_push_tail (parser->path, parser->path_add);
691 parser->path_add = NULL;
692 }
693
694 // Check for expected end of file
695 if (parser->expect == GVM_JSON_PULL_EXPECT_EOF)
696 {
697 if (gvm_json_pull_skip_space (parser, event, TRUE))
698 {
699 // EOF was reached, or an error occurred.
700 // The event type is already set, and if an error occurred, then
701 // error_message is also already set.
702 return;
703 }
704
705 // Skipping space succeeded. Check for unexpected characters at EOF.
706
707 if (parser->last_read_char == GVM_JSON_CHAR_EOF)
708 return;
709
710 event->type = GVM_JSON_PULL_EVENT_ERROR;
711 event->error_message = g_strdup_printf (
712 "unexpected character at end of file (%d)", parser->last_read_char);
713 return;
714 }
715
716 if (parser->expect == GVM_JSON_PULL_EXPECT_COMMA)
717 {
718 if (gvm_json_pull_parse_comma (parser, event))
719 return;
720 }
721
722 if (parser->expect == GVM_JSON_PULL_EXPECT_KEY)
723 {
724 if (gvm_json_pull_parse_key (parser, event))
725 return;
726 }
727
728 if (parser->expect == GVM_JSON_PULL_EXPECT_VALUE)
729 {
730 gvm_json_pull_parse_value (parser, event);
731 }
732}
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.
Definition jsonpull.c:266
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.
Definition jsonpull.c:496
void gvm_json_pull_event_cleanup(gvm_json_pull_event_t *event)
Frees all data of JSON pull event data structure.
Definition jsonpull.c:61
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.
Definition jsonpull.c:564
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.
Definition jsonpull.c:425
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.
Definition jsonpull.c:237

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().

Here is the call graph for this function:

◆ gvm_json_pull_path_elem_free()

void gvm_json_pull_path_elem_free ( gvm_json_path_elem_t * elem)

Frees a JSON path element.

Parameters
[in]elemThe element to free

Definition at line 38 of file jsonpull.c.

39{
40 g_free (elem->key);
41 g_free (elem);
42}
char * key
Key if element is in an object.
Definition jsonpull.h:33

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().

Here is the caller graph for this function:

◆ gvm_json_pull_path_elem_new()

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.

Parameters
[in]parent_typeType of the parent (array, object, none/root)
[in]depthThe depth in the document tree
Returns
The newly allocated path element

Definition at line 23 of file jsonpull.c.

25{
26 gvm_json_path_elem_t *new_elem = g_malloc0 (sizeof (gvm_json_path_elem_t));
27 new_elem->parent_type = parent_type;
28 new_elem->depth = depth;
29 return new_elem;
30}

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().

Here is the caller graph for this function: