Code cleanup

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2919 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.0
James Golovich 22 years ago
parent 66b96f417c
commit 46b24e8a27

21
app.c

@ -260,23 +260,24 @@ int ast_app_messagecount(const char *mailbox, int *newmsgs, int *oldmsgs)
return 0; return 0;
} }
int ast_dtmf_stream(struct ast_channel *chan,struct ast_channel *peer,char *digits,int between) { int ast_dtmf_stream(struct ast_channel *chan,struct ast_channel *peer,char *digits,int between)
{
char *ptr=NULL; char *ptr=NULL;
int res=0; int res=0;
struct ast_frame f; struct ast_frame f;
if(!between) if (!between)
between = 100; between = 100;
if(peer) if (peer)
res = ast_autoservice_start(peer); res = ast_autoservice_start(peer);
if (!res) { if (!res) {
res = ast_waitfor(chan,100); res = ast_waitfor(chan,100);
if(res > -1) { if (res > -1) {
for(ptr=digits;*ptr;*ptr++) { for (ptr=digits;*ptr;*ptr++) {
if(*ptr == 'w') { if (*ptr == 'w') {
res = ast_safe_sleep(chan, 500); res = ast_safe_sleep(chan, 500);
if(res) if (res)
break; break;
continue; continue;
} }
@ -286,8 +287,7 @@ int ast_dtmf_stream(struct ast_channel *chan,struct ast_channel *peer,char *digi
f.src = "ast_dtmf_stream"; f.src = "ast_dtmf_stream";
if (strchr("0123456789*#abcdABCD",*ptr)==NULL) { if (strchr("0123456789*#abcdABCD",*ptr)==NULL) {
ast_log(LOG_WARNING, "Illegal DTMF character '%c' in string. (0-9*#aAbBcCdD allowed)\n",*ptr); ast_log(LOG_WARNING, "Illegal DTMF character '%c' in string. (0-9*#aAbBcCdD allowed)\n",*ptr);
} } else {
else {
res = ast_write(chan, &f); res = ast_write(chan, &f);
if (res) if (res)
break; break;
@ -298,9 +298,8 @@ int ast_dtmf_stream(struct ast_channel *chan,struct ast_channel *peer,char *digi
} }
} }
} }
if(peer) if (peer)
res = ast_autoservice_stop(peer); res = ast_autoservice_stop(peer);
} }
return res; return res;
} }

@ -25,6 +25,7 @@
#include <asterisk/musiconhold.h> #include <asterisk/musiconhold.h>
#include <asterisk/callerid.h> #include <asterisk/callerid.h>
#include <asterisk/utils.h> #include <asterisk/utils.h>
#include <asterisk/app.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
@ -469,7 +470,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
if ((sdtmfptr = strstr(transfer, "D("))) { if ((sdtmfptr = strstr(transfer, "D("))) {
strncpy(sdtmfdata, sdtmfptr + 2, sizeof(sdtmfdata) - 1); strncpy(sdtmfdata, sdtmfptr + 2, sizeof(sdtmfdata) - 1);
/* Overwrite with X's what was the sdtmf info */ /* Overwrite with X's what was the sdtmf info */
while(*sdtmfptr && (*sdtmfptr != ')')) while (*sdtmfptr && (*sdtmfptr != ')'))
*(sdtmfptr++) = 'X'; *(sdtmfptr++) = 'X';
if (*sdtmfptr) if (*sdtmfptr)
*sdtmfptr = 'X'; *sdtmfptr = 'X';
@ -477,10 +478,9 @@ static int dial_exec(struct ast_channel *chan, void *data)
sdtmfptr = strchr(sdtmfdata, ')'); sdtmfptr = strchr(sdtmfdata, ')');
if (sdtmfptr) if (sdtmfptr)
*sdtmfptr = '\0'; *sdtmfptr = '\0';
else { else
ast_log(LOG_WARNING, "D( Data lacking trailing ')'\n"); ast_log(LOG_WARNING, "D( Data lacking trailing ')'\n");
} }
}
/* XXX LIMIT SUPPORT */ /* XXX LIMIT SUPPORT */
if ((limitptr = strstr(transfer, "L("))) { if ((limitptr = strstr(transfer, "L("))) {
@ -494,9 +494,8 @@ static int dial_exec(struct ast_channel *chan, void *data)
limitptr = strchr(limitdata, ')'); limitptr = strchr(limitdata, ')');
if (limitptr) if (limitptr)
*limitptr = '\0'; *limitptr = '\0';
else { else
ast_log(LOG_WARNING, "Limit Data lacking trailing ')'\n"); ast_log(LOG_WARNING, "Limit Data lacking trailing ')'\n");
}
var = pbx_builtin_getvar_helper(chan,"LIMIT_PLAYAUDIO_CALLER"); var = pbx_builtin_getvar_helper(chan,"LIMIT_PLAYAUDIO_CALLER");
play_to_caller = var ? ast_true(var) : 1; play_to_caller = var ? ast_true(var) : 1;
@ -504,7 +503,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
var = pbx_builtin_getvar_helper(chan,"LIMIT_PLAYAUDIO_CALLEE"); var = pbx_builtin_getvar_helper(chan,"LIMIT_PLAYAUDIO_CALLEE");
play_to_callee = var ? ast_true(var) : 0; play_to_callee = var ? ast_true(var) : 0;
if(! play_to_caller && ! play_to_callee) if (!play_to_caller && !play_to_callee)
play_to_caller=1; play_to_caller=1;
var = pbx_builtin_getvar_helper(chan,"LIMIT_WARNING_FILE"); var = pbx_builtin_getvar_helper(chan,"LIMIT_WARNING_FILE");
@ -519,11 +518,11 @@ static int dial_exec(struct ast_channel *chan, void *data)
var=stack=limitdata; var=stack=limitdata;
var = strsep(&stack, ":"); var = strsep(&stack, ":");
if(var) { if (var) {
timelimit = atol(var); timelimit = atol(var);
playargs++; playargs++;
var = strsep(&stack, ":"); var = strsep(&stack, ":");
if(var) { if (var) {
play_warning = atol(var); play_warning = atol(var);
playargs++; playargs++;
var = strsep(&stack, ":"); var = strsep(&stack, ":");
@ -534,18 +533,17 @@ static int dial_exec(struct ast_channel *chan, void *data)
} }
} }
if(! timelimit) { if (!timelimit) {
timelimit=play_to_caller=play_to_callee=play_warning=warning_freq=0; timelimit=play_to_caller=play_to_callee=play_warning=warning_freq=0;
warning_sound=NULL; warning_sound=NULL;
} }
/* undo effect of S(x) in case they are both used */ /* undo effect of S(x) in case they are both used */
calldurationlimit=0; calldurationlimit=0;
/* more efficient do it like S(x) does since no advanced opts*/ /* more efficient do it like S(x) does since no advanced opts*/
if(! play_warning && ! start_sound && ! end_sound && timelimit) { if (!play_warning && !start_sound && !end_sound && timelimit) {
calldurationlimit=timelimit/1000; calldurationlimit=timelimit/1000;
timelimit=play_to_caller=play_to_callee=play_warning=warning_freq=0; timelimit=play_to_caller=play_to_callee=play_warning=warning_freq=0;
} } else if (option_verbose > 2) {
else if (option_verbose > 2) {
ast_verbose(VERBOSE_PREFIX_3"Limit Data:\n"); ast_verbose(VERBOSE_PREFIX_3"Limit Data:\n");
ast_verbose(VERBOSE_PREFIX_3"timelimit=%ld\n",timelimit); ast_verbose(VERBOSE_PREFIX_3"timelimit=%ld\n",timelimit);
ast_verbose(VERBOSE_PREFIX_3"play_warning=%ld\n",play_warning); ast_verbose(VERBOSE_PREFIX_3"play_warning=%ld\n",play_warning);
@ -556,7 +554,6 @@ static int dial_exec(struct ast_channel *chan, void *data)
ast_verbose(VERBOSE_PREFIX_3"warning_sound=%s\n",warning_sound ? warning_sound : "UNDEF"); ast_verbose(VERBOSE_PREFIX_3"warning_sound=%s\n",warning_sound ? warning_sound : "UNDEF");
ast_verbose(VERBOSE_PREFIX_3"end_sound=%s\n",end_sound ? end_sound : "UNDEF"); ast_verbose(VERBOSE_PREFIX_3"end_sound=%s\n",end_sound ? end_sound : "UNDEF");
} }
} }
/* XXX ANNOUNCE SUPPORT */ /* XXX ANNOUNCE SUPPORT */
@ -845,21 +842,19 @@ static int dial_exec(struct ast_channel *chan, void *data)
// Ok, done. stop autoservice // Ok, done. stop autoservice
res = ast_autoservice_stop(chan); res = ast_autoservice_stop(chan);
} } else
else
res = 0; res = 0;
if(!res) { if (!res) {
if (calldurationlimit > 0) { if (calldurationlimit > 0) {
time(&now); time(&now);
chan->whentohangup = now + calldurationlimit; chan->whentohangup = now + calldurationlimit;
} }
if (!ast_strlen_zero(sdtmfdata))
if(strlen(sdtmfdata))
res = ast_dtmf_stream(peer,chan,sdtmfdata,0); res = ast_dtmf_stream(peer,chan,sdtmfdata,0);
} }
if(!res) { if (!res) {
memset(&config,0,sizeof(struct ast_bridge_config)); memset(&config,0,sizeof(struct ast_bridge_config));
config.play_to_caller=play_to_caller; config.play_to_caller=play_to_caller;
config.play_to_callee=play_to_callee; config.play_to_callee=play_to_callee;
@ -873,8 +868,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
config.end_sound = end_sound; config.end_sound = end_sound;
config.start_sound = start_sound; config.start_sound = start_sound;
res = ast_bridge_call(chan,peer,&config); res = ast_bridge_call(chan,peer,&config);
} } else
else
res = -1; res = -1;
if (res != AST_PBX_NO_HANGUP_PEER) if (res != AST_PBX_NO_HANGUP_PEER)

@ -48,8 +48,8 @@ extern int ast_app_messagecount(const char *mailbox, int *newmsgs, int *oldmsgs)
//! Safely spawn an external program while closingn file descriptors //! Safely spawn an external program while closingn file descriptors
extern int ast_safe_system(const char *s); extern int ast_safe_system(const char *s);
// send DTMF to chan (optionally entertain peer) //! Send DTMF to chan (optionally entertain peer)
int ast_dtmf_stream(struct ast_channel *chan,struct ast_channel *peer,char *digits,int between); int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, char *digits, int between);
#if defined(__cplusplus) || defined(c_plusplus) #if defined(__cplusplus) || defined(c_plusplus)
} }

Loading…
Cancel
Save