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

Dialplan extension evaluation function. More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
Include dependency graph for func_evalexten.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD_EXTENDED (ASTERISK_GPL_KEY, "Extension evaluation function")
 
static int eval_exten_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int load_module (void)
 
static int unload_module (void)
 

Variables

static struct ast_custom_function eval_exten_function
 

Detailed Description

Dialplan extension evaluation function.

Author
Naveen Albert aster.nosp@m.isk@.nosp@m.phrea.nosp@m.knet.nosp@m..org

Definition in file func_evalexten.c.

Function Documentation

◆ AST_MODULE_INFO_STANDARD_EXTENDED()

AST_MODULE_INFO_STANDARD_EXTENDED ( ASTERISK_GPL_KEY  ,
"Extension evaluation function"   
)

◆ eval_exten_read()

static int eval_exten_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 91 of file func_evalexten.c.

92{
93 char *exten, *pri, *context, *parse;
94 int ipri;
95 char tmpbuf[len];
96
97 if (ast_strlen_zero(data)) {
98 ast_log(LOG_WARNING, "The EVAL_EXTEN function requires an extension\n");
99 return -1;
100 }
101
102 parse = ast_strdupa(data);
103 /* Split context,exten,pri */
104 context = strsep(&parse, ",");
105 exten = strsep(&parse, ",");
106 pri = strsep(&parse, ",");
107
108 if (pbx_parse_location(chan, &context, &exten, &pri, &ipri, NULL, NULL)) {
109 return -1;
110 }
111
112 if (ast_strlen_zero(exten) || ast_strlen_zero(context)) { /* only lock if we really need to */
113 ast_channel_lock(chan);
114 if (ast_strlen_zero(exten)) {
115 exten = ast_strdupa(ast_channel_exten(chan));
116 }
119 }
120 ast_channel_unlock(chan);
121 }
122
123 if (ast_get_extension_data(tmpbuf, len, chan, context, exten, ipri)) {
124 return -1; /* EVAL_EXTEN failed */
125 }
126
127 pbx_substitute_variables_helper_full_location(chan, (chan) ? ast_channel_varshead(chan) : NULL, tmpbuf, buf, len, NULL, context, exten, ipri);
128
129 return 0;
130}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_log
Definition: astobj2.c:42
struct varshead * ast_channel_varshead(struct ast_channel *chan)
#define ast_channel_lock(chan)
Definition: channel.h:2922
const char * ast_channel_context(const struct ast_channel *chan)
const char * ast_channel_exten(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition: channel.h:2923
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
char * strsep(char **str, const char *delims)
#define LOG_WARNING
int ast_get_extension_data(char *buf, int bufsize, struct ast_channel *c, const char *context, const char *exten, int priority)
Fill a string buffer with the data at a dialplan extension.
Definition: pbx.c:8567
void pbx_substitute_variables_helper_full_location(struct ast_channel *c, struct varshead *headp, const char *cp1, char *cp2, int cp2_size, size_t *used, const char *context, const char *exten, int pri)
Substitutes variables, similar to pbx_substitute_variables_helper_full, but allows passing the contex...
int pbx_parse_location(struct ast_channel *chan, char **context, char **exten, char **pri, int *ipri, int *mode, char *rest)
Parses a dialplan location into context, extension, priority.
Definition: pbx.c:8791
#define NULL
Definition: resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65

References ast_channel_context(), ast_channel_exten(), ast_channel_lock, ast_channel_unlock, ast_channel_varshead(), ast_get_extension_data(), ast_log, ast_strdupa, ast_strlen_zero(), buf, voicemailpwcheck::context, len(), LOG_WARNING, NULL, pbx_parse_location(), pbx_substitute_variables_helper_full_location(), and strsep().

◆ load_module()

static int load_module ( void  )
static

Definition at line 142 of file func_evalexten.c.

143{
145}
static struct ast_custom_function eval_exten_function
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1558

References ast_custom_function_register, and eval_exten_function.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 137 of file func_evalexten.c.

138{
140}
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.

References ast_custom_function_unregister(), and eval_exten_function.

Variable Documentation

◆ eval_exten_function

struct ast_custom_function eval_exten_function
static
Initial value:
= {
.name = "EVAL_EXTEN",
.read = eval_exten_read,
}
static int eval_exten_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 132 of file func_evalexten.c.

Referenced by load_module(), and unload_module().