summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-11-13 15:01:09 +0100
committerChristian Grothoff <christian@grothoff.org>2019-11-13 15:01:09 +0100
commitc8047726772c2f4a18a6b0ebc7ce879bf260860a (patch)
treea6bab2e9a42c72a720c893b9c2505077067e6bfc /src/include
downloadsync-c8047726772c2f4a18a6b0ebc7ce879bf260860a.tar.gz
sync-c8047726772c2f4a18a6b0ebc7ce879bf260860a.tar.bz2
sync-c8047726772c2f4a18a6b0ebc7ce879bf260860a.zip
skeleton
Diffstat (limited to 'src/include')
-rw-r--r--src/include/Makefile.am10
-rw-r--r--src/include/platform.h60
-rw-r--r--src/include/sync_database_lib.h46
-rw-r--r--src/include/sync_database_plugin.h117
-rw-r--r--src/include/sync_service.h64
5 files changed, 297 insertions, 0 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
new file mode 100644
index 0000000..abcbfe9
--- /dev/null
+++ b/src/include/Makefile.am
@@ -0,0 +1,10 @@
+# This Makefile.am is in the public domain
+EXTRA_DIST = \
+ platform.h
+
+talerincludedir = $(includedir)/taler
+
+talerinclude_HEADERS = \
+ sync_database_plugin.h \
+ sync_service.h \
+ sync_database_lib.h
diff --git a/src/include/platform.h b/src/include/platform.h
new file mode 100644
index 0000000..b17c64f
--- /dev/null
+++ b/src/include/platform.h
@@ -0,0 +1,60 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014, 2015, 2016 GNUnet e.V. and INRIA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+
+/**
+ * @file include/platform.h
+ * @brief This file contains the includes and definitions which are used by the
+ * rest of the modules
+ * @author Sree Harsha Totakura <sreeharsha@totakura.in>
+ */
+
+#ifndef PLATFORM_H_
+#define PLATFORM_H_
+
+/* Include our configuration header */
+#ifndef HAVE_USED_CONFIG_H
+# define HAVE_USED_CONFIG_H
+# ifdef HAVE_CONFIG_H
+# include "sync_config.h"
+# endif
+#endif
+
+
+#if (GNUNET_EXTRA_LOGGING >= 1)
+#define VERBOSE(cmd) cmd
+#else
+#define VERBOSE(cmd) do { break; } while (0)
+#endif
+
+/* Include the features available for GNU source */
+#define _GNU_SOURCE
+
+/* Include GNUnet's platform file */
+#include <gnunet/platform.h>
+
+/* Do not use shortcuts for gcrypt mpi */
+#define GCRYPT_NO_MPI_MACROS 1
+
+/* Do not use deprecated functions from gcrypt */
+#define GCRYPT_NO_DEPRECATED 1
+
+/* Ignore MHD deprecations for now as we want to be compatible
+ to "ancient" MHD releases. */
+#define MHD_NO_DEPRECATION 1
+
+#endif /* PLATFORM_H_ */
+
+/* end of platform.h */
diff --git a/src/include/sync_database_lib.h b/src/include/sync_database_lib.h
new file mode 100644
index 0000000..2a67ec3
--- /dev/null
+++ b/src/include/sync_database_lib.h
@@ -0,0 +1,46 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2017 Inria & GNUnet e.V.
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ *
+ */
+#ifndef SYNC_DB_LIB_H
+#define SYNC_DB_LIB_H
+
+#include <taler/taler_util.h>
+#include "sync_database_plugin.h"
+
+/**
+ * Initialize the plugin.
+ *
+ * @param cfg configuration to use
+ * @return NULL on failure
+ */
+struct SYNC_DatabasePlugin *
+SYNC_DB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg);
+
+
+/**
+ * Shutdown the plugin.
+ *
+ * @param plugin plugin to unload
+ */
+void
+SYNC_DB_plugin_unload (struct SYNC_DatabasePlugin *plugin);
+
+
+#endif /* SYNC_DB_LIB_H */
+
+/* end of sync_database_lib.h */
diff --git a/src/include/sync_database_plugin.h b/src/include/sync_database_plugin.h
new file mode 100644
index 0000000..5563cf3
--- /dev/null
+++ b/src/include/sync_database_plugin.h
@@ -0,0 +1,117 @@
+/*
+ This file is part of Sync
+ Copyright (C) 2019 Taler Systems SA
+
+ Sync is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ Sync is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ Sync; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/sync_database_plugin.h
+ * @brief database access for Sync
+ * @author Christian Grothoff
+ */
+#ifndef TALER_SYNC_DATABASE_PLUGIN_H
+#define TALER_SYNC_DATABASE_PLUGIN_H
+
+#include <gnunet/gnunet_util_lib.h>
+#include <sync_error_codes.h>
+#include "sync_service.h"
+#include <jansson.h>
+#include <taler/taler_util.h>
+
+/**
+ * Handle to interact with the database.
+ *
+ * Functions ending with "_TR" run their OWN transaction scope
+ * and MUST NOT be called from within a transaction setup by the
+ * caller. Functions ending with "_NT" require the caller to
+ * setup a transaction scope. Functions without a suffix are
+ * simple, single SQL queries that MAY be used either way.
+ */
+struct SYNC_DatabasePlugin
+{
+
+ /**
+ * Closure for all callbacks.
+ */
+ void *cls;
+
+ /**
+ * Name of the library which generated this plugin. Set by the
+ * plugin loader.
+ */
+ char *library_name;
+
+ /**
+ * Drop sync tables. Used for testcases.
+ *
+ * @param cls closure
+ * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
+ */
+ int
+ (*drop_tables) (void *cls);
+
+ /**
+ * Function called to perform "garbage collection" on the
+ * database, expiring records we no longer require. Deletes
+ * all user records that are not paid up (and by cascade deletes
+ * the associated recovery documents). Also deletes expired
+ * truth and financial records older than @a fin_expire.
+ *
+ * @param cls closure
+ * @param fin_expire financial records older than the given
+ * time stamp should be garbage collected (usual
+ * values might be something like 6-10 years in the past)
+ * @return transaction status
+ */
+ enum SYNC_DB_QueryStatus
+ (*gc)(void *cls,
+ struct GNUNET_TIME_Absolute fin_expire);
+
+ /**
+ * Do a pre-flight check that we are not in an uncommitted transaction.
+ * If we are, try to commit the previous transaction and output a warning.
+ * Does not return anything, as we will continue regardless of the outcome.
+ *
+ * @param cls the `struct PostgresClosure` with the plugin-specific state
+ */
+ void
+ (*preflight) (void *cls);
+
+ /**
+ * Check that the database connection is still up.
+ *
+ * @param pg connection to check
+ */
+ void
+ (*check_connection) (void *cls);
+
+ /**
+ * Store backup.
+ *
+ * @param cls closure
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*store_backup)(void *cls,
+ ...);
+
+ /**
+ * Obtain backup.
+ *
+ * @param cls closure
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_backup)(void *cls,
+ ...);
+
+};
+#endif
diff --git a/src/include/sync_service.h b/src/include/sync_service.h
new file mode 100644
index 0000000..efe46fe
--- /dev/null
+++ b/src/include/sync_service.h
@@ -0,0 +1,64 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2019 Taler Systems SA
+
+ Anastasis is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ Anastasis; see the file COPYING.LIB. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/sync_service.h
+ * @brief C interface of libsync, a C library to use sync's HTTP API
+ * @author Christian Grothoff
+ */
+#ifndef _SYNC_SERVICE_H
+#define _SYNC_SERVICE_H
+
+#include <gnunet/gnunet_curl_lib.h>
+#include <jansson.h>
+
+
+/**
+ * An EdDSA public key that is used to identify a user's account.
+ */
+struct SYNC_AccountPubP
+{
+ struct GNUNET_CRYPTO_EddsaPublicKey pub;
+};
+
+
+struct SYNC_UploadOperation;
+
+struct SYNC_UploadOperation *
+SYNC_upload (struct GNUNET_CURL_Context *ctx,
+ const char *base_url,
+ ...);
+
+
+void
+SYNC_upload_cancel (struct SYNC_UploadOperation *uo);
+
+
+
+struct SYNC_DownloadOperation;
+
+struct SYNC_DownloadOperation *
+SYNC_download (struct GNUNET_CURL_Context *ctx,
+ const char *base_url,
+ ...);
+
+
+void
+SYNC_download_cancel (struct SYNC_DownloadOperation *uo);
+
+
+
+
+#endif /* _SYNC_SERVICE_H */