]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - Ventoy2Disk/Ventoy2Disk/VentoyJson.h
1 /******************************************************************************
4 * Copyright (c) 2021, longpanda <admin@ventoy.net>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #ifndef __VENTOY_JSON_H__
22 #define __VENTOY_JSON_H__
24 #ifdef FOR_VTOY_JSON_CHECK
25 typedef unsigned char UINT8
;
26 typedef unsigned short UINT16
;
27 typedef unsigned int UINT32
;
28 typedef unsigned long long UINT64
;
31 #define strcpy_s(a, b, c) strncpy(a, c, b)
32 #define sprintf_s snprintf
35 #define JSON_SUCCESS 0
37 #define JSON_NOT_FOUND 2
39 typedef enum _JSON_TYPE
51 typedef struct _VTOY_JSON
53 struct _VTOY_JSON
*pstPrev
;
54 struct _VTOY_JSON
*pstNext
;
55 struct _VTOY_JSON
*pstChild
;
68 typedef struct _JSON_PARSE
75 #define JSON_NEW_ITEM(pstJson, ret) \
77 (pstJson) = (VTOY_JSON *)malloc(sizeof(VTOY_JSON)); \
78 if (NULL == (pstJson)) \
80 Log("Failed to alloc memory for json.\n"); \
83 memset((pstJson), 0, sizeof(VTOY_JSON));\
86 VTOY_JSON
*vtoy_json_find_item
92 int vtoy_json_parse_value
100 VTOY_JSON
* vtoy_json_create(void);
101 int vtoy_json_parse(VTOY_JSON
*pstJson
, const char *szJsonData
);
103 int vtoy_json_scan_parse
105 const VTOY_JSON
*pstJson
,
107 JSON_PARSE
*pstJsonParse
110 int vtoy_json_scan_array
114 VTOY_JSON
**ppstArrayItem
117 int vtoy_json_scan_array_ex
121 VTOY_JSON
**ppstArrayItem
123 int vtoy_json_scan_object
127 VTOY_JSON
**ppstObjectItem
129 int vtoy_json_get_int
135 int vtoy_json_get_uint
141 int vtoy_json_get_uint64
147 int vtoy_json_get_bool
153 int vtoy_json_get_string
160 const char * vtoy_json_get_string_ex(VTOY_JSON
*pstJson
, const char *szKey
);
161 int vtoy_json_destroy(VTOY_JSON
*pstJson
);
163 #endif /* __VENTOY_JSON_H__ */