mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
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: https://origsvn.digium.com/svn/asterisk/trunk@38389 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -314,11 +314,16 @@ static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int
|
|||||||
return running;
|
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;
|
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);
|
ast_channel_unlock(this);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@@ -364,23 +369,23 @@ static int common_exec(struct ast_channel *chan, const int silent, const int bro
|
|||||||
waitms = 100;
|
waitms = 100;
|
||||||
peer = prev = next = NULL;
|
peer = prev = next = NULL;
|
||||||
|
|
||||||
for (peer = next_channel(peer);
|
for (peer = next_channel(peer, spec);
|
||||||
peer;
|
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;
|
const char *group;
|
||||||
int igrp = 0;
|
int igrp = !mygroup;
|
||||||
char *groups[25];
|
char *groups[25];
|
||||||
int num_groups = 0;
|
int num_groups = 0;
|
||||||
char *dup_group;
|
char *dup_group;
|
||||||
int x;
|
int x;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
if (peer == chan)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (peer == prev)
|
if (peer == prev)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (peer == chan)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (mygroup) {
|
if (mygroup) {
|
||||||
if ((group = pbx_builtin_getvar_helper(peer, "SPYGROUP"))) {
|
if ((group = pbx_builtin_getvar_helper(peer, "SPYGROUP"))) {
|
||||||
dup_group = ast_strdupa(group);
|
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]));
|
sizeof(groups) / sizeof(groups[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_groups) {
|
for (x = 0; x < num_groups; x++) {
|
||||||
for (x = 0; x < num_groups; x++) {
|
if (!strcmp(mygroup, groups[x])) {
|
||||||
if (!strcmp(mygroup, groups[x])) {
|
igrp = 1;
|
||||||
igrp = 1;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!igrp)
|
if (!igrp)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (spec && strncasecmp(peer->name, spec, strlen(spec)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (bronly && !ast_bridged_channel(peer))
|
if (bronly && !ast_bridged_channel(peer))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@@ -905,7 +905,8 @@ struct ast_channel *ast_get_channel_by_name_prefix_locked(const char *name, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Get next channel by name prefix and lock it */
|
/*! \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);
|
return channel_find_locked(chan, name, namelen, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
@@ -874,7 +874,7 @@ struct ast_channel *ast_get_channel_by_name_locked(const char *chan);
|
|||||||
struct ast_channel *ast_get_channel_by_name_prefix_locked(const char *name, const int namelen);
|
struct ast_channel *ast_get_channel_by_name_prefix_locked(const char *name, const int namelen);
|
||||||
|
|
||||||
/*! \brief Get channel by name prefix (locks channel) */
|
/*! \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 */
|
/*! \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);
|
struct ast_channel *ast_get_channel_by_exten_locked(const char *exten, const char *context);
|
||||||
|
Reference in New Issue
Block a user