Asterisk - The Open Source Telephony Project GIT-master-754dea3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
Macros | Functions | Variables
func_strings.c File Reference

String manipulation dialplan functions. More...

#include "asterisk.h"
#include <regex.h>
#include <ctype.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/localtime.h"
#include "asterisk/test.h"
Include dependency graph for func_strings.c:

Go to the source code of this file.

Macros

#define beginning   (cmd[0] == 'S') /* SHIFT */
 
#define beginning   (cmd[0] == 'U') /* UNSHIFT */
 
#define HASH_FORMAT   HASH_PREFIX "%s~"
 
#define HASH_PREFIX   "~HASH~%s~"
 
#define ltrim(s)   while (isspace(*s)) s++;
 
#define rtrim(s)
 

Functions

static void __init_result_buf (void)
 
static void __init_tmp_buf (void)
 
static void __reg_module (void)
 
static void __unreg_module (void)
 
static int acf_strftime (struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t buflen)
 
static int acf_strptime (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
 
static int array (struct ast_channel *chan, const char *cmd, char *var, const char *value)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static void clearvar_prefix (struct ast_channel *chan, const char *prefix)
 
static int csv_quote (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int exec_clearhash (struct ast_channel *chan, const char *data)
 
static int filter (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 function_eval2 (struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t buflen)
 
static int function_fieldnum (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 function_fieldnum_str (struct ast_channel *chan, const char *cmd, char *parse, struct ast_str **buf, ssize_t len)
 
static int function_fieldqty (struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
 
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 function_fieldqty_str (struct ast_channel *chan, const char *cmd, char *parse, struct ast_str **buf, ssize_t len)
 
static int function_ltrim (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 function_trim (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static const char * get_key (const struct ast_str *prefix, const struct ast_var_t *var)
 
static int hash_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int hash_write (struct ast_channel *chan, const char *cmd, char *var, const char *value)
 
static int hashkeys_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int hashkeys_read2 (struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
 
static int keypadhash (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
 
static int len (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
 
static int listfilter (struct ast_channel *chan, const char *cmd, char *parse, char *buf, struct ast_str **bufstr, ssize_t len)
 
static int listfilter_read (struct ast_channel *chan, const char *cmd, char *parse, 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 int load_module (void)
 
static int passthru (struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
 
static int quote (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int regex (struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
 
static int replace (struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
 
static int shift_pop (struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
 
static int strbetween (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 string_tolower2 (struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t buflen)
 
static int string_toupper (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 int strreplace (struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
 
static int unload_module (void)
 
static int unshift_push (struct ast_channel *chan, const char *cmd, char *data, const char *new_value)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "String handling dialplan functions" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static char * app_clearhash = "ClearHash"
 
static struct ast_custom_function array_function
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_custom_function csv_quote_function
 
static struct ast_custom_function eval_function
 
static struct ast_custom_function fieldnum_function
 
static struct ast_custom_function fieldqty_function
 
static struct ast_custom_function filter_function
 
static struct ast_custom_function hash_function
 
static struct ast_custom_function hashkeys_function
 
static struct ast_custom_function keypadhash_function
 
static struct ast_custom_function len_function
 
static struct ast_custom_function listfilter_function
 
static struct ast_custom_function ltrim_function
 
static struct ast_custom_function passthru_function
 
static struct ast_custom_function pop_function
 
static struct ast_custom_function push_function
 
static struct ast_custom_function quote_function
 
static struct ast_custom_function regex_function
 
static struct ast_custom_function replace_function
 
static struct ast_threadstorage result_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_result_buf , .custom_init = NULL , }
 
static struct ast_custom_function rtrim_function
 
static struct ast_custom_function shift_function
 
static struct ast_custom_function strbetween_function
 
static struct ast_custom_function strftime_function
 
static struct ast_custom_function strptime_function
 
static struct ast_custom_function strreplace_function
 
static struct ast_threadstorage tmp_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_tmp_buf , .custom_init = NULL , }
 
static struct ast_custom_function tolower_function
 
static struct ast_custom_function toupper_function
 
static struct ast_custom_function trim_function
 
static struct ast_custom_function unshift_function
 

Detailed Description

String manipulation dialplan functions.

Author
Tilghman Lesher
Anthony Minessale II
Naveen Albert

Definition in file func_strings.c.

Macro Definition Documentation

◆ beginning [1/2]

#define beginning   (cmd[0] == 'S') /* SHIFT */

◆ beginning [2/2]

#define beginning   (cmd[0] == 'U') /* UNSHIFT */

◆ HASH_FORMAT

#define HASH_FORMAT   HASH_PREFIX "%s~"

Definition at line 1306 of file func_strings.c.

◆ HASH_PREFIX

#define HASH_PREFIX   "~HASH~%s~"

Definition at line 1305 of file func_strings.c.

◆ ltrim

#define ltrim (   s)    while (isspace(*s)) s++;

Definition at line 1185 of file func_strings.c.

◆ rtrim

#define rtrim (   s)

Definition at line 1186 of file func_strings.c.

Function Documentation

◆ __init_result_buf()

static void __init_result_buf ( void  )
static

Definition at line 47 of file func_strings.c.

632{

◆ __init_tmp_buf()

static void __init_tmp_buf ( void  )
static

Definition at line 48 of file func_strings.c.

632{

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 2495 of file func_strings.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 2495 of file func_strings.c.

◆ acf_strftime()

static int acf_strftime ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buf,
size_t  buflen 
)
static

Definition at line 1687 of file func_strings.c.

1689{
1691 AST_APP_ARG(epoch);
1692 AST_APP_ARG(timezone);
1693 AST_APP_ARG(format);
1694 );
1695 struct timeval when;
1696 struct ast_tm tm;
1697
1698 buf[0] = '\0';
1699
1701
1702 ast_get_timeval(args.epoch, &when, ast_tvnow(), NULL);
1703 ast_localtime(&when, &tm, args.timezone);
1704
1705 if (!args.format)
1706 args.format = "%c";
1707
1708 if (ast_strftime(buf, buflen, args.format, &tm) <= 0)
1709 ast_log(LOG_WARNING, "C function strftime() output nothing?!!\n");
1710
1711 buf[buflen - 1] = '\0';
1712
1713 return 0;
1714}
#define ast_log
Definition: astobj2.c:42
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define LOG_WARNING
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
Definition: localtime.c:1739
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...
Definition: localtime.c:2524
#define NULL
Definition: resample.c:96
int ast_get_timeval(const char *src, struct timeval *tv, struct timeval _default, int *consumed)
Parse a time (float) string.
Definition: utils.c:2419
const char * args
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159

References args, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_get_timeval(), ast_localtime(), ast_log, AST_STANDARD_APP_ARGS, ast_strftime(), ast_tvnow(), buf, LOG_WARNING, and NULL.

◆ acf_strptime()

static int acf_strptime ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  buflen 
)
static

Definition at line 1721 of file func_strings.c.

1723{
1725 AST_APP_ARG(timestring);
1726 AST_APP_ARG(timezone);
1727 AST_APP_ARG(format);
1728 );
1729 struct ast_tm tm;
1730
1731 buf[0] = '\0';
1732
1733 if (!data) {
1735 "Asterisk function STRPTIME() requires an argument.\n");
1736 return -1;
1737 }
1738
1740
1741 if (ast_strlen_zero(args.format)) {
1743 "No format supplied to STRPTIME(<timestring>,<timezone>,<format>)");
1744 return -1;
1745 }
1746
1747 if (!ast_strptime(args.timestring, args.format, &tm)) {
1748 ast_log(LOG_WARNING, "STRPTIME() found no time specified within the string\n");
1749 } else {
1750 struct timeval when;
1751 when = ast_mktime(&tm, args.timezone);
1752 snprintf(buf, buflen, "%d", (int) when.tv_sec);
1753 }
1754
1755 return 0;
1756}
#define LOG_ERROR
struct timeval ast_mktime(struct ast_tm *const tmp, const char *zone)
Timezone-independent version of mktime(3).
Definition: localtime.c:2357
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....
Definition: localtime.c:2550
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65

References args, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log, ast_mktime(), AST_STANDARD_APP_ARGS, ast_strlen_zero(), ast_strptime(), buf, LOG_ERROR, and LOG_WARNING.

◆ array()

static int array ( struct ast_channel chan,
const char *  cmd,
char *  var,
const char *  value 
)
static

Definition at line 1332 of file func_strings.c.

1334{
1336 AST_APP_ARG(var)[100];
1337 );
1339 AST_APP_ARG(val)[100];
1340 );
1341 char *origvar = "", *value2, varname[256];
1342 int i, ishash = 0;
1343
1344 if (!var) {
1345 return -1;
1346 }
1347 value2 = ast_strdupa(value);
1348
1349 if (!strcmp(cmd, "HASH")) {
1350 const char *var2 = pbx_builtin_getvar_helper(chan, "~ODBCFIELDS~");
1351 origvar = var;
1352 if (var2)
1353 var = ast_strdupa(var2);
1354 else {
1355 if (chan)
1357 return -1;
1358 }
1359 ishash = 1;
1360 }
1361
1362 /* The functions this will generally be used with are SORT and ODBC_*, which
1363 * both return comma-delimited lists. However, if somebody uses literal lists,
1364 * their commas will be translated to vertical bars by the load, and I don't
1365 * want them to be surprised by the result. Hence, we prefer commas as the
1366 * delimiter, but we'll fall back to vertical bars if commas aren't found.
1367 */
1368 ast_debug(1, "array (%s=%s)\n", var, S_OR(value2, ""));
1370
1371 AST_STANDARD_APP_ARGS(arg2, value2);
1372
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) {
1377 if (ishash) {
1378 if (origvar[0] == '_') {
1379 if (origvar[1] == '_') {
1380 snprintf(varname, sizeof(varname), "__" HASH_FORMAT, origvar + 2, arg1.var[i]);
1381 } else {
1382 snprintf(varname, sizeof(varname), "_" HASH_FORMAT, origvar + 1, arg1.var[i]);
1383 }
1384 } else {
1385 snprintf(varname, sizeof(varname), HASH_FORMAT, origvar, arg1.var[i]);
1386 }
1387
1388 pbx_builtin_setvar_helper(chan, varname, arg2.val[i]);
1389 } else {
1390 pbx_builtin_setvar_helper(chan, arg1.var[i], arg2.val[i]);
1391 }
1392 } else {
1393 /* We could unset the variable, by passing a NULL, but due to
1394 * pushvar semantics, that could create some undesired behavior. */
1395 if (ishash) {
1396 snprintf(varname, sizeof(varname), HASH_FORMAT, origvar, arg1.var[i]);
1397 pbx_builtin_setvar_helper(chan, varname, "");
1398 } else {
1399 pbx_builtin_setvar_helper(chan, arg1.var[i], "");
1400 }
1401 }
1402 }
1403
1404 return 0;
1405}
#define var
Definition: ast_expr2f.c:605
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266
#define HASH_FORMAT
#define ast_debug(level,...)
Log a DEBUG message.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
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 S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition: strings.h:80
Definition: ast_expr2.c:325
int value
Definition: syslog.c:37

References AST_APP_ARG, ast_autoservice_stop(), ast_debug, AST_DECLARE_APP_ARGS, AST_STANDARD_APP_ARGS, ast_strdupa, HASH_FORMAT, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), S_OR, value, and var.

Referenced by __ast_app_separate_args(), app_event_filter_matched(), app_to_json(), append_json(), ast_app_separate_args(), ast_json_array_append(), ast_json_array_clear(), ast_json_array_extend(), ast_json_array_get(), ast_json_array_insert(), ast_json_array_remove(), ast_json_array_set(), ast_json_array_size(), device_to_json_cb(), devices_to_json(), hash_write(), json_array_from_list(), NearestNeighbor(), stasis_app_device_states_to_json(), and stasis_app_mailboxes_to_json().

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 2495 of file func_strings.c.

◆ clearvar_prefix()

static void clearvar_prefix ( struct ast_channel chan,
const char *  prefix 
)
static

Definition at line 1311 of file func_strings.c.

1312{
1313 struct ast_var_t *var;
1314 int len = strlen(prefix);
1316 if (strncmp(prefix, ast_var_name(var), len) == 0) {
1318 ast_free(var);
1319 }
1320 }
1322}
#define ast_free(a)
Definition: astmm.h:180
struct varshead * ast_channel_varshead(struct ast_channel *chan)
const char * ast_var_name(const struct ast_var_t *var)
Definition: chanvars.c:60
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static char prefix[MAX_PREFIX]
Definition: http.c:144
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:615
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:529
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:557
struct ast_var_t::@213 entries

References ast_channel_varshead(), ast_free, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_var_name(), ast_var_t::entries, len(), prefix, and var.

Referenced by exec_clearhash().

◆ csv_quote()

static int csv_quote ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1634 of file func_strings.c.

1635{
1636 char *bufptr = buf, *dataptr = data;
1637
1638 if (len < 3) { /* at least two for quotes and one for binary zero */
1639 ast_log(LOG_ERROR, "Not enough buffer\n");
1640 return -1;
1641 }
1642
1643 if (ast_strlen_zero(data)) {
1644 ast_copy_string(buf, "\"\"", len);
1645 return 0;
1646 }
1647
1648 *bufptr++ = '"';
1649 for (; bufptr < buf + len - 3; dataptr++){
1650 if (*dataptr == '"') {
1651 *bufptr++ = '"';
1652 *bufptr++ = '"';
1653 } else if (*dataptr == '\0') {
1654 break;
1655 } else {
1656 *bufptr++ = *dataptr;
1657 }
1658 }
1659 *bufptr++ = '"';
1660 *bufptr='\0';
1661 return 0;
1662}
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425

References ast_copy_string(), ast_log, ast_strlen_zero(), buf, len(), and LOG_ERROR.

◆ exec_clearhash()

static int exec_clearhash ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 1324 of file func_strings.c.

1325{
1326 char prefix[80];
1327 snprintf(prefix, sizeof(prefix), HASH_PREFIX, data ? (char *)data : "null");
1328 clearvar_prefix(chan, prefix);
1329 return 0;
1330}
static void clearvar_prefix(struct ast_channel *chan, const char *prefix)
#define HASH_PREFIX

References clearvar_prefix(), HASH_PREFIX, and prefix.

Referenced by load_module().

◆ filter()

static int filter ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buf,
size_t  len 
)
static
Note
Looks a little strange, until you realize that we can overflow the size of a char.

Definition at line 899 of file func_strings.c.

901{
903 AST_APP_ARG(allowed);
904 AST_APP_ARG(string);
905 );
906 char *outbuf = buf;
907 unsigned char ac;
908 char allowed[256] = "";
909 size_t allowedlen = 0;
910 int32_t bitfield[8] = { 0, }; /* 256 bits */
911
913
914 if (!args.string) {
915 ast_log(LOG_ERROR, "Usage: FILTER(<allowed-chars>,<string>)\n");
916 return -1;
917 }
918
919 if (args.allowed[0] == '"' && !ast_opt_dont_warn) {
920 ast_log(LOG_WARNING, "FILTER allowed characters includes the quote (\") character. This may not be what you want.\n");
921 }
922
923 /* Expand ranges */
924 for (; *(args.allowed);) {
925 char c1 = 0, c2 = 0;
926 size_t consumed = 0;
927
928 if (ast_get_encoded_char(args.allowed, &c1, &consumed))
929 return -1;
930 args.allowed += consumed;
931
932 if (*(args.allowed) == '-') {
933 if (ast_get_encoded_char(args.allowed + 1, &c2, &consumed))
934 c2 = c1;
935 args.allowed += consumed + 1;
936
937 if ((unsigned char) c2 < (unsigned char) c1 && !ast_opt_dont_warn) {
938 ast_log(LOG_WARNING, "Range wrapping in FILTER(%s,%s). This may not be what you want.\n", parse, args.string);
939 }
940
941 /*!\note
942 * Looks a little strange, until you realize that we can overflow
943 * the size of a char.
944 */
945 for (ac = (unsigned char) c1; ac != (unsigned char) c2; ac++) {
946 bitfield[ac / 32] |= 1 << (ac % 32);
947 }
948 bitfield[ac / 32] |= 1 << (ac % 32);
949
950 ast_debug(4, "c1=%d, c2=%d\n", c1, c2);
951 } else {
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);
955 }
956 }
957
958 for (ac = 1; ac != 0; ac++) {
959 if (bitfield[ac / 32] & (1 << (ac % 32))) {
960 allowed[allowedlen++] = ac;
961 }
962 }
963
964 ast_debug(1, "Allowed: %s\n", allowed);
965
966 for (; *(args.string) && (buf + len - 1 > outbuf); (args.string)++) {
967 if (strchr(allowed, *(args.string)))
968 *outbuf++ = *(args.string);
969 }
970 *outbuf = '\0';
971
972 return 0;
973}
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
Definition: main/app.c:3087
#define AST_STANDARD_RAW_ARGS(args, parse)
#define ast_opt_dont_warn
Definition: options.h:125

References args, AST_APP_ARG, ast_debug, AST_DECLARE_APP_ARGS, ast_get_encoded_char(), ast_log, ast_opt_dont_warn, AST_STANDARD_RAW_ARGS, buf, len(), LOG_ERROR, and LOG_WARNING.

Referenced by action_filter(), action_getconfig(), action_getconfigjson(), app_event_filter_set(), app_events_allowed_set(), app_events_disallowed_set(), append_var_and_value_to_filter(), ast_category_browse_filtered(), ast_category_exist(), ast_category_get(), ast_variable_retrieve_filtered(), category_get_sep(), create_lookup_filter(), iax_firmware_traverse(), kqueue_timer_ack(), next_available_category(), process_text_line(), realtime_ldap_base_ap(), stasis_app_event_filter_set(), stasis_caching_set_filter(), stasis_cp_single_set_filter(), stasis_subscription_set_filter(), and update2_ldap().

◆ function_eval()

static int function_eval ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  buflen 
)
static

Definition at line 1763 of file func_strings.c.

1765{
1766 if (ast_strlen_zero(data)) {
1767 ast_log(LOG_WARNING, "EVAL requires an argument: EVAL(<string>)\n");
1768 return -1;
1769 }
1770
1771 pbx_substitute_variables_helper(chan, data, buf, buflen - 1);
1772
1773 return 0;
1774}
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
Definition: ael_main.c:211

References ast_log, ast_strlen_zero(), buf, LOG_WARNING, and pbx_substitute_variables_helper().

◆ function_eval2()

static int function_eval2 ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  buflen 
)
static

Definition at line 1776 of file func_strings.c.

1778{
1779 if (ast_strlen_zero(data)) {
1780 ast_log(LOG_WARNING, "EVAL requires an argument: EVAL(<string>)\n");
1781 return -1;
1782 }
1783
1784 ast_str_substitute_variables(buf, buflen, chan, data);
1785
1786 return 0;
1787}
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)

References ast_log, ast_str_substitute_variables(), ast_strlen_zero(), buf, and LOG_WARNING.

◆ function_fieldnum()

static int function_fieldnum ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buf,
size_t  len 
)
static

