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];
105 for (i = 0; i <
ARRAY_LEN(values); i++) {
106 setter(c, values[i]);
110 if (strcmp(getter(c),
ast_str_buffer(str)) != 0 || strcmp(getter(c), workspace) != 0) {
116 expression, okay ?
"passed" :
"FAILED");
126 const char *
values[] = {
"one",
"three",
"reallylongdinosaursoundingthingwithwordsinit" };
128 char workspace[4096];
133 for (i = 0; i <
ARRAY_LEN(values); i++) {
138 if (strcmp(values[i],
ast_str_buffer(str)) != 0 || strcmp(values[i], workspace) != 0) {
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");
229 struct ast_vector_string *funcs;
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; } 274 TEST(
test_2way_function(test, c,
"${AES_ENCRYPT(abcdefghijklmnop,",
")}",
"${AES_DECRYPT(abcdefghijklmnop,",
")}"));
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);
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
struct ast_party_caller caller
Channel Caller ID information.
String manipulation functions.
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
#define AST_TEST_REGISTER(cb)
#define ast_str_alloca(init_len)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
Definitions to aid in the use of thread local storage.
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)
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
struct ast_party_id id
Caller party ID.
struct ast_vector_string * ast_cli_completion_vector(const char *text, const char *word)
Generates a vector of strings for CLI completion.
General Asterisk PBX channel definitions.
AST_TEST_DEFINE(test_substitution)
#define ast_test_status_update(a, b, c...)
Data structure associated with a custom dialplan function.
static enum ast_test_result_state test_chan_integer(struct ast_test *test, struct ast_channel *c, int *ifield, const char *expression)
const char * ast_channel_exten(const struct ast_channel *chan)
Core PBX routines and definitions.
static enum ast_test_result_state test_chan_function(struct ast_test *test, struct ast_channel *c, const char *expression)
struct ast_custom_function * ast_custom_function_find(const char *name)
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
#define AST_TEST_UNREGISTER(cb)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
#define ast_channel_unlock(chan)
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
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)
Vector container support.
#define AST_VECTOR_PTR_FREE(vec)
Deallocates this vector pointer.
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
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...
static int load_module(void)
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
void ast_channel_context_set(struct ast_channel *chan, const char *value)
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)
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
static enum ast_test_result_state test_expected_result(struct ast_test *test, struct ast_channel *c, const char *expression, const char *result)
const char * ast_channel_context(const struct ast_channel *chan)
static int unload_module(void)
#define ASTERISK_GPL_KEY
The text the key() function should return.
void ast_channel_priority_set(struct ast_channel *chan, int value)
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
static enum ast_test_result_state test_chan_variable(struct ast_test *test, struct ast_channel *c, const char *varname)
Asterisk module definitions.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
struct ast_party_number number
Subscriber phone number.