#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/app.h"
#include "asterisk/features.h"
#include "asterisk/options.h"
Go to the source code of this file.
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | asyncgoto_exec (struct ast_channel *chan, void *data) |
static int | load_module (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Channel Redirect" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "f450f61f60e761b3aa089ebed76ca8a5" , .load = load_module, .unload = unload_module, } |
static char * | app = "ChannelRedirect" |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static char * | descrip |
static char * | synopsis = "Redirects given channel to a dialplan target." |
Definition in file app_channelredirect.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 140 of file app_channelredirect.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 140 of file app_channelredirect.c.
static int asyncgoto_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 52 of file app_channelredirect.c.
References AST_APP_ARG, ast_async_goto_if_exists(), AST_DECLARE_APP_ARGS, ast_findlabel_extension(), ast_get_channel_by_name_locked(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_mutex_unlock(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_channel::cid, ast_callerid::cid_num, ast_channel::context, context, ast_channel::exten, exten, ast_channel::lock, LOG_DEBUG, LOG_WARNING, option_debug, quit, and S_OR.
Referenced by load_module().
00053 { 00054 int res = -1; 00055 struct ast_module_user *u; 00056 char *info, *context, *exten, *priority; 00057 int prio = 1; 00058 struct ast_channel *chan2 = NULL; 00059 00060 AST_DECLARE_APP_ARGS(args, 00061 AST_APP_ARG(channel); 00062 AST_APP_ARG(label); 00063 ); 00064 00065 if (ast_strlen_zero(data)) { 00066 ast_log(LOG_WARNING, "%s requires an argument (channel|[[context|]exten|]priority)\n", app); 00067 return -1; 00068 } 00069 00070 u = ast_module_user_add(chan); 00071 00072 info = ast_strdupa(data); 00073 AST_STANDARD_APP_ARGS(args, info); 00074 00075 if (ast_strlen_zero(args.channel) || ast_strlen_zero(args.label)) { 00076 ast_log(LOG_WARNING, "%s requires an argument (channel|[[context|]exten|]priority)\n", app); 00077 goto quit; 00078 } 00079 00080 chan2 = ast_get_channel_by_name_locked(args.channel); 00081 if (!chan2) { 00082 ast_log(LOG_WARNING, "No such channel: %s\n", args.channel); 00083 goto quit; 00084 } 00085 00086 /* Parsed right to left, so standard parsing won't work */ 00087 context = strsep(&args.label, "|"); 00088 exten = strsep(&args.label, "|"); 00089 if (exten) { 00090 priority = strsep(&args.label, "|"); 00091 if (!priority) { 00092 priority = exten; 00093 exten = context; 00094 context = NULL; 00095 } 00096 } else { 00097 priority = context; 00098 context = NULL; 00099 } 00100 00101 /* ast_findlabel_extension does not convert numeric priorities; it only does a lookup */ 00102 if (!(prio = atoi(priority)) && !(prio = ast_findlabel_extension(chan2, S_OR(context, chan2->context), 00103 S_OR(exten, chan2->exten), priority, chan2->cid.cid_num))) { 00104 ast_log(LOG_WARNING, "'%s' is not a known priority or label\n", priority); 00105 goto chanquit; 00106 } 00107 00108 if (option_debug > 1) 00109 ast_log(LOG_DEBUG, "Attempting async goto (%s) to %s|%s|%d\n", args.channel, S_OR(context, chan2->context), S_OR(exten, chan2->exten), prio); 00110 00111 if (ast_async_goto_if_exists(chan2, S_OR(context, chan2->context), S_OR(exten, chan2->exten), prio)) 00112 ast_log(LOG_WARNING, "%s failed for %s\n", app, args.channel); 00113 else 00114 res = 0; 00115 00116 chanquit: 00117 ast_mutex_unlock(&chan2->lock); 00118 quit: 00119 ast_module_user_remove(u); 00120 00121 return res; 00122 }
static int load_module | ( | void | ) | [static] |
Definition at line 135 of file app_channelredirect.c.
References ast_register_application(), and asyncgoto_exec().
00136 { 00137 return ast_register_application(app, asyncgoto_exec, synopsis, descrip); 00138 }
static int unload_module | ( | void | ) | [static] |
Definition at line 124 of file app_channelredirect.c.
References ast_module_user_hangup_all, and ast_unregister_application().
00125 { 00126 int res; 00127 00128 res = ast_unregister_application(app); 00129 00130 ast_module_user_hangup_all(); 00131 00132 return res; 00133 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Channel Redirect" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "f450f61f60e761b3aa089ebed76ca8a5" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 140 of file app_channelredirect.c.
char* app = "ChannelRedirect" [static] |
Definition at line 45 of file app_channelredirect.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 140 of file app_channelredirect.c.
char* descrip [static] |
Initial value:
"ChannelRedirect(channel|[[context|]extension|]priority):\n" " Sends the specified channel to the specified extension priority\n"
Definition at line 47 of file app_channelredirect.c.
char* synopsis = "Redirects given channel to a dialplan target." [static] |
Definition at line 46 of file app_channelredirect.c.