Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions | Variables
app_channelredirect.c File Reference

ChannelRedirect application. More...

#include "asterisk.h"
#include "asterisk/file.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 dependency graph for app_channelredirect.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int asyncgoto_exec (struct ast_channel *chan, const char *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_LOAD_ORDER , .description = "Redirects a given channel to a dialplan target" , .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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static const char app [] = "ChannelRedirect"
 
static const struct ast_module_infoast_module_info = &__mod_info
 

Detailed Description

ChannelRedirect application.

Author
Sergey Basmanov serge.nosp@m.y_ba.nosp@m.smano.nosp@m.v@ma.nosp@m.il.ru

Definition in file app_channelredirect.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 117 of file app_channelredirect.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 117 of file app_channelredirect.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 117 of file app_channelredirect.c.

◆ asyncgoto_exec()

static int asyncgoto_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 67 of file app_channelredirect.c.

68{
69 int res = -1;
70 char *info;
71 struct ast_channel *chan2 = NULL;
72
74 AST_APP_ARG(channel);
75 AST_APP_ARG(label);
76 );
77
78 if (ast_strlen_zero(data)) {
79 ast_log(LOG_WARNING, "%s requires an argument (channel,[[context,]exten,]priority)\n", app);
80 return -1;
81 }
82
85
86 if (ast_strlen_zero(args.channel) || ast_strlen_zero(args.label)) {
87 ast_log(LOG_WARNING, "%s requires an argument (channel,[[context,]exten,]priority)\n", app);
88 return -1;
89 }
90
91 if (!(chan2 = ast_channel_get_by_name(args.channel))) {
92 ast_log(LOG_WARNING, "No such channel: %s\n", args.channel);
93 pbx_builtin_setvar_helper(chan, "CHANNELREDIRECT_STATUS", "NOCHANNEL");
94 return 0;
95 }
96
97 res = ast_async_parseable_goto(chan2, args.label);
98
99 chan2 = ast_channel_unref(chan2);
100
101 pbx_builtin_setvar_helper(chan, "CHANNELREDIRECT_STATUS", "SUCCESS");
102
103 return res;
104}
static const char app[]
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_log
Definition: astobj2.c:42
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:3004
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
Definition: channel.c:1473
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define LOG_WARNING
def info(msg)
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string)
Definition: pbx.c:8871
#define NULL
Definition: resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Main Channel structure associated with a channel.
const char * data
const char * args

References app, args, AST_APP_ARG, ast_async_parseable_goto(), ast_channel_get_by_name(), ast_channel_unref, AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_channel::data, sip_to_pjsip::info(), LOG_WARNING, NULL, and pbx_builtin_setvar_helper().

Referenced by load_module().

◆ load_module()

static int load_module ( void  )
static

Definition at line 111 of file app_channelredirect.c.

112{
115}
static int asyncgoto_exec(struct ast_channel *chan, const char *data)
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:640

References app, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, and asyncgoto_exec().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 106 of file app_channelredirect.c.

107{
109}
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

References app, and ast_unregister_application().

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Redirects a given channel to a dialplan target" , .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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 117 of file app_channelredirect.c.

◆ app

const char app[] = "ChannelRedirect"
static

Definition at line 65 of file app_channelredirect.c.

Referenced by asyncgoto_exec(), load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 117 of file app_channelredirect.c.