From 9c26a7ea4265b6f372ba40ea5fcb6fc440538813 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: Sun, 27 Jun 2021 23:51:46 +0800 Subject: Make headers function inline --- Makefile.am | 2 +- pikul.c | 1 + shipping.c | 12 ------------ shipping.h | 11 ++++++++++- 4 files changed, 12 insertions(+), 14 deletions(-) delete mode 100644 shipping.c diff --git a/Makefile.am b/Makefile.am index 5d8f4d7..f5a691e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ lib_LTLIBRARIES = libpikul.la -libpikul_la_SOURCES = pikul.c shipping.c handler.c \ +libpikul_la_SOURCES = pikul.c handler.c \ anteraja.c libpikul_la_CPPFLAGS = $(DEPS_CFLAGS) libpikul_la_LDFLAGS = $(DEPS_LIBS) diff --git a/pikul.c b/pikul.c index b13d64a..f078449 100644 --- a/pikul.c +++ b/pikul.c @@ -6,6 +6,7 @@ CURL *curl; json_tokener *tokener; static struct shipping shipping; +extern inline void headers(struct shipping *shipping, const char *fields[], char *provisions[]); extern void anteraja_init(char *[], struct shipping *); extern void anteraja_services_request(const char *, const char *, double, struct shipping *, char **, char **); diff --git a/shipping.c b/shipping.c deleted file mode 100644 index f2e263c..0000000 --- a/shipping.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include "shipping.h" - -void headers(struct shipping *shipping, 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); - } -} diff --git a/shipping.h b/shipping.h index 345eaef..dc7d7df 100644 --- a/shipping.h +++ b/shipping.h @@ -1,3 +1,4 @@ +#include #include #include "pikul.h" @@ -7,4 +8,12 @@ struct shipping { struct curl_slist *headers; }; -void headers(struct shipping *, const char *[], char *[]); +inline void headers(struct shipping *shipping, 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); + } +} -- cgit v1.2.3