149 static int isnull(
struct ast_channel *chan,
const char *cmd,
char *data,
150 char *buf,
size_t len)
152 strcpy(buf, data && *data ?
"0" :
"1");
157 static int exists(
struct ast_channel *chan,
const char *cmd,
char *data,
char *buf,
160 strcpy(buf, data && *data ?
"1" :
"0");
165 static int iftime(
struct ast_channel *chan,
const char *cmd,
char *data,
char *buf,
174 expr = strsep(&data,
"?");
175 iftrue = strsep(&data,
":");
178 if (ast_strlen_zero(expr) || !(iftrue || iffalse)) {
180 "Syntax IFTIME(<timespec>?[<true>][:<false>])\n");
185 ast_log(LOG_WARNING,
"Invalid Time Spec.\n");
201 static int acf_if(
struct ast_channel *chan,
const char *cmd,
char *data,
char *buf,
212 args2.iftrue = args2.iffalse = NULL;
222 if (ast_strlen_zero(args1.expr) || !(args2.iftrue || args2.iffalse)) {
223 ast_debug(1,
"<expr>='%s', <true>='%s', and <false>='%s'\n", args1.expr, args2.iftrue, args2.iffalse);
231 args2.iffalse =
ast_strip(args2.iffalse);
238 static int set(
struct ast_channel *chan,
const char *cmd,
char *data,
char *buf,
244 varname = strsep(&data,
"=");
247 if (ast_strlen_zero(varname) || !val) {
248 ast_log(LOG_WARNING,
"Syntax SET(<varname>=[<value>])\n");
260 static int set2(
struct ast_channel *chan,
const char *cmd,
char *data,
struct ast_str **str, ssize_t len)
263 ast_str_make_space(str, len == 0 ? strlen(data) : len);
268 static int import_helper(
struct ast_channel *chan,
const char *cmd,
char *data,
char *buf,
struct ast_str **str, ssize_t len)
279 if (!ast_strlen_zero(args.varname)) {
283 char *s =
ast_alloca(strlen(args.varname) + 4);
284 sprintf(s,
"${%s}", args.varname);
285 ast_channel_lock(chan2);
287 pbx_substitute_variables_helper(chan2, s, buf, len);
291 ast_channel_unlock(chan2);
299 static int import_read(
struct ast_channel *chan,
const char *cmd,
char *data,
char *buf,
size_t len)
301 return import_helper(chan, cmd, data, buf, NULL, len);
304 static int import_read2(
struct ast_channel *chan,
const char *cmd,
char *data,
struct ast_str **str, ssize_t len)
306 return import_helper(chan, cmd, data, NULL, str, len);
309 static int delete_write(
struct ast_channel *chan,
const char *cmd,
char *data,
const char *value)
316 static int variable_exists_read(
struct ast_channel *chan,
const char *cmd,
char *data,
317 char *buf,
size_t len)
321 strcpy(buf, var ?
"1" :
"0");
357 .read2 = import_read2,
362 .write = delete_write,
366 .
name =
"VARIABLE_EXISTS",
367 .read = variable_exists_read,
370 static int unload_module(
void)
386 static int load_module(
void)
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
int ast_build_timing(struct ast_timing *i, const char *info_in)
Construct a timing bitmap, for use in time-based conditionals.
#define ast_channel_unref(c)
Decrease channel reference count.
size_t ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
int pbx_checkcondition(const char *condition)
Evaluate a condition.
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
char * ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
Strip leading/trailing whitespace and quotes from a string.
General Asterisk PBX channel definitions.
Data structure associated with a custom dialplan function.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
#define ast_debug(level,...)
Log a DEBUG message.
Core PBX routines and definitions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Support for dynamic strings.
int ast_check_timing(const struct ast_timing *i)
Evaluate a pre-constructed bitmap as to whether the current time falls within the range specified...
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
int ast_destroy_timing(struct ast_timing *i)
Deallocates memory structures associated with a timing bitmap.
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...
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
#define ASTERISK_GPL_KEY
The text the key() function should return.
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
Asterisk module definitions.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_custom_function_register(acf)
Register a custom function.
#define AST_APP_ARG(name)
Define an application argument.