diff options
author | Erik Prabowo Kamal <erik@darapsa.co.id> | 2019-08-27 08:10:42 +0800 |
---|---|---|
committer | Erik Prabowo Kamal <erik@darapsa.co.id> | 2019-08-27 08:10:42 +0800 |
commit | 67486d924802c74056ab5e4ff486fceaa610f271 (patch) | |
tree | 8024bf8ec4367aa3b0ae1f0aadd2732e6bd8c7dd |
Uses libcurl
-rw-r--r-- | rtclient.c | 33 | ||||
-rw-r--r-- | rtclient.h | 15 |
2 files changed, 48 insertions, 0 deletions
diff --git a/rtclient.c b/rtclient.c new file mode 100644 index 0000000..1be0579 --- /dev/null +++ b/rtclient.c @@ -0,0 +1,33 @@ +#ifdef DEBUG +#ifdef ANDROID +#include <android/log.h> +#else +#include <stdio.h> +#endif // ANDROID +#endif // DEBUG +#include <stdbool.h> +#include <curl/curl.h> +#include "rtclient.h" + +static CURL *handle = NULL; + +bool rtclient_init() +{ + curl_global_init(CURL_GLOBAL_SSL); + handle = curl_easy_init(); + if (handle) { + curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L); +#ifdef DEBUG + curl_easy_setopt(handle, CURLOPT_VERBOSE, 1L); +#endif + } + + return (bool)handle; +} + +void rtclient_cleanup() +{ + if (handle) + curl_easy_cleanup(handle); + curl_global_cleanup(); +} diff --git a/rtclient.h b/rtclient.h new file mode 100644 index 0000000..53b8a51 --- /dev/null +++ b/rtclient.h @@ -0,0 +1,15 @@ +#ifndef RTCLIENT_H +#define RTCLIENT_H + +#ifdef __cplusplus +extern "C" { +#endif + + bool rtclient_init(); + void rtclient_cleanup(); + +#ifdef __cplusplus +} +#endif + +#endif // RTCLIENT_H |