Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Enumerations | Functions | Variables
res_config_mysql.c File Reference

MySQL CDR backend. More...

#include "asterisk.h"
#include <sys/stat.h>
#include <mysql/mysql.h>
#include <mysql/errmsg.h>
#include "asterisk/channel.h"
#include "asterisk/logger.h"
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/options.h"
#include "asterisk/cli.h"
#include "asterisk/utils.h"
#include "asterisk/threadstorage.h"
#include "asterisk/strings.h"

Go to the source code of this file.

Data Structures

struct  columns
 
struct  databases
 
struct  tables::mysql_columns
 
struct  mysql_conn
 
struct  mysql_tables
 
struct  tables
 

Macros

#define ESCAPE_STRING(buf, var)
 
#define IS_SQL_LIKE_CLAUSE(x)   ((x) && ast_ends_with(x, " LIKE"))
 
#define READHANDLE   0
 
#define release_database(a)   ast_mutex_unlock(&(a)->lock)
 
#define RES_CONFIG_MYSQL_CONF   "res_config_mysql.conf"
 
#define RES_CONFIG_MYSQL_CONF_OLD   "res_mysql.conf"
 
#define WRITEHANDLE   1
 

Enumerations

enum  requirements { RQ_WARN, RQ_CREATECLOSE, RQ_CREATECHAR }
 

Functions

static void __init_find_buf (void)
 
static void __init_modify2_buf (void)
 
static void __init_modify3_buf (void)
 
static void __init_modify_buf (void)
 
static void __init_scratch2_buf (void)
 
static void __init_scratch_buf (void)
 
static void __init_sql2_buf (void)
 
static void __init_sql_buf (void)
 
static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static struct ast_configconfig_mysql (const char *database, const char *table, const char *file, struct ast_config *cfg, struct ast_flags config_flags, const char *unused, const char *who_asked)
 
static char * decode_chunk (char *chunk)
 
static int destroy_mysql (const char *database, const char *table, const char *keyfield, const char *lookup, const struct ast_variable *rt_fields)
 
static void destroy_table (struct tables *table)
 
static struct columnsfind_column (struct tables *table, const char *colname)
 
static struct mysql_connfind_database (const char *database, int for_write)
 
static struct tablesfind_table (const char *database, const char *tablename)
 
static char * handle_cli_realtime_mysql_cache (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_realtime_mysql_status (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static int load_module (void)
 
static int load_mysql_config (struct ast_config *config, const char *category, struct mysql_conn *conn)
 
static int mysql_reconnect (struct mysql_conn *conn)
 
static int parse_config (int reload)
 
static struct ast_configrealtime_multi_mysql (const char *database, const char *table, const struct ast_variable *rt_fields)
 
static struct ast_variablerealtime_mysql (const char *database, const char *table, const struct ast_variable *rt_fields)
 
static void release_table (struct tables *table)
 
static int reload (void)
 
static int require_mysql (const char *database, const char *tablename, va_list ap)
 
static int store_mysql (const char *database, const char *table, const struct ast_variable *rt_fields)
 
static int unload_module (void)
 
static int unload_mysql (const char *database, const char *tablename)
 
static int update2_mysql (const char *database, const char *tablename, const struct ast_variable *lookup_fields, const struct ast_variable *update_fields)
 
static int update_mysql (const char *database, const char *tablename, const char *keyfield, const char *lookup, const struct ast_variable *rt_fields)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "MySQL RealTime Configuration Driver" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "da6642af068ee5e6490c5b1d2cc1d238" , .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_REALTIME_DRIVER, .requires = "extconfig", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_cli_entry cli_realtime_mysql_status []
 
static struct databases databases = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , }
 
static char * ESCAPE_CLAUSE = " ESCAPE '\\\\'"
 
static struct ast_threadstorage find_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_find_buf , .custom_init = NULL , }
 
static struct ast_threadstorage modify2_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_modify2_buf , .custom_init = NULL , }
 
static struct ast_threadstorage modify3_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_modify3_buf , .custom_init = NULL , }
 
static struct ast_threadstorage modify_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_modify_buf , .custom_init = NULL , }
 
static struct ast_config_engine mysql_engine
 
static struct mysql_tables mysql_tables = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , }
 
static struct ast_threadstorage scratch2_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_scratch2_buf , .custom_init = NULL , }
 
static struct ast_threadstorage scratch_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_scratch_buf , .custom_init = NULL , }
 
static struct ast_threadstorage sql2_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_sql2_buf , .custom_init = NULL , }
 
static struct ast_threadstorage sql_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_sql_buf , .custom_init = NULL , }
 

Detailed Description

MySQL CDR backend.

Definition in file res_config_mysql.c.

Variable Documentation

struct ast_cli_entry cli_realtime_mysql_status[]
static
Initial value:
= {
{ .handler = handle_cli_realtime_mysql_status , .summary = "Shows connection information for the MySQL RealTime driver" ,},
{ .handler = handle_cli_realtime_mysql_cache , .summary = "Shows cached tables within the MySQL realtime driver" ,},
}

Definition at line 127 of file res_config_mysql.c.