LCOV - code coverage report
Current view: top level - exchangedb - exchangedb_plugin.c (source / functions) Hit Total Coverage
Test: GNU Taler coverage report Lines: 14 18 77.8 %
Date: 2021-04-12 06:08:44 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          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 "platform.h"
      23             : #include "taler_exchangedb_plugin.h"
      24             : #include <ltdl.h>
      25             : 
      26             : 
      27             : /**
      28             :  * Initialize the plugin.
      29             :  *
      30             :  * @param cfg configuration to use
      31             :  * @return #GNUNET_OK on success
      32             :  */
      33             : struct TALER_EXCHANGEDB_Plugin *
      34          71 : TALER_EXCHANGEDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
      35             : {
      36             :   char *plugin_name;
      37             :   char *lib_name;
      38             :   struct TALER_EXCHANGEDB_Plugin *plugin;
      39             : 
      40          71 :   if (GNUNET_SYSERR ==
      41          71 :       GNUNET_CONFIGURATION_get_value_string (cfg,
      42             :                                              "exchange",
      43             :                                              "db",
      44             :                                              &plugin_name))
      45             :   {
      46           0 :     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
      47             :                                "exchange",
      48             :                                "db");
      49           0 :     return NULL;
      50             :   }
      51          71 :   GNUNET_asprintf (&lib_name,
      52             :                    "libtaler_plugin_exchangedb_%s",
      53             :                    plugin_name);
      54          71 :   GNUNET_free (plugin_name);
      55          71 :   plugin = GNUNET_PLUGIN_load (lib_name,
      56             :                                (void *) cfg);
      57          71 :   if (NULL != plugin)
      58          71 :     plugin->library_name = lib_name;
      59             :   else
      60           0 :     GNUNET_free (lib_name);
      61          71 :   return plugin;
      62             : }
      63             : 
      64             : 
      65             : /**
      66             :  * Shutdown the plugin.
      67             :  *
      68             :  * @param plugin the plugin to unload
      69             :  */
      70             : void
      71          70 : TALER_EXCHANGEDB_plugin_unload (struct TALER_EXCHANGEDB_Plugin *plugin)
      72             : {
      73             :   char *lib_name;
      74             : 
      75          70 :   if (NULL == plugin)
      76           0 :     return;
      77          70 :   lib_name = plugin->library_name;
      78          70 :   GNUNET_assert (NULL == GNUNET_PLUGIN_unload (lib_name,
      79             :                                                plugin));
      80          70 :   GNUNET_free (lib_name);
      81             : }
      82             : 
      83             : 
      84             : /* end of exchangedb_plugin.c */

Generated by: LCOV version 1.14