Definition at line 754 of file func_strings.c.

756{
757 return function_fieldnum_helper(chan, cmd, parse, buf, NULL, len);
758}
static int function_fieldnum_helper(struct ast_channel *chan, const char *cmd, char *parse, char *buf, struct ast_str **sbuf, ssize_t len)
Definition: func_strings.c:693

References buf, function_fieldnum_helper(), len(), and NULL.

◆ function_fieldnum_helper()

static int function_fieldnum_helper ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buf,
struct ast_str **  sbuf,
ssize_t  len 
)
static

Definition at line 693 of file func_strings.c.

695{
696 char *varsubst, *field;
698 int fieldindex = 0, res = 0;
700 AST_APP_ARG(varname);
701 AST_APP_ARG(delim);
702 AST_APP_ARG(field);
703 );
704 char delim[2] = "";
705 size_t delim_used;
706
707 if (!str) {
708 return -1;
709 }
710
712
713 if (args.argc < 3) {
714 ast_log(LOG_ERROR, "Usage: FIELDNUM(<listname>,<delimiter>,<fieldvalue>)\n");
715 res = -1;
716 } else {
717 varsubst = ast_alloca(strlen(args.varname) + 4);
718 sprintf(varsubst, "${%s}", args.varname);
719
720 ast_str_substitute_variables(&str, 0, chan, varsubst);
721
722 if (ast_str_strlen(str) == 0 || ast_strlen_zero(args.delim)) {
723 fieldindex = 0;
724 } else if (ast_get_encoded_char(args.delim, delim, &delim_used) == -1) {
725 res = -1;
726 } else {
727 char *varval = ast_str_buffer(str);
728
729 while ((field = strsep(&varval, delim)) != NULL) {
730 fieldindex++;
731
732 if (!strcasecmp(field, args.field)) {
733 break;
734 }
735 }
736
737 if (!field) {
738 fieldindex = 0;
739 }
740
741 res = 0;
742 }
743 }
744
745 if (sbuf) {
746 ast_str_set(sbuf, len, "%d", fieldindex);
747 } else {
748 snprintf(buf, len, "%d", fieldindex);
749 }
750
751 return res;
752}
const char * str
Definition: app_jack.c:150
char * strsep(char **str, const char *delims)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:288
static struct ast_threadstorage result_buf
Definition: func_strings.c:47
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition: strings.h:1113
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:730
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
Definition: strings.h:909
Support for dynamic strings.
Definition: strings.h:623

