From 74ccf9e85a81f2347730103108cc0b9d773e5f3c 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: Wed, 14 Jul 2021 17:29:25 +0800 Subject: Log that works Log will show up with libcurl's before the HTML, and only log that is within libcurl's, i.e. in the WRITEFUNCTION. --- anteraja.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/anteraja.c b/anteraja.c index e0c53cf..c84ab9d 100644 --- a/anteraja.c +++ b/anteraja.c @@ -33,9 +33,6 @@ void anteraja_services(const char *origin, const char *destination, double weigh *post = malloc(strlen(POST) + strlen(origin) + strlen(destination) + strlen("50000") - 2 * strlen("%s") - strlen("%d") + 1); sprintf(*post, POST, origin, destination, (int)weight * 1000); -#ifdef DEBUG - printf("POST: %s\n", *post); -#endif curl_easy_setopt(curl, CURLOPT_POSTFIELDS, *post); } @@ -45,7 +42,7 @@ size_t anteraja_services_handle(const char *contents, size_t size, size_t nmemb, size_t realsize = size * nmemb; #ifdef DEBUG ((char *)contents)[realsize] = '\0'; - printf("%s\n", contents); + fprintf(stderr, "%s\n", contents); #endif handle_services(contents, realsize, status_trail, (const char *[]){ "content", -- cgit v1.2.3 From c94ad9f218da96aa57098a0560247e23d5a954b7 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: Wed, 14 Jul 2021 17:31:40 +0800 Subject: By default, Anteraja will not round up to minimum --- anteraja.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anteraja.c b/anteraja.c index c84ab9d..5e5111d 100644 --- a/anteraja.c +++ b/anteraja.c @@ -32,7 +32,7 @@ void anteraja_services(const char *origin, const char *destination, double weigh sprintf(*url, "%s%s", shipping->base, path); *post = malloc(strlen(POST) + strlen(origin) + strlen(destination) + strlen("50000") - 2 * strlen("%s") - strlen("%d") + 1); - sprintf(*post, POST, origin, destination, (int)weight * 1000); + sprintf(*post, POST, origin, destination, weight < 1.0 ? 1000 : (int)weight * 1000); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, *post); } -- cgit v1.2.3 From 98e006f67c205a2674a1b35c3a215ba41ae1881b 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: Wed, 14 Jul 2021 18:23:53 +0800 Subject: When debugging, debugs for all services/companies because libcurl's verbose will hit anyway. There's no point trying to debug for a company and not the others. --- anteraja.c | 7 ------- handler.h | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/anteraja.c b/anteraja.c index 5e5111d..462ff5d 100644 --- a/anteraja.c +++ b/anteraja.c @@ -1,6 +1,3 @@ -#ifdef DEBUG -#include -#endif #include "shipping.h" #include "handler.h" @@ -40,10 +37,6 @@ size_t anteraja_services_handle(const char *contents, size_t size, size_t nmemb, struct pikul_services **services) { size_t realsize = size * nmemb; -#ifdef DEBUG - ((char *)contents)[realsize] = '\0'; - fprintf(stderr, "%s\n", contents); -#endif handle_services(contents, realsize, status_trail, (const char *[]){ "content", "services", diff --git a/handler.h b/handler.h index 7b2ac90..9c46975 100644 --- a/handler.h +++ b/handler.h @@ -1,3 +1,6 @@ +#ifdef DEBUG +#include +#endif #include #include #include "pikul.h" @@ -8,6 +11,10 @@ void recurse(struct json_object *, const char *[], struct json_object **); inline void handle_services(const char *contents, size_t num_bytes, const char *status_trail[], const char *trail[], const char *attributes[], struct pikul_services **services) { +#ifdef DEBUG + ((char *)contents)[num_bytes] = '\0'; + fprintf(stderr, "%s\n", contents); +#endif json_object *response = json_tokener_parse_ex(tokener, contents, num_bytes); enum json_tokener_error error = json_tokener_get_error(tokener); if (!response) { -- cgit v1.2.3