From 99bd7dc2d2a4e1c35b09c148bd3afb433ef32460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Tue, 4 Oct 2022 17:00:52 +0800 Subject: Template that compiles --- .gitignore | 18 ++++++++++++++++++ COPYING | 20 ++++++++++++++++++++ Makefile.am | 12 ++++++++++++ configure.ac | 21 +++++++++++++++++++++ midtrans.c | 23 +++++++++++++++++++++++ midtrans.h | 15 +++++++++++++++ 6 files changed, 109 insertions(+) create mode 100644 .gitignore create mode 100644 COPYING create mode 100644 Makefile.am create mode 100644 configure.ac create mode 100644 midtrans.c create mode 100644 midtrans.h 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 diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..8b4be80 --- /dev/null +++ b/COPYING @@ -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 +#include +#ifdef __EMSCRIPTEN__ +#include +#else +#include +#endif +#include +#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 -- cgit v1.2.3