diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-16 10:44:12 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-16 10:44:12 +0800 |
commit | 7e15b32baaf737d28e0086b516b9ed307ab3f0c5 (patch) | |
tree | f8821ea48a84bdadeec39873e61bb10a81347d98 /anteraja.c | |
parent | 1c51604909c9953acd874e24abe90ba565c650d2 (diff) |
No need for shipping to be passed as pointer
when it needs to be global anyway.
Diffstat (limited to 'anteraja.c')
-rw-r--r-- | anteraja.c | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -13,21 +13,19 @@ extern CURL *curl; static const char *status_trail[] = { "status", NULL }; -void anteraja_init(char *provisions[], struct shipping *shipping) +void anteraja_init(char *provisions[]) { - enum { BASE_PATH, ACCESS_KEY }; - shipping->base = malloc(strlen(provisions[BASE_PATH]) + 1); - strcpy(shipping->base, provisions[BASE_PATH]); - headers((const char *[]){ "access-key-id", "secret-access-key", NULL }, - &provisions[ACCESS_KEY], shipping); - shipping->headers = curl_slist_append(shipping->headers, "Content-Type:application/json"); + enum { BASE_PATH, ACCESS_KEY_ID, SECRET_ACCESS_KEY, PREFIX }; + shipping.base = malloc(strlen(provisions[BASE_PATH]) + 1); + strcpy(shipping.base, provisions[BASE_PATH]); + headers((const char *[]){ "access-key-id", "secret-access-key", NULL }, &provisions[ACCESS_KEY_ID]); + shipping.headers = curl_slist_append(shipping.headers, "Content-Type:application/json"); } -void anteraja_services(const char *origin, const char *destination, double weight, - struct shipping *shipping, char **url, char **post) +void anteraja_services(const char *origin, const char *destination, double weight, char **url, char **post) { - *url = malloc(strlen(shipping->base) + strlen(SERVICES_PATH) + 1); - sprintf(*url, "%s%s", shipping->base, SERVICES_PATH); + *url = malloc(strlen(shipping.base) + strlen(SERVICES_PATH) + 1); + sprintf(*url, "%s%s", shipping.base, SERVICES_PATH); *post = malloc(strlen(SERVICES_POST) + strlen(origin) + strlen(destination) + strlen("50000") - 2 * strlen("%s") - strlen("%d") + 1); sprintf(*post, SERVICES_POST, origin, destination, weight < 1.0 ? 1000 : (int)weight * 1000); |