fix group and arg parsing bug

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5300 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Anthony Minessale II
2005-03-29 17:46:37 +00:00
parent 9a019128c6
commit c5df0c5e49

View File

@@ -455,12 +455,13 @@ static int chanspy_exec(struct ast_channel *chan, void *data)
if (options) { if (options) {
char *opts[2]; char *opts[2];
ast_parseoptions(chanspy_opts, &flags, opts, options); ast_parseoptions(chanspy_opts, &flags, opts, options);
if (ast_test_flag(&flags, OPTION_GROUP)) if (ast_test_flag(&flags, OPTION_GROUP)) {
mygroup = opts[0]; mygroup = opts[1];
}
silent = ast_test_flag(&flags, OPTION_QUIET); silent = ast_test_flag(&flags, OPTION_QUIET);
bronly = ast_test_flag(&flags, OPTION_BRIDGED); bronly = ast_test_flag(&flags, OPTION_BRIDGED);
if (ast_test_flag(&flags, OPTION_VOLUME) && opts[1]) { if (ast_test_flag(&flags, OPTION_VOLUME) && opts[1]) {
if (sscanf(opts[1], "%d", &volfactor) != 1) if (sscanf(opts[0], "%d", &volfactor) != 1)
ast_log(LOG_NOTICE, "volfactor must be a number between -4 and 4\n"); ast_log(LOG_NOTICE, "volfactor must be a number between -4 and 4\n");
else { else {
volfactor = minmax(volfactor, 4); volfactor = minmax(volfactor, 4);
@@ -490,19 +491,20 @@ static int chanspy_exec(struct ast_channel *chan, void *data)
while(peer) { while(peer) {
if (peer != chan) { if (peer != chan) {
char *group = NULL; char *group = NULL;
int igrp = 1;
if (peer == prev) { if (peer == prev) {
break; break;
} }
group = pbx_builtin_getvar_helper(peer, "SPYGROUP");
group = pbx_builtin_getvar_helper(chan, "SPYGROUP"); if (mygroup) {
if (!group || strcmp(mygroup, group)) {
if (mygroup && group && strcmp(group, mygroup)) { igrp = 0;
continue; }
} }
if (!spec || ((strlen(spec) < strlen(peer->name) &&
!strncasecmp(peer->name, spec, strlen(spec))))) { if (igrp && (!spec || ((strlen(spec) < strlen(peer->name) &&
!strncasecmp(peer->name, spec, strlen(spec)))))) {
if (peer && (!bronly || ast_bridged_channel(peer)) && if (peer && (!bronly || ast_bridged_channel(peer)) &&
!ast_check_hangup(peer) && !ast_test_flag(peer, AST_FLAG_SPYING)) { !ast_check_hangup(peer) && !ast_test_flag(peer, AST_FLAG_SPYING)) {
int x = 0; int x = 0;