aboutsummaryrefslogtreecommitdiff
path: root/src/auditordb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-11-02 12:17:05 +0100
committerChristian Grothoff <christian@grothoff.org>2022-11-02 12:17:05 +0100
commit821c87ccbddbb7b0d0896f350de0a671f210ae40 (patch)
tree39b3f7c8294ea60c436730d9d2bcaa5ec97eeab0 /src/auditordb
parent1d483e2e17efc9fce5e2b3c27fe533e386178e3d (diff)
clean up exchange DB logic a bit, add missing function
Diffstat (limited to 'src/auditordb')
-rw-r--r--src/auditordb/Makefile.am12
-rw-r--r--src/auditordb/pg_template.c26
-rw-r--r--src/auditordb/pg_template.h29
-rwxr-xr-xsrc/auditordb/pg_template.sh21
-rw-r--r--src/auditordb/plugin_auditordb_postgres.c26
5 files changed, 113 insertions, 1 deletions
diff --git a/src/auditordb/Makefile.am b/src/auditordb/Makefile.am
index 7ca168d01..d00c4fb23 100644
--- a/src/auditordb/Makefile.am
+++ b/src/auditordb/Makefile.am
@@ -23,7 +23,9 @@ EXTRA_DIST = \
auditordb-postgres.conf \
test-auditor-db-postgres.conf \
$(sql_DATA) \
- 9999.sql
+ 9999.sql \
+ pg_template.h pg_template.c \
+ pg_template.sh
plugindir = $(libdir)/taler
@@ -83,6 +85,14 @@ libtaler_plugin_auditordb_postgres_la_SOURCES = \
pg_delete_exchange.h pg_delete_exchange.c \
pg_insert_exchange_signkey.h pg_insert_exchange_signkey.c \
pg_insert_deposit_confirmation.h pg_insert_deposit_confirmation.c \
+ pg_get_purse_info.h pg_get_purse_info.c \
+ pg_delete_purse_info.h pg_delete_purse_info.c \
+ pg_update_purse_info.h pg_update_purse_info.c \
+ pg_insert_purse_info.h pg_insert_purse_info.c \
+ pg_get_purse_summary.h pg_get_purse_summary.c \
+ pg_select_purse_expired.h pg_select_purse_expired.c \
+ pg_insert_purse_summary.h pg_insert_purse_summary.c \
+ pg_update_purse_summary.h pg_update_purse_summary.c \
pg_get_deposit_confirmations.h pg_get_deposit_confirmations.c
libtaler_plugin_auditordb_postgres_la_LIBADD = \
$(LTLIBINTL)
diff --git a/src/auditordb/pg_template.c b/src/auditordb/pg_template.c
new file mode 100644
index 000000000..3e9cb642e
--- /dev/null
+++ b/src/auditordb/pg_template.c
@@ -0,0 +1,26 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2022 Taler Systems SA
+
+ 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/>
+ */
+/**
+ * @file auditordb/pg_template.c
+ * @brief Implementation of the template function for Postgres
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "taler_error_codes.h"
+#include "taler_dbevents.h"
+#include "taler_pq_lib.h"
+#include "pg_template.h"
+#include "pg_helper.h"
diff --git a/src/auditordb/pg_template.h b/src/auditordb/pg_template.h
new file mode 100644
index 000000000..acada6059
--- /dev/null
+++ b/src/auditordb/pg_template.h
@@ -0,0 +1,29 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2022 Taler Systems SA
+
+ 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/>
+ */
+/**
+ * @file auditordb/pg_template.h
+ * @brief implementation of the template function for Postgres
+ * @author Christian Grothoff
+ */
+#ifndef PG_TEMPLATE_H
+#define PG_TEMPLATE_H
+
+#include "taler_util.h"
+#include "taler_json_lib.h"
+#include "taler_auditordb_plugin.h"
+
+
+#endif
diff --git a/src/auditordb/pg_template.sh b/src/auditordb/pg_template.sh
new file mode 100755
index 000000000..73bd7e989
--- /dev/null
+++ b/src/auditordb/pg_template.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# This file is in the public domain.
+#
+# Instantiates pg_template for a particular function.
+
+for n in $*
+do
+ NCAPS=`echo $n | tr a-z A-Z`
+ if test ! -e pg_$n.c
+ then
+ cat pg_template.c | sed -e s/template/$n/g -e s/TEMPLATE/$NCAPS/g > pg_$n.c
+ cat pg_template.h | sed -e s/template/$n/g -e s/TEMPLATE/$NCAPS/g > pg_$n.h
+ echo " plugin->$n\n = &TEH_PG_$n;" >> tmpl.c
+ echo "#include \"pg_$n.h\"" >> tmpl.inc
+ echo " pg_$n.h pg_$n.c \\" >> tmpl.am
+ fi
+done
+
+echo "Add lines from tmpl.am to Makefile.am"
+echo "Add lines from tmpl.inc to plugin_exchangedb_postgres.c at the beginning"
+echo "Add lines from tmpl.c to plugin_exchangedb_postgres.c at the end"
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c
index 2a6f200cc..64c7b5033 100644
--- a/src/auditordb/plugin_auditordb_postgres.c
+++ b/src/auditordb/plugin_auditordb_postgres.c
@@ -87,6 +87,14 @@
#include "pg_get_wire_auditor_progress.h"
#include "pg_insert_historic_reserve_revenue.h"
#include "pg_helper.h"
+#include "pg_get_purse_info.h"
+#include "pg_delete_purse_info.h"
+#include "pg_update_purse_info.h"
+#include "pg_insert_purse_info.h"
+#include "pg_get_purse_summary.h"
+#include "pg_select_purse_expired.h"
+#include "pg_insert_purse_summary.h"
+#include "pg_update_purse_summary.h"
#define LOG(kind,...) GNUNET_log_from (kind, "taler-auditordb-postgres", \
__VA_ARGS__)
@@ -508,6 +516,24 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
= &TAH_PG_update_predicted_result;
plugin->insert_predicted_result
= &TAH_PG_insert_predicted_result;
+ plugin->get_purse_info
+ = &TEH_PG_get_purse_info;
+
+ plugin->delete_purse_info
+ = &TEH_PG_delete_purse_info;
+ plugin->update_purse_info
+ = &TEH_PG_update_purse_info;
+ plugin->insert_purse_info
+ = &TEH_PG_insert_purse_info;
+ plugin->get_purse_summary
+ = &TEH_PG_get_purse_summary;
+
+ plugin->select_purse_expired
+ = &TEH_PG_select_purse_expired;
+ plugin->insert_purse_summary
+ = &TEH_PG_insert_purse_summary;
+ plugin->update_purse_summary
+ = &TEH_PG_update_purse_summary;
return plugin;
}