[asterisk-commits] mmichelson: trunk r114857 - /trunk/apps/app_chanspy.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Apr 29 16:07:36 CDT 2008
Author: mmichelson
Date: Tue Apr 29 16:07:36 2008
New Revision: 114857
URL: http://svn.digium.com/view/asterisk?view=rev&rev=114857
Log:
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
Modified:
trunk/apps/app_chanspy.c
Modified: trunk/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_chanspy.c?view=diff&rev=114857&r1=114856&r2=114857
==============================================================================
--- trunk/apps/app_chanspy.c (original)
+++ trunk/apps/app_chanspy.c Tue Apr 29 16:07:36 2008
@@ -49,6 +49,7 @@
#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 @@
" 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 @@
" 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 @@
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 @@
}
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;
+ }
}
}
}
More information about the asterisk-commits
mailing list