References args, ast_alloca, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_get_encoded_char(), ast_log, AST_STANDARD_APP_ARGS, ast_str_buffer(), ast_str_set(), ast_str_strlen(), ast_str_substitute_variables(), ast_str_thread_get(), ast_strlen_zero(), buf, len(), LOG_ERROR, NULL, result_buf, str, and strsep().

Referenced by function_fieldnum(), and function_fieldnum_str().

◆ function_fieldnum_str()

static int function_fieldnum_str ( struct ast_channel chan,
const char *  cmd,
char *  parse,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 760 of file func_strings.c.

762{
763 return function_fieldnum_helper(chan, cmd, parse, NULL, buf, len);
764}

References buf, function_fieldnum_helper(), len(), and NULL.

◆ function_fieldqty()

static int function_fieldqty ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buf,
size_t  len 
)
static

Definition at line 675 of file func_strings.c.

677{
678 return function_fieldqty_helper(chan, cmd, parse, buf, NULL, len);
679}
static int function_fieldqty_helper(struct ast_channel *chan, const char *cmd, char *parse, char *buf, struct ast_str **sbuf, ssize_t len)
Definition: func_strings.c:630

References buf, function_fieldqty_helper(), len(), and NULL.

◆ function_fieldqty_helper()

static int function_fieldqty_helper ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buf,
struct ast_str **  sbuf,
ssize_t  len 
)
static

Definition at line 630 of file func_strings.c.

632{
633 char *varsubst;
635 int fieldcount = 0;
637 AST_APP_ARG(varname);
638 AST_APP_ARG(delim);
639 );
640 char delim[2] = "";
641 size_t delim_used;
642
643 if (!str) {
644 return -1;
645 }
646
648 if (args.delim) {
649 ast_get_encoded_char(args.delim, delim, &delim_used);
650
651 varsubst = ast_alloca(strlen(args.varname) + 4);
652
653 sprintf(varsubst, "${%s}", args.varname);
654 ast_str_substitute_variables(&str, 0, chan, varsubst);
655 if (ast_str_strlen(str) == 0) {
656 fieldcount = 0;
657 } else {
658 char *varval = ast_str_buffer(str);
659 while (strsep(&varval, delim)) {
660 fieldcount++;
661 }
662 }
663 } else {
664 fieldcount = 1;
665 }
666 if (sbuf) {
667 ast_str_set(sbuf, len, "%d", fieldcount);
668 } else {
669 snprintf(buf, len, "%d", fieldcount);
670 }
671
672 return 0;
673}

References args, ast_alloca, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_get_encoded_char(), AST_STANDARD_APP_ARGS, ast_str_buffer(), ast_str_set(), ast_str_strlen(), ast_str_substitute_variables(), ast_str_thread_get(), buf, len(), result_buf, str, and strsep().

Referenced by function_fieldqty(), and function_fieldqty_str().

◆ function_fieldqty_str()

static int function_fieldqty_str ( struct ast_channel chan,
const char *  cmd,
char *  parse,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 681 of file func_strings.c.

683{
684 return function_fieldqty_helper(chan, cmd, parse, NULL, buf, len);
685}

References buf, function_fieldqty_helper(), len(), and NULL.

◆ function_ltrim()

static int function_ltrim ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1213 of file func_strings.c.

1214{
1215 char *c;
1216
1217 if (ast_strlen_zero(data)) {
1218 return -1;
1219 }
1220
1221 c = data;
1222 ltrim(c);
1223
1225
1226 return 0;
1227}
#define ltrim(s)
static struct test_val c

References ast_copy_string(), ast_strlen_zero(), buf, c, len(), and ltrim.

◆ function_rtrim()

static int function_rtrim ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1229 of file func_strings.c.

1230{
1231 char *c;
1232
1233 if (ast_strlen_zero(data)) {
1234 return -1;
1235 }
1236
1237 c = ast_strdupa(data);
1238 rtrim(c);
1239
1241
1242 return 0;
1243}
#define rtrim(s)

References ast_copy_string(), ast_strdupa, ast_strlen_zero(), buf, c, len(), and rtrim.

◆ function_trim()

static int function_trim ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1196 of file func_strings.c.

1197{
1198 char *c;
1199
1200 if (ast_strlen_zero(data)) {
1201 return -1;
1202 }
1203
1204 c = ast_strdupa(data);
1205 ltrim(c);
1206 rtrim(c);
1207
1209
1210 return 0;
1211}

References ast_copy_string(), ast_strdupa, ast_strlen_zero(), buf, c, len(), ltrim, and rtrim.

◆ get_key()

static const char * get_key ( const struct ast_str prefix,
const struct ast_var_t var 
)
static

Definition at line 1407 of file func_strings.c.

1408{
1409 const char *prefix_name = ast_str_buffer(prefix);
1410 const char *var_name = ast_var_name(var);
1411 int prefix_len;
1412 int var_len;
1413
1414 if (ast_strlen_zero(var_name)) {
1415 return NULL;
1416 }
1417
1418 prefix_len = ast_str_strlen(prefix);
1419 var_len = strlen(var_name);
1420
1421 /*
1422 * Make sure we only match on non-empty, hash function created keys. If valid
1423 * then return a pointer to the variable that's just after the prefix.
1424 */
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;
1427}

References ast_str_buffer(), ast_str_strlen(), ast_strlen_zero(), ast_var_name(), NULL, prefix, and var.

Referenced by hashkeys_read(), and hashkeys_read2().

◆ hash_read()

static int hash_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1517 of file func_strings.c.

1518{
1519 char varname[256];
1520 const char *varvalue;
1522 AST_APP_ARG(hashname);
1523 AST_APP_ARG(hashkey);
1524 );
1525
1526 AST_STANDARD_APP_ARGS(arg, data);
1527 if (arg.argc == 2) {
1528 snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg.hashkey);
1529 varvalue = pbx_builtin_getvar_helper(chan, varname);
1530 if (varvalue)
1531 ast_copy_string(buf, varvalue, len);
1532 else
1533 *buf = '\0';
1534 } else if (arg.argc == 1) {
1535 char colnames[4096];
1536 int i;
1538 AST_APP_ARG(col)[100];
1539 );
1540
1541 if (!chan) {
1542 ast_log(LOG_WARNING, "No channel and only 1 parameter was provided to %s function.\n", cmd);
1543 return -1;
1544 }
1545
1546 /* Get column names, in no particular order */
1547 hashkeys_read(chan, "HASHKEYS", arg.hashname, colnames, sizeof(colnames));
1548 pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", colnames);
1549
1550 AST_STANDARD_APP_ARGS(arg2, colnames);
1551 *buf = '\0';
1552
1553 /* Now get the corresponding column values, in exactly the same order */
1554 for (i = 0; i < arg2.argc; i++) {
1555 snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg2.col[i]);
1556 varvalue = pbx_builtin_getvar_helper(chan, varname);
1557 /*
1558 * If the value is NULL, there was probably a malformation in the
1559 * column name (unbalanced quote, etc.) This makes everything
1560 * suspect so we should return nothing at all.
1561 */
1562 if (!varvalue) {
1563 ast_log(LOG_WARNING, "No value found for '%s'\n", varname);
1564 *buf = '\0';
1565 return -1;
1566 }
1567 strncat(buf, varvalue, len - strlen(buf) - 1);
1568 strncat(buf, ",", len - strlen(buf) - 1);
1569 }
1570
1571 /* Strip trailing comma */
1572 buf[strlen(buf) - 1] = '\0';
1573 }
1574
1575 return 0;
1576}
static int hashkeys_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

References AST_APP_ARG, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, buf, HASH_FORMAT, hashkeys_read(), len(), LOG_WARNING, pbx_builtin_getvar_helper(), and pbx_builtin_setvar_helper().

◆ hash_write()

static int hash_write ( struct ast_channel chan,
const char *  cmd,
char *  var,
const char *  value 
)
static

Definition at line 1489 of file func_strings.c.

1490{
1491 char varname[256];
1493 AST_APP_ARG(hashname);
1494 AST_APP_ARG(hashkey);
1495 );
1496
1497 if (!strchr(var, ',')) {
1498 /* Single argument version */
1499 return array(chan, "HASH", var, value);
1500 }
1501
1503 if (arg.hashname[0] == '_') {
1504 if (arg.hashname[1] == '_') {
1505 snprintf(varname, sizeof(varname), "__" HASH_FORMAT, arg.hashname + 2, arg.hashkey);
1506 } else {
1507 snprintf(varname, sizeof(varname), "_" HASH_FORMAT, arg.hashname + 1, arg.hashkey);
1508 }
1509 } else {
1510 snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg.hashkey);
1511 }
1512 pbx_builtin_setvar_helper(chan, varname, value);
1513
1514 return 0;
1515}
static int array(struct ast_channel *chan, const char *cmd, char *var, const char *value)

References array(), AST_APP_ARG, AST_DECLARE_APP_ARGS, AST_STANDARD_APP_ARGS, HASH_FORMAT, pbx_builtin_setvar_helper(), value, and var.

◆ hashkeys_read()

static int hashkeys_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1429 of file func_strings.c.

