plugin_auditordb_postgres.c (1750B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2014-2024 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file plugin_auditordb_postgres.c 18 * @brief Low-level (statement-level) Postgres database access for the auditor 19 * @author Christian Grothoff 20 * @author Gabor X Toth 21 */ 22 #include "taler/taler_pq_lib.h" 23 #include <pthread.h> 24 #include <libpq-fe.h> 25 #include "taler/taler_auditordb_lib.h" 26 #include "pg_helper.h" 27 28 29 struct AUDITORDB_PostgresContext * 30 TALER_AUDITORDB_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 31 bool skip_preflight) 32 { 33 struct AUDITORDB_PostgresContext *pg; 34 35 pg = GNUNET_new (struct AUDITORDB_PostgresContext); 36 pg->cfg = cfg; 37 if (GNUNET_OK != 38 TALER_config_get_currency (cfg, 39 "exchange", 40 &pg->currency)) 41 { 42 GNUNET_free (pg); 43 return NULL; 44 } 45 return pg; 46 } 47 48 49 void 50 TALER_AUDITORDB_disconnect (struct AUDITORDB_PostgresContext *pg) 51 { 52 if (NULL == pg) 53 return; 54 if (NULL != pg->conn) 55 GNUNET_PQ_disconnect (pg->conn); 56 GNUNET_free (pg->currency); 57 GNUNET_free (pg); 58 } 59 60 61 /* end of plugin_auditordb_postgres.c */