convert a bunch of apps to use ast_goto_if_exists() (issue #5138)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6533 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2-netsec
Kevin P. Fleming 20 years ago
parent 1bd1a35a9a
commit e0f02b46f1

@ -174,8 +174,7 @@ static int auth_exec(struct ast_channel *chan, void *data)
if (!res)
res = ast_waitstream(chan, "");
} else {
if (jump && ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) {
chan->priority+=100;
if (jump && ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) {
res = 0;
} else {
if (!ast_streamfile(chan, "vm-goodbye", chan->language))

@ -125,9 +125,7 @@ static int chanavail_exec(struct ast_channel *chan, void *data)
if (res < 1) {
pbx_builtin_setvar_helper(chan, "AVAILCHAN", "");
pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", "");
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority+=100;
else
if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
return -1;
}

@ -449,7 +449,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
if (f) {
if (f->frametype == AST_FRAME_CONTROL) {
switch(f->subclass) {
case AST_CONTROL_ANSWER:
case AST_CONTROL_ANSWER:
/* This is our guy if someone answered. */
if (!peer) {
if (option_verbose > 2)
@ -558,7 +558,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
f = ast_read(in);
#if 0
if (f && (f->frametype != AST_FRAME_VOICE))
printf("Frame type: %d, %d\n", f->frametype, f->subclass);
printf("Frame type: %d, %d\n", f->frametype, f->subclass);
else if (!f || (f->frametype != AST_FRAME_VOICE))
printf("Hangup received on %s\n", in->name);
#endif
@ -806,25 +806,25 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
}
if (!timelimit) {
timelimit=play_to_caller=play_to_callee=play_warning=warning_freq=0;
warning_sound=NULL;
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;
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;
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");
ast_verbose(VERBOSE_PREFIX_3 "Limit Data for this call:\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");
}
}
@ -1000,15 +1000,12 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
goto out;
}
else if( privdb_val == AST_PRIVACY_KILL ) {
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 201, chan->cid.cid_num))
chan->priority+=200;
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 201);
res = 0;
goto out; /* Is this right? */
}
else if( privdb_val == AST_PRIVACY_TORTURE ) {
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 301, chan->cid.cid_num))
chan->priority+=300;
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 301);
res = 0;
goto out; /* is this right??? */
@ -1252,13 +1249,12 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
if (!peer) {
if (result) {
res = result;
}
else if (to)
} else if (to)
/* Musta gotten hung up */
res = -1;
else
/* Nobody answered, next please? */
res=0;
res = 0;
goto out;
}
@ -1482,7 +1478,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
res = ast_autoservice_start(chan);
/* Now Stream the File */
if (!res)
res = ast_streamfile(peer,announcemsg,peer->language);
res = ast_streamfile(peer, announcemsg, peer->language);
if (!res) {
digit = ast_waitstream(peer, AST_DIGIT_ANY);
}
@ -1497,7 +1493,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
res = 0;
if (chan && peer && dblgoto) {
for (mac=dblgoto; *mac; mac++) {
for (mac = dblgoto; *mac; mac++) {
if(*mac == '^') {
*mac = '|';
}
@ -1521,7 +1517,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
app = pbx_findapp("Macro");
if (app && !res) {
for (res=0;res<strlen(macroname);res++)
for (res = 0; res<strlen(macroname); res++)
if (macroname[res] == '^')
macroname[res] = '|';
res = pbx_exec(peer, app, macroname, 1);

@ -182,11 +182,7 @@ static int play_mailbox_owner(struct ast_channel *chan, char *context, char *dia
case '1':
/* Name selected */
loop = 0;
if (ast_exists_extension(chan,dialcontext,ext,1,chan->cid.cid_num)) {
ast_copy_string(chan->exten, ext, sizeof(chan->exten));
chan->priority = 0;
ast_copy_string(chan->context, dialcontext, sizeof(chan->context));
} else {
if (!ast_goto_if_exists(chan, dialcontext, ext, 1)) {
ast_log(LOG_WARNING,
"Can't find extension '%s' in context '%s'. "
"Did you pass the wrong context to Directory?\n",
@ -293,11 +289,8 @@ static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *
return -1;
}
if (digit == '0') {
if (ast_exists_extension(chan,chan->context,"o",1,chan->cid.cid_num) ||
(!ast_strlen_zero(chan->macrocontext) &&
ast_exists_extension(chan, chan->macrocontext, "o", 1, chan->cid.cid_num))) {
strcpy(chan->exten, "o");
chan->priority = 0;
if (ast_goto_if_exists(chan, chan->context, "o", 1) ||
(!ast_strlen_zero(chan->macrocontext) && ast_goto_if_exists(chan, chan->macrocontext, "o", 1))) {
return 0;
} else {
@ -307,14 +300,10 @@ static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *
}
}
if (digit == '*') {
if (ast_exists_extension(chan,chan->context,"a",1,chan->cid.cid_num) ||
(!ast_strlen_zero(chan->macrocontext) &&
ast_exists_extension(chan, chan->macrocontext, "a", 1, chan->cid.cid_num))) {
strcpy(chan->exten, "a");
chan->priority = 0;
if (ast_goto_if_exists(chan, chan->context, "a", 1) ||
(!ast_strlen_zero(chan->macrocontext) && ast_goto_if_exists(chan, chan->macrocontext, "a", 1))) {
return 0;
} else {
ast_log(LOG_WARNING, "Can't find extension 'a' in current context. "
"Not Exiting the Directory!\n");
res = 0;

@ -318,7 +318,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
}
}
if (k==3 && ast_exists_extension(chan,ourcontext,exten,1, chan->cid.cid_num))
if (k==3 && ast_exists_extension(chan, ourcontext, exten, 1, chan->cid.cid_num))
{
ast_playtones_stop(chan);
/* We're authenticated and have a valid extension */
@ -327,13 +327,12 @@ static int disa_exec(struct ast_channel *chan, void *data)
ast_callerid_split(ourcallerid, ourcidname, sizeof(ourcidname), ourcidnum, sizeof(ourcidnum));
ast_set_callerid(chan, ourcidnum, ourcidname, ourcidnum);
}
strncpy(chan->exten, exten, sizeof(chan->exten) - 1);
strncpy(chan->context, ourcontext, sizeof(chan->context) - 1);
if (!ast_strlen_zero(acctcode)) {
strncpy(chan->accountcode, acctcode, sizeof(chan->accountcode) - 1);
}
chan->priority = 0;
ast_cdr_reset(chan->cdr,AST_CDR_FLAG_POSTED);
ast_cdr_reset(chan->cdr, AST_CDR_FLAG_POSTED);
ast_goto_if_exists(chan, ourcontext, exten, 1);
LOCAL_USER_REMOVE(u);
return 0;
}

@ -146,9 +146,7 @@ static int group_check_exec(struct ast_channel *chan, void *data)
if ((sscanf(limit, "%d", &max) == 1) && (max > -1)) {
count = ast_app_group_get_count(pbx_builtin_getvar_helper(chan, category), category);
if (count > max) {
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
else
if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
res = -1;
}
} else

@ -130,9 +130,7 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data)
if (vmcount > 0) {
/* Branch to the next extension */
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) {
chan->priority += 100;
} else
if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
ast_log(LOG_WARNING, "VM box %s@%s has new voicemail, but extension %s, priority %d doesn't exist\n", vmbox, context, chan->exten, chan->priority + 101);
}
} else {

@ -76,8 +76,9 @@ lookupblacklist_exec (struct ast_channel *chan, void *data)
}
}
if (bl && ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority+=100;
if (bl)
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
LOCAL_USER_REMOVE (u);
return 0;
}

@ -118,10 +118,9 @@ static int md5check_exec(struct ast_channel *chan, void *data)
}
if (option_debug > 2)
ast_log(LOG_DEBUG, "ERROR: MD5 not verified: %s -- %s\n", hash, string);
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
else if (option_debug > 2)
ast_log(LOG_DEBUG, "ERROR: Can't jump to exten+101 (e%s,p%d), sorry\n", chan->exten,chan->priority+101);
if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
if (option_debug > 2)
ast_log(LOG_DEBUG, "ERROR: Can't jump to exten+101 (e%s,p%d), sorry\n", chan->exten,chan->priority+101);
LOCAL_USER_REMOVE(u);
return res;
}

@ -1263,13 +1263,11 @@ zapretry:
char tmp[2];
tmp[0] = f->subclass;
tmp[1] = '\0';
if (ast_exists_extension(chan, exitcontext, tmp, 1, chan->cid.cid_num)) {
ast_copy_string(chan->context, exitcontext, sizeof(chan->context));
ast_copy_string(chan->exten, tmp, sizeof(chan->exten));
chan->priority = 0;
if (ast_goto_if_exists(chan, exitcontext, tmp, 1)) {
ret = 0;
break;
}
} else if (option_debug > 1)
ast_log(LOG_DEBUG, "Exit by single digit did not work in meetme. Extension %s does not exist in context %s\n", tmp, exitcontext);
} else if ((f->frametype == AST_FRAME_DTMF) && (f->subclass == '#') && (confflags & CONFFLAG_POUNDEXIT)) {
ret = 0;
break;

@ -132,8 +132,7 @@ static int osplookup_exec(struct ast_channel *chan, void *data)
}
if (!res) {
/* Look for a "busy" place */
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
} else if (res > 0)
res = 0;
LOCAL_USER_REMOVE(u);
@ -176,8 +175,7 @@ static int ospnext_exec(struct ast_channel *chan, void *data)
}
if (!res) {
/* Look for a "busy" place */
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
} else if (res > 0)
res = 0;
LOCAL_USER_REMOVE(u);
@ -223,8 +221,7 @@ static int ospfinished_exec(struct ast_channel *chan, void *data)
}
if (!res) {
/* Look for a "busy" place */
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
} else if (res > 0)
res = 0;
LOCAL_USER_REMOVE(u);

