[asterisk-commits] kpfleming: trunk r38389 - in /trunk: ./ apps/ include/asterisk/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jul 27 16:16:09 MST 2006


Author: kpfleming
Date: Thu Jul 27 18:16:08 2006
New Revision: 38389

URL: http://svn.digium.com/view/asterisk?rev=38389&view=rev
Log:
more simplification, and correct a bug i introduced in the last commit
fix prototype for a channel walking function to use a const input pointer
use existing channel walk by name prefix instead of reproducing that code in this app

Modified:
    trunk/apps/app_chanspy.c
    trunk/channel.c
    trunk/include/asterisk/channel.h

Modified: trunk/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_chanspy.c?rev=38389&r1=38388&r2=38389&view=diff
==============================================================================
--- trunk/apps/app_chanspy.c (original)
+++ trunk/apps/app_chanspy.c Thu Jul 27 18:16:08 2006
@@ -314,11 +314,16 @@
 	return running;
 }
 
-static struct ast_channel *next_channel(const struct ast_channel *last)
+static struct ast_channel *next_channel(const struct ast_channel *last, const char *spec)
 {
 	struct ast_channel *this;
 
-	if ((this = ast_channel_walk_locked(last)))
+	if (spec)
+		this = ast_walk_channel_by_name_prefix_locked(last, spec, strlen(spec));
+	else
+		this = ast_channel_walk_locked(last);
+
+	if (this)
 		ast_channel_unlock(this);
 
 	return this;
@@ -364,22 +369,22 @@
 		waitms = 100;
 		peer = prev = next = NULL;
 
-		for (peer = next_channel(peer);
+		for (peer = next_channel(peer, spec);
 		     peer;
-		     prev = peer, peer = next ? next : next_channel(peer), next = NULL) {
+		     prev = peer, peer = next ? next : next_channel(peer, spec), next = NULL) {
 			const char *group;
-			int igrp = 0;
+			int igrp = !mygroup;
 			char *groups[25];
 			int num_groups = 0;
 			char *dup_group;
 			int x;
 			char *s;
 				
+			if (peer == prev)
+				break;
+
 			if (peer == chan)
 				continue;
-
-			if (peer == prev)
-				break;
 
 			if (mygroup) {
 				if ((group = pbx_builtin_getvar_helper(peer, "SPYGROUP"))) {
@@ -388,20 +393,15 @@
 									   sizeof(groups) / sizeof(groups[0]));
 				}
 				
-				if (num_groups) {
-					for (x = 0; x < num_groups; x++) {
-						if (!strcmp(mygroup, groups[x])) {
-							igrp = 1;
-							break;
-						}
+				for (x = 0; x < num_groups; x++) {
+					if (!strcmp(mygroup, groups[x])) {
+						igrp = 1;
+						break;
 					}
-				} 
+				}
 			}
 			
 			if (!igrp)
-				continue;
-
-			if (spec && strncasecmp(peer->name, spec, strlen(spec)))
 				continue;
 
 			if (bronly && !ast_bridged_channel(peer))

Modified: trunk/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/channel.c?rev=38389&r1=38388&r2=38389&view=diff
==============================================================================
--- trunk/channel.c (original)
+++ trunk/channel.c Thu Jul 27 18:16:08 2006
@@ -905,7 +905,8 @@
 }
 
 /*! \brief Get next channel by name prefix and lock it */
-struct ast_channel *ast_walk_channel_by_name_prefix_locked(struct ast_channel *chan, const char *name, const int namelen)
+struct ast_channel *ast_walk_channel_by_name_prefix_locked(const struct ast_channel *chan, const char *name,
+							   const int namelen)
 {
 	return channel_find_locked(chan, name, namelen, NULL, NULL);
 }

Modified: trunk/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/channel.h?rev=38389&r1=38388&r2=38389&view=diff
==============================================================================
--- trunk/include/asterisk/channel.h (original)
+++ trunk/include/asterisk/channel.h Thu Jul 27 18:16:08 2006
@@ -874,7 +874,7 @@
 struct ast_channel *ast_get_channel_by_name_prefix_locked(const char *name, const int namelen);
 
 /*! \brief Get channel by name prefix (locks channel) */
-struct ast_channel *ast_walk_channel_by_name_prefix_locked(struct ast_channel *chan, const char *name, const int namelen);
+struct ast_channel *ast_walk_channel_by_name_prefix_locked(const struct ast_channel *chan, const char *name, const int namelen);
 
 /*! \brief Get channel by exten (and optionally context) and lock it */
 struct ast_channel *ast_get_channel_by_exten_locked(const char *exten, const char *context);



More information about the asterisk-commits mailing list