From 62511367857a6f34f6b2f81dc094f9d632ad01bd Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Sat, 2 Jul 2022 14:49:22 +0200 Subject: add support for conditional vdf values, return NULL on invalid state --- src/vdf/vdf.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/vdf/vdf.c b/src/vdf/vdf.c index c9130a6..5b2f274 100644 --- a/src/vdf/vdf.c +++ b/src/vdf/vdf.c @@ -13,6 +13,8 @@ #define CHAR_DOUBLE_QUOTE '"' #define CHAR_OPEN_CURLY_BRACKET '{' #define CHAR_CLOSED_CURLY_BRACKET '}' +#define CHAR_OPEN_ANGLED_BRACKET '[' +#define CHAR_CLOSED_ANGLED_BRACKET ']' #define CHAR_FRONTSLASH '/' #define CHAR_BACKSLASH '\\' @@ -231,7 +233,23 @@ struct vdf_object* vdf_parse_buffer(const char* buffer, size_t size) break; + case CHAR_OPEN_ANGLED_BRACKET: + printf("%i\n", buf); + if (!buf) + while (*tail != '\0' && *tail != CHAR_CLOSED_ANGLED_BRACKET) + ++tail; + break; + default: + if (!buf) + { + // we found something we are probably not suppose to + // the easiest way out is to just terminate + vdf_free_object(root_object); + return NULL; + } + break; + case CHAR_NEWLINE: case CHAR_SPACE: case CHAR_TAB: -- cgit v1.2.3