merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

merchantdb_plugin.c (2433B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2015, 2016, 2020 Taler Systems SA
      4 
      5   TALER 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   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 merchantdb_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/taler_util.h>
     24 #include "taler_merchant_util.h"
     25 #include "taler_merchantdb_plugin.h"
     26 #include "taler_merchantdb_lib.h"
     27 #include <ltdl.h>
     28 
     29 
     30 struct TALER_MERCHANTDB_Plugin *
     31 TALER_MERCHANTDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
     32 {
     33   char *plugin_name;
     34   char *lib_name;
     35   struct TALER_MERCHANTDB_Plugin *plugin;
     36 
     37   if (GNUNET_SYSERR ==
     38       GNUNET_CONFIGURATION_get_value_string (cfg,
     39                                              "merchant",
     40                                              "db",
     41                                              &plugin_name))
     42   {
     43     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
     44                                "merchant",
     45                                "db");
     46     return NULL;
     47   }
     48   (void) GNUNET_asprintf (&lib_name,
     49                           "libtaler_plugin_merchantdb_%s",
     50                           plugin_name);
     51   GNUNET_free (plugin_name);
     52   plugin = GNUNET_PLUGIN_load (TALER_MERCHANT_project_data (),
     53                                lib_name,
     54                                (void *) cfg);
     55   if (NULL == plugin)
     56   {
     57     GNUNET_free (lib_name);
     58     return NULL;
     59   }
     60   plugin->library_name = lib_name;
     61   return plugin;
     62 }
     63 
     64 
     65 void
     66 TALER_MERCHANTDB_plugin_unload (struct TALER_MERCHANTDB_Plugin *plugin)
     67 {
     68   char *lib_name;
     69 
     70   if (NULL == plugin)
     71     return;
     72   lib_name = plugin->library_name;
     73   GNUNET_assert (NULL == GNUNET_PLUGIN_unload (lib_name,
     74                                                plugin));
     75   GNUNET_free (lib_name);
     76 }
     77 
     78 
     79 /* end of merchantdb_plugin.c */