summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pikul.c10
-rw-r--r--sicepat.c20
2 files changed, 15 insertions, 15 deletions
diff --git a/pikul.c b/pikul.c
index a2e61b5..b059dd8 100644
--- a/pikul.c
+++ b/pikul.c
@@ -17,9 +17,9 @@ void anteraja_order(const char *, const char *, const char *, const char *, cons
size_t anteraja_order_handle(const char *, size_t size, size_t nmemb, char **);
void anteraja_cleanup();
-extern void sicepat_init(char *[], struct shipping *);
-extern void sicepat_services(const char *, const char *, double, struct shipping *, char **);
-extern size_t sicepat_services_handle(const char *, size_t, size_t, struct pikul_services **);
+void sicepat_init(char *[]);
+void sicepat_services(const char *, const char *, double, char **);
+size_t sicepat_services_handle(const char *, size_t, size_t, struct pikul_services **);
void pikul_init(enum pikul_company company, char *provisions[])
{
@@ -34,7 +34,7 @@ void pikul_init(enum pikul_company company, char *provisions[])
anteraja_init(provisions);
break;
case PIKUL_SICEPAT:
- sicepat_init(provisions, &shipping);
+ sicepat_init(provisions);
break;
default:
break;
@@ -66,7 +66,7 @@ struct pikul_services *pikul_services(const char *origin, const char *destinatio
handler = anteraja_services_handle;
break;
case PIKUL_SICEPAT:
- sicepat_services(origin, destination, weight, &shipping, &url);
+ sicepat_services(origin, destination, weight, &url);
handler = sicepat_services_handle;
break;
default:
diff --git a/sicepat.c b/sicepat.c
index e03be36..ffa83c3 100644
--- a/sicepat.c
+++ b/sicepat.c
@@ -1,6 +1,8 @@
#include "shipping.h"
#include "handler.h"
+#define BASE "http://api.sicepat.com/customer/"
+
extern CURL *curl;
static const char *status_trail[] = {
@@ -10,20 +12,18 @@ static const char *status_trail[] = {
NULL
};
-void sicepat_init(char *provisions[], struct shipping *shipping)
+void sicepat_init(char *provisions[])
{
- static const char *url = "http://api.sicepat.com/customer/";
- shipping->base = malloc(strlen(url) + 1);
- strcpy(shipping->base, url);
- headers((const char *[]){ "api-key", NULL }, provisions, shipping);
+ shipping.base = malloc(strlen(BASE) + 1);
+ strcpy(shipping.base, BASE);
+ headers((const char *[]){ "api-key", NULL }, provisions);
}
-void sicepat_services(const char *origin, const char *destination, double weight,
- struct shipping *shipping, char **url)
+void sicepat_services(const char *origin, const char *destination, double weight, char **url)
{
- *url = malloc(strlen(shipping->base) + strlen("tariff?origin=") + strlen(origin)
+ *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,
+ sprintf(*url, "%stariff?origin=%s&destination=%s&weight=%f", shipping.base,
origin, destination, weight);
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
}
@@ -32,7 +32,7 @@ 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 *[]){
+ handle(SERVICES, contents, realsize, status_trail, (const char *[]){
"sicepat",
"results",
NULL