File: solv_jsonparser.h

package info (click to toggle)
libsolv 0.7.35-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,804 kB
  • sloc: ansic: 73,004; python: 871; perl: 742; tcl: 730; ruby: 705; sh: 263; cpp: 204; makefile: 41
file content (53 lines) | stat: -rw-r--r-- 1,075 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * Copyright (c) 2018, SUSE LLC
 *
 * This program is licensed under the BSD license, read LICENSE.BSD
 * for further information
 */

#ifndef SOLV_JSONPARSER_H
#define SOLV_JSONPARSER_H

#include "queue.h"

struct solv_jsonparser {
  FILE *fp;
  int flags;
  int line;
  int depth;

  char *key;
  size_t keylen;
  char *value;
  size_t valuelen;

  int state;		/* START, END, OBJECT, ARRAY */
  Queue stateq;
  int nextc;
  int nextline;
  char *space;
  size_t nspace;
  size_t aspace;
};

#define JP_FLAG_RAWSTRINGS	1

#define JP_ERROR	-1
#define JP_END		0
#define JP_START	1
#define JP_STRING	2
#define JP_NUMBER	3
#define JP_BOOL		4
#define JP_NULL		5
#define JP_OBJECT	6
#define JP_OBJECT_END	7
#define JP_ARRAY	8
#define JP_ARRAY_END	9

void jsonparser_init(struct solv_jsonparser *jp, FILE *fp);
void jsonparser_free(struct solv_jsonparser *jp);
int jsonparser_parse(struct solv_jsonparser *jp);
int jsonparser_skip(struct solv_jsonparser *jp, int type);
int jsonparser_collect(struct solv_jsonparser *jp, int type, char **jsonp);

#endif /* SOLV_JSONPARSER_H */