|
|
|
@ -70,7 +70,7 @@ struct values {
|
|
|
|
|
|
|
|
|
|
static AST_LIST_HEAD_STATIC(sql_values, values);
|
|
|
|
|
|
|
|
|
|
static void free_config(void);
|
|
|
|
|
static void free_config(int reload);
|
|
|
|
|
|
|
|
|
|
static int load_column_config(const char *tmp)
|
|
|
|
|
{
|
|
|
|
@ -163,7 +163,7 @@ static int load_config(int reload)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (reload) {
|
|
|
|
|
free_config();
|
|
|
|
|
free_config(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(mappingvar = ast_variable_browse(cfg, "master"))) {
|
|
|
|
@ -183,14 +183,14 @@ static int load_config(int reload)
|
|
|
|
|
/* Columns */
|
|
|
|
|
if (load_column_config(ast_variable_retrieve(cfg, "master", "columns"))) {
|
|
|
|
|
ast_config_destroy(cfg);
|
|
|
|
|
free_config();
|
|
|
|
|
free_config(0);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Values */
|
|
|
|
|
if (load_values_config(ast_variable_retrieve(cfg, "master", "values"))) {
|
|
|
|
|
ast_config_destroy(cfg);
|
|
|
|
|
free_config();
|
|
|
|
|
free_config(0);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -201,11 +201,11 @@ static int load_config(int reload)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void free_config(void)
|
|
|
|
|
static void free_config(int reload)
|
|
|
|
|
{
|
|
|
|
|
struct values *value;
|
|
|
|
|
|
|
|
|
|
if (db) {
|
|
|
|
|
if (!reload && db) {
|
|
|
|
|
sqlite3_close(db);
|
|
|
|
|
db = NULL;
|
|
|
|
|
}
|
|
|
|
@ -288,7 +288,7 @@ static int unload_module(void)
|
|
|
|
|
{
|
|
|
|
|
ast_cdr_unregister(name);
|
|
|
|
|
|
|
|
|
|
free_config();
|
|
|
|
|
free_config(0);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
@ -309,7 +309,7 @@ static int load_module(void)
|
|
|
|
|
res = sqlite3_open(filename, &db);
|
|
|
|
|
if (res != SQLITE_OK) {
|
|
|
|
|
ast_log(LOG_ERROR, "Could not open database %s.\n", filename);
|
|
|
|
|
free_config();
|
|
|
|
|
free_config(0);
|
|
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -325,7 +325,7 @@ static int load_module(void)
|
|
|
|
|
if (res != SQLITE_OK) {
|
|
|
|
|
ast_log(LOG_WARNING, "Unable to create table '%s': %s.\n", table, error);
|
|
|
|
|
sqlite3_free(error);
|
|
|
|
|
free_config();
|
|
|
|
|
free_config(0);
|
|
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -333,7 +333,7 @@ static int load_module(void)
|
|
|
|
|
res = ast_cdr_register(name, desc, sqlite3_log);
|
|
|
|
|
if (res) {
|
|
|
|
|
ast_log(LOG_ERROR, "Unable to register custom SQLite3 CDR handling\n");
|
|
|
|
|
free_config();
|
|
|
|
|
free_config(0);
|
|
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|