From 1cbb45492da9a4c5351f3156b00286447a8b014a 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: Sun, 22 Sep 2019 16:19:13 +0800 Subject: Login and logout functions --- icclient/client.h | 10 +++++++--- icclient/request.h | 50 -------------------------------------------------- 2 files changed, 7 insertions(+), 53 deletions(-) delete mode 100644 icclient/request.h (limited to 'icclient') diff --git a/icclient/client.h b/icclient/client.h index 9273987..bea8b51 100644 --- a/icclient/client.h +++ b/icclient/client.h @@ -1,15 +1,19 @@ -#ifndef ICCLIENT_H -#define ICCLIENT_H +#ifndef ICCLIENT_CLIENT_H +#define ICCLIENT_CLIENT_H #ifdef __cplusplus extern "C" { #endif bool icclient_init(const char *url); + void icclient_login(const char *username, const char *password + , const char *successpage, const char *nextpage + , const char *failpage); + void icclient_logout(); void icclient_cleanup(); #ifdef __cplusplus } #endif -#endif // ICCLIENT_H +#endif // ICCLIENT_CLIENT_H diff --git a/icclient/request.h b/icclient/request.h deleted file mode 100644 index 192a154..0000000 --- a/icclient/request.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef ICCLIENT_REQUEST_H -#define ICCLIENT_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 - , size_t (*writefunction)(void *, size_t, size_t, void *) - , void *writedata, struct curl_httppost *post) -{ - char url[strlen(server_url) + strlen(path) + 1]; - sprintf(url, "%s%s", server_url, path); - 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, "libicclient", "%s: %s" - , __func__, error); -#else - fprintf(stderr, "%s: %s\n", __func__, error); -#endif // ANDROID - } -#endif // DEBUG -} -#endif // ICCLIENT_REQUEST_H -- cgit v1.2.3