Thu Apr 28 2011 17:15:33

Asterisk developer's documentation


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"
Include dependency graph for app_transfer.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int load_module (void)
static int transfer_exec (struct ast_channel *chan, void *data)
static int unload_module (void)

Variables

static struct ast_module_info
__MODULE_INFO_SECTION 
__mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Transfers a caller to another extension" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, }
static const char * app = "Transfer"
static struct ast_module_infoast_module_info = &__mod_info

Detailed Description

Transfer a caller.

Author:
Mark Spencer <markster@digium.com>

Requires transfer support from channel driver

Definition in file app_transfer.c.


Function Documentation

static void __reg_module ( void  ) [static]

Definition at line 142 of file app_transfer.c.

static void __unreg_module ( void  ) [static]

Definition at line 142 of file app_transfer.c.

static int load_module ( void  ) [static]
static int transfer_exec ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 77 of file app_transfer.c.

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

Referenced by load_module().

{
   int res;
   int len;
   char *slash;
   char *tech = NULL;
   char *dest = NULL;
   char *status;
   char *parse;
   AST_DECLARE_APP_ARGS(args,
      AST_APP_ARG(dest);
   );

   if (ast_strlen_zero((char *)data)) {
      ast_log(LOG_WARNING, "Transfer requires an argument ([Tech/]destination)\n");
      pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
      return 0;
   } else
      parse = ast_strdupa(data);

   AST_STANDARD_APP_ARGS(args, parse);

   dest = args.dest;

   if ((slash = strchr(dest, '/')) && (len = (slash - dest))) {
      tech = dest;
      dest = slash + 1;
      /* Allow execution only if the Tech/destination agrees with the type of the channel */
      if (strncasecmp(chan->tech->type, tech, len)) {
         pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
         return 0;
      }
   }

   /* Check if the channel supports transfer before we try it */
   if (!chan->tech->transfer) {
      pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "UNSUPPORTED");
      return 0;
   }

   res = ast_transfer(chan, dest);

   if (res < 0) {
      status = "FAILURE";
      res = 0;
   } else {
      status = "SUCCESS";
      res = 0;
   }

   pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", status);

   return res;
}
static int unload_module ( void  ) [static]

Definition at line 132 of file app_transfer.c.

References ast_unregister_application().


Variable Documentation

struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Transfers a caller to another extension" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static]

Definition at line 142 of file app_transfer.c.

const char* app = "Transfer" [static]

Definition at line 75 of file app_transfer.c.

Definition at line 142 of file app_transfer.c.