Asterisk - The Open Source Telephony Project  GIT-master-9ed6387
Functions | Variables
app_transfer.c File Reference

Transfer a caller. More...

#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/channel.h"

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 load_module (void)
 
static int transfer_exec (struct ast_channel *chan, const char *data)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Transfers a caller to another extension" , .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 *const app = "Transfer"
 
static const struct ast_module_infoast_module_info = &__mod_info
 

Detailed Description

Transfer a caller.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

Requires transfer support from channel driver

Definition in file app_transfer.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 144 of file app_transfer.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 144 of file app_transfer.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 144 of file app_transfer.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 139 of file app_transfer.c.

References app, ast_register_application_xml, and transfer_exec().

140 {
142 }
static const char *const app
Definition: app_transfer.c:77
static int transfer_exec(struct ast_channel *chan, const char *data)
Definition: app_transfer.c:79
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626

◆ transfer_exec()

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

Definition at line 79 of file app_transfer.c.

References args, AST_APP_ARG, ast_channel_tech(), AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, ast_transfer(), len(), LOG_WARNING, NULL, parse(), pbx_builtin_setvar_helper(), status, transfer, and type.

Referenced by load_module().

80 {
81  int res;
82  int len;
83  char *slash;
84  char *tech = NULL;
85  char *dest = NULL;
86  char *status;
87  char *parse;
89  AST_APP_ARG(dest);
90  );
91 
92  if (ast_strlen_zero((char *)data)) {
93  ast_log(LOG_WARNING, "Transfer requires an argument ([Tech/]destination)\n");
94  pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
95  return 0;
96  } else
97  parse = ast_strdupa(data);
98 
100 
101  dest = args.dest;
102 
103  if ((slash = strchr(dest, '/')) && (len = (slash - dest))) {
104  tech = dest;
105  dest = slash + 1;
106  /* Allow execution only if the Tech/destination agrees with the type of the channel */
107  if (strncasecmp(ast_channel_tech(chan)->type, tech, len)) {
108  pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
109  return 0;
110  }
111  }
112 
113  /* Check if the channel supports transfer before we try it */
114  if (!ast_channel_tech(chan)->transfer) {
115  pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "UNSUPPORTED");
116  return 0;
117  }
118 
119  res = ast_transfer(chan, dest);
120 
121  if (res < 0) {
122  status = "FAILURE";
123  res = 0;
124  } else {
125  status = "SUCCESS";
126  res = 0;
127  }
128 
129  pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", status);
130 
131  return res;
132 }
static const char type[]
Definition: chan_ooh323.c:109
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
#define LOG_WARNING
Definition: logger.h:274
const char * args
#define NULL
Definition: resample.c:96
static int transfer
Definition: chan_mgcp.c:194
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ast_strlen_zero(a)
Definition: muted.c:73
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
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_transfer(struct ast_channel *chan, char *dest)
Transfer a channel (if supported).
Definition: channel.c:6445
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
jack_status_t status
Definition: app_jack.c:146
#define AST_APP_ARG(name)
Define an application argument.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 134 of file app_transfer.c.

References app, and ast_unregister_application().

135 {
137 }
static const char *const app
Definition: app_transfer.c:77
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Transfers a caller to another extension" , .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 144 of file app_transfer.c.

◆ app

const char* const app = "Transfer"
static

Definition at line 77 of file app_transfer.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 144 of file app_transfer.c.