From 4298408d8e810ecfd22927987dc8482b0129466d 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: Fri, 16 Jul 2021 10:46:39 +0800 Subject: Services weight max length macro --- anteraja.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/anteraja.c b/anteraja.c index cd2932f..49d2802 100644 --- a/anteraja.c +++ b/anteraja.c @@ -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); -- cgit v1.2.3