Iterate though cdr.conf setting

Review: https://reviewboard.asterisk.org/r/1426/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@335170 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Paul Belanger
2011-09-11 18:21:39 +00:00
parent 1fed068bae
commit b52b026a35
2 changed files with 38 additions and 45 deletions

View File

@@ -27,6 +27,13 @@ func_enum:
differentiate between a failed query and a successful query with 0 results differentiate between a failed query and a successful query with 0 results
matching the specified type. matching the specified type.
Configuration Files:
- Files listed below have been updated to be more consistent with how Asterisk
parses configuration files. This makes configuration files more consistent
with what is expected across modules.
- cdr.conf
From 1.8 to 10: From 1.8 to 10:
cel_pgsql: cel_pgsql:

View File

@@ -1514,21 +1514,12 @@ static struct ast_cli_entry cli_status = AST_CLI_DEFINE(handle_cli_status, "Disp
static int do_reload(int reload) static int do_reload(int reload)
{ {
struct ast_config *config; struct ast_config *config;
const char *enabled_value; struct ast_variable *v;
const char *unanswered_value;
const char *congestion_value;
const char *batched_value;
const char *scheduleronly_value;
const char *batchsafeshutdown_value;
const char *size_value;
const char *time_value;
const char *end_before_h_value;
const char *initiatedseconds_value;
int cfg_size; int cfg_size;
int cfg_time; int cfg_time;
int was_enabled; int was_enabled;
int was_batchmode; int was_batchmode;
int res=0; int res = 0;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
if ((config = ast_config_load2("cdr.conf", "cdr", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) { if ((config = ast_config_load2("cdr.conf", "cdr", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
@@ -1557,45 +1548,40 @@ static int do_reload(int reload)
/* don't run the next scheduled CDR posting while reloading */ /* don't run the next scheduled CDR posting while reloading */
AST_SCHED_DEL(sched, cdr_sched); AST_SCHED_DEL(sched, cdr_sched);
if (config) { for (v = ast_variable_browse(config, "general"); v; v = v->next) {
if ((enabled_value = ast_variable_retrieve(config, "general", "enable"))) { if (!strcasecmp(v->name, "enable")) {
enabled = ast_true(enabled_value); enabled = ast_true(v->value);
} } else if (!strcasecmp(v->name, "unanswered")) {
if ((unanswered_value = ast_variable_retrieve(config, "general", "unanswered"))) { unanswered = ast_true(v->value);
unanswered = ast_true(unanswered_value); } else if (!strcasecmp(v->name, "congestion")) {
} congestion = ast_true(v->value);
if ((congestion_value = ast_variable_retrieve(config, "general", "congestion"))) { } else if (!strcasecmp(v->name, "batch")) {
congestion = ast_true(congestion_value); batchmode = ast_true(v->value);
} } else if (!strcasecmp(v->name, "scheduleronly")) {
if ((batched_value = ast_variable_retrieve(config, "general", "batch"))) { batchscheduleronly = ast_true(v->value);
batchmode = ast_true(batched_value); } else if (!strcasecmp(v->name, "safeshutdown")) {
} batchsafeshutdown = ast_true(v->value);
if ((scheduleronly_value = ast_variable_retrieve(config, "general", "scheduleronly"))) { } else if (!strcasecmp(v->name, "size")) {
batchscheduleronly = ast_true(scheduleronly_value); if (sscanf(v->value, "%30d", &cfg_size) < 1) {
} ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", v->value);
if ((batchsafeshutdown_value = ast_variable_retrieve(config, "general", "safeshutdown"))) { } else if (cfg_size < 0) {
batchsafeshutdown = ast_true(batchsafeshutdown_value);
}
if ((size_value = ast_variable_retrieve(config, "general", "size"))) {
if (sscanf(size_value, "%30d", &cfg_size) < 1)
ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", size_value);
else if (cfg_size < 0)
ast_log(LOG_WARNING, "Invalid maximum batch size '%d' specified, using default\n", cfg_size); ast_log(LOG_WARNING, "Invalid maximum batch size '%d' specified, using default\n", cfg_size);
else } else {
batchsize = cfg_size; batchsize = cfg_size;
} }
if ((time_value = ast_variable_retrieve(config, "general", "time"))) { } else if (!strcasecmp(v->name, "time")) {
if (sscanf(time_value, "%30d", &cfg_time) < 1) if (sscanf(v->value, "%30d", &cfg_time) < 1) {
ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", time_value); ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", v->value);
else if (cfg_time < 0) } else if (cfg_time < 0) {
ast_log(LOG_WARNING, "Invalid maximum batch time '%d' specified, using default\n", cfg_time); ast_log(LOG_WARNING, "Invalid maximum batch time '%d' specified, using default\n", cfg_time);
else } else {
batchtime = cfg_time; batchtime = cfg_time;
} }
if ((end_before_h_value = ast_variable_retrieve(config, "general", "endbeforehexten"))) } else if (!strcasecmp(v->name, "endbeforehexten")) {
ast_set2_flag(&ast_options, ast_true(end_before_h_value), AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN); ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN);
if ((initiatedseconds_value = ast_variable_retrieve(config, "general", "initiatedseconds"))) } else if (!strcasecmp(v->name, "initiatedseconds")) {
ast_set2_flag(&ast_options, ast_true(initiatedseconds_value), AST_OPT_FLAG_INITIATED_SECONDS); ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_INITIATED_SECONDS);
}
} }
if (enabled && !batchmode) { if (enabled && !batchmode) {