From c328f6c002446245ae81fc5f6009555ef71d071c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Mon, 28 Jun 2021 10:58:50 +0800 Subject: Handle whose status is other than 200 At the same time, refactor the JSON handling. --- anteraja.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'anteraja.c') diff --git a/anteraja.c b/anteraja.c index 05fa870..1268820 100644 --- a/anteraja.c +++ b/anteraja.c @@ -1,15 +1,16 @@ #include "shipping.h" #include "handler.h" -enum { - BASE_PATH, - ACCESS_KEY -}; - extern CURL *curl; +static const char *status_trail[] = { + "status", + NULL +}; + void anteraja_init(char *provisions[], struct shipping *shipping) { + enum { BASE_PATH, ACCESS_KEY }; shipping->base = malloc(strlen(provisions[BASE_PATH]) + 1); strcpy(shipping->base, provisions[BASE_PATH]); headers(shipping, (const char *[]){ "access-key-id", "secret-access-key", NULL }, @@ -38,13 +39,15 @@ size_t anteraja_services_handle(const char *contents, size_t size, size_t nmemb, struct pikul_services **services) { size_t realsize = size * nmemb; - handle(contents, realsize, &(struct container){ services, (const char *[]){ + handle_services(contents, realsize, status_trail, (const char *[]){ + "content", + "services", + NULL + }, (const char *[]){ "product_code", "product_name", "etd", - "rates", - "content", - "services", - NULL}}); + "rates" + }, services); return realsize; } -- cgit v1.2.3