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) if (!res)
res = ast_waitstream(chan, ""); res = ast_waitstream(chan, "");
} else { } else {
if (jump && ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) { if (jump && ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) {
chan->priority+=100;
res = 0; res = 0;
} else { } else {
if (!ast_streamfile(chan, "vm-goodbye", chan->language)) 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) { if (res < 1) {
pbx_builtin_setvar_helper(chan, "AVAILCHAN", ""); pbx_builtin_setvar_helper(chan, "AVAILCHAN", "");
pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", ""); pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", "");
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
chan->priority+=100;
else
return -1; return -1;
} }

@ -816,15 +816,15 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
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 for this call:\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);
ast_verbose(VERBOSE_PREFIX_3"play_to_caller=%s\n",play_to_caller ? "yes" : "no"); 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 "- 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 "- 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 "- 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 "- 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");
} }
} }
@ -1000,15 +1000,12 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
goto out; goto out;
} }
else if( privdb_val == AST_PRIVACY_KILL ) { else if( privdb_val == AST_PRIVACY_KILL ) {
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 201, chan->cid.cid_num)) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 201);
chan->priority+=200;
res = 0; res = 0;
goto out; /* Is this right? */ goto out; /* Is this right? */
} }
else if( privdb_val == AST_PRIVACY_TORTURE ) { else if( privdb_val == AST_PRIVACY_TORTURE ) {
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 301, chan->cid.cid_num)) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 301);
chan->priority+=300;
res = 0; res = 0;
goto out; /* is this right??? */ goto out; /* is this right??? */
@ -1252,8 +1249,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
if (!peer) { if (!peer) {
if (result) { if (result) {
res = result; res = result;
} } else if (to)
else if (to)
/* Musta gotten hung up */ /* Musta gotten hung up */
res = -1; res = -1;
else else

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

@ -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_callerid_split(ourcallerid, ourcidname, sizeof(ourcidname), ourcidnum, sizeof(ourcidnum));
ast_set_callerid(chan, ourcidnum, ourcidname, 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)) { if (!ast_strlen_zero(acctcode)) {
strncpy(chan->accountcode, acctcode, sizeof(chan->accountcode) - 1); 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); LOCAL_USER_REMOVE(u);
return 0; 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)) { if ((sscanf(limit, "%d", &max) == 1) && (max > -1)) {
count = ast_app_group_get_count(pbx_builtin_getvar_helper(chan, category), category); count = ast_app_group_get_count(pbx_builtin_getvar_helper(chan, category), category);
if (count > max) { if (count > max) {
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
chan->priority += 100;
else
res = -1; res = -1;
} }
} else } else

@ -130,9 +130,7 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data)
if (vmcount > 0) { if (vmcount > 0) {
/* Branch to the next extension */ /* Branch to the next extension */
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) { if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
chan->priority += 100;
} else
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); 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 { } 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)) if (bl)
chan->priority+=100; ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
LOCAL_USER_REMOVE (u); LOCAL_USER_REMOVE (u);
return 0; return 0;
} }

@ -118,9 +118,8 @@ static int md5check_exec(struct ast_channel *chan, void *data)
} }
if (option_debug > 2) if (option_debug > 2)
ast_log(LOG_DEBUG, "ERROR: MD5 not verified: %s -- %s\n", hash, string); 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)) if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
chan->priority += 100; if (option_debug > 2)
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); 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); LOCAL_USER_REMOVE(u);
return res; return res;

@ -1263,13 +1263,11 @@ zapretry:
char tmp[2]; char tmp[2];
tmp[0] = f->subclass; tmp[0] = f->subclass;
tmp[1] = '\0'; tmp[1] = '\0';
if (ast_exists_extension(chan, exitcontext, tmp, 1, chan->cid.cid_num)) { if (ast_goto_if_exists(chan, exitcontext, tmp, 1)) {
ast_copy_string(chan->context, exitcontext, sizeof(chan->context));
ast_copy_string(chan->exten, tmp, sizeof(chan->exten));
chan->priority = 0;
ret = 0; ret = 0;
break; 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)) { } else if ((f->frametype == AST_FRAME_DTMF) && (f->subclass == '#') && (confflags & CONFFLAG_POUNDEXIT)) {
ret = 0; ret = 0;
break; break;

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

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

@ -145,8 +145,7 @@ privacy_exec (struct ast_channel *chan, void *data)
ast_verbose (VERBOSE_PREFIX_3 "Changed Caller*ID to %s\n",phone); ast_verbose (VERBOSE_PREFIX_3 "Changed Caller*ID to %s\n",phone);
} else { } else {
/* Send the call to n+101 priority, where n is the current priority */ /* 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)) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
chan->priority+=100;
} }
if (cfg) if (cfg)
ast_config_destroy(cfg); ast_config_destroy(cfg);

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

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

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

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

Loading…
Cancel
Save