summaryrefslogtreecommitdiff
path: root/client.c
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-16 20:19:31 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-16 20:20:53 +0800
commit47be7ba91f07acb7bf88b66fc706ee6b4add69bd (patch)
treeb39b02a576df5ccffa22ae966b637f1e43cbc308 /client.c
Takes the server URL as a parameter
Diffstat (limited to 'client.c')
-rw-r--r--client.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/client.c b/client.c
new file mode 100644
index 0000000..2213ebf
--- /dev/null
+++ b/client.c
@@ -0,0 +1,34 @@
+#include <stdbool.h>
+#include <string.h>
+#include <stdlib.h>
+#include <curl/curl.h>
+#include "icclient/client.h"
+
+CURL *curl = NULL;
+char *server_url = NULL;
+
+bool icclient_init(const char *url)
+{
+ curl_global_init(CURL_GLOBAL_SSL);
+ curl = curl_easy_init();
+ if (curl) {
+ curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
+ curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
+#ifdef DEBUG
+ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+#endif
+ server_url = malloc(strlen(url) + 1);
+ strcpy(server_url, url);
+ }
+
+ return (bool)curl;
+}
+
+void icclient_cleanup()
+{
+ if (curl) {
+ free(server_url);
+ curl_easy_cleanup(curl);
+ }
+ curl_global_cleanup();
+}