modules/db_unixodbc/db_unixodbc.c
e3649ef3
 /* 
  * $Id$ 
  *
  * UNIXODBC module interface
  *
  * Copyright (C) 2005-2006 Marco Lorrai
4c7d0961
  * Copyright (C) 2008 1&1 Internet AG
e3649ef3
  *
27642a08
  * This file is part of Kamailio, a free SIP server.
e3649ef3
  *
27642a08
  * Kamailio is free software; you can redistribute it and/or modify
e3649ef3
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version
  *
27642a08
  * Kamailio is distributed in the hope that it will be useful,
e3649ef3
  * 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, write to the Free Software 
9e1ff448
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
e3649ef3
  *
  *
  * History:
  * --------
  *  2005-12-01  initial commit (chgen)
  */
 
 #include "../../sr_module.h"
02fb0169
 #include "../../lib/srdb1/db.h"
5cd87175
 #include "../../lib/srdb1/db_query.h"
e3649ef3
 #include "dbase.h"
5408633b
 #include "db_unixodbc.h"
e3649ef3
 
 int ping_interval = 5 * 60; /* Default is 5 minutes */
 int auto_reconnect = 1;     /* Default is enabled */
4c8c7b62
 int use_escape_common = 0;  /* Enable common escaping */
e3649ef3
 
 MODULE_VERSION
 
abd89a1c
 int db_unixodbc_bind_api(db_func_t *dbb);
5cd87175
 int unixodbc_mod_init(void);
e3649ef3
 
 /*
  * MySQL database module interface
  */
 static cmd_export_t cmds[] = {
abd89a1c
 	{"db_bind_api",    (cmd_function)db_unixodbc_bind_api,    0, 0, 0, 0},
80998a7f
 	{0, 0, 0, 0, 0, 0}
e3649ef3
 };
 
 
 /*
  * Exported parameters
  */
 static param_export_t params[] = {
4c8c7b62
 	{"ping_interval",     INT_PARAM, &ping_interval},
 	{"auto_reconnect",    INT_PARAM, &auto_reconnect},
 	{"use_escape_common", INT_PARAM, &use_escape_common},
e3649ef3
 	{0, 0, 0}
 };
 
 
 struct module_exports exports = {	
bdc86c15
 	"db_unixodbc",
51716422
 	DEFAULT_DLFLAGS, /* dlopen flags */
e3649ef3
 	cmds,
5cd87175
 	params,             /*  module parameters */
 	0,                  /* exported statistics */
 	0,                  /* exported MI functions */
 	0,                  /* exported pseudo-variables */
 	0,                  /* extra processes */
 	unixodbc_mod_init,  /* module initialization function */
 	0,                  /* response function*/
 	0,                  /* destroy function */
 	0                   /* per-child init function */
e3649ef3
 };
 
abd89a1c
 int db_unixodbc_bind_api(db_func_t *dbb)
 {
 	if(dbb==NULL)
 		return -1;
 
 	memset(dbb, 0, sizeof(db_func_t));
 
 	dbb->use_table        = db_unixodbc_use_table;
 	dbb->init             = db_unixodbc_init;
 	dbb->close            = db_unixodbc_close;
 	dbb->query            = db_unixodbc_query;
c331ec44
 	dbb->fetch_result     = db_unixodbc_fetch_result;
abd89a1c
 	dbb->raw_query        = db_unixodbc_raw_query;
 	dbb->free_result      = db_unixodbc_free_result;
 	dbb->insert           = db_unixodbc_insert;
 	dbb->delete           = db_unixodbc_delete; 
 	dbb->update           = db_unixodbc_update;
 	dbb->replace          = db_unixodbc_replace;
 
 	return 0;
 }
 
f122ee6e
 int mod_register(char *path, int *dlflags, void *p1, void *p2)
 {
 	if(db_api_init()<0)
 		return -1;
 	return 0;
 }
 
5cd87175
 int unixodbc_mod_init(void)
 {
f122ee6e
 	return 0;
5cd87175
 }