@ -93,8 +93,7 @@ static int playback_exec(struct ast_channel *chan, void *data)
ast_stopstream(chan);
} else {
ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char *)data);
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority+=100;
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
res = 0;
}
front = back;

@ -144,9 +144,8 @@ privacy_exec (struct ast_channel *chan, void *data)
if (option_verbose > 2)
ast_verbose (VERBOSE_PREFIX_3 "Changed Caller*ID to %s\n",phone);
} else {
/*Send the call to n+101 priority, where n is the current priority*/
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority+=100;
/* Send the call to n+101 priority, where n is the current priority */
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
}
if (cfg)
ast_config_destroy(cfg);

@ -1007,10 +1007,7 @@ static int valid_exit(struct queue_ent *qe, char digit)
}
/* We have an exact match */
if (ast_exists_extension(qe->chan, qe->context, qe->digits, 1, qe->chan->cid.cid_num)) {
ast_copy_string(qe->chan->context, qe->context, sizeof(qe->chan->context));
ast_copy_string(qe->chan->exten, qe->digits, sizeof(qe->chan->exten));
qe->chan->priority = 0;
if (ast_goto_if_exists(qe->chan, qe->context, qe->digits, 1)) {
return 1;
}
return 0;
@ -2546,8 +2543,7 @@ static int pqm_exec(struct ast_channel *chan, void *data)
if (set_member_paused(queuename, interface, 1)) {
ast_log(LOG_WARNING, "Attempt to pause interface %s, not found\n", interface);
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) {
chan->priority += 100;
if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) {
LOCAL_USER_REMOVE(u);
return 0;
}
@ -2588,8 +2584,7 @@ static int upqm_exec(struct ast_channel *chan, void *data)
if (set_member_paused(queuename, interface, 0)) {
ast_log(LOG_WARNING, "Attempt to unpause interface %s, not found\n", interface);
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) {
chan->priority += 100;
if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) {
LOCAL_USER_REMOVE(u);
return 0;
}
@ -2645,9 +2640,7 @@ static int rqm_exec(struct ast_channel *chan, void *data)
break;
case RES_EXISTS:
ast_log(LOG_WARNING, "Unable to remove interface '%s' from queue '%s': Not there\n", interface, queuename);
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) {
chan->priority += 100;
}
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
res = 0;
break;
case RES_NOSUCHQUEUE:
@ -2722,9 +2715,7 @@ static int aqm_exec(struct ast_channel *chan, void *data)
break;
case RES_EXISTS:
ast_log(LOG_WARNING, "Unable to add interface '%s' to queue '%s': Already there\n", interface, queuename);
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) {
chan->priority += 100;
}
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
res = 0;
break;
case RES_NOSUCHQUEUE:

