MCPcopy Create free account
hub / github.com/cppla/ServerStatus / json_parse_ex

Function json_parse_ex

server/src/json.c:211–890  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209 flag_block_comment = 1 << 14;
210
211json_value * json_parse_ex (json_settings * settings,
212 const json_char * json,
213 size_t length,
214 char * error_buf)
215{
216 json_char error [json_error_max];
217 unsigned int cur_line;
218 const json_char * cur_line_begin, * i, * end;
219 json_value * top, * root, * alloc = 0;
220 json_state state = { 0 };
221 long flags;
222 long num_digits = 0, num_e = 0;
223 json_int_t num_fraction = 0;
224
225 /* Skip UTF-8 BOM
226 */
227 if (length >= 3 && ((unsigned char) json [0]) == 0xEF
228 && ((unsigned char) json [1]) == 0xBB
229 && ((unsigned char) json [2]) == 0xBF)
230 {
231 json += 3;
232 length -= 3;
233 }
234
235 error[0] = '\0';
236 end = (json + length);
237
238 memcpy (&state.settings, settings, sizeof (json_settings));
239
240 if (!state.settings.mem_alloc)
241 state.settings.mem_alloc = default_alloc;
242
243 if (!state.settings.mem_free)
244 state.settings.mem_free = default_free;
245
246 memset (&state.uint_max, 0xFF, sizeof (state.uint_max));
247 memset (&state.ulong_max, 0xFF, sizeof (state.ulong_max));
248
249 state.uint_max -= 8; /* limit of how much can be added before next check */
250 state.ulong_max -= 8;
251
252 for (state.first_pass = 1; state.first_pass >= 0; -- state.first_pass)
253 {
254 json_uchar uchar;
255 unsigned char uc_b1, uc_b2, uc_b3, uc_b4;
256 json_char * string = 0;
257 unsigned int string_length = 0;
258
259 top = root = 0;
260 flags = flag_seek_value;
261
262 cur_line = 1;
263 cur_line_begin = json;
264
265 for (i = json ;; ++ i)
266 {
267 json_char b = (i == end ? 0 : *i);
268

Callers 3

json_parseFunction · 0.85
HandleMessageMethod · 0.85
ReadConfigMethod · 0.85

Calls 3

hex_valueFunction · 0.85
new_valueFunction · 0.85
json_value_free_exFunction · 0.85

Tested by

no test coverage detected