summaryrefslogtreecommitdiff
path: root/ext/solv_jsonparser.h
blob: f728fb68a73373eb1f391b91066f05c052ecfc3a (plain)
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
/*
 * 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 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_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);

#endif /* SOLV_JSONPARSER_H */