Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit b99768d

Browse files
committed
add parson(github.com/kgabis/parson)
Signed-off-by: Lai Jiangshan <[email protected]>
1 parent 1a61298 commit b99768d

File tree

5 files changed

+2306
-3
lines changed

5 files changed

+2306
-3
lines changed

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
AM_CFLAGS = -Wall
22
bin_PROGRAMS=init
3-
init_SOURCES=init.c jsmn.c net.c util.c parse.c container.c exec.c event.c portmapping.c
3+
init_SOURCES=init.c jsmn.c net.c util.c parse.c parson.c container.c exec.c event.c portmapping.c

src/parse.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
/* parse_utf_16() and process_string() are copied from https://github.com/kgabis/parson */
1010
#include <ctype.h>
1111

12-
#define JSONFailure (-1)
13-
#define JSONSuccess (0)
1412
#define parson_malloc malloc
1513
#define parson_free free
1614

@@ -1598,3 +1596,13 @@ int hyper_parse_read_file(struct hyper_reader *reader, char *json, int length)
15981596
reader->file = NULL;
15991597
goto out;
16001598
}
1599+
1600+
JSON_Value *hyper_json_parse(char *json, int length)
1601+
{
1602+
char *str = strndup(json, length);
1603+
if (str == NULL)
1604+
return NULL;
1605+
JSON_Value *ret = json_parse_string(str);
1606+
free(str);
1607+
return ret;
1608+
}

src/parse.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "hyper.h"
55
#include "jsmn.h"
6+
#include "parson.h"
67

78
int hyper_parse_pod(struct hyper_pod *pod, char *json, int length);
89
struct hyper_exec *hyper_parse_execcmd(char *json, int length);
@@ -16,5 +17,6 @@ struct hyper_container *hyper_parse_new_container(struct hyper_pod *pod, char *j
1617
void hyper_free_container(struct hyper_container *c);
1718
struct hyper_interface *hyper_parse_setup_interface(char *json, int length);
1819
int hyper_parse_setup_routes(struct hyper_route **routes, uint32_t *r_num, char *json, int length);
20+
JSON_Value *hyper_json_parse(char *json, int length);
1921

2022
#endif

0 commit comments

Comments
 (0)