summaryrefslogtreecommitdiff
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
Takes the server URL as a parameter
-rw-r--r--.gitignore21
-rw-r--r--COPYING20
-rw-r--r--Makefile.am4
-rw-r--r--client.c34
-rw-r--r--configure.ac9
-rw-r--r--icclient/client.h15
6 files changed, 103 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f3cf82c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,21 @@
+*~
+*.a
+*.o
+*.swp
+.deps
+Makefile
+Makefile.am.user
+Makefile.in
+aclocal.m4
+ar-lib
+autom4te.cache
+compile
+config.h
+config.h.in
+config.log
+config.status
+configure
+depcomp
+install-sh
+missing
+stamp-h1
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..086fa3c
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,20 @@
+Copyright (c) 2019 Erik Prabowo Kamal
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..942a013
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,4 @@
+noinst_LIBRARIES = libicclient.a
+libicclient_a_SOURCES = \
+ icclient/client.h \
+ client.c
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();
+}
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..84a8f08
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,9 @@
+AC_INIT([libicclient], [0.0], [rt@darapsa.co.id])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign])
+AC_PROG_CC
+AC_PROG_RANLIB
+AM_PROG_AR
+AC_CONFIG_HEADERS([config.h])
+AC_CHECK_HEADER_STDBOOL
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/icclient/client.h b/icclient/client.h
new file mode 100644
index 0000000..9273987
--- /dev/null
+++ b/icclient/client.h
@@ -0,0 +1,15 @@
+#ifndef ICCLIENT_H
+#define ICCLIENT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ bool icclient_init(const char *url);
+ void icclient_cleanup();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ICCLIENT_H