--- NEW FILE: cdr_addon_mysql.c ---
/*
* Asterisk -- A telephony toolkit for Linux.
*
* MySQL CDR logger
*
* James Sharp <jsharp@psychoses.org>
*
* Modified August 2003
* Tilghman Lesher <asterisk__cdr__cdr_mysql__200308@the-tilghman.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License.
*
*/
tmp = ast_variable_retrieve(cfg,"global","port");
if (tmp) {
if (sscanf(tmp,"%d",&dbport) < 1) {
ast_log(LOG_WARNING,"Invalid MySQL port number. Using default\n");
dbport = 0;
}
}
ast_destroy(cfg);
ast_log(LOG_DEBUG,"cdr_mysql: got hostname of %s\n",hostname);
ast_log(LOG_DEBUG,"cdr_mysql: got port of %d\n",dbport);
if (dbsock)
ast_log(LOG_DEBUG,"cdr_mysql: got sock file of %s\n",dbsock);
ast_log(LOG_DEBUG,"cdr_mysql: got user of %s\n",dbuser);
ast_log(LOG_DEBUG,"cdr_mysql: got dbname of %s\n",dbname);
ast_log(LOG_DEBUG,"cdr_mysql: got password of %s\n",password);
mysql_init(&mysql);
if (!mysql_real_connect(&mysql, hostname, dbuser, password, dbname, dbport, dbsock, 0)) {
ast_log(LOG_ERROR, "Failed to connect to mysql database %s on %s.\n", dbname, hostname);
connected = 0;
} else {
ast_log(LOG_DEBUG,"Successfully connected to MySQL database.\n");
connected = 1;
}
res = ast_cdr_register(name, desc, mysql_log);
if (res) {
ast_log(LOG_ERROR, "Unable to register MySQL CDR handling\n");
}
return res;
}
int load_module(void)
{
return my_load_module();
}
int unload_module(void)
{
return my_unload_module();
}
int reload(void)
{
my_unload_module();
return my_load_module();
}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum