Index: apps/app_authenticate.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_authenticate.c,v retrieving revision 1.13 diff -u -r1.13 app_authenticate.c --- apps/app_authenticate.c 23 Aug 2005 15:21:48 -0000 1.13 +++ apps/app_authenticate.c 6 Sep 2005 09:44:25 -0000 @@ -174,8 +174,7 @@ 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)) Index: apps/app_chanisavail.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_chanisavail.c,v retrieving revision 1.17 diff -u -r1.17 app_chanisavail.c --- apps/app_chanisavail.c 8 Jul 2005 21:14:34 -0000 1.17 +++ apps/app_chanisavail.c 6 Sep 2005 09:44:25 -0000 @@ -125,9 +125,7 @@ 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; } Index: apps/app_dial.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_dial.c,v retrieving revision 1.164 diff -u -r1.164 app_dial.c --- apps/app_dial.c 30 Aug 2005 02:12:09 -0000 1.164 +++ apps/app_dial.c 6 Sep 2005 09:44:26 -0000 @@ -449,7 +449,7 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ res = 0; if (chan && peer && dblgoto) { - for (mac=dblgoto; *mac; mac++) { + for (mac = dblgoto; *mac; mac++) { if(*mac == '^') { *mac = '|'; } @@ -1521,7 +1517,7 @@ app = pbx_findapp("Macro"); if (app && !res) { - for (res=0;rescid.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 @@ 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_extension(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 @@ } } 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_extension(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; Index: apps/app_disa.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_disa.c,v retrieving revision 1.31 diff -u -r1.31 app_disa.c --- apps/app_disa.c 19 Jul 2005 23:45:21 -0000 1.31 +++ apps/app_disa.c 6 Sep 2005 09:44:26 -0000 @@ -318,7 +318,7 @@ } } - 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 @@ 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; } Index: apps/app_groupcount.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_groupcount.c,v retrieving revision 1.19 diff -u -r1.19 app_groupcount.c --- apps/app_groupcount.c 15 Jul 2005 16:13:26 -0000 1.19 +++ apps/app_groupcount.c 6 Sep 2005 09:44:26 -0000 @@ -146,9 +146,7 @@ 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 Index: apps/app_hasnewvoicemail.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_hasnewvoicemail.c,v retrieving revision 1.14 diff -u -r1.14 app_hasnewvoicemail.c --- apps/app_hasnewvoicemail.c 6 Jun 2005 22:39:31 -0000 1.14 +++ apps/app_hasnewvoicemail.c 6 Sep 2005 09:44:26 -0000 @@ -130,9 +130,7 @@ 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 { Index: apps/app_lookupblacklist.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_lookupblacklist.c,v retrieving revision 1.9 diff -u -r1.9 app_lookupblacklist.c --- apps/app_lookupblacklist.c 6 Jun 2005 22:39:31 -0000 1.9 +++ apps/app_lookupblacklist.c 6 Sep 2005 09:44:26 -0000 @@ -76,8 +76,9 @@ } } - 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; } Index: apps/app_meetme.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_meetme.c,v retrieving revision 1.103 diff -u -r1.103 app_meetme.c --- apps/app_meetme.c 8 Aug 2005 02:32:37 -0000 1.103 +++ apps/app_meetme.c 6 Sep 2005 09:44:27 -0000 @@ -1112,13 +1112,11 @@ 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; Index: apps/app_md5.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_md5.c,v retrieving revision 1.6 diff -u -r1.6 app_md5.c --- apps/app_md5.c 6 Jun 2005 22:39:31 -0000 1.6 +++ apps/app_md5.c 6 Sep 2005 09:44:27 -0000 @@ -118,10 +118,9 @@ } 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; } Index: apps/app_osplookup.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_osplookup.c,v retrieving revision 1.8 diff -u -r1.8 app_osplookup.c --- apps/app_osplookup.c 6 Jun 2005 22:39:31 -0000 1.8 +++ apps/app_osplookup.c 6 Sep 2005 09:44:27 -0000 @@ -132,8 +132,7 @@ } 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 @@ } 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 @@ } 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); Index: apps/app_playback.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_playback.c,v retrieving revision 1.18 diff -u -r1.18 app_playback.c --- apps/app_playback.c 6 Jun 2005 22:39:31 -0000 1.18 +++ apps/app_playback.c 6 Sep 2005 09:44:27 -0000 @@ -93,8 +93,7 @@ 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; Index: apps/app_queue.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_queue.c,v retrieving revision 1.160 diff -u -r1.160 app_queue.c --- apps/app_queue.c 1 Sep 2005 22:32:29 -0000 1.160 +++ apps/app_queue.c 6 Sep 2005 09:44:27 -0000 @@ -1007,10 +1007,7 @@ } /* 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 @@ 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_extension(chan, chan->context, chan->exten, chan->priority + 101)) { LOCAL_USER_REMOVE(u); return 0; } @@ -2588,8 +2584,7 @@ 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 @@ 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 @@ 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: Index: apps/app_privacy.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_privacy.c,v retrieving revision 1.15 diff -u -r1.15 app_privacy.c --- apps/app_privacy.c 6 Jun 2005 22:39:31 -0000 1.15 +++ apps/app_privacy.c 6 Sep 2005 09:44:27 -0000 @@ -144,9 +144,8 @@ 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); Index: apps/app_talkdetect.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_talkdetect.c,v retrieving revision 1.11 diff -u -r1.11 app_talkdetect.c --- apps/app_talkdetect.c 15 Jul 2005 23:00:46 -0000 1.11 +++ apps/app_talkdetect.c 6 Sep 2005 09:44:27 -0000 @@ -155,10 +155,7 @@ 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; Index: apps/app_txtcidname.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_txtcidname.c,v retrieving revision 1.14 diff -u -r1.14 app_txtcidname.c --- apps/app_txtcidname.c 10 Jul 2005 23:12:25 -0000 1.14 +++ apps/app_txtcidname.c 6 Sep 2005 09:44:27 -0000 @@ -73,15 +73,13 @@ 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; Index: apps/app_voicemail.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_voicemail.c,v retrieving revision 1.243 diff -u -r1.243 app_voicemail.c --- apps/app_voicemail.c 29 Aug 2005 16:08:53 -0000 1.243 +++ apps/app_voicemail.c 6 Sep 2005 09:44:28 -0000 @@ -5471,9 +5471,7 @@ 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; } @@ -5539,9 +5537,7 @@ } 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);