[asterisk-commits] rmudgett: branch rmudgett/parking r330820 - in /team/rmudgett/parking: config...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Aug 3 12:05:41 CDT 2011
Author: rmudgett
Date: Wed Aug 3 12:05:37 2011
New Revision: 330820
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=330820
Log:
Factored process_applicationmap_line() out of process_config() to
eliminate using ast_strdupa() within a loop in a function.
Modified:
team/rmudgett/parking/configs/features.conf.sample
team/rmudgett/parking/main/features.c
Modified: team/rmudgett/parking/configs/features.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/parking/configs/features.conf.sample?view=diff&rev=330820&r1=330819&r2=330820
==============================================================================
--- team/rmudgett/parking/configs/features.conf.sample (original)
+++ team/rmudgett/parking/configs/features.conf.sample Wed Aug 3 12:05:37 2011
@@ -124,7 +124,7 @@
;<FeatureName> => <DTMF_sequence>,<ActivateOn>[/<ActivatedBy>],<Application>([<AppArguments>])[,MOH_Class]
;
-; FeatureName -> This is the name of the feature used in when setting the
+; FeatureName -> This is the name of the feature used when setting the
; DYNAMIC_FEATURES variable to enable usage of this feature.
; DTMF_sequence -> This is the key sequence used to activate this feature.
; ActivateOn -> This is the channel of the call that the application will be executed
Modified: team/rmudgett/parking/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/parking/main/features.c?view=diff&rev=330820&r1=330819&r2=330820
==============================================================================
--- team/rmudgett/parking/main/features.c (original)
+++ team/rmudgett/parking/main/features.c Wed Aug 3 12:05:37 2011
@@ -4298,6 +4298,7 @@
ast_debug(1,
"MOH on parked call stopped by outside source. Restarting on channel %s.\n",
chan->name);
+/* BUGBUG update last request of ring or hold to peer. */
ast_indicate_data(chan, AST_CONTROL_HOLD,
S_OR(pu->parkinglot->cfg.mohclass, NULL),
(!ast_strlen_zero(pu->parkinglot->cfg.mohclass)
@@ -5054,6 +5055,111 @@
return parkinglot;
}
+/*!
+ * \internal
+ * \brief Process an applicationmap section config line.
+ *
+ * \param var Config variable line.
+ *
+ * \return Nothing
+ */
+static void process_applicationmap_line(struct ast_variable *var)
+{
+ char *tmp_val = ast_strdupa(var->value);
+ char *activateon;
+ struct ast_call_feature *feature;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(exten);
+ AST_APP_ARG(activatedby);
+ AST_APP_ARG(app);
+ AST_APP_ARG(app_args);
+ AST_APP_ARG(moh_class);
+ );
+
+ AST_STANDARD_APP_ARGS(args, tmp_val);
+ if (strchr(args.app, '(')) {
+ /* New syntax */
+ args.moh_class = args.app_args;
+ args.app_args = strchr(args.app, '(');
+ *args.app_args++ = '\0';
+ if (args.app_args[strlen(args.app_args) - 1] == ')') {
+ args.app_args[strlen(args.app_args) - 1] = '\0';
+ }
+ }
+
+ activateon = strsep(&args.activatedby, "/");
+
+ /*! \todo XXX var_name or app_args ? */
+ if (ast_strlen_zero(args.app)
+ || ast_strlen_zero(args.exten)
+ || ast_strlen_zero(activateon)
+ || ast_strlen_zero(var->name)) {
+ ast_log(LOG_NOTICE,
+ "Please check the feature Mapping Syntax, either extension, name, or app aren't provided %s %s %s %s\n",
+ args.app, args.exten, activateon, var->name);
+ return;
+ }
+
+ AST_RWLIST_RDLOCK(&feature_list);
+ if (find_dynamic_feature(var->name)) {
+ AST_RWLIST_UNLOCK(&feature_list);
+ ast_log(LOG_WARNING, "Dynamic Feature '%s' specified more than once!\n",
+ var->name);
+ return;
+ }
+ AST_RWLIST_UNLOCK(&feature_list);
+
+ if (!(feature = ast_calloc(1, sizeof(*feature)))) {
+ return;
+ }
+
+ ast_copy_string(feature->sname, var->name, FEATURE_SNAME_LEN);
+ ast_copy_string(feature->app, args.app, FEATURE_APP_LEN);
+ ast_copy_string(feature->exten, args.exten, FEATURE_EXTEN_LEN);
+
+ if (args.app_args) {
+ ast_copy_string(feature->app_args, args.app_args, FEATURE_APP_ARGS_LEN);
+ }
+
+ if (args.moh_class) {
+ ast_copy_string(feature->moh_class, args.moh_class, FEATURE_MOH_LEN);
+ }
+
+ ast_copy_string(feature->exten, args.exten, sizeof(feature->exten));
+ feature->operation = feature_exec_app;
+ ast_set_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF);
+
+ /* Allow caller and callee to be specified for backwards compatability */
+ if (!strcasecmp(activateon, "self") || !strcasecmp(activateon, "caller")) {
+ ast_set_flag(feature, AST_FEATURE_FLAG_ONSELF);
+ } else if (!strcasecmp(activateon, "peer") || !strcasecmp(activateon, "callee")) {
+ ast_set_flag(feature, AST_FEATURE_FLAG_ONPEER);
+ } else {
+ ast_log(LOG_NOTICE, "Invalid 'ActivateOn' specification for feature '%s',"
+ " must be 'self', or 'peer'\n", var->name);
+ return;
+ }
+
+ if (ast_strlen_zero(args.activatedby)) {
+ ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
+ } else if (!strcasecmp(args.activatedby, "caller")) {
+ ast_set_flag(feature, AST_FEATURE_FLAG_BYCALLER);
+ } else if (!strcasecmp(args.activatedby, "callee")) {
+ ast_set_flag(feature, AST_FEATURE_FLAG_BYCALLEE);
+ } else if (!strcasecmp(args.activatedby, "both")) {
+ ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
+ } else {
+ ast_log(LOG_NOTICE, "Invalid 'ActivatedBy' specification for feature '%s',"
+ " must be 'caller', or 'callee', or 'both'\n", var->name);
+ return;
+ }
+
+ ast_register_feature(feature);
+
+ ast_verb(2, "Mapping Feature '%s' to app '%s(%s)' with code '%s'\n",
+ var->name, args.app, args.app_args, args.exten);
+}
+
static int process_config(struct ast_config *cfg)
{
int i;
@@ -5088,7 +5194,6 @@
var = ast_variable_browse(cfg, "general");
build_parkinglot(DEFAULT_PARKINGLOT, var);
-
for (; var; var = var->next) {
if (!strcasecmp(var->name, "parkeddynamic")) {
parkeddynamic = ast_true(var->value);
@@ -5162,94 +5267,7 @@
/* Map a key combination to an application */
ast_unregister_features();
for (var = ast_variable_browse(cfg, "applicationmap"); var; var = var->next) {
-/* BUGBUG alloca in a loop */
- char *tmp_val = ast_strdupa(var->value);
- char *activateon;
- struct ast_call_feature *feature;
- AST_DECLARE_APP_ARGS(args,
- AST_APP_ARG(exten);
- AST_APP_ARG(activatedby);
- AST_APP_ARG(app);
- AST_APP_ARG(app_args);
- AST_APP_ARG(moh_class);
- );
-
- AST_STANDARD_APP_ARGS(args, tmp_val);
- if (strchr(args.app, '(')) {
- /* New syntax */
- args.moh_class = args.app_args;
- args.app_args = strchr(args.app, '(');
- *args.app_args++ = '\0';
- if (args.app_args[strlen(args.app_args) - 1] == ')') {
- args.app_args[strlen(args.app_args) - 1] = '\0';
- }
- }
-
- activateon = strsep(&args.activatedby, "/");
-
- /*! \todo XXX var_name or app_args ? */
- if (ast_strlen_zero(args.app) || ast_strlen_zero(args.exten) || ast_strlen_zero(activateon) || ast_strlen_zero(var->name)) {
- ast_log(LOG_NOTICE, "Please check the feature Mapping Syntax, either extension, name, or app aren't provided %s %s %s %s\n",
- args.app, args.exten, activateon, var->name);
- continue;
- }
-
- AST_RWLIST_RDLOCK(&feature_list);
- if ((feature = find_dynamic_feature(var->name))) {
- AST_RWLIST_UNLOCK(&feature_list);
- ast_log(LOG_WARNING, "Dynamic Feature '%s' specified more than once!\n", var->name);
- continue;
- }
- AST_RWLIST_UNLOCK(&feature_list);
-
- if (!(feature = ast_calloc(1, sizeof(*feature)))) {
- continue;
- }
-
- ast_copy_string(feature->sname, var->name, FEATURE_SNAME_LEN);
- ast_copy_string(feature->app, args.app, FEATURE_APP_LEN);
- ast_copy_string(feature->exten, args.exten, FEATURE_EXTEN_LEN);
-
- if (args.app_args) {
- ast_copy_string(feature->app_args, args.app_args, FEATURE_APP_ARGS_LEN);
- }
-
- if (args.moh_class) {
- ast_copy_string(feature->moh_class, args.moh_class, FEATURE_MOH_LEN);
- }
-
- ast_copy_string(feature->exten, args.exten, sizeof(feature->exten));
- feature->operation = feature_exec_app;
- ast_set_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF);
-
- /* Allow caller and callee to be specified for backwards compatability */
- if (!strcasecmp(activateon, "self") || !strcasecmp(activateon, "caller")) {
- ast_set_flag(feature, AST_FEATURE_FLAG_ONSELF);
- } else if (!strcasecmp(activateon, "peer") || !strcasecmp(activateon, "callee")) {
- ast_set_flag(feature, AST_FEATURE_FLAG_ONPEER);
- } else {
- ast_log(LOG_NOTICE, "Invalid 'ActivateOn' specification for feature '%s',"
- " must be 'self', or 'peer'\n", var->name);
- continue;
- }
-
- if (ast_strlen_zero(args.activatedby)) {
- ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
- } else if (!strcasecmp(args.activatedby, "caller")) {
- ast_set_flag(feature, AST_FEATURE_FLAG_BYCALLER);
- } else if (!strcasecmp(args.activatedby, "callee")) {
- ast_set_flag(feature, AST_FEATURE_FLAG_BYCALLEE);
- } else if (!strcasecmp(args.activatedby, "both")) {
- ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
- } else {
- ast_log(LOG_NOTICE, "Invalid 'ActivatedBy' specification for feature '%s',"
- " must be 'caller', or 'callee', or 'both'\n", var->name);
- continue;
- }
-
- ast_register_feature(feature);
-
- ast_verb(2, "Mapping Feature '%s' to app '%s(%s)' with code '%s'\n", var->name, args.app, args.app_args, args.exten);
+ process_applicationmap_line(var);
}
ast_unregister_groups();
More information about the asterisk-commits
mailing list