From 314f1aa68ebcab0a9c5f8a1d1247098fb8eb9d6e 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 00:16:24 +0800 Subject: Simplify the enums --- handler.h | 20 ++++++++++---------- pikul.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/handler.h b/handler.h index 9c80ab6..fa5e000 100644 --- a/handler.h +++ b/handler.h @@ -3,11 +3,11 @@ #include "pikul.h" enum { - KEY_CODE, - KEY_NAME, - KEY_ETD, - KEY_COST, - KEY_OBJECTS + CODE, + NAME, + ETD, + COST, + OBJECTS }; struct container { @@ -32,7 +32,7 @@ inline void handle(const char *contents, size_t num_bytes, struct container *con } else if (!json_object_is_type(response, json_type_object) || error != json_tokener_success) return; struct json_object *services = NULL; - recurse(response, &(*container->keys)[KEY_OBJECTS], &services); + recurse(response, &(*container->keys)[OBJECTS], &services); size_t length = json_object_array_length(services); *(container->services) = malloc(sizeof(struct pikul_services) + sizeof(struct pikul_service *[length])); @@ -46,18 +46,18 @@ inline void handle(const char *contents, size_t num_bytes, struct container *con while (!json_object_iter_equal(&iterator, &iterator_end)) { const char *key = json_object_iter_peek_name(&iterator); json_object *val = json_object_iter_peek_value(&iterator); - if (!strcmp(key, (*container->keys)[KEY_COST])) + if (!strcmp(key, (*container->keys)[COST])) service->cost = json_object_get_double(val); else { int len = json_object_get_string_len(val); if (len) { char *value = malloc(len + 1); strcpy(value, json_object_get_string(val)); - if (!strcmp(key, (*container->keys)[KEY_CODE])) + if (!strcmp(key, (*container->keys)[CODE])) service->code = value; - else if (!strcmp(key, (*container->keys)[KEY_NAME])) + else if (!strcmp(key, (*container->keys)[NAME])) service->name = value; - else if (!strcmp(key, (*container->keys)[KEY_ETD])) + else if (!strcmp(key, (*container->keys)[ETD])) service->etd = value; } } diff --git a/pikul.h b/pikul.h index 8046d09..72b4834 100644 --- a/pikul.h +++ b/pikul.h @@ -2,7 +2,7 @@ #define PIKUL_H enum pikul_company { - PIKUL_COMPANY_ANTERAJA = 0, + PIKUL_COMPANY_ANTERAJA, PIKUL_COMPANY_SICEPAT }; -- cgit v1.2.3