[asterisk-commits] mmichelson: branch group/CCSS r234373 - /team/group/CCSS/channels/chan_dahdi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 11 09:50:38 CST 2009


Author: mmichelson
Date: Fri Dec 11 09:50:32 2009
New Revision: 234373

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=234373
Log:
Place the group matching and channel matching logic in its own function.


Modified:
    team/group/CCSS/channels/chan_dahdi.c

Modified: team/group/CCSS/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/chan_dahdi.c?view=diff&rev=234373&r1=234372&r2=234373
==============================================================================
--- team/group/CCSS/channels/chan_dahdi.c (original)
+++ team/group/CCSS/channels/chan_dahdi.c Fri Dec 11 09:50:32 2009
@@ -12088,6 +12088,25 @@
 	return p;
 }
 
+static int is_group_or_channel_match(struct dahdi_pvt *p, ast_group_t groupmatch, int *groupmatched, int channelmatch, int *channelmatched)
+{
+	if (groupmatch) {
+		if ((p->group & groupmatch) != groupmatch)
+			/* Doesn't match the specified group, try the next one */
+			return 0;
+		*groupmatched = 1;
+	}
+	/* Check to see if we have a channel match */
+	if (channelmatch != -1) {
+		if (p->channel != channelmatch)
+			/* Doesn't match the specified channel, try the next one */
+			return 0;
+		*channelmatched = 1;
+	}
+
+	return 1;
+}
+
 static struct ast_channel *dahdi_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
 {
 	ast_group_t groupmatch = 0;
@@ -12116,20 +12135,10 @@
 		ast_verbose("name = %s, %d, %d, %llu\n",p->owner ? p->owner->name : "<none>", p->channel, channelmatch, groupmatch);
 #endif
 		/* First, check group matching */
-		if (groupmatch) {
-			if ((p->group & groupmatch) != groupmatch)
-				/* Doesn't match the specified group, try the next one */
-				goto next;
-			groupmatched = 1;
-		}
-		/* Check to see if we have a channel match */
-		if (channelmatch != -1) {
-			if (p->channel != channelmatch)
-				/* Doesn't match the specified channel, try the next one */
-				goto next;
-			channelmatched = 1;
-		}
-
+		if (!is_group_or_channel_match(p, groupmatch, &groupmatched, channelmatch, &channelmatched)) {
+			goto next;
+		}
+		
 		if (p && available(p, channelmatch, groupmatch, &unavailreason, &channelmatched, &groupmatched)) {
 			ast_debug(1, "Using channel %d\n", p->channel);
 




More information about the asterisk-commits mailing list