653        sprintf(varsubst, 
"${%s}", 
args.varname);
 
  659            while (
strsep(&varval, delim)) {
 
  669        snprintf(
buf, 
len, 
"%d", fieldcount);
 
 
  676                 char *parse, 
char *
buf, 
size_t len)
 
 
  696    char *varsubst, *field;
 
  698    int fieldindex = 0, res = 0;
 
  714        ast_log(
LOG_ERROR, 
"Usage: FIELDNUM(<listname>,<delimiter>,<fieldvalue>)\n");
 
  718        sprintf(varsubst, 
"${%s}", 
args.varname);
 
  729            while ((field = 
strsep(&varval, delim)) != 
NULL) {
 
  732                if (!strcasecmp(field, 
args.field)) {
 
  748        snprintf(
buf, 
len, 
"%d", fieldindex);
 
 
  755                 char *parse, 
char *
buf, 
size_t len)
 
 
  780    const char *begin, *cur, *next;
 
  781    int dlen, flen, 
first = 1;
 
  783    char *delim, *varsubst;
 
  797        ast_log(
LOG_ERROR, 
"Usage: LISTFILTER(<listname>,<delimiter>,<fieldvalue>)\n");
 
  802    sprintf(varsubst, 
"${%s}", 
args.listname);
 
  829    dlen = strlen(
args.delimiter);
 
  833    if ((dlen = strlen(delim)) == 0) {
 
  838    flen = strlen(
args.fieldvalue);
 
  847    next = strstr(begin, delim);
 
  853            next = strstr(cur + dlen, delim);
 
  855            cur = strchr(begin + dlen, 
'\0');
 
  858        if (flen == cur - begin && !strncmp(begin, 
args.fieldvalue, flen)) {
 
  860            begin += flen + dlen;
 
  871    } 
while (*cur != 
'\0');
 
 
  894    .
name = 
"LISTFILTER",
 
 
  908    char allowed[256] = 
"";
 
  909    size_t allowedlen = 0;
 
  910    int32_t bitfield[8] = { 0, }; 
 
  920        ast_log(
LOG_WARNING, 
"FILTER allowed characters includes the quote (\") character.  This may not be what you want.\n");
 
  924    for (; *(
args.allowed);) {
 
  930        args.allowed += consumed;
 
  932        if (*(
args.allowed) == 
'-') {
 
  935            args.allowed += consumed + 1;
 
  938                ast_log(
LOG_WARNING, 
"Range wrapping in FILTER(%s,%s).  This may not be what you want.\n", parse, 
args.string);
 
  945            for (ac = (
unsigned char) c1; ac != (
unsigned char) c2; ac++) {
 
  946                bitfield[ac / 32] |= 1 << (ac % 32);
 
  948            bitfield[ac / 32] |= 1 << (ac % 32);
 
  952            ac = (
unsigned char) c1;
 
  953            ast_debug(4, 
"c1=%d, consumed=%d, args.allowed=%s\n", c1, (
int) consumed, 
args.allowed - consumed);
 
  954            bitfield[ac / 32] |= 1 << (ac % 32);
 
  958    for (ac = 1; ac != 0; ac++) {
 
  959        if (bitfield[ac / 32] & (1 << (ac % 32))) {
 
  960            allowed[allowedlen++] = ac;
 
  966    for (; *(
args.string) && (
buf + 
len - 1 > outbuf); (
args.string)++) {
 
  967        if (strchr(allowed, *(
args.string)))
 
  968            *outbuf++ = *(
args.string);
 
 
  987    char *strptr, *varsubst;
 
 1000        ast_log(
LOG_ERROR, 
"Usage: %s(<varname>,<search-chars>[,<replace-char>])\n", cmd);
 
 1009        ast_log(
LOG_ERROR, 
"The characters to search for and the variable name must not be empty.\n");
 
 1014    sprintf(varsubst, 
"${%s}", 
args.varname);
 
 1023    ast_debug(3, 
"Characters to find: (%s)\n", find);
 
 1029        if (strchr(find, *strptr)) {
 
 1031                memmove(strptr, strptr + 1, strlen(strptr + 1) + 1);
 
 
 1055    unsigned max_matches; 
 
 1078    if (
args.argc < 2) {
 
 1081            "Usage: %s(<varname>,<find-string>[,<replace-string>,[<max-replacements>]])\n",
 
 1096    find_size = strlen(
args.find_string);
 
 1100    sprintf(varsubstr, 
"${%s}", 
args.varname);
 
 1104    if (!
args.max_replacements
 
 1105        || (max_matches = atoi(
args.max_replacements)) <= 0) {
 
 1112    for (count = 0; count < max_matches; ++count) {
 
 1113        end = strstr(start, 
args.find_string);
 
 1122        if (
args.replace_string) {
 
 1126        start = 
end + find_size;
 
 
 1134    .
name = 
"STRREPLACE",
 
 
 1141    char *varsubstr, *origstr;
 
 1165    sprintf(varsubstr, 
"${%s}", 
args.varname);
 
 1168    origsize = strlen(origstr);
 
 1169    for (
c = 0; 
c < origsize; 
c++) {
 
 1172        if (
c < (origsize - 1)) {
 
 
 1181    .
name = 
"STRBETWEEN",
 
 
 1185#define ltrim(s) while (isspace(*s)) s++; 
 1188        char *back = s + strlen(s); \ 
 1189        while (back != s && isspace(*--back)); \ 
 1191            *(back + 1) = '\0'; \ 
 
 1278    if (
args.argc != 3) {
 
 1279        ast_log(
LOG_ERROR, 
"Unexpected arguments: should have been in the form '\"<regex>\" <string>'\n");
 
 1282    if ((*
args.str == 
' ') || (*
args.str == 
'\t'))
 
 1287    if ((errcode = regcomp(®exbuf, 
args.reg, REG_EXTENDED | REG_NOSUB))) {
 
 1288        regerror(errcode, ®exbuf, 
buf, 
len);
 
 1293    strcpy(
buf, regexec(®exbuf, 
args.str, 0, 
NULL, 0) ? 
"0" : 
"1");
 
 
 1305#define HASH_PREFIX "~HASH~%s~" 
 1306#define HASH_FORMAT HASH_PREFIX "%s~" 
 1341    char *origvar = 
"", *value2, varname[256];
 
 1349    if (!strcmp(cmd, 
"HASH")) {
 
 1373    for (i = 0; i < arg1.argc; i++) {
 
 1374        ast_debug(1, 
"array set value (%s=%s)\n", arg1.var[i],
 
 1375                S_OR(arg2.val[i], 
""));
 
 1376        if (i < arg2.argc) {
 
 1378                if (origvar[0] == 
'_') {
 
 1379                    if (origvar[1] == 
'_') {
 
 1380                        snprintf(varname, 
sizeof(varname), 
"__" HASH_FORMAT, origvar + 2, arg1.var[i]);
 
 1382                        snprintf(varname, 
sizeof(varname), 
"_" HASH_FORMAT, origvar + 1, arg1.var[i]);
 
 1385                    snprintf(varname, 
sizeof(varname), 
HASH_FORMAT, origvar, arg1.var[i]);
 
 1396                snprintf(varname, 
sizeof(varname), 
HASH_FORMAT, origvar, arg1.var[i]);
 
 
 1419    var_len = strlen(var_name);
 
 1425    return var_len > (prefix_len + 1) && var_name[var_len - 1] == 
'~' &&
 
 1426        strncmp(prefix_name, var_name, prefix_len) == 0 ? var_name + prefix_len : 
NULL;
 
 
 1447            strncat(
buf, key, 
len - strlen(
buf) - 1);
 
 1449            buf[strlen(
buf) - 1] = 
',';
 
 1453    buf_len = strlen(
buf);
 
 1455        buf[buf_len - 1] = 
'\0';
 
 
 1497    if (!strchr(
var, 
',')) {
 
 1503    if (arg.hashname[0] == 
'_') {
 
 1504        if (arg.hashname[1] == 
'_') {
 
 1505            snprintf(varname, 
sizeof(varname), 
"__" HASH_FORMAT, arg.hashname + 2, arg.hashkey);
 
 1507            snprintf(varname, 
sizeof(varname), 
"_" HASH_FORMAT, arg.hashname + 1, arg.hashkey);
 
 1510        snprintf(varname, 
sizeof(varname), 
HASH_FORMAT, arg.hashname, arg.hashkey);
 
 
 1520    const char *varvalue;
 
 1527    if (arg.argc == 2) {
 
 1528        snprintf(varname, 
sizeof(varname), 
HASH_FORMAT, arg.hashname, arg.hashkey);
 
 1534    } 
else if (arg.argc == 1) {
 
 1535        char colnames[4096];
 
 1542            ast_log(
LOG_WARNING, 
"No channel and only 1 parameter was provided to %s function.\n", cmd);
 
 1547        hashkeys_read(chan, 
"HASHKEYS", arg.hashname, colnames, 
sizeof(colnames));
 
 1554        for (i = 0; i < arg2.argc; i++) {
 
 1555            snprintf(varname, 
sizeof(varname), 
HASH_FORMAT, arg.hashname, arg2.col[i]);
 
 1567            strncat(
buf, varvalue, 
len - strlen(
buf) - 1);
 
 1568            strncat(
buf, 
",", 
len - strlen(
buf) - 1);
 
 1572        buf[strlen(
buf) - 1] = 
'\0';
 
 
 1597    char *bufptr = 
buf, *dataptr = data;
 
 1611    for (; bufptr < 
buf + 
len - 3; dataptr++) {
 
 1612        if (*dataptr == 
'\\') {
 
 1615        } 
else if (*dataptr == 
'"') {
 
 1618        } 
else if (*dataptr == 
'\0') {
 
 1621            *bufptr++ = *dataptr;
 
 
 1636    char *bufptr = 
buf, *dataptr = data;
 
 1649    for (; bufptr < 
buf + 
len - 3; dataptr++){
 
 1650        if (*dataptr == 
'"') {
 
 1653        } 
else if (*dataptr == 
'\0') {
 
 1656            *bufptr++ = *dataptr;
 
 
 1665    .
name = 
"CSV_QUOTE",
 
 
 1674        length = strlen(data);
 
 1676    snprintf(
buf, buflen, 
"%d", length);
 
 
 1688            char *
buf, 
size_t buflen)
 
 1695    struct timeval when;
 
 1711    buf[buflen - 1] = 
'\0';
 
 
 1722            char *
buf, 
size_t buflen)
 
 1735                "Asterisk function STRPTIME() requires an argument.\n");
 
 1743                "No format supplied to STRPTIME(<timestring>,<timezone>,<format>)");
 
 1750        struct timeval when;
 
 1752        snprintf(
buf, buflen, 
"%d", (
int) when.tv_sec);
 
 
 1764             char *
buf, 
size_t buflen)
 
 
 1797    char *bufptr, *dataptr;
 
 1799    for (bufptr = 
buf, dataptr = data; bufptr < 
buf + buflen - 1; dataptr++) {
 
 1800        if (*dataptr == 
'\0') {
 
 1803        } 
else if (*dataptr == 
'1') {
 
 1805        } 
else if (strchr(
"AaBbCc2", *dataptr)) {
 
 1807        } 
else if (strchr(
"DdEeFf3", *dataptr)) {
 
 1809        } 
else if (strchr(
"GgHhIi4", *dataptr)) {
 
 1811        } 
else if (strchr(
"JjKkLl5", *dataptr)) {
 
 1813        } 
else if (strchr(
"MmNnOo6", *dataptr)) {
 
 1815        } 
else if (strchr(
"PpQqRrSs7", *dataptr)) {
 
 1817        } 
else if (strchr(
"TtUuVv8", *dataptr)) {
 
 1819        } 
else if (strchr(
"WwXxYyZz9", *dataptr)) {
 
 1821        } 
else if (*dataptr == 
'0') {
 
 1825    buf[buflen - 1] = 
'\0';
 
 
 1831    .
name = 
"KEYPADHASH",
 
 
 1837    char *bufptr = 
buf, *dataptr = data;
 
 1839    while ((bufptr < 
buf + buflen - 1) && (*bufptr++ = toupper(*dataptr++)));
 
 
 1846    char *bufptr, *dataptr = data;
 
 
 1866    char *bufptr = 
buf, *dataptr = data;
 
 1868    while ((bufptr < 
buf + buflen - 1) && (*bufptr++ = tolower(*dataptr++)));
 
 
 1875    char *bufptr, *dataptr = data;
 
 
 1895#define beginning   (cmd[0] == 'S')  
 1896    char *after, delimiter[2] = 
",", *varsubst;
 
 1899    char *(*search_func)(
const char *s, 
int c) = (
beginning ? strchr : strrchr);
 
 1917    sprintf(varsubst, 
"${%s}", 
args.var);
 
 1929    if (!(after = search_func(
ast_str_buffer(before), delimiter[0]))) {
 
 
 1955#define beginning   (cmd[0] == 'U')  
 1956    char delimiter[2] = 
",", *varsubst;
 
 1963    const char *stripped_var;
 
 1987    stripped_var = 
args.var + 
MIN(strspn(
args.var, 
"_"), 2);
 
 1988    varsubst = 
ast_alloca(strlen(stripped_var) + 4);
 
 1989    sprintf(varsubst, 
"${%s}", stripped_var);
 
 
 2028#ifdef TEST_FRAMEWORK 
 2034    char expression[256];
 
 2039        const char *expected;
 
 2041        {
"abc,def,ghi,jkl", 
"\\,",     
"ghi", 
"3"},
 
 2042        {
"abc def ghi jkl", 
" ",       
"abc", 
"1"},
 
 2043        {
"abc/def/ghi/jkl", 
"\\\\x2f", 
"def", 
"2"},
 
 2044        {
"abc$def$ghi$jkl", 
"",        
"ghi", 
"0"},
 
 2045        {
"abc,def,ghi,jkl", 
"-",       
"",    
"0"},
 
 2046        {
"abc-def-ghi-jkl", 
"-",       
"mno", 
"0"}
 
 2051        info->name = 
"func_FIELDNUM_test";
 
 2052        info->category = 
"/funcs/func_strings/";
 
 2053        info->summary = 
"Test FIELDNUM function";
 
 2054        info->description = 
"Verify FIELDNUM behavior";
 
 2071    for (i = 0; i < 
ARRAY_LEN(test_args); i++) {
 
 2081        snprintf(expression, 
sizeof(expression), 
"${FIELDNUM(%s,%s,%s)}", 
var->name, test_args[i].delim, test_args[i].field);
 
 2106    char expression[256];
 
 2108        const char *test_string;
 
 2109        const char *find_chars;
 
 2110        const char *replace_char;
 
 2111        const char *expected;
 
 2113        {
"abc,def", 
"\\,", 
"-", 
"abc-def"},
 
 2114        {
"abc,abc", 
"bc",  
"a", 
"aaa,aaa"},
 
 2115        {
"abc,def", 
"x",   
"?", 
"abc,def"},
 
 2116        {
"abc,def", 
"\\,", 
"",  
"abcdef"}
 
 2121        info->name = 
"func_REPLACE_test";
 
 2122        info->category = 
"/funcs/func_strings/";
 
 2123        info->summary = 
"Test REPLACE function";
 
 2124        info->description = 
"Verify REPLACE behavior";
 
 2141    for (i = 0; i < 
ARRAY_LEN(test_args); i++) {
 
 2151        snprintf(expression, 
sizeof(expression), 
"${REPLACE(%s,%s,%s)}", 
var->name, test_args[i].find_chars, test_args[i].replace_char);
 
 2177        {
"\\x41-R",        
"DAHDI"},
 
 2178        {
"0-9A-Ca-c",      
"0042133333A12212"},
 
 2179        {
"0-9a-cA-C_+\\-", 
"0042133333A12212"},
 
 2185        info->name = 
"func_FILTER_test";
 
 2186        info->category = 
"/funcs/func_strings/";
 
 2187        info->summary = 
"Test FILTER function";
 
 2188        info->description = 
"Verify FILTER behavior";
 
 2195        char tmp[256], tmp2[256] = 
"";
 
 2196        snprintf(tmp, 
sizeof(tmp), 
"${FILTER(%s,0042133333&DAHDI/g1/2212)}", 
test_strings[i][0]);
 
 2213        {
"Weasels have eaten my telephone system", 
"have eaten my", 
"are eating our", 
"", 
"Weasels are eating our telephone system"}, 
 
 2214        {
"Did you know twenty plus two is twenty-two?", 
"twenty", 
"thirty", 
NULL, 
"Did you know thirty plus two is thirty-two?"}, 
 
 2215        {
"foofoofoofoofoofoofoo", 
"foofoo", 
"bar", 
NULL, 
"barbarbarfoo"}, 
 
 2216        {
"My pet dog once ate a dog who sat on a dog while eating a corndog.", 
"dog", 
"cat", 
"3", 
"My pet cat once ate a cat who sat on a cat while eating a corndog."},
 
 2217        {
"One and one and one is three", 
"and", 
"plus", 
"1", 
"One plus one and one is three"}, 
 
 2218        {
"", 
"fhqwagads", 
"spelunker", 
NULL, 
""}, 
 
 2219        {
"Part of this string is missing.", 
"missing", 
NULL, 
NULL, 
"Part of this string is ."}, 
 
 2220        {
"'Accidentally' left off a bunch of stuff.", 
NULL, 
NULL, 
NULL, 
""}, 
 
 2221        {
"This test will also error.", 
"", 
"", 
"", 
""}, 
 
 2222        {
"This is an \"escape character\" test.", 
"\\\"escape character\\\"", 
"evil", 
NULL, 
"This is an evil test."}
 
 2227        info->name = 
"func_STRREPLACE_test";
 
 2228        info->category = 
"/funcs/func_strings/";
 
 2229        info->summary = 
"Test STRREPLACE function";
 
 2230        info->description = 
"Verify STRREPLACE behavior";
 
 2248        char tmp[512], tmp2[512] = 
"";
 
 2265            snprintf(tmp, 
sizeof(tmp), 
"${STRREPLACE(%s,%s)}", 
"test_string", 
test_strings[i][1]);
 
 2267            snprintf(tmp, 
sizeof(tmp), 
"${STRREPLACE(%s)}", 
"test_string");
 
 2291        {
"212", 
"w", 
"2w1w2"},
 
 2292        {
"212", 
"55", 
"2551552"},
 
 2293        {
"212", 
" ", 
"2 1 2"},
 
 2296        {
"abcdefg", 
"_", 
"a_b_c_d_e_f_g"},
 
 2299        {
"AAA", 
"B", 
"ABABA"},
 
 2304        info->name = 
"func_STRBETWEEN";
 
 2305        info->category = 
"/funcs/func_strings/";
 
 2306        info->summary = 
"Test STRBETWEEN function";
 
 2307        info->description = 
"Verify STRBETWEEN behavior";
 
 2325        char tmp[512], tmp2[512] = 
"";
 
 2338            snprintf(tmp, 
sizeof(tmp), 
"${STRBETWEEN(%s,%s)}", 
"test_string", 
test_strings[i][1]);
 
 2340            snprintf(tmp, 
sizeof(tmp), 
"${STRBETWEEN(%s)}", 
"test_string");
 
 2362        {
"TRIM", 
"  abcd ", 
"abcd"},
 
 2363        {
"LTRIM", 
" abcd ", 
"abcd "},
 
 2364        {
"RTRIM", 
" abcd ", 
" abcd"},
 
 2365        {
"TRIM", 
"abcd", 
"abcd"},
 
 2366        {
"TRIM", 
" a b c d ", 
"a b c d"},
 
 2371        info->name = 
"func_TRIM";
 
 2372        info->category = 
"/funcs/func_strings/";
 
 2373        info->summary = 
"Test TRIM functions";
 
 2374        info->description = 
"Verify TRIM behavior";
 
 2392        char tmp[512], tmp2[512] = 
"";
 
struct sla_ringing_trunk * first
char * strsep(char **str, const char *delims)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strdupa(s)
duplicate a string in memory from the stack
General Asterisk PBX channel definitions.
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
struct varshead * ast_channel_varshead(struct ast_channel *chan)
#define ast_channel_lock(chan)
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
#define ast_dummy_channel_alloc()
Create a fake channel structure.
#define ast_channel_unlock(chan)
const char * ast_var_name(const struct ast_var_t *var)
#define ast_var_assign(name, value)
void ast_var_delete(struct ast_var_t *var)
static struct ast_custom_function fieldqty_function
static struct ast_custom_function trim_function
static int function_fieldqty_str(struct ast_channel *chan, const char *cmd, char *parse, struct ast_str **buf, ssize_t len)
static struct ast_custom_function eval_function
static const char * get_key(const struct ast_str *prefix, const struct ast_var_t *var)
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static struct ast_custom_function shift_function
static int function_ltrim(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static struct ast_custom_function hashkeys_function
static int function_trim(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int listfilter(struct ast_channel *chan, const char *cmd, char *parse, char *buf, struct ast_str **bufstr, ssize_t len)
static struct ast_custom_function fieldnum_function
static struct ast_custom_function filter_function
static struct ast_custom_function hash_function
static int function_fieldnum_str(struct ast_channel *chan, const char *cmd, char *parse, struct ast_str **buf, ssize_t len)
static struct ast_custom_function strptime_function
static struct ast_custom_function ltrim_function
static int csv_quote(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static struct ast_custom_function strbetween_function
static int hash_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static struct ast_custom_function regex_function
static int shift_pop(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
static int string_tolower(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int unshift_push(struct ast_channel *chan, const char *cmd, char *data, const char *new_value)
static struct ast_custom_function replace_function
static char * app_clearhash
static int hashkeys_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int listfilter_read2(struct ast_channel *chan, const char *cmd, char *parse, struct ast_str **buf, ssize_t len)
static struct ast_custom_function strreplace_function
static int function_fieldqty_helper(struct ast_channel *chan, const char *cmd, char *parse, char *buf, struct ast_str **sbuf, ssize_t len)
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
static struct ast_custom_function passthru_function
static struct ast_custom_function listfilter_function
static int acf_strptime(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static struct ast_custom_function pop_function
static int string_tolower2(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t buflen)
static struct ast_custom_function unshift_function
static int hashkeys_read2(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
static struct ast_custom_function keypadhash_function
static struct ast_custom_function rtrim_function
static struct ast_custom_function strftime_function
static int listfilter_read(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static struct ast_custom_function toupper_function
static int array(struct ast_channel *chan, const char *cmd, char *var, const char *value)
static int function_eval2(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t buflen)
static int strreplace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
static int string_toupper(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int quote(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int function_rtrim(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int passthru(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
static struct ast_custom_function quote_function
static int load_module(void)
static int keypadhash(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static struct ast_custom_function csv_quote_function
static int unload_module(void)
static int function_fieldqty(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static int function_eval(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int string_toupper2(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t buflen)
static void clearvar_prefix(struct ast_channel *chan, const char *prefix)
static struct ast_custom_function tolower_function
static struct ast_custom_function array_function
static struct ast_custom_function push_function
static int acf_strftime(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t buflen)
static int function_fieldnum(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static int strbetween(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
static int hash_write(struct ast_channel *chan, const char *cmd, char *var, const char *value)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int filter(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static int function_fieldnum_helper(struct ast_channel *chan, const char *cmd, char *parse, char *buf, struct ast_str **sbuf, ssize_t len)
static int exec_clearhash(struct ast_channel *chan, const char *data)
static struct ast_custom_function len_function
static char prefix[MAX_PREFIX]
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
#define AST_STANDARD_RAW_ARGS(args, parse)
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
char * ast_get_encoded_str(const char *stream, char *result, size_t result_len)
Decode a stream of encoded control or extended ASCII characters.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Custom localtime functions for multiple timezones.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
struct timeval ast_mktime(struct ast_tm *const tmp, const char *zone)
Timezone-independent version of mktime(3).
char * ast_strptime(const char *s, const char *format, struct ast_tm *tm)
Special version of strptime(3) which places the answer in the common structure ast_tm....
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_unregister_application(const char *app)
Unregister an application.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define ast_opt_dont_warn
Core PBX routines and definitions.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
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.
#define ast_custom_function_register(acf)
Register a custom function.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
char * ast_str_truncate(struct ast_str *buf, ssize_t len)
Truncates the enclosed string to the given length.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
size_t attribute_pure ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
char * ast_str_append_substr(struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc)
Append a non-NULL terminated substring to the end of a dynamic string.
#define ast_str_alloca(init_len)
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
#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.
#define ast_str_make_space(buf, new_len)
void ast_str_update(struct ast_str *buf)
Update the length of the buffer, after using ast_str merely as a buffer.
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
size_t attribute_pure ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
int ast_get_timeval(const char *src, struct timeval *tv, struct timeval _default, int *consumed)
Parse a time (float) string.
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Support for dynamic strings.
struct ast_var_t::@224 entries
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
#define AST_TEST_DEFINE(hdr)
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.