1430{
1431 struct ast_var_t *newvar;
1432 struct ast_str *prefix = ast_str_alloca(80);
1433 size_t buf_len;
1434
1435 if (!chan) {
1436 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1437 return -1;
1438 }
1439
1440 ast_str_set(&prefix, -1, HASH_PREFIX, data);
1441 memset(buf, 0, len);
1442
1443 AST_LIST_TRAVERSE(ast_channel_varshead(chan), newvar, entries) {
1444 const char *key = get_key(prefix, newvar);
1445
1446 if (key) {
1447 strncat(buf, key, len - strlen(buf) - 1);
1448 /* Replace the trailing ~ */
1449 buf[strlen(buf) - 1] = ',';
1450 }
1451 }
1452 /* Trim the trailing comma */
1453 buf_len = strlen(buf);
1454 if (buf_len) {
1455 buf[buf_len - 1] = '\0';
1456 }
1457 return 0;
1458}
static const char * get_key(const struct ast_str *prefix, const struct ast_var_t *var)
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
#define ast_str_alloca(init_len)
Definition: strings.h:848

References ast_channel_varshead(), AST_LIST_TRAVERSE, ast_log, ast_str_alloca, ast_str_set(), buf, get_key(), HASH_PREFIX, len(), LOG_WARNING, and prefix.

Referenced by hash_read().

◆ hashkeys_read2()

static int hashkeys_read2 ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 1460 of file func_strings.c.

1461{
1462 struct ast_var_t *newvar;
1463 struct ast_str *prefix = ast_str_alloca(80);
1464
1465 if (!chan) {
1466 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1467 return -1;
1468 }
1469
1470 ast_str_set(&prefix, -1, HASH_PREFIX, data);
1471
1472 AST_LIST_TRAVERSE(ast_channel_varshead(chan), newvar, entries) {
1473 const char *key = get_key(prefix, newvar);
1474
1475 if (key) {
1476 char *tmp;
1477
1478 ast_str_append(buf, len, "%s", key);
1479 /* Replace the trailing ~ */
1480 tmp = ast_str_buffer(*buf);
1481 tmp[ast_str_strlen(*buf) - 1] = ',';
1482 }
1483 }
1484
1485 ast_str_truncate(*buf, -1);
1486 return 0;
1487}
char * ast_str_truncate(struct ast_str *buf, ssize_t len)
Truncates the enclosed string to the given length.
Definition: strings.h:786
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1139

References ast_channel_varshead(), AST_LIST_TRAVERSE, ast_log, ast_str_alloca, ast_str_append(), ast_str_buffer(), ast_str_set(), ast_str_strlen(), ast_str_truncate(), buf, get_key(), HASH_PREFIX, len(), LOG_WARNING, and prefix.

◆ keypadhash()

static int keypadhash ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  buflen 
)
static

Definition at line 1795 of file func_strings.c.

1796{
1797 char *bufptr, *dataptr;
1798
1799 for (bufptr = buf, dataptr = data; bufptr < buf + buflen - 1; dataptr++) {
1800 if (*dataptr == '\0') {
1801 *bufptr++ = '\0';
1802 break;
1803 } else if (*dataptr == '1') {
1804 *bufptr++ = '1';
1805 } else if (strchr("AaBbCc2", *dataptr)) {
1806 *bufptr++ = '2';
1807 } else if (strchr("DdEeFf3", *dataptr)) {
1808 *bufptr++ = '3';
1809 } else if (strchr("GgHhIi4", *dataptr)) {
1810 *bufptr++ = '4';
1811 } else if (strchr("JjKkLl5", *dataptr)) {
1812 *bufptr++ = '5';
1813 } else if (strchr("MmNnOo6", *dataptr)) {
1814 *bufptr++ = '6';
1815 } else if (strchr("PpQqRrSs7", *dataptr)) {
1816 *bufptr++ = '7';
1817 } else if (strchr("TtUuVv8", *dataptr)) {
1818 *bufptr++ = '8';
1819 } else if (strchr("WwXxYyZz9", *dataptr)) {
1820 *bufptr++ = '9';
1821 } else if (*dataptr == '0') {
1822 *bufptr++ = '0';
1823 }
1824 }
1825 buf[buflen - 1] = '\0';
1826
1827 return 0;
1828}

References buf.

◆ len()

static int len ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  buflen 
)
static

Definition at line 1669 of file func_strings.c.

1670{
1671 int length = 0;
1672
1673 if (data)
1674 length = strlen(data);
1675
1676 snprintf(buf, buflen, "%d", length);
1677
1678 return 0;
1679}

References buf.

