1 /*
2  * Copyright (C) 2009 - 2011 Vivien Malerba <malerba@gnome-db.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  */
19 
20 #include <string.h>
21 #include "reuse-all.h"
22 
23 #include "postgres/gda-postgres-reuseable.h"
24 #include "mysql/gda-mysql-reuseable.h"
25 
26 /**
27  * _gda_provider_reuseable_new
28  * @provider_name: a database provider name
29  * @version_major: the major version number, or %NULL
30  * @version_minor: the minor version number, or %NULL
31  *
32  * Entry point to get provider's reuseable features for a provider.
33  *
34  * Returns: a new GdaProviderReuseable pointer, or %NULL
35  */
36 GdaProviderReuseable *
_gda_provider_reuseable_new(const gchar * provider_name)37 _gda_provider_reuseable_new (const gchar *provider_name)
38 {
39 	GdaProviderReuseable *reuseable = NULL;
40 	GdaProviderReuseableOperations *ops = NULL;
41 	g_return_val_if_fail (provider_name && *provider_name, NULL);
42 	if (!strcmp (provider_name, "PostgreSQL"))
43 		ops = _gda_postgres_reuseable_get_ops ();
44 	else if (!strcmp (provider_name, "MySQL"))
45 		ops = _gda_mysql_reuseable_get_ops ();
46 
47 	if (ops) {
48 		reuseable = ops->re_new_data ();
49 		g_assert (reuseable->operations == ops);
50 	}
51 
52 	return reuseable;
53 }
54