These changes are the raw update to qemu-2.6.
[kvmfornfv.git] / qemu / include / qapi / qmp / json-streamer.h
1 /*
2  * JSON streaming support
3  *
4  * Copyright IBM, Corp. 2009
5  *
6  * Authors:
7  *  Anthony Liguori   <aliguori@us.ibm.com>
8  *
9  * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
10  * See the COPYING.LIB file in the top-level directory.
11  *
12  */
13
14 #ifndef QEMU_JSON_STREAMER_H
15 #define QEMU_JSON_STREAMER_H
16
17 #include "qapi/qmp/json-lexer.h"
18
19 typedef struct JSONToken {
20     int type;
21     int x;
22     int y;
23     char str[];
24 } JSONToken;
25
26 typedef struct JSONMessageParser
27 {
28     void (*emit)(struct JSONMessageParser *parser, GQueue *tokens);
29     JSONLexer lexer;
30     int brace_count;
31     int bracket_count;
32     GQueue *tokens;
33     uint64_t token_size;
34 } JSONMessageParser;
35
36 void json_message_parser_init(JSONMessageParser *parser,
37                               void (*func)(JSONMessageParser *, GQueue *));
38
39 int json_message_parser_feed(JSONMessageParser *parser,
40                              const char *buffer, size_t size);
41
42 int json_message_parser_flush(JSONMessageParser *parser);
43
44 void json_message_parser_destroy(JSONMessageParser *parser);
45
46 #endif