diff options
author | Erik Prabowo Kamal <erik@darapsa.co.id> | 2019-08-23 15:36:18 +0800 |
---|---|---|
committer | Erik Prabowo Kamal <erik@darapsa.co.id> | 2019-08-23 15:36:18 +0800 |
commit | f14878b05ee885f1747feab256011b4da72ae778 (patch) | |
tree | e9415590ecccaa1fe30b20a49f418990d650302f /rtclient.c | |
parent | c592064dda137e81cee7a421bb68fa83535542bd (diff) |
Started to use cURL
Diffstat (limited to 'rtclient.c')
-rw-r--r-- | rtclient.c | 33 |
1 files changed, 33 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(); +} |