[asterisk-commits] trunk r25892 - /trunk/pbx.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue May 9 00:49:17 MST 2006


Author: rizzo
Date: Tue May  9 02:49:17 2006
New Revision: 25892

URL: http://svn.digium.com/view/asterisk?rev=25892&view=rev
Log:
more code simplifications.


Modified:
    trunk/pbx.c

Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=25892&r1=25891&r2=25892&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Tue May  9 02:49:17 2006
@@ -1734,8 +1734,8 @@
 		/* For extension callbacks */
 		for (cblist = hint->callbacks; cblist; cblist = cblist->next)
 			cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data);
-			
-		hint->laststate = state;
+
+		hint->laststate = state;	/* record we saw the change */
 	}
 
 	AST_LIST_UNLOCK(&hints);
@@ -1827,7 +1827,6 @@
 
 	AST_LIST_LOCK(&hints);
 
-	/* id is zero is a callback without extension */
 	if (!id) {	/* id == 0 is a callback without extension */
 		for (p_cur = &statecbs; *p_cur; p_cur = &(*p_cur)->next) {
 	 		if ((*p_cur)->callback == callback)
@@ -1837,7 +1836,7 @@
 		struct ast_hint *hint;
 		AST_LIST_TRAVERSE(&hints, hint, list) {
 			for (p_cur = &hint->callbacks; *p_cur; p_cur = &(*p_cur)->next) {
-	    			if ((*p_cur)->id == id)
+				if ((*p_cur)->id == id)
 					break;
 			}
 			if (*p_cur)	/* found in the inner loop */
@@ -3158,30 +3157,20 @@
 
 	/* we obtain [exten@]context? if yes, split them ... */
 	if (argc == 3) {
-		char *splitter = ast_strdupa(argv[2]);
-		/* is there a '@' character? */
-		if (splitter && strchr(argv[2], '@')) {
-			/* yes, split into exten & context ... */
-			exten   = strsep(&splitter, "@");
-			context = splitter;
-
-			/* check for length and change to NULL if ast_strlen_zero() */
+		if (strchr(argv[2], '@')) {	/* split into exten & context */
+			context = ast_strdupa(argv[2]);
+			exten = strsep(&context, "@");
+			/* change empty strings to NULL */
 			if (ast_strlen_zero(exten))
 				exten = NULL;
-			if (ast_strlen_zero(context))
-				context = NULL;
-			show_dialplan_helper(fd, context, exten, &counters, NULL, 0, incstack);
-		} else {
-			/* no '@' char, only context given */
+		} else { /* no '@' char, only context given */
 			context = argv[2];
-			if (ast_strlen_zero(context))
-				context = NULL;
-			show_dialplan_helper(fd, context, exten, &counters, NULL, 0, incstack);
-		}
-	} else {
-		/* Show complete dial plan */
-		show_dialplan_helper(fd, NULL, NULL, &counters, NULL, 0, incstack);
-	}
+		}
+		if (ast_strlen_zero(context))
+			context = NULL;
+	}
+	/* else Show complete dial plan, context and exten are NULL */
+	show_dialplan_helper(fd, context, exten, &counters, NULL, 0, incstack);
 
 	/* check for input failure and throw some error messages */
 	if (context && !counters.context_existence) {
@@ -3338,6 +3327,7 @@
 
 AST_LIST_HEAD(store_hints, store_hint);
 
+/* XXX this does not check that multiple contexts are merged */
 void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char *registrar)
 {
 	struct ast_context *tmp, *lasttmp = NULL;
@@ -3718,7 +3708,6 @@
 	/* allocate new include structure ... */
 	if (!(new_include = ast_calloc(1, length)))
 		return -1;
-	
 	/* Fill in this structure. Use 'p' for assignments, as the fields
 	 * in the structure are 'const char *'
 	 */
@@ -3807,7 +3796,6 @@
 	/* allocate new sw structure ... */
 	if (!(new_sw = ast_calloc(1, length)))
 		return -1;
-	
 	/* ... fill in this structure ... */
 	p = new_sw->stuff;
 	new_sw->name = p;
@@ -3906,7 +3894,6 @@
 		ret = ast_context_add_ignorepat2(c, value, registrar);
 		ast_unlock_contexts();
 	}
-
 	return ret;
 }
 
@@ -3974,7 +3961,6 @@
 			application, data, datad, registrar);
 		ast_unlock_contexts();
 	}
-
 	return ret;
 }
 
@@ -4165,7 +4151,7 @@
 		datad = null_datad;
 	if (!(tmp = ast_calloc(1, length)))
 		return -1;
-		
+
 	/* use p as dst in assignments, as the fields are const char * */
 	p = tmp->stuff;
 	if (label) {
@@ -4389,7 +4375,6 @@
 				chan = NULL;
 			}
 		}
-			
 	}
 	free(as);
 	if (chan)



More information about the asterisk-commits mailing list