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