From b7e36b50cca19e8b9d367edb8e33e37daa46507b Mon Sep 17 00:00:00 2001 From: Luigi Rizzo <rizzo@icir.org> Date: Sun, 16 Apr 2006 23:05:42 +0000 Subject: [PATCH] preparation for reduction of the nesting of a large function git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@20733 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_features.c | 47 +++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/res/res_features.c b/res/res_features.c index fd44284ab8..f4f0d2afb9 100644 --- a/res/res_features.c +++ b/res/res_features.c @@ -642,8 +642,6 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st struct ast_bridge_config bconfig; const char *transferer_real_context; char xferto[256],dialstr[265]; - char *cid_num; - char *cid_name; int res; struct ast_frame *f = NULL; struct ast_bridge_thread_obj *tobj; @@ -666,18 +664,37 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st /* this is specific of atxfer */ res = ast_app_dtget(transferer, transferer_real_context, xferto, sizeof(xferto), 100, transferdigittimeout); - if (!res) { + if (res < 0) { /* hangup, would be 0 for invalid and 1 for valid */ + finishup(transferee); + return res; + } + if (res == 0) { ast_log(LOG_WARNING, "Did not read data.\n"); + finishup(transferee); if (stream_and_wait(transferer, "beeperr", transferer->language, "")) return -1; - } else { - cid_num = transferer->cid.cid_num; - cid_name = transferer->cid.cid_name; - if (ast_exists_extension(transferer, transferer_real_context,xferto, 1, cid_num)) { + return FEATURE_RETURN_SUCCESS; + } + /* valid extension, res == 1 */ + { + if (!ast_exists_extension(transferer, transferer_real_context,xferto, 1, transferer->cid.cid_num)) { + ast_log(LOG_WARNING, "Extension %s does not exist in context %s\n",xferto,transferer_real_context); + finishup(transferee); + if (stream_and_wait(transferer, "beeperr", transferer->language, "")) + return -1; + } else { snprintf(dialstr, sizeof(dialstr), "%s@%s/n", xferto, transferer_real_context); - newchan = ast_feature_request_and_dial(transferer, "Local", ast_best_codec(transferer->nativeformats), dialstr, 15000, &outstate, cid_num, cid_name); + newchan = ast_feature_request_and_dial(transferer, "Local", ast_best_codec(transferer->nativeformats), dialstr, 15000, &outstate, transferer->cid.cid_num, transferer->cid.cid_name); ast_indicate(transferer, -1); - if (newchan) { + if (!newchan) { + finishup(transferee); + /* any reason besides user requested cancel and busy triggers the failed sound */ + if (outstate != AST_CONTROL_UNHOLD && outstate != AST_CONTROL_BUSY && + stream_and_wait(transferer, xferfailsound, transferer->language, "")) + return -1; + return FEATURE_RETURN_SUCCESS; + } + { res = ast_channel_make_compatible(transferer, newchan); if (res < 0) { ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", transferer->name, newchan->name); @@ -760,19 +777,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st } return -1; - } else { - finishup(transferee); - /* any reason besides user requested cancel and busy triggers the failed sound */ - if (outstate != AST_CONTROL_UNHOLD && outstate != AST_CONTROL_BUSY && - stream_and_wait(transferer, xferfailsound, transferer->language, "")) - return -1; - return FEATURE_RETURN_SUCCESS; } - } else { - ast_log(LOG_WARNING, "Extension %s does not exist in context %s\n",xferto,transferer_real_context); - finishup(transferee); - if (stream_and_wait(transferer, "beeperr", transferer->language, "")) - return -1; } } finishup(transferee); -- GitLab