diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-16 10:46:39 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-16 10:46:39 +0800 |
commit | 4298408d8e810ecfd22927987dc8482b0129466d (patch) | |
tree | 66cabdf4db6a629d24117b022486b80a9ba7ded8 | |
parent | 7e15b32baaf737d28e0086b516b9ed307ab3f0c5 (diff) |
Services weight max length macro
-rw-r--r-- | anteraja.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -8,6 +8,7 @@ \"destination\":\"%s\",\ \"weight\":%d\ }" +#define SERVICES_WEIGHT 5 extern CURL *curl; @@ -26,7 +27,7 @@ void anteraja_services(const char *origin, const char *destination, double weigh { *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") + *post = malloc(strlen(SERVICES_POST) + strlen(origin) + strlen(destination) + SERVICES_WEIGHT - 2 * strlen("%s") - strlen("%d") + 1); sprintf(*post, SERVICES_POST, origin, destination, weight < 1.0 ? 1000 : (int)weight * 1000); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, *post); |