diff options
Diffstat (limited to 'sicepat.c')
-rw-r--r-- | sicepat.c | 61 |
1 files changed, 30 insertions, 31 deletions
@@ -1,42 +1,41 @@ -#include "common.h" +#include <stdlib.h> +#include <string.h> +#include "private.h" #define BASE "http://api.sicepat.com/customer/" -static const char *status_trail[] = { - "sicepat", - "status", - "code", - NULL -}; - -void sicepat_init(char *provisions[]) +const char **sicepat_init(char *provisions[]) { shipping.base = malloc(strlen(BASE) + 1); strcpy(shipping.base, BASE); - headers((const char *[]){ "api-key", NULL }, provisions); + static const char *status_trail[] = { + "sicepat", + "status", + "code", + NULL + }; + shipping.status_trail = status_trail; + static const char *fields[] = { "api-key", NULL }; + return fields; } -void sicepat_services(const char *origin, const char *destination, double weight, char **url) +const char **sicepat_services(const char *origin, const char *destination, double weight) { - *url = malloc(strlen(shipping.base) + strlen("tariff?origin=") + strlen(origin) + shipping.url = malloc(strlen(shipping.base) + strlen("tariff?origin=") + strlen(origin) + strlen("&destination=") + strlen(destination) + strlen("&weight=") + 9); - sprintf(*url, "%stariff?origin=%s&destination=%s&weight=%f", shipping.base, origin, destination, - weight); -} - -size_t sicepat_services_handle(const char *contents, size_t size, size_t nmemb, - struct pikul_services **services) -{ - size_t realsize = size * nmemb; - handle(SERVICES, contents, realsize, status_trail, (const char *[]){ - "sicepat", - "results", - NULL - }, (const char *[]){ - "service", - "description", - "etd", - "tariff" - }, services); - return realsize; + sprintf(shipping.url, "%stariff?origin=%s&destination=%s&weight=%f", shipping.base, origin, + destination, weight); + static const char *trail[] = { + "sicepat", + "results", + NULL + }; + shipping.trail = trail; + static const char *attributes[] = { + "service", + "description", + "etd", + "tariff" + }; + return attributes; } |