LCOV - code coverage report
Current view: top level - challengerdb - pg.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 68.2 % 22 15
Test Date: 2026-06-09 21:00:27 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /*
       2              :   This file is part of Challenger
       3              :   (C) 2023 Taler Systems SA
       4              : 
       5              :   Challenger is free software; you can redistribute it and/or modify it under the
       6              :   terms of the GNU Lesser General Public License as published by the Free Software
       7              :   Foundation; either version 3, or (at your option) any later version.
       8              : 
       9              :   Challenger is distributed in the hope that it will be useful, but WITHOUT ANY
      10              :   WARRANTY; without even the implied warranty of ANASTASISABILITY 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              :   Challenger; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15              : */
      16              : /**
      17              :  * @file challengerdb/plugin_challengerdb_postgres.c
      18              :  * @brief database helper functions for postgres used by challenger
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "platform.h"
      22              : #include <gnunet/gnunet_util_lib.h>
      23              : #include <gnunet/gnunet_db_lib.h>
      24              : #include <gnunet/gnunet_pq_lib.h>
      25              : #include <taler/taler_pq_lib.h>
      26              : #include "challenger_database_lib.h"
      27              : #include "challenger_util.h"
      28              : #include "challenger-database/preflight.h"
      29              : #include "pg_helper.h"
      30              : 
      31              : 
      32              : struct CHALLENGERDB_PostgresContext *
      33           10 : CHALLENGERDB_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
      34              :                       bool skip_preflight)
      35              : {
      36              :   struct CHALLENGERDB_PostgresContext *pg;
      37              : 
      38           10 :   pg = GNUNET_new (struct CHALLENGERDB_PostgresContext);
      39           10 :   pg->cfg = cfg;
      40           10 :   if (GNUNET_OK !=
      41           10 :       GNUNET_CONFIGURATION_get_value_filename (cfg,
      42              :                                                "challengerdb-postgres",
      43              :                                                "SQL_DIR",
      44              :                                                &pg->sql_dir))
      45              :   {
      46            0 :     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
      47              :                                "challengerdb-postgres",
      48              :                                "SQL_DIR");
      49            0 :     GNUNET_free (pg);
      50            0 :     return NULL;
      51              :   }
      52           10 :   if (! skip_preflight)
      53              :   {
      54            6 :     if (GNUNET_OK !=
      55            6 :         CHALLENGERDB_preflight (pg))
      56              :     {
      57            0 :       GNUNET_free (pg->sql_dir);
      58            0 :       GNUNET_free (pg);
      59            0 :       return NULL;
      60              :     }
      61              :   }
      62           10 :   return pg;
      63              : }
      64              : 
      65              : 
      66              : void
      67           10 : CHALLENGERDB_disconnect (struct CHALLENGERDB_PostgresContext *pg)
      68              : {
      69           10 :   if (NULL == pg)
      70            0 :     return;
      71           10 :   if (NULL != pg->conn)
      72            6 :     GNUNET_PQ_disconnect (pg->conn);
      73           10 :   GNUNET_free (pg->sql_dir);
      74           10 :   GNUNET_free (pg);
      75              : }
      76              : 
      77              : 
      78              : /* end of plugin_challengerdb_postgres.c */
        

Generated by: LCOV version 2.0-1