[Asterisk-cvs]
asterisk/res res_adsi.c, 1.9, 1.10 res_config_odbc.c,
1.22, 1.23 res_features.c, 1.36, 1.37 res_indications.c, 1.9,
1.10 res_musiconhold.c, 1.51, 1.52 res_odbc.c, 1.10,
1.11 res_osp.c, 1.11, 1.12
markster at lists.digium.com
markster at lists.digium.com
Tue Jan 25 00:08:02 CST 2005
- Previous message: [Asterisk-cvs] asterisk/channels chan_agent.c, 1.107,
1.108 chan_alsa.c, 1.35, 1.36 chan_h323.c, 1.100,
1.101 chan_iax2.c, 1.241, 1.242 chan_mgcp.c, 1.105,
1.106 chan_modem.c, 1.36, 1.37 chan_oss.c, 1.41,
1.42 chan_phone.c, 1.42, 1.43 chan_sip.c, 1.637,
1.638 chan_skinny.c, 1.64, 1.65 chan_vpb.c, 1.63,
1.64 chan_zap.c, 1.403, 1.404 iax2-provision.c, 1.8, 1.9
- Next message: [Asterisk-cvs] asterisk config_old.c,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /usr/cvsroot/asterisk/res
In directory mongoose.digium.com:/tmp/cvs-serv27198/res
Modified Files:
res_adsi.c res_config_odbc.c res_features.c res_indications.c
res_musiconhold.c res_odbc.c res_osp.c
Log Message:
Merge config updates (bug #3406)
Index: res_adsi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_adsi.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- res_adsi.c 14 Jul 2004 13:57:15 -0000 1.9
+++ res_adsi.c 25 Jan 2005 06:10:20 -0000 1.10
@@ -1024,7 +1024,7 @@
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 @@
}
if (x)
speeds = x;
- ast_destroy(conf);
+ ast_config_destroy(conf);
}
}
Index: res_config_odbc.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_config_odbc.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- res_config_odbc.c 22 Jan 2005 22:13:11 -0000 1.22
+++ res_config_odbc.c 25 Jan 2005 06:10:20 -0000 1.23
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
&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 @@
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 @@
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 @@
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 @@
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;
-
- cur_cat = *new_cat_p;
- cur_v = NULL;
-
- 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;
-
- }
+ if (!rowcount) {
+ ast_log (LOG_NOTICE, "found nothing\n");
+ return cfg;
+ }
- new_v = ast_new_variable (var_name, var_val);
+ cur_cat = ast_config_get_current_category(cfg);
- 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 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;
Index: res_features.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_features.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- res_features.c 21 Jan 2005 07:06:25 -0000 1.36
+++ res_features.c 25 Jan 2005 06:10:20 -0000 1.37
@@ -1444,9 +1444,9 @@
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 @@
ast_log(LOG_NOTICE, "Unknown feature '%s'\n", var->name);
var = var->next;
}
- ast_destroy(cfg);
+ ast_config_destroy(cfg);
}
if (con)
Index: res_indications.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_indications.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- res_indications.c 9 Jan 2005 20:17:51 -0000 1.9
+++ res_indications.c 25 Jan 2005 06:10:20 -0000 1.10
@@ -230,7 +230,7 @@
/* 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 @@
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 @@
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 @@
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 @@
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 @@
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;
}
Index: res_musiconhold.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_musiconhold.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- res_musiconhold.c 21 Jan 2005 07:06:25 -0000 1.51
+++ res_musiconhold.c 25 Jan 2005 06:10:20 -0000 1.52
@@ -865,7 +865,7 @@
char *args;
int x = 0;
- cfg = ast_load("musiconhold.conf");
+ cfg = ast_config_load("musiconhold.conf");
if (!cfg)
return 0;
@@ -897,7 +897,7 @@
var = var->next;
}
- ast_destroy(cfg);
+ ast_config_destroy(cfg);
return x;
}
Index: res_odbc.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_odbc.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- res_odbc.c 21 Jan 2005 07:06:25 -0000 1.10
+++ res_odbc.c 25 Jan 2005 06:10:20 -0000 1.11
@@ -93,7 +93,7 @@
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 @@
}
}
- ast_destroy(config);
+ ast_config_destroy(config);
}
return 0;
}
Index: res_osp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_osp.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- res_osp.c 21 Jan 2005 07:06:25 -0000 1.11
+++ res_osp.c 25 Jan 2005 06:10:20 -0000 1.12
@@ -746,7 +746,7 @@
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 @@
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);
- Previous message: [Asterisk-cvs] asterisk/channels chan_agent.c, 1.107,
1.108 chan_alsa.c, 1.35, 1.36 chan_h323.c, 1.100,
1.101 chan_iax2.c, 1.241, 1.242 chan_mgcp.c, 1.105,
1.106 chan_modem.c, 1.36, 1.37 chan_oss.c, 1.41,
1.42 chan_phone.c, 1.42, 1.43 chan_sip.c, 1.637,
1.638 chan_skinny.c, 1.64, 1.65 chan_vpb.c, 1.63,
1.64 chan_zap.c, 1.403, 1.404 iax2-provision.c, 1.8, 1.9
- Next message: [Asterisk-cvs] asterisk config_old.c,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the svn-commits
mailing list