Referenced by __analog_ss_thread(), __ast_cli_register(), __ast_cli_register_multiple(), __ast_dsp_call_progress(), __ast_dsp_silence_noise(), __ast_frdup(), OrderedDict::__eq__(), OrderedDict::__init__(), __rtp_recvfrom(), __rtp_sendto(), MultiOrderedDict::__setitem__(), AbsQuantW(), acf_curl_exec(), acf_curlopt_helper(), acf_curlopt_read(), acf_curlopt_read2(), acf_cut_exec(), acf_cut_exec2(), acf_escape(), acf_escape_backslashes(), acf_escape_ticks(), acf_faxopt_read(), acf_fetch(), acf_iaxvar_read(), acf_if(), acf_meetme_info(), acf_odbc_read(), acf_sort_exec(), acf_sprintf(), acf_transaction_read(), acf_vm_info(), acf_vmcount_exec(), action_command(), FaxPcap::add(), adsi_careful_send(), ael_token_subst(), aes_helper(), agent_function_read(), amdf_pitch(), anaFilter(), analog_ss_thread(), anti_injection(), aoc_parse_ie(), append_attr_address(), append_attr_string(), append_interface(), append_var_and_value_to_filter(), apply_outgoing(), ast_agi_register_multiple(), ast_agi_unregister_multiple(), ast_app_group_set_channel(), ast_app_options2str64(), ast_beep_start(), ast_bucket_alloc(), ast_bucket_file_alloc(), ast_callerid_vmwi_generate(), ast_carefulwrite(), ast_channel_get_cc_agent_type(), ast_channel_get_device_name(), ast_check_command_in_path(), ast_cli_complete(), ast_cli_unregister_multiple(), ast_dsp_process(), ast_dsp_silence_noise_with_energy(), ast_format_str_reduce(), ast_frame_type2str(), ast_func_read(), ast_gen_cas(), ast_get_builtin_feature(), ast_get_feature(), ast_get_namedgroups(), ast_http_prefix(), ast_http_send(), ast_http_uri_link(), ast_iostream_gets(), ast_iostream_printf(), ast_join_delim(), ast_json_nvp_array_to_ast_variables(), ast_json_utf8_check_len(), ast_media_cache_retrieve(), ast_media_cache_retrieve_metadata(), ast_mkdir(), ast_msg_data_alloc(), ast_read_image(), ast_readstring(), ast_readstring_full(), ast_recvfrom(), ast_rtcp_generate_report(), ast_rtcp_generate_sdes(), ast_rtcp_interpret(), ast_rtp_interpret(), ast_say_number_full_ka(), ast_sendto(), ast_sip_sanitize_xml(), ast_smoother_read(), ast_sockaddr_copy_sockaddr(), ast_speech_get_setting(), ast_speech_write(), ast_srtp_get_random(), ast_srtp_protect(), ast_srtp_unprotect(), ast_statsd_log_string(), ast_stir_shaken_vs_verify(), ast_str_buffer(), ast_str_substitute_variables_full2(), ast_strftime(), ast_strftime_locale(), ast_stun_handle_packet(), ast_tdd_gen_ecdisa(), AST_TEST_DEFINE(), ast_translate(), ast_udptl_write(), ast_websocket_write_string(), ast_xml_escape(), ast_xmldoc_printable(), auth_exec(), authenticate(), base64_buf_helper(), base64_helper(), base64_str_helper(), blacklist_read(), blacklist_read2(), bridge_p2p_rtp_write(), bucket_copy(), bucket_file_wizard_retrieve(), bucket_wizard_retrieve(), buf_hash(), buf_hash_add(), build_device(), build_ha(), build_rand_pad(), build_regex(), builtin_feature_get_exten(), calc_energy(), calendar_event_read(), calendar_join_attendees(), calendar_query_exec(), calendar_query_result_exec(), callerid_feed(), callerid_feed_jp(), callerid_full_tz_generate(), callerid_read(), canonicalize_tn(), careful_write(), category_set_sublevels(), CB_ADD_LEN(), cdata(), cdr_read(), channel_do_masquerade(), chararray_handler_fn(), check_dirpath(), chunked_atoh(), cleaned_basedn(), clearvar_prefix(), cli_complete(), cli_console_sendtext(), sip_to_pjsip::cli_options(), sip_to_pjsql::cli_options(), complete_confno(), complete_dialplan_add_extension(), complete_dialplan_add_ignorepat(), complete_dialplan_add_include(), complete_dialplan_remove_context(), complete_dialplan_remove_extension(), complete_dialplan_remove_ignorepat(), complete_dialplan_remove_include(), complete_meetmecmd_list(), complete_meetmecmd_mute_kick(), complete_peer_helper(), complete_userno(), conf_get_pin(), conf_play(), config_function_read(), connectedline_read(), copy(), copy_string(), create_dirpath(), create_video_frame(), crement_function_read(), crypto_get_cert_subject(), csv_quote(), custom_level_still_exists(), dahdi_func_read(), dahdi_sendtext(), dahdi_setoption(), dbl_list_expect_reverse(), dcbias_(), decode_length(), decode_open_type(), decrypt_memcpy(), DEFINE_SQL_STATEMENT(), devstate_read(), devstate_write(), dialgroup_read(), dialgroup_refreshdb(), dictate_exec(), dns_parse_answer(), dtmf_store_framehook(), dump_addr(), dump_answer(), dump_byte(), dump_cause(), dump_datetime(), dump_eid(), dump_encrypted(), dump_hint(), dump_ies(), dump_int(), dump_ipaddr(), dump_prefs(), dump_prov(), dump_prov_flags(), dump_prov_ies(), dump_raw(), dump_samprate(), dump_short(), dump_string(), dump_string_hex(), dump_versioned_codec(), dundi_encrypt(), dundi_parse_ies(), dundi_query_read(), dundi_result_read(), dundi_send(), dundifunc_read(), ebl_callback(), encode_length(), encode_open_type(), encrypt_memcpy(), energy_(), enum_callback(), enum_query_read(), enum_result_read(), env_read(), eval_exten_read(), eval_sub_read(), expand_gosub_args(), expr2_token_subst(), ext_cmp_exten_strlen(), ext_strncpy(), extract_oli(), extstate_read(), fbuf_append(), feature_read(), featuremap_get(), featuremap_read(), fetch_callerid_num(), fetch_response_reader(), ffmpeg_decode(), file2display(), file_basename(), file_count_line(), file_dirname(), file_format(), file_read(), filename_parse(), filter(), frame_set_var(), fsk_serial(), func_channel_read(), func_confbridge_channels(), func_confbridge_info(), func_get_parkingslot_channel(), func_mchan_read(), func_mixmonitor_read(), func_read(), func_read_header(), func_read_headers(), func_read_param(), func_response_read_header(), func_response_read_headers(), function_amiclient(), function_db_delete(), function_db_exists(), function_db_keycount(), function_db_read(), function_enum(), function_fieldnum(), function_fieldnum_helper(), function_fieldnum_str(), function_fieldqty(), function_fieldqty_helper(), function_fieldqty_str(), function_iaxpeer(), function_ltrim(), function_ooh323_read(), function_realtime_read(), function_realtime_readdestroy(), function_rtrim(), function_trim(), function_txtcidname(), g722_decode(), g722_encode(), gen_tone(), gen_tones(), general_get(), geoloc_profile_read(), PathSegment::get_child(), get_date(), get_name_from_resource(), global_read(), group_count_function_read(), group_function_read(), group_list_function_read(), group_match_count_function_read(), gsm_write(), gsmtolin_framein(), h261_decap(), h261_encap(), h263_decap(), h263_encap(), h263_read(), h263_write(), h263p_decap(), h263p_encap(), h264_decap(), h264_read(), h264_write(), handle_cli_devstate_change(), handle_cli_mobile_search(), handle_cli_moh_unregister_class(), handle_cli_presencestate_change(), handle_commandmatchesarray(), handle_output(), handle_show_sysinfo(), hangupcause_keys_read(), hangupcause_read(), Model::has_properties(), Model::has_subtypes(), hash_read(), hashkeys_read(), hashkeys_read2(), header_identify_match_check(), help1(), hepv3_create_capture_info(), hint_read(), hook_read(), hpInput(), hpOutput(), http_request_headers_get(), httpd_process_request(), iax2_getpeername(), iax_frame_subclass2str(), iax_parse_ies(), iax_str2flags(), iconv_read(), ifmodule_read(), iftime(), import_helper(), import_read(), import_read2(), inner_product_single(), internal_feature_read(), internal_featuremap_read(), interpolate_product_single(), ip_identify_apply(), isodate(), ivfilt_(), json_decode_read(), json_utf8_check_full(), linear_generator(), listener(), listfilter(), listfilter_read(), listfilter_read2(), load_file(), local_read(), lock_read(), lpc10_decode(), lpc10tolin_framein(), lpfilt_(), refcounter::main(), main(), spandspflow2pcap::main(), make_dir(), make_file(), make_filename(), manager_login(), math(), MD5Update(), media_offer_read_av(), memcpy_decrypt(), memcpy_encrypt(), message_template_parse_emailbody(), milliwatt_generate(), minivm_account_func_read(), minivm_counter_func_read(), moh_generate(), monmp3thread(), mpeg4_decap(), mpeg4_encap(), msg_data_func_read(), msg_func_read(), msg_to_endpoint(), my_dahdi_write(), newpvt(), PathSegment::num_children(), parse_bookmark(), parse_cdata(), parse_ie(), refcounter::parse_line(), get_documentation::parse_manager_event_instance(), parse_naptr(), parse_node(), parse_srv(), partial_match(), party_id_read(), party_name_read(), party_number_read(), party_subaddress_read(), passthru(), pbx_substitute_variables_helper_full(), pbx_substitute_variables_helper_full_location(), peek_read(), phoneprov_callback(), pickup_get(), pjsip_acf_channel_read(), pjsip_acf_dial_contacts_read(), pjsip_acf_dtmf_mode_read(), pjsip_acf_media_offer_read(), pjsip_acf_moh_passthrough_read(), pjsip_aor_function_read(), pjsip_contact_function_read(), pjsip_endpoint_function_read(), playtone(), playtones_generator(), plc_fillin(), plc_rx(), pp_each_extension_helper(), pp_each_extension_read(), pp_each_extension_read2(), pp_each_user_helper(), pp_each_user_read(), pp_each_user_read2(), presence_read(), presence_write(), print_body(), process_cn_rfc3389(), process_dtmf_cisco(), process_dtmf_rfc2833(), reflocks::process_file(), refstats::process_file(), queue_function_exists(), queue_function_mem_read(), queue_function_memberpenalty_read(), queue_function_qac_dep(), queue_function_queuegetchannel(), queue_function_queuememberlist(), queue_function_queuewaitingcount(), queue_function_var(), quote(), read_credentials(), read_header(), read_headers(), realtimefield_read(), red_t140_to_red(), redirecting_read(), refer_blind_callback(), regex(), remove_header(), replace(), request_identify_match_check(), res_sdp_srtp_get_attr(), reschedule_precache(), resource_name_baselen(), rtp_instance_parse_extmap_extensions(), run_agi(), save_history(), sayfile_exec(), scan_thread(), schedule_delivery(), sco_accept(), sco_write(), send_signal(), send_string(), set(), set2(), set_bridge_peer_vars_multiparty(), sha1(), shared_read(), shared_write(), shell_helper(), shift_pop(), skip_name(), smdi_msg_read(), smdi_msg_retrieve_read(), sms_generate(), sms_messagetx(), socket_process_meta(), sorcery_function_read(), speech_aeap_engine_get_setting(), speech_aeap_engine_write(), speech_engine_read(), speech_grammar(), speech_read(), speech_score(), speech_text(), speex_get_wb_sz_at(), speex_read(), speex_samples(), sprint_list_entry(), srv_callback(), srv_query_read(), srv_result_read(), stackpeek_read(), start_automixmonitor(), stat_read(), StateConstructW(), StateSearchW(), static_callback(), strbetween(), strreplace(), syntFilter(), sysinfo_helper(), t38_tx_packet_handler(), tdd_feed(), term_filter_escapes(), timeout_read(), tonepair_generator(), transfer_exec(), try_firmware(), trylock_read(), txt_callback(), udptl_build_packet(), udptl_rx_packet(), unistim_sp(), unlock_read(), unquote(), OrderedDict::update(), uri_parse_and_default(), uridecode(), uriencode(), varlist_to_str(), vm_check_password_shell(), wav_write(), websocket_client_handshake_get_response(), ws_safe_read(), ws_send_msg(), xfer_get(), xmldoc_get_syntax_fun(), xmldoc_reverse_helper(), xmldoc_setpostbr(), xmpp_client_authenticate_sasl(), xmpp_client_receive(), xmpp_client_send_raw_message(), and xmpp_io_recv().

◆ listfilter()

static int listfilter ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buf,
struct ast_str **  bufstr,
ssize_t  len 
)
static

Definition at line 772 of file func_strings.c.

773{
775 AST_APP_ARG(listname);
776 AST_APP_ARG(delimiter);
777 AST_APP_ARG(fieldvalue);
778 );
779 struct ast_str *orig_list = ast_str_thread_get(&tmp_buf, 16);
780 const char *begin, *cur, *next;
781 int dlen, flen, first = 1;
782 struct ast_str *result, **result_ptr = &result;
783 char *delim, *varsubst;
784
786
787 if (buf) {
788 if (!(result = ast_str_thread_get(&result_buf, 16))) {
789 return -1;
790 }
791 } else {
792 /* Place the result directly into the output buffer */
793 result_ptr = bufstr;
794 }
795
796 if (args.argc < 3) {
797 ast_log(LOG_ERROR, "Usage: LISTFILTER(<listname>,<delimiter>,<fieldvalue>)\n");
798 return -1;
799 }
800
801 varsubst = ast_alloca(strlen(args.listname) + 4);
802 sprintf(varsubst, "${%s}", args.listname);
803
804 /* If we don't lock the channel, the variable could disappear out from underneath us. */
805 if (chan) {
806 ast_channel_lock(chan);
807 }
808 ast_str_substitute_variables(&orig_list, 0, chan, varsubst);
809 if (!ast_str_strlen(orig_list)) {
810 if (chan) {
811 ast_channel_unlock(chan);
812 }
813 return -1;
814 }
815
816 /* If the string isn't there, just copy out the string and be done with it. */
817 if (!strstr(ast_str_buffer(orig_list), args.fieldvalue)) {
818 if (buf) {
820 } else {
821 ast_str_set(result_ptr, len, "%s", ast_str_buffer(orig_list));
822 }
823 if (chan) {
824 ast_channel_unlock(chan);
825 }
826 return 0;
827 }
828
829 dlen = strlen(args.delimiter);
830 delim = ast_alloca(dlen + 1);
831 ast_get_encoded_str(args.delimiter, delim, dlen + 1);
832
833 if ((dlen = strlen(delim)) == 0) {
834 delim = ",";
835 dlen = 1;
836 }
837
838 flen = strlen(args.fieldvalue);
839
840 ast_str_reset(*result_ptr);
841 /* Enough space for any result */
842 if (len > -1) {
843 ast_str_make_space(result_ptr, len ? len : ast_str_strlen(orig_list) + 1);
844 }
845
846 begin = ast_str_buffer(orig_list);
847 next = strstr(begin, delim);
848
849 do {
850 /* Find next boundary */
851 if (next) {
852 cur = next;
853 next = strstr(cur + dlen, delim);
854 } else {
855 cur = strchr(begin + dlen, '\0');
856 }
857
858 if (flen == cur - begin && !strncmp(begin, args.fieldvalue, flen)) {
859 /* Skip field */
860 begin += flen + dlen;
861 } else {
862 /* Copy field to output */
863 if (!first) {
864 ast_str_append(result_ptr, len, "%s", delim);
865 }
866
867 ast_str_append_substr(result_ptr, len, begin, cur - begin);
868 first = 0;
869 begin = cur + dlen;
870 }
871 } while (*cur != '\0');
872 if (chan) {
873 ast_channel_unlock(chan);
874 }
875
876 if (buf) {
878 }
879
880 return 0;
881}
struct sla_ringing_trunk * first
Definition: app_sla.c:338
static PGresult * result
Definition: cel_pgsql.c:84
#define ast_channel_lock(chan)
Definition: channel.h:2970
#define ast_channel_unlock(chan)
Definition: channel.h:2971
static struct ast_threadstorage tmp_buf
Definition: func_strings.c:48
char * ast_get_encoded_str(const char *stream, char *result, size_t result_len)
Decode a stream of encoded control or extended ASCII characters.
Definition: main/app.c:3162
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.
Definition: strings.h:1062
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
Definition: strings.h:693
#define ast_str_make_space(buf, new_len)
Definition: strings.h:828

