[asterisk-commits] russell: branch russell/chan_refcount r102960 - in /team/russell/chan_refcoun...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Feb 7 16:24:35 CST 2008
Author: russell
Date: Thu Feb 7 16:24:35 2008
New Revision: 102960
URL: http://svn.digium.com/view/asterisk?view=rev&rev=102960
Log:
sync with trunk
Modified:
team/russell/chan_refcount/ (props changed)
team/russell/chan_refcount/apps/app_chanspy.c
Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
automerge = *
Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Feb 7 16:24:35 2008
@@ -1,1 +1,1 @@
-/trunk:1-102928
+/trunk:1-102959
Modified: team/russell/chan_refcount/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_chanspy.c?view=diff&rev=102960&r1=102959&r2=102960
==============================================================================
--- team/russell/chan_refcount/apps/app_chanspy.c (original)
+++ team/russell/chan_refcount/apps/app_chanspy.c Thu Feb 7 16:24:35 2008
@@ -88,6 +88,9 @@
" specified by the SPY_EXIT_CONTEXT channel variable. The\n"
" name of the last channel that was spied on will be stored\n"
" in the SPY_CHANNEL variable.\n"
+" e(ext) - Enable 'enforced' mode, so the spying channel can\n"
+" only monitor extensions whose name is in the 'ext' : \n"
+" delimited list.\n"
;
static const char *app_ext = "ExtenSpy";
@@ -137,12 +140,14 @@
OPTION_PRIVATE = (1 << 6), /* Private Whisper mode */
OPTION_READONLY = (1 << 7), /* Don't mix the two channels */
OPTION_EXIT = (1 << 8), /* Exit to a valid single digit extension */
+ OPTION_ENFORCED = (1 << 9), /* Enforced mode */
} chanspy_opt_flags;
enum {
OPT_ARG_VOLUME = 0,
OPT_ARG_GROUP,
OPT_ARG_RECORD,
+ OPT_ARG_ENFORCED,
OPT_ARG_ARRAY_SIZE,
} chanspy_opt_args;
@@ -154,6 +159,7 @@
AST_APP_OPTION_ARG('v', OPTION_VOLUME, OPT_ARG_VOLUME),
AST_APP_OPTION_ARG('g', OPTION_GROUP, OPT_ARG_GROUP),
AST_APP_OPTION_ARG('r', OPTION_RECORD, OPT_ARG_RECORD),
+ AST_APP_OPTION_ARG('e', OPTION_ENFORCED, OPT_ARG_ENFORCED),
AST_APP_OPTION('o', OPTION_READONLY),
AST_APP_OPTION('X', OPTION_EXIT),
});
@@ -375,8 +381,8 @@
}
static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
- int volfactor, const int fd, const char *mygroup, const char *spec,
- const char *exten, const char *context)
+ int volfactor, const int fd, const char *mygroup, const char *myenforced,
+ const char *spec, const char *exten, const char *context)
{
struct ast_channel *peer, *prev, *next;
char nameprefix[AST_NAME_STRLEN];
@@ -473,7 +479,12 @@
char *dup_group;
int x;
char *s;
-
+ char *buffer;
+ char *end;
+ char *ext;
+ char *form_enforced;
+ int ienf = !myenforced;
+
if (peer == prev)
break;
@@ -502,6 +513,37 @@
}
if (!igrp)
+ continue;
+
+ if (myenforced) {
+
+ /* We don't need to allocate more space than just the
+ length of (peer->name) for ext as we will cut the
+ channel name's ending before copying into ext */
+
+ ext = alloca(strlen(peer->name));
+
+ form_enforced = alloca(strlen(myenforced) + 3);
+
+ strcpy(form_enforced, ":");
+ strcat(form_enforced, myenforced);
+ strcat(form_enforced, ":");
+
+ buffer = ast_strdupa(peer->name);
+
+ if ((end = strchr(buffer, '-'))) {
+ *end++ = ':';
+ *end = '\0';
+ }
+
+ strcpy(ext, ":");
+ strcat(ext, buffer);
+
+ if (strcasestr(form_enforced, ext))
+ ienf = 1;
+ }
+
+ if (!ienf)
continue;
strcpy(peer_name, "spy-");
@@ -555,6 +597,7 @@
static int chanspy_exec(struct ast_channel *chan, void *data)
{
+ char *myenforced = NULL;
char *mygroup = NULL;
char *recbase = NULL;
int fd = 0;
@@ -594,6 +637,10 @@
if (ast_test_flag(&flags, OPTION_PRIVATE))
ast_set_flag(&flags, OPTION_WHISPER);
+
+ if (ast_test_flag(&flags, OPTION_ENFORCED))
+ myenforced = opts[OPT_ARG_ENFORCED];
+
} else
ast_clear_flag(&flags, AST_FLAGS_ALL);
@@ -613,7 +660,7 @@
}
}
- res = common_exec(chan, &flags, volfactor, fd, mygroup, args.spec, NULL, NULL);
+ res = common_exec(chan, &flags, volfactor, fd, mygroup, myenforced, args.spec, NULL, NULL);
if (fd)
close(fd);
@@ -692,7 +739,8 @@
}
}
- res = common_exec(chan, &flags, volfactor, fd, mygroup, NULL, exten, args.context);
+
+ res = common_exec(chan, &flags, volfactor, fd, mygroup, NULL, NULL, exten, args.context);
if (fd)
close(fd);
More information about the asterisk-commits
mailing list