neocities.h

a C library for interacting with Neocities' API
git clone https://github.com/tanguyandreani/neocities.h
Log | Files | Refs | README | LICENSE

commit eb2e7abecdad96e2cdc095d99116f628aba9805a
parent 283a76b4384e4f5f4f7b5b61f3bb6691782a8ba4
Author: Tanguy Andreani <dev@tanguy.space>
Date:   Sat, 23 Feb 2019 03:20:25 +0100

Fixed: no longer error out on empty last_updated

Diffstat:
Mneocities.h | 17++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/neocities.h b/neocities.h @@ -468,7 +468,7 @@ enum neocities_low_level_error neocities_json_to_struct(json_object * jobj, if (jobj_iter.key != NULL && strcmp(jobj_iter.key, "error_type") == 0) { - res->result = -1; // in case wasn't sent in usual order + res->result = -1; // in case wasn't sent in usual order res->type = NEOCITIES_ERROR_STRUCT; res->data.error.type = UNSUPPORTED_ERROR; @@ -581,13 +581,16 @@ enum neocities_low_level_error neocities_json_to_struct(json_object * jobj, } else if (strcmp(jobj_iter_info.key, "last_updated") == 0) { if (json_object_get_type - (jobj_iter_info.val) != json_type_string) - return NEOCITIES_LLVL_ERR_EXPECTED_STRING; + (jobj_iter_info.val) != json_type_string + && json_object_get_type(jobj_iter_info.val) != + json_type_null) + return NEOCITIES_LLVL_ERR_EXPECTED_STRING_OR_NULL; tmp_string = json_object_get_string(jobj_iter_info.val); - rfc5322_date_parse(tmp_string, strlen(tmp_string), - &res->data.info.last_updated, true); + if (tmp_string != NULL) + rfc5322_date_parse(tmp_string, strlen(tmp_string), + &res->data.info.last_updated, true); } else if (strcmp(jobj_iter_info.key, "tags") == 0) { @@ -678,8 +681,8 @@ enum neocities_low_level_error neocities_json_to_struct(json_object * jobj, continue; rfc5322_date_parse(tmp_string, strlen(tmp_string), - &(res->data.list. - files)[i].updated_at, true); + &(res->data.list.files)[i]. + updated_at, true); } else if (strcmp(jobj_iter_list.key, "size") == 0) {