References args, ast_alloca, AST_APP_ARG, ast_channel_lock, ast_channel_unlock, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_get_encoded_str(), ast_log, AST_STANDARD_APP_ARGS, ast_str_append(), ast_str_append_substr(), ast_str_buffer(), ast_str_make_space, ast_str_reset(), ast_str_set(), ast_str_strlen(), ast_str_substitute_variables(), ast_str_thread_get(), buf, first, len(), LOG_ERROR, result, result_buf, and tmp_buf.

Referenced by listfilter_read(), and listfilter_read2().

◆ listfilter_read()

static int listfilter_read ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buf,
size_t  len 
)
static

Definition at line 883 of file func_strings.c.

884{
885 return listfilter(chan, cmd, parse, buf, NULL, len);
886}
static int listfilter(struct ast_channel *chan, const char *cmd, char *parse, char *buf, struct ast_str **bufstr, ssize_t len)
Definition: func_strings.c:772

References buf, len(), listfilter(), and NULL.

◆ listfilter_read2()

static int listfilter_read2 ( struct ast_channel chan,
const char *  cmd,
char *  parse,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 888 of file func_strings.c.

889{
890 return listfilter(chan, cmd, parse, NULL, buf, len);
891}

References buf, len(), listfilter(), and NULL.

◆ load_module()

static int load_module ( void  )
static

Definition at line 2452 of file func_strings.c.

2453{
2454 int res = 0;
2455
2456 AST_TEST_REGISTER(test_FIELDNUM);
2457 AST_TEST_REGISTER(test_REPLACE);
2458 AST_TEST_REGISTER(test_FILTER);
2459 AST_TEST_REGISTER(test_STRREPLACE);
2460 AST_TEST_REGISTER(test_STRBETWEEN);
2461 AST_TEST_REGISTER(test_TRIM);
2491
2492 return res;
2493}
static struct ast_custom_function fieldqty_function
Definition: func_strings.c:687
static struct ast_custom_function trim_function
static struct ast_custom_function eval_function
static struct ast_custom_function shift_function
static struct ast_custom_function hashkeys_function
static struct ast_custom_function fieldnum_function
Definition: func_strings.c:766
static struct ast_custom_function filter_function
Definition: func_strings.c:975
static struct ast_custom_function hash_function
static struct ast_custom_function strptime_function
static struct ast_custom_function ltrim_function
static struct ast_custom_function strbetween_function
static struct ast_custom_function regex_function
static struct ast_custom_function replace_function
static char * app_clearhash
static struct ast_custom_function strreplace_function
static struct ast_custom_function passthru_function
static struct ast_custom_function listfilter_function
Definition: func_strings.c:893
static struct ast_custom_function pop_function
static struct ast_custom_function unshift_function
static struct ast_custom_function keypadhash_function
static struct ast_custom_function rtrim_function
static struct ast_custom_function strftime_function
static struct ast_custom_function toupper_function
static struct ast_custom_function quote_function
static struct ast_custom_function csv_quote_function
static struct ast_custom_function tolower_function
static struct ast_custom_function array_function
static struct ast_custom_function push_function
static int exec_clearhash(struct ast_channel *chan, const char *data)
static struct ast_custom_function len_function
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:640
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1559
#define AST_TEST_REGISTER(cb)
Definition: test.h:127

References app_clearhash, array_function, ast_custom_function_register, ast_register_application_xml, AST_TEST_REGISTER, csv_quote_function, eval_function, exec_clearhash(), fieldnum_function, fieldqty_function, filter_function, hash_function, hashkeys_function, keypadhash_function, len_function, listfilter_function, ltrim_function, passthru_function, pop_function, push_function, quote_function, regex_function, replace_function, rtrim_function, shift_function, strbetween_function, strftime_function, strptime_function, strreplace_function, tolower_function, toupper_function, trim_function, and unshift_function.

◆ passthru()

static int passthru ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 2017 of file func_strings.c.

2018{
2019 ast_str_set(buf, len, "%s", data);
2020 return 0;
2021}

References ast_str_set(), buf, and len().

◆ quote()

static int quote ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1595 of file func_strings.c.

1596{
1597 char *bufptr = buf, *dataptr = data;
1598
1599 if (len < 3){ /* at least two for quotes and one for binary zero */
1600 ast_log(LOG_ERROR, "Not enough buffer\n");
1601 return -1;
1602 }
1603
1604 if (ast_strlen_zero(data)) {
1605 ast_log(LOG_WARNING, "No argument specified!\n");
1606 ast_copy_string(buf, "\"\"", len);
1607 return 0;
1608 }
1609
1610 *bufptr++ = '"';
1611 for (; bufptr < buf + len - 3; dataptr++) {
1612 if (*dataptr == '\\') {
1613 *bufptr++ = '\\';
1614 *bufptr++ = '\\';
1615 } else if (*dataptr == '"') {
1616 *bufptr++ = '\\';
1617 *bufptr++ = '"';
1618 } else if (*dataptr == '\0') {
1619 break;
1620 } else {
1621 *bufptr++ = *dataptr;
1622 }
1623 }
1624 *bufptr++ = '"';
1625 *bufptr = '\0';
1626 return 0;
1627}

References ast_copy_string(), ast_log, ast_strlen_zero(), buf, len(), LOG_ERROR, and LOG_WARNING.

Referenced by __ast_app_separate_args(), ast_app_separate_args(), ast_strsep_quoted(), ast_variable_list_from_quoted_string(), and parse_options().

◆ regex()

static int regex ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buf,
size_t  len 
)
static

Definition at line 1263 of file func_strings.c.

1265{
1267 AST_APP_ARG(null);
1268 AST_APP_ARG(reg);
1270 );
1271 int errcode;
1272 regex_t regexbuf;
1273
1274 buf[0] = '\0';
1275
1276 AST_NONSTANDARD_APP_ARGS(args, parse, '"');
1277
1278 if (args.argc != 3) {
1279 ast_log(LOG_ERROR, "Unexpected arguments: should have been in the form '\"<regex>\" <string>'\n");
1280 return -1;
1281 }
1282 if ((*args.str == ' ') || (*args.str == '\t'))
1283 args.str++;
1284
1285 ast_debug(1, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str);
1286
1287 if ((errcode = regcomp(&regexbuf, args.reg, REG_EXTENDED | REG_NOSUB))) {
1288 regerror(errcode, &regexbuf, buf, len);
1289 ast_log(LOG_WARNING, "Malformed input %s(%s): %s\n", cmd, parse, buf);
1290 return -1;
1291 }
1292
1293 strcpy(buf, regexec(&regexbuf, args.str, 0, NULL, 0) ? "0" : "1");
1294
1295 regfree(&regexbuf);
1296
1297 return 0;
1298}
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.

References args, AST_APP_ARG, ast_debug, AST_DECLARE_APP_ARGS, ast_log, AST_NONSTANDARD_APP_ARGS, buf, len(), LOG_ERROR, LOG_WARNING, NULL, and str.

Referenced by ast_mwi_mailbox_delete_by_regex(), ast_mwi_mailbox_get_by_regex(), ast_sip_cli_traverse_objects(), ast_sorcery_object_fields_register(), ast_sorcery_retrieve_by_regex(), ast_strings_match(), build_regex(), cli_aor_get_container(), cli_channel_get_container(), cli_channelstats_get_container(), cli_contact_get_container(), cli_endpoint_get_container(), cli_get_container(), cli_list_subscriptions_inout(), cli_show_monitors(), cli_show_subscriptions_inout(), cli_show_tasks(), get_container(), make_astdb_prefix_pattern(), sorcery_astdb_retrieve_regex(), sorcery_config_retrieve_regex(), sorcery_memory_cache_retrieve_regex(), sorcery_memory_retrieve_regex(), sorcery_realtime_retrieve_regex(), xmldoc_get_syntax_config_option(), and xmldoc_update_config_option().

◆ replace()

static int replace ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 980 of file func_strings.c.

981{
983 AST_APP_ARG(varname);
984 AST_APP_ARG(find);
986 );
987 char *strptr, *varsubst;
988 RAII_VAR(struct ast_str *, str, ast_str_create(16), ast_free);
989 char find[256]; /* Only 256 characters possible */
990 char replace[2] = "";
991 size_t unused;
992
994
995 if (!str) {
996 return -1;
997 }
998
999 if (args.argc < 2) {
1000 ast_log(LOG_ERROR, "Usage: %s(<varname>,<search-chars>[,<replace-char>])\n", cmd);
1001 return -1;
1002 }
1003
1004 /* Decode escapes */
1005 ast_get_encoded_str(args.find, find, sizeof(find));
1006 ast_get_encoded_char(args.replace, replace, &unused);
1007
1008 if (ast_strlen_zero(find) || ast_strlen_zero(args.varname)) {
1009 ast_log(LOG_ERROR, "The characters to search for and the variable name must not be empty.\n");
1010 return -1;
1011 }
1012
1013 varsubst = ast_alloca(strlen(args.varname) + 4);
1014 sprintf(varsubst, "${%s}", args.varname);
1015 ast_str_substitute_variables(&str, 0, chan, varsubst);
1016
1017 if (!ast_str_strlen(str)) {
1018 /* Blank, nothing to replace */
1019 return -1;
1020 }
1021
1022 ast_debug(3, "String to search: (%s)\n", ast_str_buffer(str));
1023 ast_debug(3, "Characters to find: (%s)\n", find);
1024 ast_debug(3, "Character to replace with: (%s)\n", replace);
1025
1026 for (strptr = ast_str_buffer(str); *strptr; strptr++) {
1027 /* buf is already a mutable buffer, so we construct the result
1028 * directly there */
1029 if (strchr(find, *strptr)) {
1030 if (ast_strlen_zero(replace)) {
1031 memmove(strptr, strptr + 1, strlen(strptr + 1) + 1);
1032 strptr--;
1033 } else {
1034 /* Replace character */
1035 *strptr = *replace;
1036 }
1037 }
1038 }
1039
1041 return 0;
1042}
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:980
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:659
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941