@ -155,10 +155,7 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
sprintf(ms_str, "%d", ms );
pbx_builtin_setvar_helper(chan, "TALK_DETECTED", ms_str);
if (ast_exists_extension(chan, chan->context, "talk", 1, chan->cid.cid_num)) {
ast_copy_string(chan->exten, "talk", sizeof(chan->exten));
chan->priority = 0;
}
ast_goto_if_exists(chan, chan->context, "talk", 1);
res = 0;
ast_frfree(fr);
break;

@ -73,15 +73,13 @@ static int txtcidname_exec(struct ast_channel *chan, void *data)
if (res > 0) {
if (!ast_strlen_zero(txt)) {
pbx_builtin_setvar_helper(chan, "TXTCIDNAME", txt);
#if 0
ast_log(LOG_DEBUG, "TXTCIDNAME got '%s'\n", txt);
#endif
if (option_debug > 1)
ast_log(LOG_DEBUG, "TXTCIDNAME got '%s'\n", txt);
}
}
if (!res) {
/* Look for a "busy" place */
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
} else if (res > 0)
res = 0;
return res;

@ -5474,9 +5474,7 @@ static int vm_exec(struct ast_channel *chan, void *data)
if (res == ERROR_LOCK_PATH) {
ast_log(LOG_ERROR, "Could not leave voicemail. The path is already locked.\n");
/*Send the call to n+101 priority, where n is the current priority*/
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority+=100;
else
if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
ast_log(LOG_WARNING, "Extension %s, priority %d doesn't exist.\n", chan->exten, chan->priority + 101);
res = 0;
}
@ -5542,9 +5540,7 @@ static int vm_box_exists(struct ast_channel *chan, void *data)
}
if (find_user(&svm, context, box)) {
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) {
chan->priority += 100;
} else
if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
ast_log(LOG_WARNING, "VM box %s@%s exists, but extension %s, priority %d doesn't exist\n", box, context, chan->exten, chan->priority + 101);
}
LOCAL_USER_REMOVE(u);

Loading…
Cancel
Save