diff options
author | Eduardo Chappa <chappa@washington.edu> | 2021-07-30 09:00:04 -0600 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2021-07-30 09:00:04 -0600 |
commit | bba1f63e9be0b65c090d1707a6c9168443604ed6 (patch) | |
tree | 7dc6534d6693936d1249f81e790f264750d5e248 /imap/src/c-client/json.h | |
parent | c39814e31d89bd14111347aadca9f0e225b8f06d (diff) | |
download | alpine-bba1f63e9be0b65c090d1707a6c9168443604ed6.tar.xz |
* Improvements to the http and json code.
Diffstat (limited to 'imap/src/c-client/json.h')
-rw-r--r-- | imap/src/c-client/json.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/imap/src/c-client/json.h b/imap/src/c-client/json.h index 88585170..75a08c38 100644 --- a/imap/src/c-client/json.h +++ b/imap/src/c-client/json.h @@ -1,5 +1,5 @@ /* - * Copyright 2018 Eduardo Chappa + * Copyright 2018-2021 Eduardo Chappa * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,21 @@ typedef struct json_s { struct json_s *next; } JSON_S; -JSON_S *json_parse(unsigned char **); +#define json_value_type(J, I, T) \ + (((jx = json_body_value((J), (I))) != NIL) \ + && jx->jtype == (T) && jx->value) \ + ? ((T) == JLong \ + ? *(long *) jx->value \ + : ((T) == JBoolean \ + ? (compare_cstring("false", (char *) jx->value) ? 1 : 0)\ + : NIL \ + ) \ + ) \ + : NIL + +void json_assign(void **, JSON_S *, char *, JObjType); +JSON_S *json_by_name_and_type(JSON_S *, char *, JObjType); +JSON_S *json_parse(unsigned char *); JSON_X *json_body_value(JSON_S *, unsigned char *); void json_free(JSON_S **); |