LCOV - code coverage report
Current view: top level - auditordb - auditordb_plugin.c (source / functions) Hit Total Coverage
Test: rcoverage.info Lines: 16 20 80.0 %
Date: 2017-11-25 11:31:41 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2015, 2016 GNUnet e.V.
       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 auditordb/auditordb_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_auditordb_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_AUDITORDB_Plugin *
      34           4 : TALER_AUDITORDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
      35             : {
      36             :   char *plugin_name;
      37             :   char *lib_name;
      38             :   struct GNUNET_CONFIGURATION_Handle *cfg_dup;
      39             :   struct TALER_AUDITORDB_Plugin *plugin;
      40             : 
      41           4 :   if (GNUNET_SYSERR ==
      42           4 :       GNUNET_CONFIGURATION_get_value_string (cfg,
      43             :                                              "auditor",
      44             :                                              "db",
      45             :                                              &plugin_name))
      46             :   {
      47           0 :     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
      48             :                                "auditor",
      49             :                                "db");
      50           0 :     return NULL;
      51             :   }
      52           4 :   (void) GNUNET_asprintf (&lib_name,
      53             :                           "libtaler_plugin_auditordb_%s",
      54             :                           plugin_name);
      55           4 :   GNUNET_free (plugin_name);
      56           4 :   cfg_dup = GNUNET_CONFIGURATION_dup (cfg);
      57           4 :   plugin = GNUNET_PLUGIN_load (lib_name,
      58             :                                cfg_dup);
      59           4 :   if (NULL != plugin)
      60           4 :     plugin->library_name = lib_name;
      61             :   else
      62           0 :     GNUNET_free (lib_name);
      63           4 :   GNUNET_CONFIGURATION_destroy (cfg_dup);
      64           4 :   return plugin;
      65             : }
      66             : 
      67             : 
      68             : /**
      69             :  * Shutdown the plugin.
      70             :  *
      71             :  * @param plugin the plugin to unload
      72             :  */
      73             : void
      74           4 : TALER_AUDITORDB_plugin_unload (struct TALER_AUDITORDB_Plugin *plugin)
      75             : {
      76             :   char *lib_name;
      77             : 
      78           4 :   if (NULL == plugin)
      79           0 :     return;
      80           4 :   lib_name = plugin->library_name;
      81           4 :   GNUNET_assert (NULL == GNUNET_PLUGIN_unload (lib_name,
      82             :                                                plugin));
      83           4 :   GNUNET_free (lib_name);
      84             : }
      85             : 
      86             : 
      87             : 
      88             : /* end of auditordb_plugin.c */

Generated by: LCOV version 1.13