1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef QAPI_QMP_JSON_PARSER_H
15#define QAPI_QMP_JSON_PARSER_H
16
17typedef struct JSONLexer {
18 int start_state, state;
19 GString *token;
20 int x, y;
21} JSONLexer;
22
23typedef struct JSONMessageParser {
24 void (*emit)(void *opaque, QObject *json, Error *err);
25 void *opaque;
26 va_list *ap;
27 JSONLexer lexer;
28 int brace_count;
29 int bracket_count;
30 GQueue tokens;
31 uint64_t token_size;
32} JSONMessageParser;
33
34void json_message_parser_init(JSONMessageParser *parser,
35 void (*emit)(void *opaque, QObject *json,
36 Error *err),
37 void *opaque, va_list *ap);
38
39void json_message_parser_feed(JSONMessageParser *parser,
40 const char *buffer, size_t size);
41
42void json_message_parser_flush(JSONMessageParser *parser);
43
44void json_message_parser_destroy(JSONMessageParser *parser);
45
46#endif
47