diff --git a/Makefile b/Makefile index 0779721..d2f648c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CC ?= cc -CFLAGS = -g -ansi -Wall -Werror=implicit-function-declaration -I ./include/ +CFLAGS = -g -ansi -Wall -Werror=implicit-function-declaration -I ./include/ `pkg-config --cflags libcjson` SRC = $(wildcard src/*.c) OBJ = $(patsubst %.c,%.o,$(SRC)) TARGET = libmastodont.a # shared diff --git a/src/error.c b/src/error.c index f234202..3adedfe 100644 --- a/src/error.c +++ b/src/error.c @@ -16,6 +16,18 @@ #include #include +static void _mstdnt_val_errors_call(cJSON* v, void* _type) +{ + char** type = _type; + if (v->child && v->child->valuestring) + *type = v->child->valuestring; + else + { + *type = NULL; + return; + } +} + int mstdnt_check_error(struct mstdnt_fetch_results* results, struct mstdnt_storage* storage) { @@ -28,8 +40,10 @@ int mstdnt_check_error(struct mstdnt_fetch_results* results, storage->error = NULL; storage->error_description = NULL; + /* TODO I have no idea why multiple errors can be returned */ struct _mstdnt_val_ref refs[] = { { "error", &(storage->error), _mstdnt_val_string_call }, + { "errors", &(storage->error), _mstdnt_val_errors_call }, { "error_description", &(storage->error_description), _mstdnt_val_string_call }, };