Mon Mar 31 07:42:13 2008

Asterisk developer's documentation


pbx_loopback.c File Reference

Loopback PBX Module. More...

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/options.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/frame.h"
#include "asterisk/cli.h"
#include "asterisk/lock.h"
#include "asterisk/md5.h"
#include "asterisk/linkedlists.h"
#include "asterisk/chanvars.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
#include "asterisk/utils.h"
#include "asterisk/crypto.h"
#include "asterisk/astdb.h"

Include dependency graph for pbx_loopback.c:

Go to the source code of this file.

Defines

#define LOOPBACK_COMMON

Functions

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Loopback Switch")
static int load_module (void)
static int loopback_canmatch (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
static int loopback_exec (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
static int loopback_exists (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
static char * loopback_helper (char *buf, int buflen, const char *exten, const char *context, int priority, const char *data)
static int loopback_matchmore (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
static void loopback_subst (char **newexten, char **newcontext, int *priority, char **newpattern, char *buf)
static int unload_module (void)

Variables

static struct ast_switch loopback_switch


Detailed Description

Loopback PBX Module.

Definition in file pbx_loopback.c.


Define Documentation

#define LOOPBACK_COMMON

Definition at line 71 of file pbx_loopback.c.

Referenced by loopback_canmatch(), loopback_exec(), loopback_exists(), and loopback_matchmore().


Function Documentation

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Loopback Switch"   
)

static int load_module ( void   )  [static]

Definition at line 177 of file pbx_loopback.c.

References ast_register_switch(), and loopback_switch.

00178 {
00179    ast_register_switch(&loopback_switch);
00180    return 0;
00181 }

static int loopback_canmatch ( struct ast_channel chan,
const char *  context,
const char *  exten,
int  priority,
const char *  callerid,
const char *  data 
) [static]

Definition at line 133 of file pbx_loopback.c.

References ast_canmatch_extension(), ast_extension_match(), and LOOPBACK_COMMON.

00134 {
00135    LOOPBACK_COMMON;
00136    res = ast_canmatch_extension(chan, newcontext, newexten, newpriority, callerid);
00137    if (newpattern && !ast_extension_match(newpattern, exten))
00138       res = 0;
00139    return res;
00140 }

static int loopback_exec ( struct ast_channel chan,
const char *  context,
const char *  exten,
int  priority,
const char *  callerid,
const char *  data 
) [static]

Definition at line 142 of file pbx_loopback.c.

References ast_extension_match(), ast_spawn_extension(), and LOOPBACK_COMMON.

00143 {
00144    LOOPBACK_COMMON;
00145    res = ast_spawn_extension(chan, newcontext, newexten, newpriority, callerid);
00146    /* XXX hmmm... res is overridden ? */
00147    if (newpattern && !ast_extension_match(newpattern, exten))
00148       res = -1;
00149    return res;
00150 }

static int loopback_exists ( struct ast_channel chan,
const char *  context,
const char *  exten,
int  priority,
const char *  callerid,
const char *  data 
) [static]

Definition at line 124 of file pbx_loopback.c.

References ast_exists_extension(), ast_extension_match(), and LOOPBACK_COMMON.

00125 {
00126    LOOPBACK_COMMON;
00127    res = ast_exists_extension(chan, newcontext, newexten, newpriority, callerid);
00128    if (newpattern && !ast_extension_match(newpattern, exten))
00129       res = 0;
00130    return res;
00131 }

static char* loopback_helper ( char *  buf,
int  buflen,
const char *  exten,
const char *  context,
int  priority,
const char *  data 
) [static]

Definition at line 83 of file pbx_loopback.c.

References AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_INSERT_HEAD, AST_LIST_REMOVE_HEAD, ast_var_assign(), ast_var_delete(), and pbx_substitute_variables_varshead().

00084 {
00085    struct ast_var_t *newvariable;
00086    struct varshead headp;
00087    char tmp[80];
00088 
00089    snprintf(tmp, sizeof(tmp), "%d", priority);
00090    memset(buf, 0, buflen);
00091    AST_LIST_HEAD_INIT_NOLOCK(&headp);
00092    AST_LIST_INSERT_HEAD(&headp, ast_var_assign("EXTEN", exten), entries);
00093    AST_LIST_INSERT_HEAD(&headp, ast_var_assign("CONTEXT", context), entries);
00094    AST_LIST_INSERT_HEAD(&headp, ast_var_assign("PRIORITY", tmp), entries);
00095    /* Substitute variables */
00096    pbx_substitute_variables_varshead(&headp, data, buf, buflen);
00097    /* free the list */
00098    while ((newvariable = AST_LIST_REMOVE_HEAD(&headp, entries)))
00099                 ast_var_delete(newvariable);
00100    return buf;
00101 }

static int loopback_matchmore ( struct ast_channel chan,
const char *  context,
const char *  exten,
int  priority,
const char *  callerid,
const char *  data 
) [static]

Definition at line 152 of file pbx_loopback.c.

References ast_extension_match(), ast_matchmore_extension(), and LOOPBACK_COMMON.

00153 {
00154    LOOPBACK_COMMON;
00155    res = ast_matchmore_extension(chan, newcontext, newexten, newpriority, callerid);
00156    if (newpattern && !ast_extension_match(newpattern, exten))
00157       res = 0;
00158    return res;
00159 }

static void loopback_subst ( char **  newexten,
char **  newcontext,
int *  priority,
char **  newpattern,
char *  buf 
) [static]

Definition at line 103 of file pbx_loopback.c.

References ast_strlen_zero().

00104 {
00105    char *con;
00106    char *pri;
00107    *newpattern = strchr(buf, '/');
00108    if (*newpattern)
00109       *(*newpattern)++ = '\0';
00110    con = strchr(buf, '@');
00111    if (con) {
00112       *con++ = '\0';
00113       pri = strchr(con, ':');
00114    } else
00115       pri = strchr(buf, ':');
00116    if (!ast_strlen_zero(buf))
00117       *newexten = buf;
00118    if (!ast_strlen_zero(con))
00119       *newcontext = con;
00120    if (!ast_strlen_zero(pri))
00121       sscanf(pri, "%d", priority);
00122 }

static int unload_module ( void   )  [static]

Definition at line 171 of file pbx_loopback.c.

References ast_unregister_switch(), and loopback_switch.

00172 {
00173    ast_unregister_switch(&loopback_switch);
00174    return 0;
00175 }


Variable Documentation

struct ast_switch loopback_switch [static]

Definition at line 161 of file pbx_loopback.c.

Referenced by load_module(), and unload_module().


Generated on Mon Mar 31 07:42:13 2008 for Asterisk - the Open Source PBX by  doxygen 1.5.1