1 /* 2 * Copyright (C) 2000 - 2004 Rodrigo Moya <rodrigo@gnome-db.org> 3 * Copyright (C) 2001 - 2011 Vivien Malerba <malerba@gnome-db.org> 4 * Copyright (C) 2002 Gonzalo Paniagua Javier <gonzalo@gnome-db.org> 5 * Copyright (C) 2003 Christian Neumair <cneumair@src.gnome.org> 6 * Copyright (C) 2003 Laurent Sansonetti <lrz@gnome.org> 7 * Copyright (C) 2006 Murray Cumming <murrayc@murrayc.com> 8 * Copyright (C) 2010 David King <davidk@openismus.com> 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the 22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 23 * Boston, MA 02110-1301, USA. 24 */ 25 26 #include <glib/gi18n-lib.h> 27 #include <gmodule.h> 28 #include <libgda/gda-server-provider-extra.h> 29 #include <libgda/binreloc/gda-binreloc.h> 30 #include "gda-bdb.h" 31 #include "gda-bdb-provider.h" 32 33 static gchar *module_path = NULL; 34 const gchar *plugin_get_name (void); 35 const gchar *plugin_get_description (void); 36 gchar *plugin_get_dsn_spec (void); 37 GdaServerProvider *plugin_create_provider (void); 38 39 /* 40 * Functions executed when calling g_module_open() and g_module_close() 41 */ 42 const gchar * 43 g_module_check_init (G_GNUC_UNUSED GModule *module) 44 { 45 /*g_module_make_resident (module);*/ 46 return NULL; 47 } 48 49 void 50 g_module_unload (G_GNUC_UNUSED GModule *module) 51 { 52 g_free (module_path); 53 module_path = NULL; 54 } 55 56 /* 57 * Normal plugin functions 58 */ 59 void 60 plugin_init (const gchar *real_path) 61 { 62 if (real_path) 63 module_path = g_strdup (real_path); 64 } 65 66 const gchar * 67 plugin_get_name (void) 68 { 69 return BDB_PROVIDER_NAME; 70 } 71 72 const gchar * 73 plugin_get_description (void) 74 { 75 return _("Provider for Berkeley databases"); 76 } 77 78 gchar * 79 plugin_get_dsn_spec (void) 80 { 81 gchar *ret, *dir; 82 83 dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL); 84 ret = gda_server_provider_load_file_contents (module_path, dir, "bdb_specs_dsn.xml"); 85 g_free (dir); 86 return ret; 87 } 88 89 gchar * 90 plugin_get_auth_spec (void) 91 { 92 #define AUTH "<?xml version=\"1.0\"?>" \ 93 "<data-set-spec>" \ 94 " <parameters/>" \ 95 "</data-set-spec>" 96 97 return g_strdup (AUTH); 98 } 99 100 GdaServerProvider * 101 plugin_create_provider (void) 102 { 103 GdaServerProvider *prov; 104 105 prov = (GdaServerProvider *) g_object_new (GDA_TYPE_BDB_PROVIDER, NULL); 106 g_object_set_data ((GObject *) prov, "GDA_PROVIDER_DIR", module_path); 107 return prov; 108 } 109