-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathujson_common.h
69 lines (59 loc) · 1.54 KB
/
ujson_common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// SPDX-License-Identifier: LGPL-2.1-or-later
/*
* Copyright (C) 2021-2024 Cyril Hrubis <[email protected]>
*/
/**
* @file ujson_common.h
* @brief Common JSON reader/writer definitions.
*/
#ifndef UJSON_COMMON_H
#define UJSON_COMMON_H
/** @brief Maximal error message length. */
#define UJSON_ERR_MAX 128
/** @brief Maximal id string lenght including terminating null element. */
#define UJSON_ID_MAX 64
/** @brief Maximal recursion depth allowed. */
#define UJSON_RECURSION_MAX 128
#define UJSON_ERR_PRINT ujson_err_handler
#define UJSON_ERR_PRINT_PRIV stderr
/**
* @brief A JSON data type.
*/
enum ujson_type {
/** @brief No type. Returned when parser finishes. */
UJSON_VOID = 0,
/** @brief An integer. */
UJSON_INT,
/** @brief A floating point. */
UJSON_FLOAT,
/** @brief A boolean. */
UJSON_BOOL,
/** @brief NULL */
UJSON_NULL,
/** @brief A string. */
UJSON_STR,
/** @brief A JSON object. */
UJSON_OBJ,
/** @brief A JSON array. */
UJSON_ARR,
};
/**
* @brief Returns type name.
*
* @param type A json type.
* @return A type name.
*/
const char *ujson_type_name(enum ujson_type type);
/**
* @brief Default error print handler.
*
* @param print_priv A json buffer print_priv pointer.
* @param line A line of text to be printed.
*/
void ujson_err_handler(void *print_priv, const char *line);
typedef struct ujson_reader ujson_reader;
typedef struct ujson_writer ujson_writer;
typedef struct ujson_val ujson_val;
/** @brief An array size macro. */
#define UJSON_ARRAY_SIZE(array) (sizeof(array) / sizeof(*array))
#endif /* UJSON_COMMON_H */