58 static const char desc[] =
"Customizable SQLite3 CDR Backend";
59 static const char name[] =
"cdr_sqlite3_custom";
87 ast_log(
LOG_ERROR,
"Out of memory creating temporary buffer for column list for table '%s.'\n",
table);
91 ast_log(
LOG_ERROR,
"Out of memory creating temporary buffer for column list for table '%s.'\n",
table);
95 while ((col =
strsep(&cols,
","))) {
97 escaped = sqlite3_mprintf(
"%q", col);
105 sqlite3_free(escaped);
133 ast_log(
LOG_ERROR,
"Out of memory creating temporary buffer for value '%s'\n", tmp);
137 for (i = 0; i <
val.argc; i++) {
140 value =
ast_calloc(
sizeof(
char),
sizeof(*value) + strlen(v));
161 ast_log(
LOG_WARNING,
"Failed to %sload configuration file. %s\n", reload ?
"re" :
"", reload ?
"" :
"Module not activated.");
182 strcpy(
table,
"cdr");
188 ast_log(
LOG_WARNING,
"Invalid busy_timeout value '%s' specified. Using 1000 instead.\n", tmp);
208 ast_verb(4,
"cdr_sqlite3_custom: Logging CDR records to table '%s' in 'master.db'\n",
table);
234 static int write_cdr(
struct ast_cdr *cdr)
249 char subst_buf[2048];
256 ast_log(
LOG_ERROR,
"Unable to allocate channel for variable subsitution.\n");
264 escaped = sqlite3_mprintf(
"%q", subst_buf);
266 sqlite3_free(escaped);
274 if (sqlite3_exec(
db, sql,
NULL,
NULL, &error) != SQLITE_OK) {
312 res = sqlite3_open(filename, &
db);
313 if (res != SQLITE_OK) {
320 sql = sqlite3_mprintf(
"SELECT COUNT(AcctId) FROM %q;",
table);
323 if (res != SQLITE_OK) {
325 sql = sqlite3_mprintf(
"CREATE TABLE %q (AcctId INTEGER PRIMARY KEY, %s)",
table,
columns);
326 res = sqlite3_exec(
db, sql,
NULL,
NULL, &error);
328 if (res != SQLITE_OK) {
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
int ast_cdr_unregister(const char *name)
Unregister a CDR handling engine.
#define ast_channel_unref(c)
Decrease channel reference count.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
static int load_config(void)
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static void dummy(char *unused,...)
#define CONFIG_STATUS_FILEINVALID
static int load_values_config(const char *tmp)
struct ast_cdr * ast_cdr_dup(struct ast_cdr *cdr)
Duplicate a public CDR.
static int load_module(void)
Load the module.
#define AST_STANDARD_RAW_ARGS(args, parse)
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_mutex_lock(a)
#define ast_strdup(str)
A wrapper for strdup()
#define ast_verb(level,...)
#define ast_strlen_zero(foo)
Configuration File Parser.
char * ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
Strip leading/trailing whitespace and quotes from a string.
#define ast_debug(level,...)
Log a DEBUG message.
void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value)
#define ast_config_load(filename, flags)
Load a config file.
int ast_cdr_register(const char *name, const char *desc, ast_cdrbe be)
Register a CDR handling engine.
General Asterisk PBX channel definitions.
Asterisk file paths, configured in asterisk.conf.
static void free_config(int reload)
#define ast_dummy_channel_alloc()
Create a fake channel structure.
static const char config_file[]
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
void ast_config_destroy(struct ast_config *config)
Destroys a config.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Core PBX routines and definitions.
#define CONFIG_STATUS_FILEUNCHANGED
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
Responsible for call detail data.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
const char * ast_config_AST_LOG_DIR
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define ast_calloc(num, len)
A wrapper for calloc()
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *result,...)
The argument parsing routine.
Module has failed to load, may be in an inconsistent state.
Structure used to handle boolean flags.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
#define CONFIG_STATUS_FILEMISSING
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
char * strsep(char **str, const char *delims)
Standard Command Line Interface.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
static int load_column_config(const char *tmp)
int error(const char *format,...)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define AST_MUTEX_DEFINE_STATIC(mutex)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
#define ast_mutex_unlock(a)
#define AST_APP_ARG(name)
Define an application argument.