83 lines
2.9 KiB
C
83 lines
2.9 KiB
C
/*
|
|
* Copyright (C) 2012 - Juan Ferrer Toribio
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef DB_PLUGIN_H
|
|
#define DB_PLUGIN_H
|
|
|
|
#include <sql/sql.h>
|
|
#include "db-result-set.h"
|
|
|
|
#define DB_TYPE_PLUGIN (db_plugin_get_type ())
|
|
#define DB_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DB_TYPE_PLUGIN, DbPlugin))
|
|
#define DB_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DB_TYPE_PLUGIN))
|
|
#define DB_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DB_TYPE_PLUGIN, DbPluginClass))
|
|
#define DB_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DB_TYPE_PLUGIN))
|
|
#define DB_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DB_TYPE_PLUGIN, DbPluginClass))
|
|
|
|
typedef struct _DbPlugin DbPlugin;
|
|
typedef struct _DbPluginClass DbPluginClass;
|
|
|
|
typedef GType (* DbPluginGetTypeFunc) ();
|
|
typedef gboolean (* DbPluginOpenFunc) (DbPlugin * obj
|
|
,const gchar * host
|
|
,const gchar * schema
|
|
,const gchar * user
|
|
,const gchar * pass
|
|
,GError ** err);
|
|
typedef void (* DbPluginCloseFunc) (DbPlugin * obj);
|
|
typedef void (* DbPluginSetSSL) (DbPlugin * obj
|
|
,const gchar * ca);
|
|
typedef DbResultSet * (* DbPluginQueryFunc) (DbPlugin * obj, const gchar * sql, GError ** err);
|
|
typedef void (* DbPluginKillQueryFunc) (DbPlugin * obj);
|
|
typedef SqlStmt * (* DbPluginParseFunc) (DbPlugin * obj, const gchar * sql);
|
|
|
|
struct _DbPlugin
|
|
{
|
|
GObject parent;
|
|
GMutex mutex;
|
|
GMutex kill_mutex;
|
|
SqlRender * render;
|
|
gchar * ca;
|
|
};
|
|
|
|
struct _DbPluginClass
|
|
{
|
|
/* <private> */
|
|
GObjectClass parent;
|
|
DbPluginOpenFunc open;
|
|
DbPluginCloseFunc close;
|
|
DbPluginSetSSL set_ssl;
|
|
DbPluginQueryFunc query;
|
|
DbPluginKillQueryFunc kill_query;
|
|
DbPluginParseFunc parse;
|
|
};
|
|
|
|
GType db_plugin_get_type ();
|
|
gboolean db_plugin_open (DbPlugin * obj
|
|
,const gchar * host
|
|
,const gchar * schema
|
|
,const gchar * user
|
|
,const gchar * pass
|
|
,GError ** err);
|
|
void db_plugin_close (DbPlugin * obj);
|
|
void db_plugin_set_ssl (DbPlugin * obj, const gchar * ca);
|
|
DbResultSet * db_plugin_query (DbPlugin * obj, const gchar * sql, GError ** err);
|
|
void db_plugin_kill_query (DbPlugin * obj);
|
|
SqlStmt * db_plugin_parse (DbPlugin * obj, gchar * sql);
|
|
gchar * db_plugin_render (DbPlugin * obj, gpointer object, GError ** err);
|
|
|
|
#endif |