1*7e3dbbacSRobert Mustacchi /*
2*7e3dbbacSRobert Mustacchi  * This file and its contents are supplied under the terms of the
3*7e3dbbacSRobert Mustacchi  * Common Development and Distribution License ("CDDL"), version 1.0.
4*7e3dbbacSRobert Mustacchi  * You may only use this file in accordance with the terms of version
5*7e3dbbacSRobert Mustacchi  * 1.0 of the CDDL.
6*7e3dbbacSRobert Mustacchi  *
7*7e3dbbacSRobert Mustacchi  * A full copy of the text of the CDDL should have accompanied this
8*7e3dbbacSRobert Mustacchi  * source.  A copy of the CDDL is also available via the Internet at
9*7e3dbbacSRobert Mustacchi  * http://www.illumos.org/license/CDDL.
10*7e3dbbacSRobert Mustacchi  */
11*7e3dbbacSRobert Mustacchi 
12*7e3dbbacSRobert Mustacchi /*
13*7e3dbbacSRobert Mustacchi  * Copyright 2015 Joyent, Inc.
14*7e3dbbacSRobert Mustacchi  */
15*7e3dbbacSRobert Mustacchi 
16*7e3dbbacSRobert Mustacchi #ifndef	_JSON_NVLIST_H
17*7e3dbbacSRobert Mustacchi #define	_JSON_NVLIST_H
18*7e3dbbacSRobert Mustacchi 
19*7e3dbbacSRobert Mustacchi #include <libnvpair.h>
20*7e3dbbacSRobert Mustacchi #include <libcustr.h>
21*7e3dbbacSRobert Mustacchi 
22*7e3dbbacSRobert Mustacchi #ifdef __cplusplus
23*7e3dbbacSRobert Mustacchi extern "C" {
24*7e3dbbacSRobert Mustacchi #endif
25*7e3dbbacSRobert Mustacchi 
26*7e3dbbacSRobert Mustacchi typedef enum nvlist_parse_json_flags {
27*7e3dbbacSRobert Mustacchi 	NVJSON_FORCE_INTEGER = 0x01,
28*7e3dbbacSRobert Mustacchi 	NVJSON_FORCE_DOUBLE = 0x02,
29*7e3dbbacSRobert Mustacchi 	NVJSON_ERRORS_TO_STDERR = 0x04,
30*7e3dbbacSRobert Mustacchi 	NVJSON_DEBUG = 0x08
31*7e3dbbacSRobert Mustacchi } nvlist_parse_json_flags_t;
32*7e3dbbacSRobert Mustacchi 
33*7e3dbbacSRobert Mustacchi typedef struct nvlist_parse_json_error {
34*7e3dbbacSRobert Mustacchi 	int nje_errno;
35*7e3dbbacSRobert Mustacchi 	long nje_pos;
36*7e3dbbacSRobert Mustacchi 	char nje_message[512];
37*7e3dbbacSRobert Mustacchi } nvlist_parse_json_error_t;
38*7e3dbbacSRobert Mustacchi 
39*7e3dbbacSRobert Mustacchi #define	NVJSON_ALL						\
40*7e3dbbacSRobert Mustacchi 	(NVJSON_FORCE_INTEGER |					\
41*7e3dbbacSRobert Mustacchi 	NVJSON_FORCE_DOUBLE |					\
42*7e3dbbacSRobert Mustacchi 	NVJSON_ERRORS_TO_STDERR |				\
43*7e3dbbacSRobert Mustacchi 	NVJSON_DEBUG)
44*7e3dbbacSRobert Mustacchi 
45*7e3dbbacSRobert Mustacchi extern int nvlist_parse_json(const char *, size_t, nvlist_t **,
46*7e3dbbacSRobert Mustacchi     nvlist_parse_json_flags_t, nvlist_parse_json_error_t *);
47*7e3dbbacSRobert Mustacchi 
48*7e3dbbacSRobert Mustacchi #ifdef __cplusplus
49*7e3dbbacSRobert Mustacchi }
50*7e3dbbacSRobert Mustacchi #endif
51*7e3dbbacSRobert Mustacchi 
52*7e3dbbacSRobert Mustacchi #endif	/* _JSON_NVLIST_H */