aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-07-27 23:16:08 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-07-27 23:16:08 +0000
commit3bae4f9508f5c0cfc345e1c56b8a3fee434ceeb7 (patch)
tree0c7a3f114e15b8ef6f98a8dd61497997c9bf7735 /apps
parentfafa6738a3e225eb27e3af06cdefd266f1119679 (diff)
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 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@38389 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_chanspy.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index a109673f5..bea2b7d1e 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -314,11 +314,16 @@ static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int
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,23 +369,23 @@ static int common_exec(struct ast_channel *chan, const int silent, const int bro
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 == chan)
- continue;
-
if (peer == prev)
break;
+ if (peer == chan)
+ continue;
+
if (mygroup) {
if ((group = pbx_builtin_getvar_helper(peer, "SPYGROUP"))) {
dup_group = ast_strdupa(group);
@@ -388,22 +393,17 @@ static int common_exec(struct ast_channel *chan, const int silent, const int bro
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))
continue;