diff options
-rw-r--r-- | .gitignore | 18 | ||||
-rw-r--r-- | COPYING | 20 | ||||
-rw-r--r-- | Makefile.am | 12 | ||||
-rw-r--r-- | configure.ac | 21 | ||||
-rw-r--r-- | midtrans.c | 23 | ||||
-rw-r--r-- | midtrans.h | 15 |
6 files changed, 109 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..183ed07 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +*~ +*.swp +Makefile.in +aclocal.m4 +ar-lib +autom4te.cache +autoscan*.log +build +compile +config.guess +config.sub +configure +configure.scan +depcomp +install-sh +libtool +ltmain.sh +missing @@ -0,0 +1,20 @@ +Copyright (c) 2022 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..5ed6aa5 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,12 @@ +lib_LTLIBRARIES = libmidtrans.la +libmidtrans_la_SOURCES = midtrans.c +libmidtrans_la_CPPFLAGS = $(JSON_CFLAGS) +if IOS +libmidtrans_la_LDFLAGS = -static +endif +if WASM +libmidtrans_la_LDFLAGS = -static +else +libmidtrans_la_CPPFLAGS += $(CURL_CFLAGS) +endif +include_HEADERS = midtrans.h diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..9855fdf --- /dev/null +++ b/configure.ac @@ -0,0 +1,21 @@ +AC_INIT([midtrans], [0.0], [prabowo@darapsa.org]) +AM_INIT_AUTOMAKE([-Wall -Werror foreign]) +AC_PROG_CC +AM_PROG_AR +LT_INIT +PKG_CHECK_MODULES([JSON], [json-c]) +AC_CANONICAL_HOST +case $host in + *arm*apple-darwin1* ) ios=true;; + *) ios=false;; +esac +AM_CONDITIONAL([IOS], [test "x$ios" = xtrue]) +case $host_cpu in + *wasm* ) wasm=true;; + *) wasm=false;; +esac +AM_CONDITIONAL([WASM], [test "x$wasm" = xtrue]) +AS_IF([test "x$wasm" != xtrue], + [PKG_CHECK_MODULES([CURL], [libcurl])]) +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/midtrans.c b/midtrans.c new file mode 100644 index 0000000..590aa21 --- /dev/null +++ b/midtrans.c @@ -0,0 +1,23 @@ +#include <stdio.h> +#include <string.h> +#ifdef __EMSCRIPTEN__ +#include <emscripten/fetch.h> +#else +#include <curl/curl.h> +#endif +#include <json.h> +#include "midtrans.h" + +void midtrans_init(const char *certificate) +{ +#ifndef __EMSCRIPTEN__ + curl_global_init(CURL_GLOBAL_SSL); +#endif +} + +void midtrans_cleanup() +{ +#ifndef __EMSCRIPTEN__ + curl_global_cleanup(); +#endif +} diff --git a/midtrans.h b/midtrans.h new file mode 100644 index 0000000..4c8fbde --- /dev/null +++ b/midtrans.h @@ -0,0 +1,15 @@ +#ifndef MIDTRANS_H +#define MIDTRANS_H + +#ifdef __cplusplus +extern "C" { +#endif + +void midtrans_init(const char *certificate); +void midtrans_cleanup(); + +#ifdef __cplusplus +} +#endif + +#endif |