References args, ast_alloca, AST_APP_ARG, ast_debug, AST_DECLARE_APP_ARGS, ast_free, ast_get_encoded_char(), ast_get_encoded_str(), ast_log, AST_STANDARD_APP_ARGS, ast_str_buffer(), ast_str_create, ast_str_set(), ast_str_strlen(), ast_str_substitute_variables(), ast_strlen_zero(), buf, len(), LOG_ERROR, RAII_VAR, replace(), and str.

Referenced by FaxPcap::add(), add_header(), add_pri(), add_priority(), app_get_replace_channel_app(), app_set_replace_channel_app(), app_set_replace_channel_snapshot(), ast_add_extension(), ast_add_extension2(), ast_add_extension2_lockopt(), ast_add_extension2_nolock(), ast_add_extension_nolock(), ast_sip_add_global_request_header(), ast_sip_add_global_response_header(), ast_translator_best_choice(), bridge_features_ds_set_full(), channel_feature_hooks_set_full(), get_replace_channel_snapshot(), ResourceApi::load(), ApiDeclaration::load_file(), localized_add_extension2(), manager_dialplan_extension_add(), spandspflow2pcap::n2b(), parking_add_extension(), get_documentation::parse_manager_event_instance(), process_text_line(), replace(), replace_channel_destroy(), rtp_codecs_payload_set_rx(), and astconfigparser::try_section().

◆ shift_pop()

static int shift_pop ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 1893 of file func_strings.c.

1894{
1895#define beginning (cmd[0] == 'S') /* SHIFT */
1896 char *after, delimiter[2] = ",", *varsubst;
1897 size_t unused;
1898 struct ast_str *before = ast_str_thread_get(&result_buf, 16);
1899 char *(*search_func)(const char *s, int c) = (beginning ? strchr : strrchr);
1902 AST_APP_ARG(delimiter);
1903 );
1904
1905 if (!before) {
1906 return -1;
1907 }
1908
1910
1911 if (ast_strlen_zero(args.var)) {
1912 ast_log(LOG_WARNING, "%s requires a variable name\n", cmd);
1913 return -1;
1914 }
1915
1916 varsubst = ast_alloca(strlen(args.var) + 4);
1917 sprintf(varsubst, "${%s}", args.var);
1918 ast_str_substitute_variables(&before, 0, chan, varsubst);
1919
1920 if (args.argc > 1 && !ast_strlen_zero(args.delimiter)) {
1921 ast_get_encoded_char(args.delimiter, delimiter, &unused);
1922 }
1923
1924 if (!ast_str_strlen(before)) {
1925 /* Nothing to pop */
1926 return -1;
1927 }
1928
1929 if (!(after = search_func(ast_str_buffer(before), delimiter[0]))) {
1930 /* Only one entry in array */
1931 ast_str_set(buf, len, "%s", ast_str_buffer(before));
1932 pbx_builtin_setvar_helper(chan, args.var, "");
1933 } else {
1934 *after++ = '\0';
1935 ast_str_set(buf, len, "%s", beginning ? ast_str_buffer(before) : after);
1936 pbx_builtin_setvar_helper(chan, args.var, beginning ? after : ast_str_buffer(before));
1937 }
1938
1939 return 0;
1940#undef beginning
1941}
#define beginning

References args, ast_alloca, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_get_encoded_char(), ast_log, AST_STANDARD_APP_ARGS, ast_str_buffer(), ast_str_set(), ast_str_strlen(), ast_str_substitute_variables(), ast_str_thread_get(), ast_strlen_zero(), beginning, buf, c, len(), LOG_WARNING, pbx_builtin_setvar_helper(), result_buf, and var.

◆ strbetween()

static int strbetween ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 1138 of file func_strings.c.

1139{
1140 int c, origsize;
1141 char *varsubstr, *origstr;
1142 struct ast_str *str = ast_str_thread_get(&result_buf, 16); /* Holds the data obtained from varname */
1143
1145 AST_APP_ARG(varname);
1146 AST_APP_ARG(insert_string);
1147 AST_APP_ARG(other); /* Any remining unused arguments */
1148 );
1149
1151
1152 if (!str) {
1153 ast_log(LOG_ERROR, "Couldn't obtain string\n");
1154 return -1;
1155 }
1156
1158
1159 if (args.argc != 2 || ast_strlen_zero(args.varname)) {
1160 ast_log(LOG_ERROR, "Usage: %s(<varname>,<insert-string>)\n", cmd);
1161 return -1;
1162 }
1163
1164 varsubstr = ast_alloca(strlen(args.varname) + 4);
1165 sprintf(varsubstr, "${%s}", args.varname);
1166 ast_str_substitute_variables(&str, 0, chan, varsubstr);
1167 origstr = ast_str_buffer(str);
1168 origsize = strlen(origstr);
1169 for (c = 0; c < origsize; c++) {
1170 ast_str_append(buf, len, "%c", origstr[c]);
1171 /* no insert after the last character */
1172 if (c < (origsize - 1)) {
1173 ast_str_append(buf, len, "%s", args.insert_string);
1174 }
1175 }
1176
1177 return 0;
1178}

References args, ast_alloca, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_str_append(), ast_str_buffer(), ast_str_reset(), ast_str_substitute_variables(), ast_str_thread_get(), ast_strlen_zero(), buf, c, len(), LOG_ERROR, result_buf, and str.

◆ string_tolower()

static int string_tolower ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  buflen 
)
static

Definition at line 1864 of file func_strings.c.

1865{
1866 char *bufptr = buf, *dataptr = data;
1867
1868 while ((bufptr < buf + buflen - 1) && (*bufptr++ = tolower(*dataptr++)));
1869
1870 return 0;
1871}

References buf.

◆ string_tolower2()

static int string_tolower2 ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  buflen 
)
static

Definition at line 1873 of file func_strings.c.

1874{
1875 char *bufptr, *dataptr = data;
1876
1877 if (buflen > -1) {
1878 ast_str_make_space(buf, buflen > 0 ? buflen : strlen(data) + 1);
1879 }
1880 bufptr = ast_str_buffer(*buf);
1881 while ((bufptr < ast_str_buffer(*buf) + ast_str_size(*buf) - 1) && (*bufptr++ = tolower(*dataptr++)));
1883
1884 return 0;
1885}
void ast_str_update(struct ast_str *buf)
Update the length of the buffer, after using ast_str merely as a buffer.
Definition: strings.h:703
size_t ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
Definition: strings.h:742

References ast_str_buffer(), ast_str_make_space, ast_str_size(), ast_str_update(), and buf.

◆ string_toupper()

static int string_toupper ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  buflen 
)
static

Definition at line 1835 of file func_strings.c.

1836{
1837 char *bufptr = buf, *dataptr = data;
1838
1839 while ((bufptr < buf + buflen - 1) && (*bufptr++ = toupper(*dataptr++)));
1840
1841 return 0;
1842}

References buf.

◆ string_toupper2()

static int string_toupper2 ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  buflen 
)
static

Definition at line 1844 of file func_strings.c.

1845{
1846 char *bufptr, *dataptr = data;
1847
1848 if (buflen > -1) {
1849 ast_str_make_space(buf, buflen > 0 ? buflen : strlen(data) + 1);
1850 }
1851 bufptr = ast_str_buffer(*buf);
1852 while ((bufptr < ast_str_buffer(*buf) + ast_str_size(*buf) - 1) && (*bufptr++ = toupper(*dataptr++)));
1854
1855 return 0;
1856}

References ast_str_buffer(), ast_str_make_space, ast_str_size(), ast_str_update(), and buf.

◆ strreplace()

static int strreplace ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 1049 of file func_strings.c.

1050{
1051 char *varsubstr; /* substring for input var */
1052 char *start; /* Starting pos of substring search. */
1053 char *end; /* Ending pos of substring search. */
1054 int find_size; /* length of given find-string */
1055 unsigned max_matches; /* number of matches we find before terminating search */
1056 unsigned count; /* loop counter */
1057 struct ast_str *str = ast_str_thread_get(&result_buf, 16); /* Holds the data obtained from varname */
1058
1060 AST_APP_ARG(varname);
1061 AST_APP_ARG(find_string);
1062 AST_APP_ARG(replace_string);
1063 AST_APP_ARG(max_replacements);
1064 AST_APP_ARG(other); /* Any remining unused arguments */
1065 );
1066
1067 /* Guarantee output string is empty to start with. */
1069
1070 if (!str) {
1071 /* We failed to allocate str, forget it. We failed. */
1072 return -1;
1073 }
1074
1075 /* Parse the arguments. */
1077
1078 if (args.argc < 2) {
1079 /* Didn't receive enough arguments to do anything */
1081 "Usage: %s(<varname>,<find-string>[,<replace-string>,[<max-replacements>]])\n",
1082 cmd);
1083 return -1;
1084 }
1085
1086 /* No var name specified. Return failure, string is already empty. */
1087 if (ast_strlen_zero(args.varname)) {
1088 return -1;
1089 }
1090
1091 /* Zero length find strings are a no-no. Kill the function if we run into one. */
1092 if (ast_strlen_zero(args.find_string)) {
1093 ast_log(LOG_ERROR, "No <find-string> specified\n");
1094 return -1;
1095 }
1096 find_size = strlen(args.find_string);
1097
1098 /* set varsubstr to the matching variable */
1099 varsubstr = ast_alloca(strlen(args.varname) + 4);
1100 sprintf(varsubstr, "${%s}", args.varname);
1101 ast_str_substitute_variables(&str, 0, chan, varsubstr);
1102
1103 /* Determine how many replacements are allowed. */
1104 if (!args.max_replacements
1105 || (max_matches = atoi(args.max_replacements)) <= 0) {
1106 /* Unlimited replacements are allowed. */
1107 max_matches = -1;
1108 }
1109
1110 /* Generate the search and replaced string. */
1111 start = ast_str_buffer(str);
1112 for (count = 0; count < max_matches; ++count) {
1113 end = strstr(start, args.find_string);
1114 if (!end) {
1115 /* Did not find a matching substring in the remainder. */
1116 break;
1117 }
1118
1119 /* Replace the found substring. */
1120 *end = '\0';
1121 ast_str_append(buf, len, "%s", start);
1122 if (args.replace_string) {
1123 /* Append the replacement string */
1124 ast_str_append(buf, len, "%s", args.replace_string);
1125 }
1126 start = end + find_size;
1127 }
1128 ast_str_append(buf, len, "%s", start);
1129
1130 return 0;
1131}
char * end
Definition: eagi_proxy.c:73

