diff options
| author | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-09-14 10:42:33 +0800 |
|---|---|---|
| committer | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-09-14 10:42:33 +0800 |
| commit | 03f47c60e7963f24b8fa073abe2ad94cd688fc26 (patch) | |
| tree | 0dea477977ec8e2e3cf6c9ae18904ba0a073e54b /common.c | |
| parent | 670dc1542e022391737c5fcf01b3cbe8f04c8327 (diff) | |
Follow a convenient way for inlining request function
https://en.wikipedia.org/wiki/Inline_function#C99
Diffstat (limited to 'common.c')
| -rw-r--r-- | common.c | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/common.c b/common.c deleted file mode 100644 index 01b8a24..0000000 --- a/common.c +++ /dev/null @@ -1,46 +0,0 @@ -#ifdef DEBUG -#ifdef ANDROID -#include <android/log.h> -#else -#include <stdio.h> -#endif // ANDROID -#endif // DEBUG -#include <string.h> -#include "rtclient/common.h" - -CURL *curl = NULL; -char *server_url = NULL; - -inline void request(const char *path, const char *suffix - , size_t (*writefunction)(void *, size_t, size_t, void *) - , void *writedata, struct curl_httppost *post) -{ - char url[strlen(server_url) + strlen(path) + strlen(suffix) + 1]; - sprintf(url, "%s%s%s", server_url, path, suffix); - curl_easy_setopt(curl, CURLOPT_URL, url); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunction); - if (writedata) - curl_easy_setopt(curl, CURLOPT_WRITEDATA, writedata); - else - curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); - if (post) - curl_easy_setopt(curl, CURLOPT_HTTPPOST, post); - else - curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L); - -#ifdef DEBUG - CURLcode res = -#endif // DEBUG - curl_easy_perform(curl); -#ifdef DEBUG - if (res != CURLE_OK) { - const char *error = curl_easy_strerror(res); -#ifdef ANDROID - __android_log_print(ANDROID_LOG_ERROR, "librtclient", "%s: %s" - , __func__, error); -#else - fprintf(stderr, "%s: %s\n", __func__, error); -#endif // ANDROID - } -#endif // DEBUG -} |