donaudb_plugin.c (2205B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2024 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 donaudb/donaudb_plugin.c 18 * @brief Logic to load database plugin 19 * @author Johannes Casaburi 20 */ 21 #include "donau_config.h" 22 #include "donau_util.h" 23 #include "donaudb_lib.h" 24 #include "donaudb_plugin.h" 25 #include <ltdl.h> 26 27 28 struct DONAUDB_Plugin * 29 DONAUDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg) 30 { 31 char *plugin_name; 32 char *lib_name; 33 struct DONAUDB_Plugin *plugin; 34 35 if (GNUNET_SYSERR == 36 GNUNET_CONFIGURATION_get_value_string (cfg, 37 "donau", 38 "db", 39 &plugin_name)) 40 { 41 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 42 "donau", 43 "db"); 44 return NULL; 45 } 46 GNUNET_asprintf (&lib_name, 47 "libdonau_plugin_donaudb_%s", 48 plugin_name); 49 GNUNET_free (plugin_name); 50 plugin = GNUNET_PLUGIN_load (DONAU_project_data (), 51 lib_name, 52 (void *) cfg); 53 if (NULL != plugin) 54 plugin->library_name = lib_name; 55 else 56 GNUNET_free (lib_name); 57 return plugin; 58 } 59 60 61 void 62 DONAUDB_plugin_unload (struct DONAUDB_Plugin *plugin) 63 { 64 char *lib_name; 65 66 if (NULL == plugin) 67 return; 68 lib_name = plugin->library_name; 69 GNUNET_assert (NULL == GNUNET_PLUGIN_unload (lib_name, 70 plugin)); 71 GNUNET_free (lib_name); 72 } 73 74 75 /* end of donaudb_plugin.c */