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) 2004 Jeronimo Albi <jeronimoalbi@yahoo.com.ar>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20  * Boston, MA  02110-1301, USA.
21  */
22 
23 #include <glib/gi18n-lib.h>
24 #include <gmodule.h>
25 #include <libgda/gda-server-provider-extra.h>
26 #include <libgda/binreloc/gda-binreloc.h>
27 #include "gda-firebird.h"
28 #include "gda-firebird-provider.h"
29 
30 static gchar      *module_path = NULL;
31 const gchar       *plugin_get_name (void);
32 const gchar       *plugin_get_description (void);
main(int,char **)33 gchar             *plugin_get_dsn_spec (void);
34 GdaServerProvider *plugin_create_provider (void);
35 
36 /*
37  * Functions executed when calling g_module_open() and g_module_close()
38  */
39 const gchar *
40 g_module_check_init (G_GNUC_UNUSED GModule *module)
41 {
42         /*g_module_make_resident (module);*/
43         return NULL;
44 }
45 
46 void
47 g_module_unload (G_GNUC_UNUSED GModule *module)
48 {
49         g_free (module_path);
50         module_path = NULL;
51 }
52 
53 void
54 plugin_init (const gchar *real_path)
55 {
56         if (real_path)
57                 module_path = g_strdup (real_path);
58 }
59 
60 const gchar *
61 plugin_get_name (void)
62 {
63 	return FIREBIRD_PROVIDER_NAME;
64 }
65 
66 const gchar *
67 plugin_get_description (void)
68 {
69 	return _("Provider for Firebird databases");
70 }
71 
72 gchar *
73 plugin_get_dsn_spec (void)
74 {
75 	gchar *ret, *dir;
76 
77 	dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
78 	ret = gda_server_provider_load_file_contents (module_path, dir, "firebird_specs_dsn.xml");
79 	g_free (dir);
80 	return ret;
81 }
82 
83 GdaServerProvider *
84 plugin_create_provider (void)
85 {
86 	GdaServerProvider *prov;
87 
88 	prov = (GdaServerProvider*) g_object_new (GDA_TYPE_FIREBIRD_PROVIDER, NULL);
89         g_object_set_data ((GObject *) prov, "GDA_PROVIDER_DIR", module_path);
90         return prov;
91 }
92