aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_dial.c
diff options
context:
space:
mode:
authorcitats <citats@f38db490-d61c-443f-a65b-d21fe96a405b>2004-05-07 21:14:55 +0000
committercitats <citats@f38db490-d61c-443f-a65b-d21fe96a405b>2004-05-07 21:14:55 +0000
commit52ae3f42d4cd5c7d285bec82c06edd2e9c0b86f5 (patch)
tree35539a72ebb3554cef1dfd87d4a8395b3140cf70 /apps/app_dial.c
parentc1457252403f367fda151cf89728711629176a09 (diff)
Code cleanup
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2919 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_dial.c')
-rwxr-xr-xapps/app_dial.c216
1 files changed, 105 insertions, 111 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 2f0c8284e..983e0e9dc 100755
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -25,6 +25,7 @@
#include <asterisk/musiconhold.h>
#include <asterisk/callerid.h>
#include <asterisk/utils.h>
+#include <asterisk/app.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
@@ -467,96 +468,92 @@ static int dial_exec(struct ast_channel *chan, void *data)
/* DTMF SCRIPT*/
if ((sdtmfptr = strstr(transfer, "D("))) {
- strncpy(sdtmfdata, sdtmfptr + 2, sizeof(sdtmfdata) - 1);
- /* Overwrite with X's what was the sdtmf info */
- while(*sdtmfptr && (*sdtmfptr != ')'))
- *(sdtmfptr++) = 'X';
- if (*sdtmfptr)
- *sdtmfptr = 'X';
- /* Now find the end */
- sdtmfptr = strchr(sdtmfdata, ')');
- if (sdtmfptr)
- *sdtmfptr = '\0';
- else {
- ast_log(LOG_WARNING, "D( Data lacking trailing ')'\n");
- }
+ strncpy(sdtmfdata, sdtmfptr + 2, sizeof(sdtmfdata) - 1);
+ /* Overwrite with X's what was the sdtmf info */
+ while (*sdtmfptr && (*sdtmfptr != ')'))
+ *(sdtmfptr++) = 'X';
+ if (*sdtmfptr)
+ *sdtmfptr = 'X';
+ /* Now find the end */
+ sdtmfptr = strchr(sdtmfdata, ')');
+ if (sdtmfptr)
+ *sdtmfptr = '\0';
+ else
+ ast_log(LOG_WARNING, "D( Data lacking trailing ')'\n");
}
/* XXX LIMIT SUPPORT */
if ((limitptr = strstr(transfer, "L("))) {
- strncpy(limitdata, limitptr + 2, sizeof(limitdata) - 1);
- /* Overwrite with X's what was the limit info */
- while(*limitptr && (*limitptr != ')'))
- *(limitptr++) = 'X';
- if (*limitptr)
- *limitptr = 'X';
- /* Now find the end */
- limitptr = strchr(limitdata, ')');
- if (limitptr)
- *limitptr = '\0';
- else {
- ast_log(LOG_WARNING, "Limit Data lacking trailing ')'\n");
- }
-
- var = pbx_builtin_getvar_helper(chan,"LIMIT_PLAYAUDIO_CALLER");
- play_to_caller = var ? ast_true(var) : 1;
-
- var = pbx_builtin_getvar_helper(chan,"LIMIT_PLAYAUDIO_CALLEE");
- play_to_callee = var ? ast_true(var) : 0;
-
- if(! play_to_caller && ! play_to_callee)
- play_to_caller=1;
-
- var = pbx_builtin_getvar_helper(chan,"LIMIT_WARNING_FILE");
- warning_sound = var ? var : "timeleft";
-
- var = pbx_builtin_getvar_helper(chan,"LIMIT_TIMEOUT_FILE");
- end_sound = var ? var : NULL;
+ strncpy(limitdata, limitptr + 2, sizeof(limitdata) - 1);
+ /* Overwrite with X's what was the limit info */
+ while(*limitptr && (*limitptr != ')'))
+ *(limitptr++) = 'X';
+ if (*limitptr)
+ *limitptr = 'X';
+ /* Now find the end */
+ limitptr = strchr(limitdata, ')');
+ if (limitptr)
+ *limitptr = '\0';
+ else
+ ast_log(LOG_WARNING, "Limit Data lacking trailing ')'\n");
+
+ var = pbx_builtin_getvar_helper(chan,"LIMIT_PLAYAUDIO_CALLER");
+ play_to_caller = var ? ast_true(var) : 1;
- var = pbx_builtin_getvar_helper(chan,"LIMIT_CONNECT_FILE");
- start_sound = var ? var : NULL;
+ var = pbx_builtin_getvar_helper(chan,"LIMIT_PLAYAUDIO_CALLEE");
+ play_to_callee = var ? ast_true(var) : 0;
- var=stack=limitdata;
-
- var = strsep(&stack, ":");
- if(var) {
- timelimit = atol(var);
- playargs++;
- var = strsep(&stack, ":");
- if(var) {
- play_warning = atol(var);
- playargs++;
- var = strsep(&stack, ":");
- if(var) {
- warning_freq = atol(var);
- playargs++;
- }
- }
- }
+ if (!play_to_caller && !play_to_callee)
+ play_to_caller=1;
- if(! timelimit) {
- timelimit=play_to_caller=play_to_callee=play_warning=warning_freq=0;
- warning_sound=NULL;
- }
- /* undo effect of S(x) in case they are both used */
- calldurationlimit=0;
- /* more efficient do it like S(x) does since no advanced opts*/
- if(! play_warning && ! start_sound && ! end_sound && timelimit) {
- calldurationlimit=timelimit/1000;
- timelimit=play_to_caller=play_to_callee=play_warning=warning_freq=0;
- }
- else if (option_verbose > 2) {
- ast_verbose(VERBOSE_PREFIX_3"Limit Data:\n");
- 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_to_caller=%s\n",play_to_caller ? "yes" : "no");
- ast_verbose(VERBOSE_PREFIX_3"play_to_callee=%s\n",play_to_callee ? "yes" : "no");
- ast_verbose(VERBOSE_PREFIX_3"warning_freq=%ld\n",warning_freq);
- ast_verbose(VERBOSE_PREFIX_3"start_sound=%s\n",start_sound ? start_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");
- }
+ var = pbx_builtin_getvar_helper(chan,"LIMIT_WARNING_FILE");
+ warning_sound = var ? var : "timeleft";
+
+ var = pbx_builtin_getvar_helper(chan,"LIMIT_TIMEOUT_FILE");
+ end_sound = var ? var : NULL;
+
+ var = pbx_builtin_getvar_helper(chan,"LIMIT_CONNECT_FILE");
+ start_sound = var ? var : NULL;
+
+ var=stack=limitdata;
+
+ var = strsep(&stack, ":");
+ if (var) {
+ timelimit = atol(var);
+ playargs++;
+ var = strsep(&stack, ":");
+ if (var) {
+ play_warning = atol(var);
+ playargs++;
+ var = strsep(&stack, ":");
+ if(var) {
+ warning_freq = atol(var);
+ playargs++;
+ }
+ }
+ }
+ if (!timelimit) {
+ timelimit=play_to_caller=play_to_callee=play_warning=warning_freq=0;
+ warning_sound=NULL;
+ }
+ /* undo effect of S(x) in case they are both used */
+ calldurationlimit=0;
+ /* more efficient do it like S(x) does since no advanced opts*/
+ if (!play_warning && !start_sound && !end_sound && timelimit) {
+ calldurationlimit=timelimit/1000;
+ timelimit=play_to_caller=play_to_callee=play_warning=warning_freq=0;
+ } else if (option_verbose > 2) {
+ ast_verbose(VERBOSE_PREFIX_3"Limit Data:\n");
+ 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_to_caller=%s\n",play_to_caller ? "yes" : "no");
+ ast_verbose(VERBOSE_PREFIX_3"play_to_callee=%s\n",play_to_callee ? "yes" : "no");
+ ast_verbose(VERBOSE_PREFIX_3"warning_freq=%ld\n",warning_freq);
+ ast_verbose(VERBOSE_PREFIX_3"start_sound=%s\n",start_sound ? start_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");
+ }
}
/* XXX ANNOUNCE SUPPORT */
@@ -845,40 +842,37 @@ static int dial_exec(struct ast_channel *chan, void *data)
// Ok, done. stop autoservice
res = ast_autoservice_stop(chan);
- }
- else
- res = 0;
-
- if(!res) {
- if (calldurationlimit > 0) {
- time(&now);
- chan->whentohangup = now + calldurationlimit;
- }
+ } else
+ res = 0;
- if(strlen(sdtmfdata))
- res = ast_dtmf_stream(peer,chan,sdtmfdata,0);
+ if (!res) {
+ if (calldurationlimit > 0) {
+ time(&now);
+ chan->whentohangup = now + calldurationlimit;
+ }
+ if (!ast_strlen_zero(sdtmfdata))
+ res = ast_dtmf_stream(peer,chan,sdtmfdata,0);
}
- if(!res) {
- memset(&config,0,sizeof(struct ast_bridge_config));
- config.play_to_caller=play_to_caller;
- config.play_to_callee=play_to_callee;
- config.allowredirect_in = allowredir_in;
- config.allowredirect_out = allowredir_out;
- config.allowdisconnect = allowdisconnect;
- config.timelimit = timelimit;
- config.play_warning = play_warning;
- config.warning_freq = warning_freq;
- config.warning_sound = warning_sound;
- config.end_sound = end_sound;
- config.start_sound = start_sound;
- res = ast_bridge_call(chan,peer,&config);
- }
- else
- res = -1;
+ if (!res) {
+ memset(&config,0,sizeof(struct ast_bridge_config));
+ config.play_to_caller=play_to_caller;
+ config.play_to_callee=play_to_callee;
+ config.allowredirect_in = allowredir_in;
+ config.allowredirect_out = allowredir_out;
+ config.allowdisconnect = allowdisconnect;
+ config.timelimit = timelimit;
+ config.play_warning = play_warning;
+ config.warning_freq = warning_freq;
+ config.warning_sound = warning_sound;
+ config.end_sound = end_sound;
+ config.start_sound = start_sound;
+ res = ast_bridge_call(chan,peer,&config);
+ } else
+ res = -1;
if (res != AST_PBX_NO_HANGUP_PEER)
- ast_hangup(peer);
+ ast_hangup(peer);
}
out:
hanguptree(outgoing, NULL);