summaryrefslogtreecommitdiff
path: root/json.h
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-08-19 02:25:32 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-08-19 02:25:32 +0000
commit747088bbe5dc34c0902c0bddc492bc4815f4a7c3 (patch)
tree4c2d4ef502290f6e7ce9136a30b6284f6d7e1bcc /json.h
parent276ffa0a53aae3fe555bdcbf98c4007120a2f0e3 (diff)
downloadgpsd-747088bbe5dc34c0902c0bddc492bc4815f4a7c3.tar.gz
Give the JSON parser the ability to map strings to enumerated types.
Diffstat (limited to 'json.h')
-rw-r--r--json.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/json.h b/json.h
index 9aa983aa..b39c9417 100644
--- a/json.h
+++ b/json.h
@@ -4,10 +4,16 @@
#include <stdbool.h>
#include <ctype.h>
-typedef enum {integer, real, string, boolean, object, array, check} json_type;
+typedef enum {integer, real, string, boolean,
+ enumerated, object, array, check} json_type;
#define nullbool -1 /* not true, not false */
+struct json_enum_t {
+ char *name;
+ int value;
+};
+
struct json_array_t {
json_type element_type;
union {
@@ -17,6 +23,11 @@ struct json_array_t {
char *store;
int storelen;
} strings;
+ struct {
+ const struct json_enum_t *map;
+ int *store;
+ int storelen;
+ } enumerated;
} arr;
int *count, maxlen;
};
@@ -66,5 +77,6 @@ const char *json_error_string(int);
#define JSON_ERR_SUBTYPE 14 /* unsupported array element type */
#define JSON_ERR_BADSTRING 15 /* error while string parsing */
#define JSON_ERR_CHECKFAIL 16 /* check attribute not matched */
+#define JSON_ERR_BADENUM 17 /* invalid enumerated value */
/* json.h ends here */