diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-29 21:07:36 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-29 21:07:36 +0000 |
commit | d5d920b890c549f4ffbd0d19f8841c05bd7c7a48 (patch) | |
tree | c1467ae8dd8e31fc2f8601542146ad5e4f1c564a /apps/app_chanspy.c | |
parent | bf2873ddd9c62e9a586314d256b9eccafc8201db (diff) |
Patching app_chanspy to jibe better with what is documented. This allows for
a colon-delimited list of spygroups to be specified when calling the ChanSpy application
with the 'g' option. Prior to this, you could only specify a single group when using the
'g' option.
I also have upped the maximum number of spygroups to 128 and added a #define so that this
can be easily increased or decreased later.
(closes issue #12497)
Reported by: jsmith
Patches:
app_chanspy_multiple_groups_v2.patch uploaded by jsmith (license 15)
Tested by: atis, jvandal
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@114857 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_chanspy.c')
-rw-r--r-- | apps/app_chanspy.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c index 60992a815..d77fa4bbc 100644 --- a/apps/app_chanspy.c +++ b/apps/app_chanspy.c @@ -49,6 +49,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/lock.h" #define AST_NAME_STRLEN 256 +#define NUM_SPYGROUPS 128 static const char *tdesc = "Listen to a channel, and optionally whisper into it"; static const char *app_chan = "ChanSpy"; @@ -70,8 +71,12 @@ static const char *desc_chan = " and a digit sequence.\n" " Options:\n" " b - Only spy on channels involved in a bridged call.\n" -" g(grp) - Match only channels where their SPYGROUP variable is set to\n" -" contain 'grp' in an optional : delimited list.\n" +" g(grp) - Only spy on channels in which one or more of the groups \n" +" listed in 'grp' matches one or more groups from the\n" +" SPYGROUP variable set on the channel to be spied upon.\n" +" Note that both 'grp' and SPYGROUP can contain either a\n" +" single group or a colon-delimited list of groups, such\n" +" as 'sales:support:accounting'.\n" " n([mailbox][@context]) - Say the name of the person being spied on if that person has recorded\n" " his/her name. If a context is specified, then that voicemail context will\n" " be searched when retrieving the name, otherwise the \"default\" context\n" @@ -119,8 +124,12 @@ static const char *desc_ext = " exit to it.\n" " Options:\n" " b - Only spy on channels involved in a bridged call.\n" -" g(grp) - Match only channels where their ${SPYGROUP} variable is set to\n" -" contain 'grp' in an optional : delimited list.\n" +" g(grp) - Only spy on channels in which one or more of the groups \n" +" listed in 'grp' matches one or more groups from the\n" +" SPYGROUP variable set on the channel to be spied upon.\n" +" Note that both 'grp' and SPYGROUP can contain either a\n" +" single group or a colon-delimited list of groups, such\n" +" as 'sales:support:accounting'.\n" " n([mailbox][@context]) - Say the name of the person being spied on if that person has recorded\n" " his/her name. If a context is specified, then that voicemail context will\n" " be searched when retrieving the name, otherwise the \"default\" context\n" @@ -653,10 +662,14 @@ static int common_exec(struct ast_channel *chan, const struct ast_flags *flags, next_channel(chan, prev, spec, exten, context, &chanspy_ds), next_chanspy_ds = NULL) { const char *group; int igrp = !mygroup; - char *groups[25]; + char *groups[NUM_SPYGROUPS]; + char *mygroups[NUM_SPYGROUPS]; int num_groups = 0; char *dup_group; + int num_mygroups = 0; + char *dup_mygroup; int x; + int y; char *s; char *buffer; char *end; @@ -691,16 +704,22 @@ static int common_exec(struct ast_channel *chan, const struct ast_flags *flags, } if (mygroup) { + dup_mygroup = ast_strdupa(mygroup); + num_mygroups = ast_app_separate_args(dup_mygroup, ':', mygroups, + sizeof(mygroups) / sizeof(mygroups[0])); + if ((group = pbx_builtin_getvar_helper(peer, "SPYGROUP"))) { dup_group = ast_strdupa(group); num_groups = ast_app_separate_args(dup_group, ':', groups, sizeof(groups) / sizeof(groups[0])); } - for (x = 0; x < num_groups; x++) { - if (!strcmp(mygroup, groups[x])) { - igrp = 1; - break; + for (y = 0; y < num_mygroups; y++) { + for (x = 0; x < num_groups; x++) { + if (!strcmp(mygroups[y], groups[x])) { + igrp = 1; + break; + } } } } |