561 sprintf(varsubst,
"${%s}",
args.varname);
567 while (
strsep(&varval, delim)) {
577 snprintf(
buf,
len,
"%d", fieldcount);
584 char *parse,
char *
buf,
size_t len)
604 char *varsubst, *field;
606 int fieldindex = 0, res = 0;
622 ast_log(
LOG_ERROR,
"Usage: FIELDNUM(<listname>,<delimiter>,<fieldvalue>)\n");
626 sprintf(varsubst,
"${%s}",
args.varname);
637 while ((field =
strsep(&varval, delim)) !=
NULL) {
640 if (!strcasecmp(field,
args.field)) {
656 snprintf(
buf,
len,
"%d", fieldindex);
663 char *parse,
char *
buf,
size_t len)
688 const char *begin, *cur, *next;
689 int dlen, flen,
first = 1;
691 char *delim, *varsubst;
705 ast_log(
LOG_ERROR,
"Usage: LISTFILTER(<listname>,<delimiter>,<fieldvalue>)\n");
710 sprintf(varsubst,
"${%s}",
args.listname);
737 dlen = strlen(
args.delimiter);
741 if ((dlen = strlen(delim)) == 0) {
746 flen = strlen(
args.fieldvalue);
755 next = strstr(begin, delim);
761 next = strstr(cur + dlen, delim);
763 cur = strchr(begin + dlen,
'\0');
766 if (flen == cur - begin && !strncmp(begin,
args.fieldvalue, flen)) {
768 begin += flen + dlen;
779 }
while (*cur !=
'\0');
802 .
name =
"LISTFILTER",
816 char allowed[256] =
"";
817 size_t allowedlen = 0;
828 ast_log(
LOG_WARNING,
"FILTER allowed characters includes the quote (\") character. This may not be what you want.\n");
832 for (; *(
args.allowed);) {
838 args.allowed += consumed;
840 if (*(
args.allowed) ==
'-') {
843 args.allowed += consumed + 1;
846 ast_log(
LOG_WARNING,
"Range wrapping in FILTER(%s,%s). This may not be what you want.\n", parse,
args.string);
853 for (ac = (
unsigned char) c1; ac != (
unsigned char) c2; ac++) {
854 bitfield[ac / 32] |= 1 << (ac % 32);
856 bitfield[ac / 32] |= 1 << (ac % 32);
860 ac = (
unsigned char) c1;
861 ast_debug(4,
"c1=%d, consumed=%d, args.allowed=%s\n", c1, (
int) consumed,
args.allowed - consumed);
862 bitfield[ac / 32] |= 1 << (ac % 32);
866 for (ac = 1; ac != 0; ac++) {
867 if (bitfield[ac / 32] & (1 << (ac % 32))) {
868 allowed[allowedlen++] = ac;
874 for (; *(
args.string) && (
buf +
len - 1 > outbuf); (
args.string)++) {
875 if (strchr(allowed, *(
args.string)))
876 *outbuf++ = *(
args.string);
895 char *strptr, *varsubst;
908 ast_log(
LOG_ERROR,
"Usage: %s(<varname>,<search-chars>[,<replace-char>])\n", cmd);
917 ast_log(
LOG_ERROR,
"The characters to search for and the variable name must not be empty.\n");
922 sprintf(varsubst,
"${%s}",
args.varname);
931 ast_debug(3,
"Characters to find: (%s)\n", find);
937 if (strchr(find, *strptr)) {
939 memmove(strptr, strptr + 1, strlen(strptr + 1) + 1);
963 unsigned max_matches;
989 "Usage: %s(<varname>,<find-string>[,<replace-string>,[<max-replacements>]])\n",
1004 find_size = strlen(
args.find_string);
1008 sprintf(varsubstr,
"${%s}",
args.varname);
1012 if (!
args.max_replacements
1013 || (max_matches = atoi(
args.max_replacements)) <= 0) {
1020 for (count = 0; count < max_matches; ++count) {
1021 end = strstr(start,
args.find_string);
1030 if (
args.replace_string) {
1034 start =
end + find_size;
1042 .
name =
"STRREPLACE",
1049 char *varsubstr, *origstr;
1073 sprintf(varsubstr,
"${%s}",
args.varname);
1076 origsize = strlen(origstr);
1077 for (
c = 0;
c < origsize;
c++) {
1080 if (
c < (origsize - 1)) {
1089 .
name =
"STRBETWEEN",
1093#define ltrim(s) while (isspace(*s)) s++;
1096 char *back = s + strlen(s); \
1097 while (back != s && isspace(*--back)); \
1099 *(back + 1) = '\0'; \
1186 if (
args.argc != 3) {
1187 ast_log(
LOG_ERROR,
"Unexpected arguments: should have been in the form '\"<regex>\" <string>'\n");
1190 if ((*
args.str ==
' ') || (*
args.str ==
'\t'))
1195 if ((errcode = regcomp(®exbuf,
args.reg, REG_EXTENDED | REG_NOSUB))) {
1196 regerror(errcode, ®exbuf,
buf,
len);
1201 strcpy(
buf, regexec(®exbuf,
args.str, 0,
NULL, 0) ?
"0" :
"1");
1213#define HASH_PREFIX "~HASH~%s~"
1214#define HASH_FORMAT HASH_PREFIX "%s~"
1249 char *origvar =
"", *value2, varname[256];
1257 if (!strcmp(cmd,
"HASH")) {
1281 for (i = 0; i < arg1.argc; i++) {
1282 ast_debug(1,
"array set value (%s=%s)\n", arg1.var[i],
1283 S_OR(arg2.val[i],
""));
1284 if (i < arg2.argc) {
1286 if (origvar[0] ==
'_') {
1287 if (origvar[1] ==
'_') {
1288 snprintf(varname,
sizeof(varname),
"__" HASH_FORMAT, origvar + 2, arg1.var[i]);
1290 snprintf(varname,
sizeof(varname),
"_" HASH_FORMAT, origvar + 1, arg1.var[i]);
1293 snprintf(varname,
sizeof(varname),
HASH_FORMAT, origvar, arg1.var[i]);
1304 snprintf(varname,
sizeof(varname),
HASH_FORMAT, origvar, arg1.var[i]);
1327 var_len = strlen(var_name);
1333 return var_len > (prefix_len + 1) && var_name[var_len - 1] ==
'~' &&
1334 strncmp(prefix_name, var_name, prefix_len) == 0 ? var_name + prefix_len :
NULL;
1355 strncat(
buf, key,
len - strlen(
buf) - 1);
1357 buf[strlen(
buf) - 1] =
',';
1361 buf_len = strlen(
buf);
1363 buf[buf_len - 1] =
'\0';
1405 if (!strchr(
var,
',')) {
1411 if (arg.hashname[0] ==
'_') {
1412 if (arg.hashname[1] ==
'_') {
1413 snprintf(varname,
sizeof(varname),
"__" HASH_FORMAT, arg.hashname + 2, arg.hashkey);
1415 snprintf(varname,
sizeof(varname),
"_" HASH_FORMAT, arg.hashname + 1, arg.hashkey);
1418 snprintf(varname,
sizeof(varname),
HASH_FORMAT, arg.hashname, arg.hashkey);
1428 const char *varvalue;
1435 if (arg.argc == 2) {
1436 snprintf(varname,
sizeof(varname),
HASH_FORMAT, arg.hashname, arg.hashkey);
1442 }
else if (arg.argc == 1) {
1443 char colnames[4096];
1450 ast_log(
LOG_WARNING,
"No channel and only 1 parameter was provided to %s function.\n", cmd);
1455 hashkeys_read(chan,
"HASHKEYS", arg.hashname, colnames,
sizeof(colnames));
1462 for (i = 0; i < arg2.argc; i++) {
1463 snprintf(varname,
sizeof(varname),
HASH_FORMAT, arg.hashname, arg2.col[i]);
1465 strncat(
buf, varvalue,
len - strlen(
buf) - 1);
1466 strncat(
buf,
",",
len - strlen(
buf) - 1);
1470 buf[strlen(
buf) - 1] =
'\0';
1495 char *bufptr =
buf, *dataptr = data;
1509 for (; bufptr <
buf +
len - 3; dataptr++) {
1510 if (*dataptr ==
'\\') {
1513 }
else if (*dataptr ==
'"') {
1516 }
else if (*dataptr ==
'\0') {
1519 *bufptr++ = *dataptr;
1534 char *bufptr =
buf, *dataptr = data;
1547 for (; bufptr <
buf +
len - 3; dataptr++){
1548 if (*dataptr ==
'"') {
1551 }
else if (*dataptr ==
'\0') {
1554 *bufptr++ = *dataptr;
1563 .
name =
"CSV_QUOTE",
1572 length = strlen(data);
1574 snprintf(
buf, buflen,
"%d", length);
1586 char *
buf,
size_t buflen)
1593 struct timeval when;
1609 buf[buflen - 1] =
'\0';
1620 char *
buf,
size_t buflen)
1633 "Asterisk function STRPTIME() requires an argument.\n");
1641 "No format supplied to STRPTIME(<timestring>,<timezone>,<format>)");
1648 struct timeval when;
1650 snprintf(
buf, buflen,
"%d", (
int) when.tv_sec);
1662 char *
buf,
size_t buflen)
1695 char *bufptr, *dataptr;
1697 for (bufptr =
buf, dataptr = data; bufptr <
buf + buflen - 1; dataptr++) {
1698 if (*dataptr ==
'\0') {
1701 }
else if (*dataptr ==
'1') {
1703 }
else if (strchr(
"AaBbCc2", *dataptr)) {
1705 }
else if (strchr(
"DdEeFf3", *dataptr)) {
1707 }
else if (strchr(
"GgHhIi4", *dataptr)) {
1709 }
else if (strchr(
"JjKkLl5", *dataptr)) {
1711 }
else if (strchr(
"MmNnOo6", *dataptr)) {
1713 }
else if (strchr(
"PpQqRrSs7", *dataptr)) {
1715 }
else if (strchr(
"TtUuVv8", *dataptr)) {
1717 }
else if (strchr(
"WwXxYyZz9", *dataptr)) {
1719 }
else if (*dataptr ==
'0') {
1723 buf[buflen - 1] =
'\0';
1729 .
name =
"KEYPADHASH",
1735 char *bufptr =
buf, *dataptr = data;
1737 while ((bufptr <
buf + buflen - 1) && (*bufptr++ = toupper(*dataptr++)));
1744 char *bufptr, *dataptr = data;
1764 char *bufptr =
buf, *dataptr = data;
1766 while ((bufptr <
buf + buflen - 1) && (*bufptr++ = tolower(*dataptr++)));
1773 char *bufptr, *dataptr = data;
1793#define beginning (cmd[0] == 'S')
1794 char *after, delimiter[2] =
",", *varsubst;
1797 char *(*search_func)(
const char *s,
int c) = (
beginning ? strchr : strrchr);
1815 sprintf(varsubst,
"${%s}",
args.var);
1827 if (!(after = search_func(
ast_str_buffer(before), delimiter[0]))) {
1853#define beginning (cmd[0] == 'U')
1854 char delimiter[2] =
",", *varsubst;
1861 const char *stripped_var;
1885 stripped_var =
args.var +
MIN(strspn(
args.var,
"_"), 2);
1886 varsubst =
ast_alloca(strlen(stripped_var) + 4);
1887 sprintf(varsubst,
"${%s}", stripped_var);
1926#ifdef TEST_FRAMEWORK
1932 char expression[256];
1937 const char *expected;
1939 {
"abc,def,ghi,jkl",
"\\,",
"ghi",
"3"},
1940 {
"abc def ghi jkl",
" ",
"abc",
"1"},
1941 {
"abc/def/ghi/jkl",
"\\\\x2f",
"def",
"2"},
1942 {
"abc$def$ghi$jkl",
"",
"ghi",
"0"},
1943 {
"abc,def,ghi,jkl",
"-",
"",
"0"},
1944 {
"abc-def-ghi-jkl",
"-",
"mno",
"0"}
1949 info->name =
"func_FIELDNUM_test";
1950 info->category =
"/funcs/func_strings/";
1951 info->summary =
"Test FIELDNUM function";
1952 info->description =
"Verify FIELDNUM behavior";
1969 for (i = 0; i <
ARRAY_LEN(test_args); i++) {
1979 snprintf(expression,
sizeof(expression),
"${FIELDNUM(%s,%s,%s)}",
var->name, test_args[i].delim, test_args[i].field);
2004 char expression[256];
2006 const char *test_string;
2007 const char *find_chars;
2008 const char *replace_char;
2009 const char *expected;
2011 {
"abc,def",
"\\,",
"-",
"abc-def"},
2012 {
"abc,abc",
"bc",
"a",
"aaa,aaa"},
2013 {
"abc,def",
"x",
"?",
"abc,def"},
2014 {
"abc,def",
"\\,",
"",
"abcdef"}
2019 info->name =
"func_REPLACE_test";
2020 info->category =
"/funcs/func_strings/";
2021 info->summary =
"Test REPLACE function";
2022 info->description =
"Verify REPLACE behavior";
2039 for (i = 0; i <
ARRAY_LEN(test_args); i++) {
2049 snprintf(expression,
sizeof(expression),
"${REPLACE(%s,%s,%s)}",
var->name, test_args[i].find_chars, test_args[i].replace_char);
2075 {
"\\x41-R",
"DAHDI"},
2076 {
"0-9A-Ca-c",
"0042133333A12212"},
2077 {
"0-9a-cA-C_+\\-",
"0042133333A12212"},
2083 info->name =
"func_FILTER_test";
2084 info->category =
"/funcs/func_strings/";
2085 info->summary =
"Test FILTER function";
2086 info->description =
"Verify FILTER behavior";
2093 char tmp[256], tmp2[256] =
"";
2094 snprintf(
tmp,
sizeof(
tmp),
"${FILTER(%s,0042133333&DAHDI/g1/2212)}",
test_strings[i][0]);
2111 {
"Weasels have eaten my telephone system",
"have eaten my",
"are eating our",
"",
"Weasels are eating our telephone system"},
2112 {
"Did you know twenty plus two is twenty-two?",
"twenty",
"thirty",
NULL,
"Did you know thirty plus two is thirty-two?"},
2113 {
"foofoofoofoofoofoofoo",
"foofoo",
"bar",
NULL,
"barbarbarfoo"},
2114 {
"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."},
2115 {
"One and one and one is three",
"and",
"plus",
"1",
"One plus one and one is three"},
2116 {
"",
"fhqwagads",
"spelunker",
NULL,
""},
2117 {
"Part of this string is missing.",
"missing",
NULL,
NULL,
"Part of this string is ."},
2118 {
"'Accidentally' left off a bunch of stuff.",
NULL,
NULL,
NULL,
""},
2119 {
"This test will also error.",
"",
"",
"",
""},
2120 {
"This is an \"escape character\" test.",
"\\\"escape character\\\"",
"evil",
NULL,
"This is an evil test."}
2125 info->name =
"func_STRREPLACE_test";
2126 info->category =
"/funcs/func_strings/";
2127 info->summary =
"Test STRREPLACE function";
2128 info->description =
"Verify STRREPLACE behavior";
2146 char tmp[512], tmp2[512] =
"";
2163 snprintf(
tmp,
sizeof(
tmp),
"${STRREPLACE(%s,%s)}",
"test_string",
test_strings[i][1]);
2165 snprintf(
tmp,
sizeof(
tmp),
"${STRREPLACE(%s)}",
"test_string");
2189 {
"212",
"w",
"2w1w2"},
2190 {
"212",
"55",
"2551552"},
2191 {
"212",
" ",
"2 1 2"},
2194 {
"abcdefg",
"_",
"a_b_c_d_e_f_g"},
2197 {
"AAA",
"B",
"ABABA"},
2202 info->name =
"func_STRBETWEEN";
2203 info->category =
"/funcs/func_strings/";
2204 info->summary =
"Test STRBETWEEN function";
2205 info->description =
"Verify STRBETWEEN behavior";
2223 char tmp[512], tmp2[512] =
"";
2236 snprintf(
tmp,
sizeof(
tmp),
"${STRBETWEEN(%s,%s)}",
"test_string",
test_strings[i][1]);
2238 snprintf(
tmp,
sizeof(
tmp),
"${STRBETWEEN(%s)}",
"test_string");
2260 {
"TRIM",
" abcd ",
"abcd"},
2261 {
"LTRIM",
" abcd ",
"abcd "},
2262 {
"RTRIM",
" abcd ",
" abcd"},
2263 {
"TRIM",
"abcd",
"abcd"},
2264 {
"TRIM",
" a b c d ",
"a b c d"},
2269 info->name =
"func_TRIM";
2270 info->category =
"/funcs/func_strings/";
2271 info->summary =
"Test TRIM functions";
2272 info->description =
"Verify TRIM behavior";
2290 char tmp[512], tmp2[512] =
"";
struct sla_ringing_trunk * first
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_threadstorage result_buf
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 struct ast_threadstorage tmp_buf
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.
char * strsep(char **str, const char *delims)
#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.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str 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.
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
size_t 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::@211 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.