mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 20:56:39 +00:00
Merge config updates (bug #3406)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4889 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1024,7 +1024,7 @@ static void adsi_load(void)
|
||||
struct ast_variable *v;
|
||||
char *name, *sname;
|
||||
init_state();
|
||||
conf = ast_load("adsi.conf");
|
||||
conf = ast_config_load("adsi.conf");
|
||||
if (conf) {
|
||||
x=0;
|
||||
v = ast_variable_browse(conf, "intro");
|
||||
@@ -1067,7 +1067,7 @@ static void adsi_load(void)
|
||||
}
|
||||
if (x)
|
||||
speeds = x;
|
||||
ast_destroy(conf);
|
||||
ast_config_destroy(conf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,6 @@
|
||||
#include <asterisk/channel.h>
|
||||
#include <asterisk/pbx.h>
|
||||
#include <asterisk/config.h>
|
||||
#include <asterisk/config_pvt.h>
|
||||
#include <asterisk/module.h>
|
||||
#include <asterisk/lock.h>
|
||||
#include <asterisk/options.h>
|
||||
@@ -25,8 +24,6 @@
|
||||
#include <asterisk/utils.h>
|
||||
|
||||
static char *tdesc = "ODBC Configuration";
|
||||
static struct ast_config_reg reg1;
|
||||
|
||||
STANDARD_LOCAL_USER;
|
||||
|
||||
LOCAL_USER_DECL;
|
||||
@@ -136,14 +133,14 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
|
||||
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
||||
ast_log(LOG_WARNING, "SQL Describe Column error!\n[%s]\n\n", sql);
|
||||
if (var)
|
||||
ast_destroy_realtime(var);
|
||||
ast_variables_destroy(var);
|
||||
return NULL;
|
||||
}
|
||||
res = SQLGetData(stmt, x + 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);
|
||||
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
||||
ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
|
||||
if (var)
|
||||
ast_destroy_realtime(var);
|
||||
ast_variables_destroy(var);
|
||||
return NULL;
|
||||
}
|
||||
stringp = rowdata;
|
||||
@@ -151,11 +148,11 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
|
||||
chunk = strsep(&stringp, ";");
|
||||
if (chunk && !ast_strlen_zero(ast_strip(chunk))) {
|
||||
if (prev) {
|
||||
prev->next = ast_new_variable(coltitle, chunk);
|
||||
prev->next = ast_variable_new(coltitle, chunk);
|
||||
if (prev->next)
|
||||
prev = prev->next;
|
||||
} else
|
||||
prev = var = ast_new_variable(coltitle, chunk);
|
||||
prev = var = ast_variable_new(coltitle, chunk);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -174,7 +171,6 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
|
||||
char sql[1024];
|
||||
char coltitle[256];
|
||||
char rowdata[2048];
|
||||
char *title=NULL;
|
||||
const char *initfield=NULL;
|
||||
char *op;
|
||||
const char *newparam, *newval;
|
||||
@@ -183,7 +179,7 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
|
||||
SQLSMALLINT collen;
|
||||
int res;
|
||||
int x;
|
||||
struct ast_variable *var=NULL, *prev=NULL;
|
||||
struct ast_variable *var=NULL;
|
||||
struct ast_config *cfg=NULL;
|
||||
struct ast_category *cat=NULL;
|
||||
struct ast_realloca ra;
|
||||
@@ -268,15 +264,25 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cfg = ast_config_new();
|
||||
if (!cfg) {
|
||||
ast_log(LOG_WARNING, "Out of memory!\n");
|
||||
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (rowcount--) {
|
||||
var = NULL;
|
||||
prev = NULL;
|
||||
title = NULL;
|
||||
res = SQLFetch(stmt);
|
||||
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
||||
ast_log(LOG_WARNING, "SQL Fetch error!\n[%s]\n\n", sql);
|
||||
continue;
|
||||
}
|
||||
cat = ast_category_new("");
|
||||
if (!cat) {
|
||||
ast_log(LOG_WARNING, "Out of memory!\n");
|
||||
continue;
|
||||
}
|
||||
for (x=0;x<colcount;x++) {
|
||||
rowdata[0] = '\0';
|
||||
collen = sizeof(coltitle);
|
||||
@@ -284,48 +290,27 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
|
||||
&datatype, &colsize, &decimaldigits, &nullable);
|
||||
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
||||
ast_log(LOG_WARNING, "SQL Describe Column error!\n[%s]\n\n", sql);
|
||||
if (var)
|
||||
ast_destroy_realtime(var);
|
||||
ast_category_destroy(cat);
|
||||
continue;
|
||||
}
|
||||
res = SQLGetData(stmt, x + 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);
|
||||
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
||||
ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
|
||||
if (var)
|
||||
ast_destroy_realtime(var);
|
||||
ast_category_destroy(cat);
|
||||
continue;
|
||||
}
|
||||
stringp = rowdata;
|
||||
while(stringp) {
|
||||
chunk = strsep(&stringp, ";");
|
||||
if (chunk && !ast_strlen_zero(ast_strip(chunk))) {
|
||||
if (initfield && !strcmp(initfield, coltitle) && !title)
|
||||
title = ast_restrdupa(&ra, chunk);
|
||||
if (prev) {
|
||||
prev->next = ast_new_variable(coltitle, chunk);
|
||||
if (prev->next)
|
||||
prev = prev->next;
|
||||
} else
|
||||
prev = var = ast_new_variable(coltitle, chunk);
|
||||
|
||||
if (initfield && !strcmp(initfield, coltitle))
|
||||
ast_category_rename(cat, chunk);
|
||||
var = ast_variable_new(coltitle, chunk);
|
||||
ast_variable_append(cat, var);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (var) {
|
||||
cat = ast_new_category(title ? title : "");
|
||||
if (cat) {
|
||||
cat->root = var;
|
||||
if (!cfg)
|
||||
cfg = ast_new_config();
|
||||
if (cfg)
|
||||
ast_category_append(cfg, cat);
|
||||
else
|
||||
ast_category_destroy(cat);
|
||||
} else {
|
||||
ast_log(LOG_WARNING, "Out of memory!\n");
|
||||
ast_destroy_realtime(var);
|
||||
}
|
||||
}
|
||||
ast_category_append(cfg, cat);
|
||||
}
|
||||
|
||||
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
|
||||
@@ -410,11 +395,10 @@ static int update_odbc(const char *database, const char *table, const char *keyf
|
||||
return -1;
|
||||
}
|
||||
|
||||
static struct ast_config *config_odbc(const char *database, const char *table, const char *file, struct ast_config *new_config_s, struct ast_category **new_cat_p, int recur)
|
||||
static struct ast_config *config_odbc(const char *database, const char *table, const char *file, struct ast_config *cfg)
|
||||
{
|
||||
struct ast_config *new;
|
||||
struct ast_variable *cur_v, *new_v;
|
||||
struct ast_category *cur_cat, *new_cat;
|
||||
struct ast_variable *new_v;
|
||||
struct ast_category *cur_cat;
|
||||
int res = 0;
|
||||
odbc_obj *obj;
|
||||
SQLINTEGER err=0, commented=0, cat_metric=0, var_metric=0, last_cat_metric=0;
|
||||
@@ -422,10 +406,7 @@ static struct ast_config *config_odbc(const char *database, const char *table, c
|
||||
char sql[255] = "", filename[128], category[128], var_name[128], var_val[512];
|
||||
SQLSMALLINT rowcount=0;
|
||||
SQLHSTMT stmt;
|
||||
char last[80] = "";
|
||||
int cat_started = 0;
|
||||
int var_started = 0;
|
||||
|
||||
char last[128] = "";
|
||||
|
||||
if (!file || !strcmp (file, "res_config_odbc.conf"))
|
||||
return NULL; /* cant configure myself with myself ! */
|
||||
@@ -434,8 +415,6 @@ static struct ast_config *config_odbc(const char *database, const char *table, c
|
||||
if (!obj)
|
||||
return NULL;
|
||||
|
||||
last[0] = '\0';
|
||||
|
||||
res = SQLAllocHandle (SQL_HANDLE_STMT, obj->con, &stmt);
|
||||
|
||||
SQLBindCol (stmt, 1, SQL_C_ULONG, &id, sizeof (id), &err);
|
||||
@@ -452,90 +431,63 @@ static struct ast_config *config_odbc(const char *database, const char *table, c
|
||||
|
||||
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
||||
ast_log (LOG_WARNING, "SQL select error!\n[%s]\n\n", sql);
|
||||
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res = SQLNumResultCols (stmt, &rowcount);
|
||||
|
||||
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
||||
ast_log (LOG_WARNING, "SQL select error!\n[%s]\n\n", sql);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (new_config_s) {
|
||||
new = new_config_s;
|
||||
cat_started++;
|
||||
} else {
|
||||
new = ast_new_config ();
|
||||
}
|
||||
|
||||
if (!new) {
|
||||
ast_log(LOG_WARNING, "Out of memory!\n");
|
||||
ast_log (LOG_WARNING, "SQL NumResultCols error!\n[%s]\n\n", sql);
|
||||
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (rowcount) {
|
||||
res = SQLFetch (stmt);
|
||||
cat_started = 0;
|
||||
if (!rowcount) {
|
||||
ast_log (LOG_NOTICE, "found nothing\n");
|
||||
return cfg;
|
||||
}
|
||||
|
||||
cur_cat = *new_cat_p;
|
||||
cur_v = NULL;
|
||||
cur_cat = ast_config_get_current_category(cfg);
|
||||
|
||||
if (cur_cat)
|
||||
cat_started = 1;
|
||||
if (cur_v)
|
||||
var_started = 1;
|
||||
|
||||
while (res != SQL_NO_DATA) {
|
||||
if (!strcmp (var_name, "#include") && recur < MAX_INCLUDE_LEVEL) {
|
||||
|
||||
config_odbc(database, table, var_val, new, &cur_cat, recur + 1);
|
||||
} else {
|
||||
if (strcmp (last, category) || last_cat_metric != cat_metric) {
|
||||
strncpy(last, category, sizeof(last) - 1);
|
||||
last_cat_metric = cat_metric;
|
||||
new_cat = (struct ast_category *) ast_new_category (category);
|
||||
|
||||
if (!cat_started) {
|
||||
cat_started++;
|
||||
new->root = new_cat;
|
||||
cur_cat = new->root;
|
||||
} else {
|
||||
cur_cat->next = new_cat;
|
||||
cur_cat = cur_cat->next;
|
||||
}
|
||||
var_started = 0;
|
||||
|
||||
}
|
||||
|
||||
new_v = ast_new_variable (var_name, var_val);
|
||||
|
||||
if (!var_started) {
|
||||
var_started++;
|
||||
cur_cat->root = new_v;
|
||||
cur_v = cur_cat->root;
|
||||
} else {
|
||||
cur_v->next = new_v;
|
||||
cur_v = cur_v->next;
|
||||
}
|
||||
while ((res = SQLFetch(stmt)) != SQL_NO_DATA) {
|
||||
if (!strcmp (var_name, "#include")) {
|
||||
if (!ast_config_internal_load(var_val, cfg)) {
|
||||
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* next row */
|
||||
res = SQLFetch (stmt);
|
||||
continue;
|
||||
}
|
||||
if (strcmp(last, category) || last_cat_metric != cat_metric) {
|
||||
cur_cat = ast_category_new(category);
|
||||
if (!cur_cat) {
|
||||
ast_log(LOG_WARNING, "Out of memory!\n");
|
||||
break;
|
||||
}
|
||||
strcpy(last, category);
|
||||
last_cat_metric = cat_metric;
|
||||
ast_category_append(cfg, cur_cat);
|
||||
}
|
||||
|
||||
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
|
||||
} else {
|
||||
ast_log (LOG_NOTICE, "found nothing\n");
|
||||
new_v = ast_variable_new(var_name, var_val);
|
||||
ast_variable_append(cur_cat, new_v);
|
||||
}
|
||||
return new;
|
||||
|
||||
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
static struct ast_config_engine odbc_engine = {
|
||||
.name = "odbc",
|
||||
.load_func = config_odbc,
|
||||
.realtime_func = realtime_odbc,
|
||||
.realtime_multi_func = realtime_multi_odbc,
|
||||
.update_func = update_odbc
|
||||
};
|
||||
|
||||
int unload_module (void)
|
||||
{
|
||||
ast_cust_config_deregister (®1);
|
||||
ast_config_engine_deregister(&odbc_engine);
|
||||
if (option_verbose)
|
||||
ast_verbose("res_config_odbc unloaded.\n");
|
||||
STANDARD_HANGUP_LOCALUSERS;
|
||||
@@ -544,13 +496,7 @@ int unload_module (void)
|
||||
|
||||
int load_module (void)
|
||||
{
|
||||
memset (®1, 0, sizeof (struct ast_config_reg));
|
||||
strncpy(reg1.name, "odbc", sizeof(reg1.name) - 1);
|
||||
reg1.static_func = config_odbc;
|
||||
reg1.realtime_func = realtime_odbc;
|
||||
reg1.realtime_multi_func = realtime_multi_odbc;
|
||||
reg1.update_func = update_odbc;
|
||||
ast_cust_config_register (®1);
|
||||
ast_config_engine_register(&odbc_engine);
|
||||
if (option_verbose)
|
||||
ast_verbose("res_config_odbc loaded.\n");
|
||||
return 0;
|
||||
|
@@ -1444,9 +1444,9 @@ static int load_config(void)
|
||||
transferdigittimeout = DEFAULT_TRANSFER_DIGIT_TIMEOUT;
|
||||
featuredigittimeout = DEFAULT_FEATURE_DIGIT_TIMEOUT;
|
||||
|
||||
cfg = ast_load("features.conf");
|
||||
cfg = ast_config_load("features.conf");
|
||||
if (!cfg) {
|
||||
cfg = ast_load("parking.conf");
|
||||
cfg = ast_config_load("parking.conf");
|
||||
if (cfg)
|
||||
ast_log(LOG_NOTICE, "parking.conf is deprecated in favor of 'features.conf'. Please rename it.\n");
|
||||
}
|
||||
@@ -1501,7 +1501,7 @@ static int load_config(void)
|
||||
ast_log(LOG_NOTICE, "Unknown feature '%s'\n", var->name);
|
||||
var = var->next;
|
||||
}
|
||||
ast_destroy(cfg);
|
||||
ast_config_destroy(cfg);
|
||||
}
|
||||
|
||||
if (con)
|
||||
|
@@ -230,7 +230,7 @@ static int ind_load_module(void)
|
||||
|
||||
/* that the following cast is needed, is yuk! */
|
||||
/* yup, checked it out. It is NOT written to. */
|
||||
cfg = ast_load((char *)config);
|
||||
cfg = ast_config_load((char *)config);
|
||||
if (!cfg)
|
||||
return 0;
|
||||
|
||||
@@ -245,7 +245,7 @@ static int ind_load_module(void)
|
||||
tones = malloc(sizeof(struct tone_zone));
|
||||
if (!tones) {
|
||||
ast_log(LOG_WARNING,"Out of memory\n");
|
||||
ast_destroy(cfg);
|
||||
ast_config_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
memset(tones,0,sizeof(struct tone_zone));
|
||||
@@ -269,7 +269,7 @@ static int ind_load_module(void)
|
||||
tmp = realloc(tones->ringcadance,(tones->nrringcadance+1)*sizeof(int));
|
||||
if (!tmp) {
|
||||
ast_log(LOG_WARNING, "Out of memory\n");
|
||||
ast_destroy(cfg);
|
||||
ast_config_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
tones->ringcadance = tmp;
|
||||
@@ -286,7 +286,7 @@ static int ind_load_module(void)
|
||||
struct tone_zone* azone = malloc(sizeof(struct tone_zone));
|
||||
if (!azone) {
|
||||
ast_log(LOG_WARNING,"Out of memory\n");
|
||||
ast_destroy(cfg);
|
||||
ast_config_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
memset(azone,0,sizeof(struct tone_zone));
|
||||
@@ -313,7 +313,7 @@ static int ind_load_module(void)
|
||||
ts = malloc(sizeof(struct tone_zone_sound));
|
||||
if (!ts) {
|
||||
ast_log(LOG_WARNING, "Out of memory\n");
|
||||
ast_destroy(cfg);
|
||||
ast_config_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
ts->next = NULL;
|
||||
@@ -341,7 +341,7 @@ out: v = v->next;
|
||||
if (!country || !*country || ast_set_indication_country(country))
|
||||
ast_log(LOG_WARNING,"Unable to set the default country (for indication tones)\n");
|
||||
|
||||
ast_destroy(cfg);
|
||||
ast_config_destroy(cfg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -865,7 +865,7 @@ static int load_moh_classes(void)
|
||||
char *args;
|
||||
int x = 0;
|
||||
|
||||
cfg = ast_load("musiconhold.conf");
|
||||
cfg = ast_config_load("musiconhold.conf");
|
||||
|
||||
if (!cfg)
|
||||
return 0;
|
||||
@@ -897,7 +897,7 @@ static int load_moh_classes(void)
|
||||
var = var->next;
|
||||
}
|
||||
|
||||
ast_destroy(cfg);
|
||||
ast_config_destroy(cfg);
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@@ -93,7 +93,7 @@ static int load_odbc_config(void)
|
||||
|
||||
odbc_obj *obj;
|
||||
|
||||
config = ast_load(cfg);
|
||||
config = ast_config_load(cfg);
|
||||
if (config) {
|
||||
for (cat = ast_category_browse(config, NULL); cat; cat=ast_category_browse(config, cat)) {
|
||||
if (!strcmp(cat, "ENV")) {
|
||||
@@ -140,7 +140,7 @@ static int load_odbc_config(void)
|
||||
|
||||
}
|
||||
}
|
||||
ast_destroy(config);
|
||||
ast_config_destroy(config);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@@ -746,7 +746,7 @@ static int config_load(void)
|
||||
osp = osp->next;
|
||||
}
|
||||
ast_mutex_unlock(&osplock);
|
||||
cfg = ast_load("osp.conf");
|
||||
cfg = ast_config_load("osp.conf");
|
||||
if (cfg) {
|
||||
if (!initialized) {
|
||||
cat = ast_variable_retrieve(cfg, "general", "accelerate");
|
||||
@@ -766,7 +766,7 @@ static int config_load(void)
|
||||
osp_build(cfg, cat);
|
||||
cat = ast_category_browse(cfg, cat);
|
||||
}
|
||||
ast_destroy(cfg);
|
||||
ast_config_destroy(cfg);
|
||||
} else
|
||||
ast_log(LOG_NOTICE, "No OSP configuration found. OSP support disabled\n");
|
||||
ast_mutex_lock(&osplock);
|
||||
|
Reference in New Issue
Block a user