From 456c2ae04a9242ad4a4a4ced74712d6843da5625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Thu, 19 Sep 2019 11:06:58 +0800 Subject: Move request header file out from the distribution header directory --- client.c | 2 +- request.c | 2 +- request.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ rtclient/request.h | 50 -------------------------------------------------- ticket.c | 2 +- user.c | 2 +- 6 files changed, 54 insertions(+), 54 deletions(-) create mode 100644 request.h delete mode 100644 rtclient/request.h diff --git a/client.c b/client.c index 8e9fed4..ebcc188 100644 --- a/client.c +++ b/client.c @@ -1,5 +1,5 @@ #include -#include "rtclient/request.h" +#include "request.h" #include "rtclient/client.h" CURL *curl = NULL; diff --git a/request.c b/request.c index fe1b8bd..e491349 100644 --- a/request.c +++ b/request.c @@ -1,4 +1,4 @@ -#include "rtclient/request.h" +#include "request.h" extern inline void request(const char *, const char * , size_t (*)(void *, size_t, size_t, void *) diff --git a/request.h b/request.h new file mode 100644 index 0000000..a523610 --- /dev/null +++ b/request.h @@ -0,0 +1,50 @@ +#ifndef RTCLIENT_REQUEST_H +#define RTCLIENT_REQUEST_H + +#ifdef DEBUG +#ifdef ANDROID +#include +#else +#include +#endif // ANDROID +#endif // DEBUG +#include +#include + +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 *) + , 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 +} +#endif // RTCLIENT_REQUEST_H diff --git a/rtclient/request.h b/rtclient/request.h deleted file mode 100644 index a523610..0000000 --- a/rtclient/request.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef RTCLIENT_REQUEST_H -#define RTCLIENT_REQUEST_H - -#ifdef DEBUG -#ifdef ANDROID -#include -#else -#include -#endif // ANDROID -#endif // DEBUG -#include -#include - -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 *) - , 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 -} -#endif // RTCLIENT_REQUEST_H diff --git a/ticket.c b/ticket.c index cd1cd7f..1d42c9a 100644 --- a/ticket.c +++ b/ticket.c @@ -1,5 +1,5 @@ #include -#include "rtclient/request.h" +#include "request.h" #include "rtclient/ticket.h" typedef struct rtclient_ticketlist rtclient_ticketlist; diff --git a/user.c b/user.c index ec97bba..bf08fa4 100644 --- a/user.c +++ b/user.c @@ -1,5 +1,5 @@ #include -#include "rtclient/request.h" +#include "request.h" #include "rtclient/user.h" typedef struct rtclient_user rtclient_user; -- cgit v1.2.3