[svn-commits] trunk r21393 - /trunk/pbx.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed Apr 19 02:31:43 MST 2006


Author: rizzo
Date: Wed Apr 19 04:31:41 2006
New Revision: 21393

URL: http://svn.digium.com/view/asterisk?rev=21393&view=rev
Log:
one more client for find_context_locked(),
plus a few minor fixes.


Modified:
    trunk/pbx.c

Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=21393&r1=21392&r2=21393&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Wed Apr 19 04:31:41 2006
@@ -2417,29 +2417,15 @@
  */
 int ast_context_remove_include(const char *context, const char *include, const char *registrar)
 {
-	struct ast_context *c = NULL;
-
-	if (ast_lock_contexts())
-		return -1;
-
-	/* walk contexts and search for the right one ...*/
-	while ( (c = ast_walk_contexts(c)) ) {
-		/* we found one ... */
-		if (!strcmp(ast_get_context_name(c), context)) {
-			int ret;
-			/* remove include from this context ... */	
-			ret = ast_context_remove_include2(c, include, registrar);
-
-			ast_unlock_contexts();
-
-			/* ... return results */
-			return ret;
-		}
-	}
-
-	/* we can't find the right one context */
-	ast_unlock_contexts();
-	return -1;
+	int ret = -1;
+	struct ast_context *c = find_context_locked(context);
+
+	if (c) {
+		/* found, remove include from this context ... */
+		ret = ast_context_remove_include2(c, include, registrar);
+		ast_unlock_contexts();
+	}
+	return ret;
 }
 
 /*
@@ -5101,10 +5087,7 @@
 static int pbx_builtin_setamaflags(struct ast_channel *chan, void *data)
 {
 	/* Copy the AMA Flags as specified */
-	if (data)
-		ast_cdr_setamaflags(chan, data);
-	else
-		ast_cdr_setamaflags(chan, "");
+	ast_cdr_setamaflags(chan, data ? data : "");
 	return 0;
 }
 
@@ -5359,7 +5342,7 @@
  */
 static int pbx_builtin_goto(struct ast_channel *chan, void *data)
 {
-	int res = ast_parseable_goto(chan, (const char *) data);
+	int res = ast_parseable_goto(chan, data);
 	if (!res && (option_verbose > 2))
 		ast_verbose( VERBOSE_PREFIX_3 "Goto (%s,%s,%d)\n", chan->context,chan->exten, chan->priority+1);
 	return res;
@@ -5601,7 +5584,7 @@
 		return 0;
 	else if (*condition >= '0' && *condition <= '9')	/* Numbers are evaluated for truth */
 		return atoi(condition);
-	else	/* Strings are true */
+	else	/* Strings are true -- XXX maybe use ast_true() ? */
 		return 1;
 }
 
@@ -5609,7 +5592,7 @@
 {
 	char *condition, *branch1, *branch2, *branch;
 	int rc;
-	char *stringp=NULL;
+	char *stringp;
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "Ignoring, since there is no variable to check\n");
@@ -5900,12 +5883,14 @@
 	if (!chan)
 		return -2;
 
+	if (context == NULL)
+		context = chan->context;
+	if (exten == NULL)
+		exten = chan->exten;
+
 	goto_func = (async) ? ast_async_goto : ast_explicit_goto;
-	if (ast_exists_extension(chan, context ? context : chan->context,
-				 exten ? exten : chan->exten, priority,
-				 chan->cid.cid_num))
-		return goto_func(chan, context ? context : chan->context,
-				 exten ? exten : chan->exten, priority);
+	if (ast_exists_extension(chan, context, exten, priority, chan->cid.cid_num))
+		return goto_func(chan, context, exten, priority);
 	else 
 		return -3;
 }



More information about the svn-commits mailing list