summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-14 10:42:33 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-14 10:42:33 +0800
commit03f47c60e7963f24b8fa073abe2ad94cd688fc26 (patch)
tree0dea477977ec8e2e3cf6c9ae18904ba0a073e54b
parent670dc1542e022391737c5fcf01b3cbe8f04c8327 (diff)
Follow a convenient way for inlining request function
https://en.wikipedia.org/wiki/Inline_function#C99
-rw-r--r--Makefile.am4
-rw-r--r--client.c5
-rw-r--r--request.c5
-rw-r--r--rtclient/common.h13
-rw-r--r--rtclient/request.h (renamed from common.c)10
-rw-r--r--ticket.c2
-rw-r--r--user.c2
7 files changed, 20 insertions, 21 deletions
diff --git a/Makefile.am b/Makefile.am
index 731f72f..657de43 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,10 +1,10 @@
noinst_LIBRARIES = librtclient.a
librtclient_a_SOURCES = \
- rtclient/common.h \
+ rtclient/request.h \
rtclient/user.h \
rtclient/ticket.h \
rtclient/rtclient.h \
- common.c \
+ request.c \
user.c \
ticket.c \
client.c
diff --git a/client.c b/client.c
index 6bb3d26..f0bb4c2 100644
--- a/client.c
+++ b/client.c
@@ -1,8 +1,11 @@
#include <stdlib.h>
#include <string.h>
-#include "rtclient/common.h"
+#include "rtclient/request.h"
#include "rtclient/rtclient.h"
+CURL *curl = NULL;
+char *server_url = NULL;
+
bool rtclient_init(const char *url)
{
curl_global_init(CURL_GLOBAL_SSL);
diff --git a/request.c b/request.c
new file mode 100644
index 0000000..fe1b8bd
--- /dev/null
+++ b/request.c
@@ -0,0 +1,5 @@
+#include "rtclient/request.h"
+
+extern inline void request(const char *, const char *
+ , size_t (*)(void *, size_t, size_t, void *)
+ , void *, struct curl_httppost *);
diff --git a/rtclient/common.h b/rtclient/common.h
deleted file mode 100644
index a63a10c..0000000
--- a/rtclient/common.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef RTCLIENT_COMMON_H
-#define RTCLIENT_COMMON_H
-
-#include <curl/curl.h>
-
-extern CURL *curl;
-extern char *server_url;
-
-void request(const char *path, const char *suffix
- , size_t (*writefunction)(void *, size_t, size_t, void *)
- , void *writedata, struct curl_httppost *post);
-
-#endif // RTCLIENT_COMMON_H
diff --git a/common.c b/rtclient/request.h
index 01b8a24..a523610 100644
--- a/common.c
+++ b/rtclient/request.h
@@ -1,3 +1,6 @@
+#ifndef RTCLIENT_REQUEST_H
+#define RTCLIENT_REQUEST_H
+
#ifdef DEBUG
#ifdef ANDROID
#include <android/log.h>
@@ -6,10 +9,10 @@
#endif // ANDROID
#endif // DEBUG
#include <string.h>
-#include "rtclient/common.h"
+#include <curl/curl.h>
-CURL *curl = NULL;
-char *server_url = NULL;
+extern CURL *curl;
+extern char *server_url;
inline void request(const char *path, const char *suffix
, size_t (*writefunction)(void *, size_t, size_t, void *)
@@ -44,3 +47,4 @@ inline void request(const char *path, const char *suffix
}
#endif // DEBUG
}
+#endif // RTCLIENT_REQUEST_H
diff --git a/ticket.c b/ticket.c
index 27bf538..80f122e 100644
--- a/ticket.c
+++ b/ticket.c
@@ -7,7 +7,7 @@
#endif // DEBUG
#include <stdlib.h>
#include <string.h>
-#include "rtclient/common.h"
+#include "rtclient/request.h"
#include "rtclient/ticket.h"
typedef struct rt_ticketlist rt_ticketlist;
diff --git a/user.c b/user.c
index 15aafde..dcd8bb8 100644
--- a/user.c
+++ b/user.c
@@ -7,7 +7,7 @@
#endif // DEBUG
#include <stdlib.h>
#include <string.h>
-#include "rtclient/common.h"
+#include "rtclient/request.h"
#include "rtclient/user.h"
typedef struct rt_user rt_user;