Wed Jan 8 2020 09:49:53

Asterisk developer's documentation


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"

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, 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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
 
static const char app [] = "ChannelRedirect"
 
static 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

static void __reg_module ( void  )
static

Definition at line 123 of file app_channelredirect.c.

static void __unreg_module ( void  )
static

Definition at line 123 of file app_channelredirect.c.

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

Definition at line 69 of file app_channelredirect.c.

References args, AST_APP_ARG, ast_async_parseable_goto(), ast_channel_get_by_name(), ast_channel_unref, AST_DECLARE_APP_ARGS, AST_FLAG_BRIDGE_HANGUP_DONT, ast_log(), ast_set_flag, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), LOG_WARNING, ast_channel::pbx, and pbx_builtin_setvar_helper().

Referenced by load_module().

70 {
71  int res = -1;
72  char *info;
73  struct ast_channel *chan2 = NULL;
74 
76  AST_APP_ARG(channel);
77  AST_APP_ARG(label);
78  );
79 
80  if (ast_strlen_zero(data)) {
81  ast_log(LOG_WARNING, "%s requires an argument (channel,[[context,]exten,]priority)\n", app);
82  return -1;
83  }
84 
85  info = ast_strdupa(data);
87 
88  if (ast_strlen_zero(args.channel) || ast_strlen_zero(args.label)) {
89  ast_log(LOG_WARNING, "%s requires an argument (channel,[[context,]exten,]priority)\n", app);
90  return -1;
91  }
92 
93  if (!(chan2 = ast_channel_get_by_name(args.channel))) {
94  ast_log(LOG_WARNING, "No such channel: %s\n", args.channel);
95  pbx_builtin_setvar_helper(chan, "CHANNELREDIRECT_STATUS", "NOCHANNEL");
96  return 0;
97  }
98 
99  if (chan2->pbx) {
100  ast_set_flag(chan2, AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */
101  }
102 
103  res = ast_async_parseable_goto(chan2, args.label);
104 
105  chan2 = ast_channel_unref(chan2);
106 
107  pbx_builtin_setvar_helper(chan, "CHANNELREDIRECT_STATUS", "SUCCESS");
108 
109  return res;
110 }
Main Channel structure associated with a channel.
Definition: channel.h:742
static const char app[]
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2502
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:144
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Definition: app.h:572
const char * data
Definition: channel.h:755
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string)
Definition: pbx.c:11331
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...
Definition: pbx.c:10546
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
Definition: app.h:604
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
Definition: channel.c:1803
struct ast_pbx * pbx
Definition: channel.h:761
static int load_module ( void  )
static

Definition at line 117 of file app_channelredirect.c.

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

118 {
121 }
static const char app[]
static int asyncgoto_exec(struct ast_channel *chan, const char *data)
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
static int unload_module ( void  )
static

Definition at line 112 of file app_channelredirect.c.

References ast_unregister_application().

113 {
115 }
static const char app[]
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705

Variable Documentation

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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static

Definition at line 123 of file app_channelredirect.c.

const char app[] = "ChannelRedirect"
static

Definition at line 67 of file app_channelredirect.c.

Definition at line 123 of file app_channelredirect.c.