[asterisk-commits] pabelanger: branch pabelanger/CDRSettings r334904 - /team/pabelanger/CDRSetti...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Sep 7 18:33:27 CDT 2011
Author: pabelanger
Date: Wed Sep 7 18:33:24 2011
New Revision: 334904
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=334904
Log:
This should work
Modified:
team/pabelanger/CDRSettings/main/cdr.c
Modified: team/pabelanger/CDRSettings/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/team/pabelanger/CDRSettings/main/cdr.c?view=diff&rev=334904&r1=334903&r2=334904
==============================================================================
--- team/pabelanger/CDRSettings/main/cdr.c (original)
+++ team/pabelanger/CDRSettings/main/cdr.c Wed Sep 7 18:33:24 2011
@@ -1517,21 +1517,12 @@
static int do_reload(int reload)
{
struct ast_config *config;
- const char *enabled_value;
- 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;
+ struct ast_variable *v;
int cfg_size;
int cfg_time;
int was_enabled;
int was_batchmode;
- int res=0;
+ int res = 0;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
if ((config = ast_config_load2("cdr.conf", "cdr", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
@@ -1560,46 +1551,50 @@
/* don't run the next scheduled CDR posting while reloading */
AST_SCHED_DEL(sched, cdr_sched);
- if (config) {
- if ((enabled_value = ast_variable_retrieve(config, "general", "enable"))) {
- enabled = ast_true(enabled_value);
- }
- if ((unanswered_value = ast_variable_retrieve(config, "general", "unanswered"))) {
- unanswered = ast_true(unanswered_value);
- }
- if ((congestion_value = ast_variable_retrieve(config, "general", "congestion"))) {
+ for (v = ast_variable_browse(config, "general"); v; v = v->next) {
+ if (!strcasecmp(v->name, "enable")) {
+ enabled = ast_true(v->value);
+ }
+ if (!strcasecmp(v->name, "unanswered")) {
+ unanswered = ast_true(v->value);
+ }
+ if (!strcasecmp(v->name, "congestion")) {
ast_verb(1, "INTHEFACEPUNCH!\n");
- congestion = ast_true(congestion_value);
- }
- if ((batched_value = ast_variable_retrieve(config, "general", "batch"))) {
- batchmode = ast_true(batched_value);
- }
- if ((scheduleronly_value = ast_variable_retrieve(config, "general", "scheduleronly"))) {
- batchscheduleronly = ast_true(scheduleronly_value);
- }
- if ((batchsafeshutdown_value = ast_variable_retrieve(config, "general", "safeshutdown"))) {
- 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)
+ congestion = ast_true(v->value);
+ }
+ if (!strcasecmp(v->name, "batch")) {
+ batchmode = ast_true(v->value);
+ }
+ if (!strcasecmp(v->name, "scheduleronly")) {
+ batchscheduleronly = ast_true(v->value);
+ }
+ if (!strcasecmp(v->name, "safeshutdown")) {
+ batchsafeshutdown = ast_true(v->value);
+ }
+ if (!strcasecmp(v->name, "size")) {
+ if (sscanf(v->value, "%30d", &cfg_size) < 1) {
+ ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", v->value);
+ } else if (cfg_size < 0) {
ast_log(LOG_WARNING, "Invalid maximum batch size '%d' specified, using default\n", cfg_size);
- else
+ } else {
batchsize = cfg_size;
- }
- if ((time_value = ast_variable_retrieve(config, "general", "time"))) {
- if (sscanf(time_value, "%30d", &cfg_time) < 1)
- ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", time_value);
- else if (cfg_time < 0)
+ }
+ }
+ if (!strcasecmp(v->name, "time")) {
+ if (sscanf(v->value, "%30d", &cfg_time) < 1) {
+ ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", v->value);
+ } else if (cfg_time < 0) {
ast_log(LOG_WARNING, "Invalid maximum batch time '%d' specified, using default\n", cfg_time);
- else
+ } else {
batchtime = cfg_time;
- }
- if ((end_before_h_value = ast_variable_retrieve(config, "general", "endbeforehexten")))
- ast_set2_flag(&ast_options, ast_true(end_before_h_value), AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN);
- if ((initiatedseconds_value = ast_variable_retrieve(config, "general", "initiatedseconds")))
- ast_set2_flag(&ast_options, ast_true(initiatedseconds_value), AST_OPT_FLAG_INITIATED_SECONDS);
+ }
+ }
+ if (!strcasecmp(v->name, "endbeforehexten")) {
+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN);
+ }
+ if (!strcasecmp(v->name, "initiatedseconds")) {
+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_INITIATED_SECONDS);
+ }
}
if (enabled && !batchmode) {
More information about the asterisk-commits
mailing list