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

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed May 10 15:14:57 MST 2006


Author: rizzo
Date: Wed May 10 17:14:56 2006
New Revision: 26686

URL: http://svn.digium.com/view/asterisk?rev=26686&view=rev
Log:
replace a macro with actual code;
mark dubious code with XXX.


Modified:
    trunk/pbx.c

Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=26686&r1=26685&r2=26686&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Wed May 10 17:14:56 2006
@@ -4218,7 +4218,9 @@
 {
 }
 
-/*! \brief add the extension in the priority chain */
+/*! \brief add the extension in the priority chain.
+ * returns 0 on success, -1 on failure
+ */
 static int add_pri(struct ast_context *con, struct ast_exten *tmp,
 	struct ast_exten *el, struct ast_exten *e, int replace)
 {
@@ -4306,21 +4308,6 @@
 	const char *application, void *data, void (*datad)(void *),
 	const char *registrar)
 {
-
-#define LOG do { 	if (option_debug) {\
-		if (tmp->matchcid) { \
-			ast_log(LOG_DEBUG, "Added extension '%s' priority %d (CID match '%s') to %s\n", tmp->exten, tmp->priority, tmp->cidmatch, con->name); \
-		} else { \
-			ast_log(LOG_DEBUG, "Added extension '%s' priority %d to %s\n", tmp->exten, tmp->priority, con->name); \
-		} \
-	} else if (option_verbose > 2) { \
-		if (tmp->matchcid) { \
-			ast_verbose( VERBOSE_PREFIX_3 "Added extension '%s' priority %d (CID match '%s')to %s\n", tmp->exten, tmp->priority, tmp->cidmatch, con->name); \
-		} else {  \
-			ast_verbose( VERBOSE_PREFIX_3 "Added extension '%s' priority %d to %s\n", tmp->exten, tmp->priority, con->name); \
-		} \
-	} } while(0)
-
 	/*
 	 * Sort extensions (or patterns) according to the rules indicated above.
 	 * These are implemented by the function ext_cmp()).
@@ -4337,7 +4324,7 @@
 	   contains variable references, then expand them
 	*/
 	ast_mutex_lock(&globalslock);
-	if ((priority == PRIORITY_HINT) && AST_LIST_FIRST(&globals) && strstr(application, "${")) {
+	if (priority == PRIORITY_HINT && AST_LIST_FIRST(&globals) && strstr(application, "${")) {
 		pbx_substitute_variables_varshead(&globals, application, expand_buf, sizeof(expand_buf));
 		application = expand_buf;
 	}
@@ -4402,28 +4389,43 @@
 			break;
 	}
 	if (e && res == 0) { /* exact match, insert in the pri chain */
-		int ret = add_pri(con, tmp, el, e, replace);
+		res = add_pri(con, tmp, el, e, replace);
 		ast_mutex_unlock(&con->lock);
-		if (ret < 0)
-			errno = EEXIST;
-		else {
-			LOG;
-		}
-		return ret;
-	}
-	/*
-	 * not an exact match, this is the first entry with this pattern,
-	 * so insert in the main list right before 'e' (if any)
-	 */
-	tmp->next = e;
-	if (el)
-		el->next = tmp;
-	else
-		con->root = tmp;
-	ast_mutex_unlock(&con->lock);
-	if (tmp->priority == PRIORITY_HINT)
-		ast_add_hint(tmp);
-	LOG;
+		if (res < 0) {
+			errno = EEXIST;	/* XXX do we care ? */
+			return 0; /* XXX should we return -1 maybe ? */
+		}
+	} else {
+		/*
+		 * not an exact match, this is the first entry with this pattern,
+		 * so insert in the main list right before 'e' (if any)
+		 */
+		tmp->next = e;
+		if (el)
+			el->next = tmp;
+		else
+			con->root = tmp;
+		ast_mutex_unlock(&con->lock);
+		if (tmp->priority == PRIORITY_HINT)
+			ast_add_hint(tmp);
+	}
+	if (option_debug) {
+		if (tmp->matchcid) {
+			ast_log(LOG_DEBUG, "Added extension '%s' priority %d (CID match '%s') to %s\n",
+				tmp->exten, tmp->priority, tmp->cidmatch, con->name);
+		} else {
+			ast_log(LOG_DEBUG, "Added extension '%s' priority %d to %s\n",
+				tmp->exten, tmp->priority, con->name);
+		}
+	} else if (option_verbose > 2) {
+		if (tmp->matchcid) {
+			ast_verbose( VERBOSE_PREFIX_3 "Added extension '%s' priority %d (CID match '%s')to %s\n",
+				tmp->exten, tmp->priority, tmp->cidmatch, con->name);
+		} else {
+			ast_verbose( VERBOSE_PREFIX_3 "Added extension '%s' priority %d to %s\n",
+				tmp->exten, tmp->priority, con->name);
+		}
+	}
 	return 0;
 }
 



More information about the asterisk-commits mailing list