LCOV - code coverage report
Current view: top level - exchangedb - exchangedb_plugin.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 66.7 % 24 16
Test Date: 2025-12-22 22:38:17 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /*
       2              :   This file is part of TALER
       3              :   Copyright (C) 2015 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 exchangedb/exchangedb_plugin.c
      18              :  * @brief Logic to load database plugin
      19              :  * @author Christian Grothoff
      20              :  * @author Sree Harsha Totakura <sreeharsha@totakura.in>
      21              :  */
      22              : #include "taler/platform.h"
      23              : #include "taler/taler_exchangedb_lib.h"
      24              : #include <ltdl.h>
      25              : 
      26              : 
      27              : struct TALER_EXCHANGEDB_Plugin *
      28          229 : TALER_EXCHANGEDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg,
      29              :                               bool skip_preflight)
      30              : {
      31              :   char *plugin_name;
      32              :   char *lib_name;
      33              :   struct TALER_EXCHANGEDB_Plugin *plugin;
      34              : 
      35          229 :   if (GNUNET_OK !=
      36          229 :       GNUNET_CONFIGURATION_get_value_string (cfg,
      37              :                                              "exchange",
      38              :                                              "db",
      39              :                                              &plugin_name))
      40              :   {
      41            0 :     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
      42              :                                "exchange",
      43              :                                "db");
      44            0 :     return NULL;
      45              :   }
      46          229 :   GNUNET_asprintf (&lib_name,
      47              :                    "libtaler_plugin_exchangedb_%s",
      48              :                    plugin_name);
      49          229 :   GNUNET_free (plugin_name);
      50          229 :   plugin = GNUNET_PLUGIN_load (TALER_EXCHANGE_project_data (),
      51              :                                lib_name,
      52              :                                (void *) cfg);
      53          229 :   if (NULL == plugin)
      54              :   {
      55            0 :     GNUNET_free (lib_name);
      56            0 :     return NULL;
      57              :   }
      58          229 :   plugin->library_name = lib_name;
      59          437 :   if ( (! skip_preflight) &&
      60              :        (GNUNET_OK !=
      61          208 :         plugin->preflight (plugin->cls)) )
      62              :   {
      63            0 :     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
      64              :                 "Database not ready. Try running taler-exchange-dbinit!\n");
      65            0 :     TALER_EXCHANGEDB_plugin_unload (plugin);
      66            0 :     return NULL;
      67              :   }
      68          229 :   return plugin;
      69              : }
      70              : 
      71              : 
      72              : void
      73          229 : TALER_EXCHANGEDB_plugin_unload (struct TALER_EXCHANGEDB_Plugin *plugin)
      74              : {
      75              :   char *lib_name;
      76              : 
      77          229 :   if (NULL == plugin)
      78            0 :     return;
      79          229 :   lib_name = plugin->library_name;
      80          229 :   GNUNET_assert (NULL == GNUNET_PLUGIN_unload (lib_name,
      81              :                                                plugin));
      82          229 :   GNUNET_free (lib_name);
      83              : }
      84              : 
      85              : 
      86              : /* end of exchangedb_plugin.c */
        

Generated by: LCOV version 2.0-1