References args, ast_alloca, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_str_append(), ast_str_buffer(), ast_str_reset(), ast_str_substitute_variables(), ast_str_thread_get(), ast_strlen_zero(), buf, end, len(), LOG_ERROR, result_buf, and str.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 2409 of file func_strings.c.

2410{
2411 int res = 0;
2412
2413 AST_TEST_UNREGISTER(test_FIELDNUM);
2414 AST_TEST_UNREGISTER(test_REPLACE);
2415 AST_TEST_UNREGISTER(test_FILTER);
2416 AST_TEST_UNREGISTER(test_STRREPLACE);
2417 AST_TEST_UNREGISTER(test_STRBETWEEN);
2418 AST_TEST_UNREGISTER(test_TRIM);
2448
2449 return res;
2450}
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
#define AST_TEST_UNREGISTER(cb)
Definition: test.h:128

References app_clearhash, array_function, ast_custom_function_unregister(), AST_TEST_UNREGISTER, ast_unregister_application(), csv_quote_function, eval_function, fieldnum_function, fieldqty_function, filter_function, hash_function, hashkeys_function, keypadhash_function, len_function, listfilter_function, ltrim_function, passthru_function, pop_function, push_function, quote_function, regex_function, replace_function, rtrim_function, shift_function, strbetween_function, strftime_function, strptime_function, strreplace_function, tolower_function, toupper_function, trim_function, and unshift_function.

◆ unshift_push()

static int unshift_push ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  new_value 
)
static

Definition at line 1953 of file func_strings.c.

1954{
1955#define beginning (cmd[0] == 'U') /* UNSHIFT */
1956 char delimiter[2] = ",", *varsubst;
1957 size_t unused;
1958 struct ast_str *buf, *previous_value;
1961 AST_APP_ARG(delimiter);
1962 );
1963 const char *stripped_var;
1964
1965 if (!(buf = ast_str_thread_get(&result_buf, 16)) ||
1966 !(previous_value = ast_str_thread_get(&tmp_buf, 16))) {
1967 return -1;
1968 }
1969
1971
1972 if (ast_strlen_zero(args.var)) {
1973 ast_log(LOG_WARNING, "%s requires a variable name\n", cmd);
1974 return -1;
1975 }
1976
1977 if (args.argc > 1 && !ast_strlen_zero(args.delimiter)) {
1978 ast_get_encoded_char(args.delimiter, delimiter, &unused);
1979 }
1980
1981 /* UNSHIFT and PUSH act as ways of setting a variable, so we need to be
1982 * sure to skip leading underscores if they appear. However, we only want
1983 * to skip up to two since that is the maximum number that can be used to
1984 * indicate variable inheritance. Any further underscores are part of the
1985 * variable name.
1986 */
1987 stripped_var = args.var + MIN(strspn(args.var, "_"), 2);
1988 varsubst = ast_alloca(strlen(stripped_var) + 4);
1989 sprintf(varsubst, "${%s}", stripped_var);
1990 ast_str_substitute_variables(&previous_value, 0, chan, varsubst);
1991
1992 if (!ast_str_strlen(previous_value)) {
1993 ast_str_set(&buf, 0, "%s", new_value);
1994 } else {
1995 ast_str_set(&buf, 0, "%s%c%s",
1996 beginning ? new_value : ast_str_buffer(previous_value),
1997 delimiter[0],
1998 beginning ? ast_str_buffer(previous_value) : new_value);
1999 }
2000
2002
2003 return 0;
2004#undef beginning
2005}
#define MIN(a, b)
Definition: utils.h:231

References args, ast_alloca, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_get_encoded_char(), ast_log, AST_STANDARD_APP_ARGS, ast_str_buffer(), ast_str_set(), ast_str_strlen(), ast_str_substitute_variables(), ast_str_thread_get(), ast_strlen_zero(), beginning, buf, LOG_WARNING, MIN, pbx_builtin_setvar_helper(), result_buf, tmp_buf, and var.

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "String handling dialplan functions" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 2495 of file func_strings.c.

◆ app_clearhash

char* app_clearhash = "ClearHash"
static

Definition at line 1308 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ array_function

struct ast_custom_function array_function
static
Initial value:
= {
.name = "ARRAY",
.write = array,
}

Definition at line 1590 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 2495 of file func_strings.c.

◆ csv_quote_function

struct ast_custom_function csv_quote_function
static
Initial value:
= {
.name = "CSV_QUOTE",
.read = csv_quote,
}
static int csv_quote(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 1664 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ eval_function

struct ast_custom_function eval_function
static
Initial value:
= {
.name = "EVAL",
.read = function_eval,
.read2 = function_eval2,
}
static int function_eval2(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t buflen)
static int function_eval(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

Definition at line 1789 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ fieldnum_function

struct ast_custom_function fieldnum_function
static
Initial value:
= {
.name = "FIELDNUM",
}
static int function_fieldnum_str(struct ast_channel *chan, const char *cmd, char *parse, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:760
static int function_fieldnum(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition: func_strings.c:754

Definition at line 766 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ fieldqty_function

struct ast_custom_function fieldqty_function
static
Initial value:
= {
.name = "FIELDQTY",
}
static int function_fieldqty_str(struct ast_channel *chan, const char *cmd, char *parse, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:681
static int function_fieldqty(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition: func_strings.c:675

Definition at line 687 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ filter_function

struct ast_custom_function filter_function
static
Initial value:
= {
.name = "FILTER",
.read = filter,
}
static int filter(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition: func_strings.c:899

Definition at line 975 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ hash_function

struct ast_custom_function hash_function
static
Initial value:
= {
.name = "HASH",
.write = hash_write,
.read = hash_read,
}
static int hash_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int hash_write(struct ast_channel *chan, const char *cmd, char *var, const char *value)

Definition at line 1578 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ hashkeys_function

struct ast_custom_function hashkeys_function
static
Initial value:
= {
.name = "HASHKEYS",
.read = hashkeys_read,
.read2 = hashkeys_read2,
}
static int hashkeys_read2(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)

Definition at line 1584 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ keypadhash_function

struct ast_custom_function keypadhash_function
static
Initial value:
= {
.name = "KEYPADHASH",
.read = keypadhash,
}
static int keypadhash(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

Definition at line 1830 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ len_function

struct ast_custom_function len_function
static
Initial value:
= {
.name = "LEN",
.read = len,
.read_max = 12,
}

Definition at line 1681 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ listfilter_function

struct ast_custom_function listfilter_function
static
Initial value:
= {
.name = "LISTFILTER",
.read = listfilter_read,
.read2 = listfilter_read2,
}
static int listfilter_read2(struct ast_channel *chan, const char *cmd, char *parse, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:888
static int listfilter_read(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition: func_strings.c:883

Definition at line 893 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ ltrim_function

struct ast_custom_function ltrim_function
static
Initial value:
= {
.name = "LTRIM",
.read = function_ltrim,
}
static int function_ltrim(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 1253 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ passthru_function

struct ast_custom_function passthru_function
static
Initial value:
= {
.name = "PASSTHRU",
.read2 = passthru,
}
static int passthru(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)

Definition at line 2023 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ pop_function

struct ast_custom_function pop_function
static
Initial value:
= {
.name = "POP",
.read2 = shift_pop,
}
static int shift_pop(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)

Definition at line 1948 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ push_function

struct ast_custom_function push_function
static
Initial value:
= {
.name = "PUSH",
.write = unshift_push,
}
static int unshift_push(struct ast_channel *chan, const char *cmd, char *data, const char *new_value)

Definition at line 2007 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ quote_function

struct ast_custom_function quote_function
static
Initial value:
= {
.name = "QUOTE",
.read = quote,
}
static int quote(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 1629 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ regex_function

struct ast_custom_function regex_function
static
Initial value:
= {
.name = "REGEX",
.read = regex,
}
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)

Definition at line 1300 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ replace_function

struct ast_custom_function replace_function
static
Initial value:
= {
.name = "REPLACE",
.read2 = replace,
}

Definition at line 1044 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ result_buf

struct ast_threadstorage result_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_result_buf , .custom_init = NULL , }
static

◆ rtrim_function

struct ast_custom_function rtrim_function
static
Initial value:
= {
.name = "RTRIM",
.read = function_rtrim,
}
static int function_rtrim(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 1258 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ shift_function

struct ast_custom_function shift_function
static
Initial value:
= {
.name = "SHIFT",
.read2 = shift_pop,
}

Definition at line 1943 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ strbetween_function

struct ast_custom_function strbetween_function
static
Initial value:
= {
.name = "STRBETWEEN",
.read2 = strbetween,
}
static int strbetween(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)

Definition at line 1180 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ strftime_function

struct ast_custom_function strftime_function
static
Initial value:
= {
.name = "STRFTIME",
.read = acf_strftime,
}
static int acf_strftime(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t buflen)

Definition at line 1716 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ strptime_function

struct ast_custom_function strptime_function
static
Initial value:
= {
.name = "STRPTIME",
.read = acf_strptime,
}
static int acf_strptime(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

Definition at line 1758 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ strreplace_function

struct ast_custom_function strreplace_function
static
Initial value:
= {
.name = "STRREPLACE",
.read2 = strreplace,
}
static int strreplace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)

Definition at line 1133 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ tmp_buf

struct ast_threadstorage tmp_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_tmp_buf , .custom_init = NULL , }
static

Definition at line 48 of file func_strings.c.

Referenced by ast_sip_security_mechanisms_to_str(), listfilter(), and unshift_push().

◆ tolower_function

struct ast_custom_function tolower_function
static
Initial value:
= {
.name = "TOLOWER",
.read = string_tolower,
.read2 = string_tolower2,
}
static int string_tolower(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int string_tolower2(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t buflen)

Definition at line 1887 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ toupper_function

struct ast_custom_function toupper_function
static
Initial value:
= {
.name = "TOUPPER",
.read = string_toupper,
.read2 = string_toupper2,
}
static int string_toupper(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)

Definition at line 1858 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ trim_function

struct ast_custom_function trim_function
static
Initial value:
= {
.name = "TRIM",
.read = function_trim,
}
static int function_trim(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 1248 of file func_strings.c.

Referenced by load_module(), and unload_module().

◆ unshift_function

struct ast_custom_function unshift_function
static
Initial value:
= {
.name = "UNSHIFT",
.write = unshift_push,
}

Definition at line 2012 of file func_strings.c.

Referenced by load_module(), and unload_module().