Imported Upstream version 0.7.27
[platform/upstream/libsolv.git] / ext / solv_jsonparser.h
1 /*
2  * Copyright (c) 2018, SUSE LLC
3  *
4  * This program is licensed under the BSD license, read LICENSE.BSD
5  * for further information
6  */
7
8 #ifndef SOLV_JSONPARSER_H
9 #define SOLV_JSONPARSER_H
10
11 #include "queue.h"
12
13 struct solv_jsonparser {
14   FILE *fp;
15   int flags;
16   int line;
17   int depth;
18
19   char *key;
20   size_t keylen;
21   char *value;
22   size_t valuelen;
23
24   int state;            /* START, END, OBJECT, ARRAY */
25   Queue stateq;
26   int nextc;
27   int nextline;
28   char *space;
29   size_t nspace;
30   size_t aspace;
31 };
32
33 #define JP_FLAG_RAWSTRINGS      1
34
35 #define JP_ERROR        -1
36 #define JP_END          0
37 #define JP_START        1
38 #define JP_STRING       2
39 #define JP_NUMBER       3
40 #define JP_BOOL         4
41 #define JP_NULL         5
42 #define JP_OBJECT       6
43 #define JP_OBJECT_END   7
44 #define JP_ARRAY        8
45 #define JP_ARRAY_END    9
46
47 void jsonparser_init(struct solv_jsonparser *jp, FILE *fp);
48 void jsonparser_free(struct solv_jsonparser *jp);
49 int jsonparser_parse(struct solv_jsonparser *jp);
50 int jsonparser_skip(struct solv_jsonparser *jp, int type);
51 int jsonparser_collect(struct solv_jsonparser *jp, int type, char **jsonp);
52
53 #endif /* SOLV_JSONPARSER_H */