49 struct ast_channel *
c,
int *ifield,
const char *expression)
51 int i, okay = 1, value1 = -1, value2 = -1;
55 for (i = 0; i < 256; i++) {
60 if (sscanf(workspace,
"%d", &value1) != 1 || value1 != i || sscanf(
ast_str_buffer(
str),
"%d", &value2) != 1 || value2 != i) {
75 int i, okay = 1, value1 = -1, value2 = -1;
79 for (i = 0; i < 256; i++) {
84 if (sscanf(workspace,
"%d", &value1) != 1 || value1 != i || sscanf(
ast_str_buffer(
str),
"%d", &value2) != 1 || value2 != i) {
98 const char *(*getter)(
const struct ast_channel *),
const char *expression)
100 const char *
values[] = {
"one",
"three",
"reallylongdinosaursoundingthingwithwordsinit" };
102 char workspace[4096];
116 expression, okay ?
"passed" :
"FAILED");
126 const char *
values[] = {
"one",
"three",
"reallylongdinosaursoundingthingwithwordsinit" };
128 char workspace[4096];
157 char workspace[4096];
169 expression, okay ?
"passed" :
"FAILED");
177 struct ast_channel *
c,
const char *encode1,
const char *encode2,
178 const char *decode1,
const char *decode2)
183 ast_str_set(&expression, 0,
"%s%s%s", encode1,
"foobarbaz", encode2);
194 encode1, encode2, decode1, decode2,
195 okay ?
"passed" :
"FAILED");
217 okay ?
"passed" :
"FAILED");
233 info->name =
"test_substitution";
234 info->category =
"/main/pbx/";
235 info->summary =
"Test variable and function substitution";
237 "This test executes a variety of variable and function substitutions "
238 "and ensures that the expected results are received.";
246 c =
ast_channel_alloc(0, 0,
"",
"",
"",
"",
"",
NULL,
NULL, 0,
"Test/substitution");
249#define TEST(t) if (t == AST_TEST_FAIL) { res = AST_TEST_FAIL; }
313 if (strcmp(cmd,
"CHANNEL") && strcmp(cmd,
"CALLERID") && strncmp(cmd,
"CURL", 4) &&
314 strncmp(cmd,
"AES", 3) && strncmp(cmd,
"BASE64", 6) &&
315 strcmp(cmd,
"CDR") && strcmp(cmd,
"ENV") && strcmp(cmd,
"GLOBAL") &&
316 strcmp(cmd,
"GROUP") && strcmp(cmd,
"CUT") && strcmp(cmd,
"LISTFILTER") &&
317 strcmp(cmd,
"PP_EACH_EXTENSION") && strcmp(cmd,
"SET")) {
321 snprintf(expression,
sizeof(expression),
"${%s(foo)}", cmd);
Asterisk main include file. File version handling, generic pbx functions.
General Asterisk PBX channel definitions.
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
const char * ast_channel_context(const struct ast_channel *chan)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
void ast_channel_context_set(struct ast_channel *chan, const char *value)
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
void ast_channel_priority_set(struct ast_channel *chan, int value)
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
const char * ast_channel_exten(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
struct ast_vector_string * ast_cli_completion_vector(const char *text, const char *word)
Generates a vector of strings for CLI completion.
Generic File Format Support. Should be included by clients of the file handling routines....
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
Asterisk locking-related definitions:
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
Core PBX routines and definitions.
struct ast_custom_function * ast_custom_function_find(const char *name)
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
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 pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
String manipulation functions.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define ast_str_alloca(init_len)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Support for dynamic strings.
String vector definitions.
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
static enum ast_test_result_state test_chan_integer(struct ast_test *test, struct ast_channel *c, int *ifield, const char *expression)
static enum ast_test_result_state test_chan_function(struct ast_test *test, struct ast_channel *c, const char *expression)
AST_TEST_DEFINE(test_substitution)
static enum ast_test_result_state test_2way_function(struct ast_test *test, struct ast_channel *c, const char *encode1, const char *encode2, const char *decode1, const char *decode2)
static enum ast_test_result_state test_chan_string(struct ast_test *test, struct ast_channel *c, void(*setter)(struct ast_channel *, const char *), const char *(*getter)(const struct ast_channel *), const char *expression)
static enum ast_test_result_state test_chan_variable(struct ast_test *test, struct ast_channel *c, const char *varname)
static int load_module(void)
static int unload_module(void)
static enum ast_test_result_state test_chan_integer_accessor(struct ast_test *test, struct ast_channel *c, void(*setter)(struct ast_channel *, int), const char *expression)
static enum ast_test_result_state test_expected_result(struct ast_test *test, struct ast_channel *c, const char *expression, const char *result)
Definitions to aid in the use of thread local storage.
Vector container support.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_PTR_FREE(vec)
Deallocates this vector pointer.
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.