[Asterisk-cvs] asterisk/pbx pbx_ael.c,1.13,1.14

markster markster
Thu Oct 13 11:41:50 CDT 2005


Update of /usr/cvsroot/asterisk/pbx
In directory mongoose.digium.com:/tmp/cvs-serv19929/pbx

Modified Files:
	pbx_ael.c 
Log Message:
Fix ael if, while, else (bug #5370)


Index: pbx_ael.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx/pbx_ael.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- pbx_ael.c	23 Sep 2005 02:57:14 -0000	1.13
+++ pbx_ael.c	13 Oct 2005 15:36:29 -0000	1.14
@@ -188,8 +188,8 @@
 							if (aeldebug & DEBUG_TOKENS)
 								ast_verbose("Returning else clause '%s'\n", c);
 						}
+						break;
 					}
-					break;
 				}
 				c++;
 			}
@@ -457,6 +457,27 @@
 	return 0;
 }
 
+static char *argument_end(char *str)
+{
+	int level=0;
+	while(*++str) {
+		switch(*str) {
+		case '(':
+			level++;
+			break;
+		case ')':
+			if(level)
+				level--;
+			else
+				return str;
+			break;
+		default:
+			break;
+		}
+	}
+	return NULL;
+}
+
 static int build_step(const char *what, const char *name, const char *filename, int lineno, struct ast_context *con, char *exten, int *pos, char *data, struct fillin **fillout, char **label);
 static int __build_step(const char *what, const char *name, const char *filename, int lineno, struct ast_context *con, char *exten, int *pos, char *data, struct fillin **fillout, char **label)
 {
@@ -485,7 +506,7 @@
 		/* Switch */
 		args = data + strlen("switch");
 		while ((*args < 33) && (*args != '(')) args++;
-		if ((*args == '(') && (c = strchr(args, ')'))) {
+		if ((*args == '(') && (c = argument_end(args))) {
 			args++;
 			*c = '\0';
 			c++;
@@ -570,7 +591,7 @@
 		/* If... */
 		args = data + strlen("if");
 		while ((*args < 33) && (*args != '(')) args++;
-		if ((*args == '(') && (c = strchr(args, ')'))) {
+		if ((*args == '(') && (c = argument_end(args))) {
 			int ifblock;
 			int ifstart;
 			int elsestart;
@@ -632,7 +653,7 @@
 		fillin = NULL;
 		args = data + strlen("while");
 		while ((*args < 33) && (*args != '(')) args++;
-		if ((*args == '(') && (c = strchr(args, ')'))) {
+		if ((*args == '(') && (c = argument_end(args))) {
 			int whileblock;
 			int whilestart;
 			int whileend;
@@ -720,7 +741,7 @@
 		fillin = NULL;
 		args = data + strlen("for");
 		while ((*args < 33) && (*args != '(')) args++;
-		if ((*args == '(') && (c = strchr(args, ')'))) {
+		if ((*args == '(') && (c = argument_end(args))) {
 			int forblock;
 			int forprep;
 			int forstart;
@@ -1166,15 +1187,6 @@
 	return 0;
 }
 
-/*
- * Standard module functions ...
- */
-int unload_module(void)
-{
-	ast_context_destroy(NULL, registrar);
-	return 0;
-}
-
 static int pbx_load_module(void)
 {
 	struct ast_context *local_contexts=NULL, *con;
@@ -1186,21 +1198,75 @@
 	return 0;
 }
 
-int load_module(void)
+/* CLI interface */
+static int ael_debug_read(int fd, int argc, char *argv[])
 {
-	if (pbx_load_module()) return -1;
- 
+	aeldebug |= DEBUG_READ;
 	return 0;
 }
 
-int reload(void)
+static int ael_debug_tokens(int fd, int argc, char *argv[])
+{
+	aeldebug |= DEBUG_TOKENS;
+	return 0;
+}
+
+static int ael_debug_macros(int fd, int argc, char *argv[])
+{
+	aeldebug |= DEBUG_MACROS;
+	return 0;
+}
+
+static int ael_debug_contexts(int fd, int argc, char *argv[])
+{
+	aeldebug |= DEBUG_CONTEXTS;
+	return 0;
+}
+
+static int ael_no_debug(int fd, int argc, char *argv[])
+{
+	aeldebug = 0;
+	return 0;
+}
+
+static int ael_reload(int fd, int argc, char *argv[])
 {
 	ast_context_destroy(NULL, registrar);
-	/* For martin's global variables, don't clear them on reload */
-	pbx_load_module();
+	return (pbx_load_module());
+}
+
+static struct ast_cli_entry  ael_cli[] = {
+	{ { "ael", "reload", NULL }, ael_reload, "Reload AEL configuration"},
+	{ { "ael", "debug", "read", NULL }, ael_debug_read, "Enable AEL read debug"},
+	{ { "ael", "debug", "tokens", NULL }, ael_debug_tokens, "Enable AEL tokens debug"},
+	{ { "ael", "debug", "macros", NULL }, ael_debug_macros, "Enable AEL macros debug"},
+	{ { "ael", "debug", "contexts", NULL }, ael_debug_contexts, "Enable AEL contexts debug"},
+	{ { "ael", "no", "debug", NULL }, ael_no_debug, "Disable AEL debug messages"},
+};
+
+/*
+ * Standard module functions ...
+ */
+int unload_module(void)
+{
+	ast_context_destroy(NULL, registrar);
+	ast_cli_unregister_multiple(ael_cli, sizeof(ael_cli)/ sizeof(ael_cli[0]));
 	return 0;
 }
 
+
+int load_module(void)
+{
+	ast_cli_register_multiple(ael_cli, sizeof(ael_cli)/ sizeof(ael_cli[0]));
+	return (pbx_load_module());
+}
+
+int reload(void)
+{
+	unload_module();
+	return (load_module());
+}
+
 int usecount(void)
 {
 	return 0;




More information about the svn-commits mailing list