[Asterisk-code-review] res_musiconhold: Remove redundant option parsing (...asterisk[master])
Joshua C. Colp
asteriskteam at digium.com
Thu Mar 14 09:19:55 CDT 2019
Joshua C. Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11121 )
Change subject: res_musiconhold: Remove redundant option parsing
......................................................................
res_musiconhold: Remove redundant option parsing
Change-Id: I481fabd8eaf2e4e7ffb5c8285b294742826e7d12
---
M res/res_musiconhold.c
1 file changed, 19 insertions(+), 43 deletions(-)
Approvals:
Joshua C. Colp: Looks good to me, but someone else must approve; Approved for Submit
Kevin Harwell: Looks good to me, approved
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index d14e209..8fc58a1 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -1088,6 +1088,9 @@
ast_copy_string(mohclass->dir, var->value, sizeof(mohclass->dir));
} else if (!strcasecmp(var->name, "application")) {
ast_copy_string(mohclass->args, var->value, sizeof(mohclass->args));
+ } else if (!strcasecmp(var->name, "announcement")) {
+ ast_copy_string(mohclass->announcement, var->value, sizeof(mohclass->announcement));
+ ast_set_flag(mohclass, MOH_ANNOUNCEMENT);
} else if (!strcasecmp(var->name, "digit") && (isdigit(*var->value) || strchr("*#", *var->value))) {
mohclass->digit = *var->value;
} else if (!strcasecmp(var->name, "random")) {
@@ -1112,6 +1115,22 @@
ast_log(LOG_WARNING, "Unknown format '%s' -- defaulting to SLIN\n", var->value);
mohclass->format = ao2_bump(ast_format_slin);
}
+ } else if (!strcasecmp(var->name, "kill_escalation_delay")) {
+ if (sscanf(var->value, "%zu", &mohclass->kill_delay) == 1) {
+ mohclass->kill_delay *= 1000;
+ } else {
+ ast_log(LOG_WARNING, "kill_escalation_delay '%s' is invalid. Setting to 100ms\n", var->value);
+ mohclass->kill_delay = 100000;
+ }
+ } else if (!strcasecmp(var->name, "kill_method")) {
+ if (!strcasecmp(var->value, "process")) {
+ mohclass->kill_method = KILL_METHOD_PROCESS;
+ } else if (!strcasecmp(var->value, "process_group")) {
+ mohclass->kill_method = KILL_METHOD_PROCESS_GROUP;
+ } else {
+ ast_log(LOG_WARNING, "kill_method '%s' is invalid. Setting to 'process_group'\n", var->value);
+ mohclass->kill_method = KILL_METHOD_PROCESS_GROUP;
+ }
}
}
}
@@ -1778,49 +1797,6 @@
/* For compatibility with the past, we overwrite any name=name
* with the context [name]. */
ast_copy_string(class->name, cat, sizeof(class->name));
- for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
- if (!strcasecmp(var->name, "mode")) {
- ast_copy_string(class->mode, var->value, sizeof(class->mode));
- } else if (!strcasecmp(var->name, "directory")) {
- ast_copy_string(class->dir, var->value, sizeof(class->dir));
- } else if (!strcasecmp(var->name, "application")) {
- ast_copy_string(class->args, var->value, sizeof(class->args));
- } else if (!strcasecmp(var->name, "announcement")) {
- ast_copy_string(class->announcement, var->value, sizeof(class->announcement));
- ast_set_flag(class, MOH_ANNOUNCEMENT);
- } else if (!strcasecmp(var->name, "digit") && (isdigit(*var->value) || strchr("*#", *var->value))) {
- class->digit = *var->value;
- } else if (!strcasecmp(var->name, "random")) {
- ast_set2_flag(class, ast_true(var->value), MOH_RANDOMIZE);
- } else if (!strcasecmp(var->name, "sort") && !strcasecmp(var->value, "random")) {
- ast_set_flag(class, MOH_RANDOMIZE);
- } else if (!strcasecmp(var->name, "sort") && !strcasecmp(var->value, "alpha")) {
- ast_set_flag(class, MOH_SORTALPHA);
- } else if (!strcasecmp(var->name, "format")) {
- ao2_cleanup(class->format);
- class->format = ast_format_cache_get(var->value);
- if (!class->format) {
- ast_log(LOG_WARNING, "Unknown format '%s' -- defaulting to SLIN\n", var->value);
- class->format = ao2_bump(ast_format_slin);
- }
- } else if (!strcasecmp(var->name, "kill_escalation_delay")) {
- if (sscanf(var->value, "%zu", &class->kill_delay) == 1) {
- class->kill_delay *= 1000;
- } else {
- ast_log(LOG_WARNING, "kill_escalation_delay '%s' is invalid. Setting to 100ms\n", var->value);
- class->kill_delay = 100000;
- }
- } else if (!strcasecmp(var->name, "kill_method")) {
- if (!strcasecmp(var->value, "process")) {
- class->kill_method = KILL_METHOD_PROCESS;
- } else if (!strcasecmp(var->value, "process_group")){
- class->kill_method = KILL_METHOD_PROCESS_GROUP;
- } else {
- ast_log(LOG_WARNING, "kill_method '%s' is invalid. Setting to 'process_group'\n", var->value);
- class->kill_method = KILL_METHOD_PROCESS_GROUP;
- }
- }
- }
if (ast_strlen_zero(class->dir)) {
if (!strcasecmp(class->mode, "custom")) {
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11121
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I481fabd8eaf2e4e7ffb5c8285b294742826e7d12
Gerrit-Change-Number: 11121
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua C. Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190314/95d0d306/attachment.html>
More information about the asterisk-code-review
mailing list