summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2006-03-26 23:45:53 +0000
committerKevin P. Fleming <kpfleming@digium.com>2006-03-26 23:45:53 +0000
commit5c6c266aa94db471f4b265bb01e908081ce516ba (patch)
tree5a13c63e254a9054a155d6f563898eac25157649 /apps
parente85d63aa1166efddf1681434086f665cb31b3a1d (diff)
rename application to have a more logical name
various code cleanups don't steal copyright from author git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@15066 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps')
-rw-r--r--apps/app_managerredirect.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/apps/app_managerredirect.c b/apps/app_managerredirect.c
index 4121db9a2..e0145f223 100644
--- a/apps/app_managerredirect.c
+++ b/apps/app_managerredirect.c
@@ -1,9 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999 - 2005, Digium, Inc.
- *
- * Mark Spencer <markster@digium.com>
+ * Copyright (C) 2006, Sergey Basmanov
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
@@ -18,10 +16,10 @@
/*! \file
*
- * \brief ManagerRedirect application
+ * \brief ChannelRedirect application
*
* \author Sergey Basmanov <sergey_basmanov@mail.ru>
- *
+ *
* \ingroup applications
*/
@@ -43,11 +41,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/app.h"
#include "asterisk/features.h"
-static char *tdesc = "Manager Redirect";
-static char *app = "ManagerRedirect";
-static char *synopsis = "Redirects another channel in dialplan.";
+static char *tdesc = "Channel Redirect";
+static char *app = "ChannelRedirect";
+static char *synopsis = "Redirects given channel to a dialplan target.";
static char *descrip =
-"ManagerRedirect(channel|[[context|]extension|]priority):\n"
+"ChannelRedirect(channel|[[context|]extension|]priority):\n"
" Sends the specified channel to the specified extension priority\n";
STANDARD_LOCAL_USER;
@@ -56,7 +54,7 @@ LOCAL_USER_DECL;
static int asyncgoto_exec(struct ast_channel *chan, void *data)
{
- int res = 0;
+ int res = -1;
struct localuser *u;
char *info, *context, *exten, *priority;
int prio = 1;
@@ -79,15 +77,13 @@ static int asyncgoto_exec(struct ast_channel *chan, void *data)
if (ast_strlen_zero(args.channel) || ast_strlen_zero(args.label)) {
ast_log(LOG_WARNING, "%s requires an argument (channel|[[context|]exten|]priority)\n", app);
- LOCAL_USER_REMOVE(u);
- return -1;
+ goto quit;
}
chan2 = ast_get_channel_by_name_locked(args.channel);
if (!chan2) {
ast_log(LOG_WARNING, "No such channel: %s\n", args.channel);
- LOCAL_USER_REMOVE(u);
- return -1;
+ goto quit;
}
/* Parsed right to left, so standard parsing won't work */
@@ -105,20 +101,22 @@ static int asyncgoto_exec(struct ast_channel *chan, void *data)
context = NULL;
}
- if (!(prio = ast_findlabel_extension(chan2, context ? context : chan2->context, exten ? exten : chan2->exten, priority, chan2->cid.cid_num))) {
+ if (!(prio = ast_findlabel_extension(chan2, S_OR(context, chan2->context), S_OR(exten, chan2->exten),
+ priority, chan2->cid.cid_num))) {
ast_log(LOG_WARNING, "'%s' is not a known priority or label\n", priority);
- ast_mutex_unlock(&chan2->lock);
- LOCAL_USER_REMOVE(u);
- return -1;
+ goto chanquit;
}
ast_log(LOG_DEBUG, "Attempting async goto (%s) to %s\n", args.channel, args.label);
- if (ast_async_goto_if_exists(chan2, context ? context : chan2->context, exten ? exten : chan2->exten, prio)) {
- ast_log(LOG_WARNING, "ManagerRedirect failed for %s\n", args.channel);
- }
+ if (ast_async_goto_if_exists(chan2, context ? context : chan2->context, exten ? exten : chan2->exten, prio))
+ ast_log(LOG_WARNING, "%s failed for %s\n", app, args.channel);
+ else
+ res = 0;
+ chanquit:
ast_mutex_unlock(&chan2->lock);
+ quit:
LOCAL_USER_REMOVE(u);
return res;