summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-19 12:03:06 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-19 12:03:06 +0800
commitc954ef683bce2217fc81723ba79d0b53b01de2e2 (patch)
treeeab02623190964c3c332bd6e4a6c9475f5c5b3c3
parent39190eb032cc6a8c2fe9d07ca85f712a229c0b69 (diff)
Merge headers into common.h
-rw-r--r--anteraja.c3
-rw-r--r--common.h (renamed from handler.h)17
-rw-r--r--pikul.c3
-rw-r--r--shipping.h19
4 files changed, 19 insertions, 23 deletions
diff --git a/anteraja.c b/anteraja.c
index 81b709a..2037db6 100644
--- a/anteraja.c
+++ b/anteraja.c
@@ -1,5 +1,4 @@
-#include "shipping.h"
-#include "handler.h"
+#include "common.h"
#define SERVICES_PATH "serviceRates"
#define SERVICES_POST \
diff --git a/handler.h b/common.h
index a2c031b..bef5e73 100644
--- a/handler.h
+++ b/common.h
@@ -2,14 +2,31 @@
#include <stdio.h>
#endif
#include <string.h>
+#include <curl/curl.h>
#include <json.h>
#include "pikul.h"
+extern struct shipping {
+ enum pikul_company company;
+ char *base;
+ struct curl_slist *headers;
+} shipping;
extern json_tokener *tokener;
+
void recurse(struct json_object *, const char *[], struct json_object **);
enum type { SERVICES, ORDER };
+inline void headers(const char *fields[], char *provisions[])
+{
+ shipping.headers = NULL;
+ while (*fields) {
+ char header[strlen(*fields) + strlen(*provisions) + 2];
+ sprintf(header, "%s:%s", *fields++, *provisions++);
+ shipping.headers = curl_slist_append(shipping.headers, header);
+ }
+}
+
inline void handle(enum type type, const char *contents, size_t num_bytes, const char *status_trail[],
const char *trail[], const char *attributes[], void *data)
{
diff --git a/pikul.c b/pikul.c
index 636aeb3..bd3a147 100644
--- a/pikul.c
+++ b/pikul.c
@@ -1,5 +1,4 @@
-#include "shipping.h"
-#include "handler.h"
+#include "common.h"
CURL *curl;
json_tokener *tokener;
diff --git a/shipping.h b/shipping.h
deleted file mode 100644
index 37ac20f..0000000
--- a/shipping.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <string.h>
-#include <curl/curl.h>
-#include "pikul.h"
-
-extern struct shipping {
- enum pikul_company company;
- char *base;
- struct curl_slist *headers;
-} shipping;
-
-inline void headers(const char *fields[], char *provisions[])
-{
- shipping.headers = NULL;
- while (*fields) {
- char header[strlen(*fields) + strlen(*provisions) + 2];
- sprintf(header, "%s:%s", *fields++, *provisions++);
- shipping.headers = curl_slist_append(shipping.headers, header);
- }
-}