[asterisk-commits] dvossel: branch dvossel/hd_confbridge r314595 - /team/dvossel/hd_confbridge/a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Apr 21 11:12:05 CDT 2011


Author: dvossel
Date: Thu Apr 21 11:12:02 2011
New Revision: 314595

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=314595
Log:
Fixes conf menu parsing errors when using dialplan_exec

Modified:
    team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c

Modified: team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c?view=diff&rev=314595&r1=314594&r2=314595
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c Thu Apr 21 11:12:02 2011
@@ -571,7 +571,7 @@
 		}
 	};
 
-	AST_LIST_INSERT_HEAD(&menu_entry->actions, menu_action, action);
+	AST_LIST_INSERT_TAIL(&menu_entry->actions, menu_action, action);
 
 	return 0;
 }
@@ -585,13 +585,43 @@
 	char *action_args;
 	char *tmp;
 	char buf[PATH_MAX];
+	char *delimiter = ",";
 
 	if (!(menu_entry = ast_calloc(1, sizeof(*menu_entry)))) {
 		return -1;
 	}
 
-	while ((action = strsep(&tmp_action_names, ","))) {
-		unsigned int action_len = strlen(action);
+	for (;;) {
+		char *comma;
+		char *startbrace;
+		char *endbrace;
+		unsigned int action_len;
+
+		if (ast_strlen_zero(tmp_action_names)) {
+			break;
+		}
+		startbrace = strchr(tmp_action_names, '(');
+		endbrace = strchr(tmp_action_names, ')');
+		comma = strchr(tmp_action_names, ',');
+
+		/* If the next action has brackets with comma delimited arguments in it,
+		 * make the delimeter ')' instead of a comma to preserve the argments */
+		if (startbrace && endbrace && comma && (comma > startbrace && comma < endbrace)) {
+			delimiter = ")";
+		} else {
+			delimiter = ",";
+		}
+
+		if (!(action = strsep(&tmp_action_names, delimiter))) {
+			break;
+		}
+
+		action = ast_strip(action);
+		if (ast_strlen_zero(action)) {
+			continue;
+		}
+
+		action_len = strlen(action);
 		ast_copy_string(menu_entry->dtmf, dtmf, sizeof(menu_entry->dtmf));
 		if (!strcasecmp(action, "toggle_mute")) {
 			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_TOGGLE_MUTE, NULL);
@@ -615,15 +645,20 @@
 			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_KICK_LAST, NULL);
 		} else if (!strcasecmp(action, "leave_conference")) {
 			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_LEAVE, NULL);
-		} else if (!strncasecmp(action, "dialplan_exec", 13)) {
+		} else if (!strncasecmp(action, "dialplan_exec(", 14)) {
 			ast_copy_string(buf, action, sizeof(buf));
 			action_args = buf;
-			if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
-				*tmp = '\0';
+			if ((action_args = strchr(action, '('))) {
 				action_args++;
 			}
+			/* it is possible that this argument may or may not
+			 * have a closing brace at this point, it all depends on if
+			 * comma delimited arguments were provided */
+			if ((tmp = strchr(action, ')'))) {
+				*tmp = '\0';
+			}
 			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DIALPLAN_EXEC, action_args);
-		} else if (action_len >= 21 && !strncasecmp(action, "playback_and_continue", 21)) {
+		} else if (action_len >= 21 && !strncasecmp(action, "playback_and_continue(", 22)) {
 			ast_copy_string(buf, action, sizeof(buf));
 			action_args = buf;
 			if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
@@ -631,7 +666,7 @@
 				action_args++;
 			}
 			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK_AND_CONTINUE, action_args);
-		} else if (action_len >= 8 && !strncasecmp(action, "playback", 8)) {
+		} else if (action_len >= 8 && !strncasecmp(action, "playback(", 9)) {
 			ast_copy_string(buf, action, sizeof(buf));
 			action_args = buf;
 			if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
@@ -652,7 +687,7 @@
 		return -1;
 	}
 
-	AST_LIST_INSERT_HEAD(&menu->entries, menu_entry, entry);
+	AST_LIST_INSERT_TAIL(&menu->entries, menu_entry, entry);
 
 	return 0;
 }




More information about the asterisk-commits mailing list