4f778298 |
/*
* MySQL module interface
*
* Copyright (C) 2001-2003 FhG Fokus
* Copyright (C) 2008 1&1 Internet AG
*
|
31f52f1d |
* This file is part of Kamailio, a free SIP server.
|
4f778298 |
*
|
31f52f1d |
* Kamailio is free software; you can redistribute it and/or modify
|
4f778298 |
* 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
*
|
31f52f1d |
* Kamailio is distributed in the hope that it will be useful,
|
4f778298 |
* 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
|
4f778298 |
*/
|
083502f8 |
/*! \file
* \brief DB_MYSQL :: Core
* \ingroup db_mysql
* Module: \ref db_mysql
*/
|
2b8cb3bf |
/*! \defgroup db_mysql DB_MYSQL :: the MySQL driver for Kamailio
* \brief The Kamailio database interface to the MySQL database
|
083502f8 |
* - http://www.mysql.org
*
*/
|
4f778298 |
#include "../../sr_module.h"
|
9c5da732 |
#include "../../dprint.h"
|
96121273 |
#include "km_dbase.h"
#include "km_db_mysql.h"
|
4f778298 |
#include <mysql/mysql.h>
unsigned int db_mysql_timeout_interval = 2; /* Default is 6 seconds */
unsigned int db_mysql_auto_reconnect = 1; /* Default is enabled */
|
61c706ef |
unsigned int db_mysql_insert_all_delayed = 0; /* Default is off */
|
bb30c83e |
unsigned int db_mysql_update_affected_found = 0; /* Default is off */
|
4f778298 |
|
10617927 |
/* MODULE_VERSION */
|
4f778298 |
|
083502f8 |
/*! \brief
|
4f778298 |
* MySQL database module interface
*/
|
10617927 |
static kam_cmd_export_t cmds[] = {
|
f5ccb8c5 |
{"db_bind_api", (cmd_function)db_mysql_bind_api, 0, 0, 0, 0},
|
4f778298 |
{0, 0, 0, 0, 0, 0}
};
|
083502f8 |
/*! \brief
|
4f778298 |
* Exported parameters
*/
static param_export_t params[] = {
|
1a058e14 |
/* {"ping_interval", INT_PARAM, &db_mysql_ping_interval}, */
|
4f778298 |
{"timeout_interval", INT_PARAM, &db_mysql_timeout_interval},
{"auto_reconnect", INT_PARAM, &db_mysql_auto_reconnect},
{0, 0, 0}
};
|
10617927 |
struct kam_module_exports kam_exports = {
|
7eb19c26 |
"db_mysql",
|
4f778298 |
DEFAULT_DLFLAGS, /* dlopen flags */
cmds,
params, /* module parameters */
0, /* exported statistics */
0, /* exported MI functions */
0, /* exported pseudo-variables */
0, /* extra processes */
|
43f01015 |
kam_mysql_mod_init, /* module initialization function */
|
4f778298 |
0, /* response function*/
0, /* destroy function */
0 /* per-child init function */
};
|
43f01015 |
int kam_mysql_mod_init(void)
|
4f778298 |
{
|
50e2150d |
LM_DBG("MySQL client version is %s\n", mysql_get_client_info());
|
9a7e99d0 |
return 0;
|
4f778298 |
}
|
f5ccb8c5 |
int db_mysql_bind_api(db_func_t *dbb)
{
if(dbb==NULL)
return -1;
memset(dbb, 0, sizeof(db_func_t));
dbb->use_table = db_mysql_use_table;
dbb->init = db_mysql_init;
dbb->close = db_mysql_close;
dbb->query = db_mysql_query;
dbb->fetch_result = db_mysql_fetch_result;
dbb->raw_query = db_mysql_raw_query;
|
14d4ea78 |
dbb->free_result = (db_free_result_f) db_mysql_free_result;
|
f5ccb8c5 |
dbb->insert = db_mysql_insert;
|
50e2150d |
dbb->delete = db_mysql_delete;
|
f5ccb8c5 |
dbb->update = db_mysql_update;
dbb->replace = db_mysql_replace;
|
a001f2f2 |
dbb->last_inserted_id = db_mysql_last_inserted_id;
dbb->insert_update = db_mysql_insert_update;
|
4c7c1b81 |
dbb->insert_delayed = db_mysql_insert_delayed;
|
588d1ffb |
dbb->affected_rows = db_mysql_affected_rows;
|
fe977dfc |
dbb->start_transaction= db_mysql_start_transaction;
dbb->end_transaction = db_mysql_end_transaction;
dbb->abort_transaction= db_mysql_abort_transaction;
|
0d78e9a9 |
dbb->raw_query_async = db_mysql_raw_query_async;
dbb->insert_async = db_mysql_insert_async;
|
f5ccb8c5 |
return 0;
}
|