From 1d483e2e17efc9fce5e2b3c27fe533e386178e3d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 2 Nov 2022 11:20:53 +0100 Subject: [PATCH] templating helper --- src/exchangedb/Makefile.am | 4 ++++ src/exchangedb/pg_template.c | 26 ++++++++++++++++++++++++++ src/exchangedb/pg_template.h | 29 +++++++++++++++++++++++++++++ src/exchangedb/pg_template.sh | 12 ++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 src/exchangedb/pg_template.c create mode 100644 src/exchangedb/pg_template.h create mode 100755 src/exchangedb/pg_template.sh diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am index f4ea5df9c..39bf4b7d6 100644 --- a/src/exchangedb/Makefile.am +++ b/src/exchangedb/Makefile.am @@ -146,3 +146,7 @@ bench_db_postgres_LDADD = \ EXTRA_test_exchangedb_postgres_DEPENDENCIES = \ libtaler_plugin_exchangedb_postgres.la + +EXTRA_DIST = \ + pg_template.h pg_template.c \ + pg_template.sh diff --git a/src/exchangedb/pg_template.c b/src/exchangedb/pg_template.c new file mode 100644 index 000000000..44878794f --- /dev/null +++ b/src/exchangedb/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 + */ +/** + * @file 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/exchangedb/pg_template.h b/src/exchangedb/pg_template.h new file mode 100644 index 000000000..fe4bdd048 --- /dev/null +++ b/src/exchangedb/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 + */ +/** + * @file 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_exchangedb_plugin.h" + + +#endif diff --git a/src/exchangedb/pg_template.sh b/src/exchangedb/pg_template.sh new file mode 100755 index 000000000..5aa8f8d45 --- /dev/null +++ b/src/exchangedb/pg_template.sh @@ -0,0 +1,12 @@ +#!/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` + 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 "\#include \"pg_$n.h\"" >> hdr.h +done