Asterisk - The Open Source Telephony Project GIT-master-7e7a603
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 1214 of file func_strings.c.

◆ HASH_PREFIX

#define HASH_PREFIX   "~HASH~%s~"

Definition at line 1213 of file func_strings.c.

◆ ltrim

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

Definition at line 1093 of file func_strings.c.

◆ rtrim

#define rtrim (   s)

Definition at line 1094 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.

540{

◆ __init_tmp_buf()

static void __init_tmp_buf ( void  )
static

Definition at line 48 of file func_strings.c.

540{

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 2393 of file func_strings.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 2393 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 1585 of file func_strings.c.

1587{
1589 AST_APP_ARG(epoch);
1590 AST_APP_ARG(timezone);
1591 AST_APP_ARG(format);
1592 );
1593 struct timeval when;
1594 struct ast_tm tm;
1595
1596 buf[0] = '\0';
1597
1599
1600 ast_get_timeval(args.epoch, &when, ast_tvnow(), NULL);
1601 ast_localtime(&when, &tm, args.timezone);
1602
1603 if (!args.format)
1604 args.format = "%c";
1605
1606 if (ast_strftime(buf, buflen, args.format, &tm) <= 0)
1607 ast_log(LOG_WARNING, "C function strftime() output nothing?!!\n");
1608
1609 buf[buflen - 1] = '\0';
1610
1611 return 0;
1612}
#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 1619 of file func_strings.c.

1621{
1623 AST_APP_ARG(timestring);
1624 AST_APP_ARG(timezone);
1625 AST_APP_ARG(format);
1626 );
1627 struct ast_tm tm;
1628
1629 buf[0] = '\0';
1630
1631 if (!data) {
1633 "Asterisk function STRPTIME() requires an argument.\n");
1634 return -1;
1635 }
1636
1638
1639 if (ast_strlen_zero(args.format)) {
1641 "No format supplied to STRPTIME(<timestring>,<timezone>,<format>)");
1642 return -1;
1643 }
1644
1645 if (!ast_strptime(args.timestring, args.format, &tm)) {
1646 ast_log(LOG_WARNING, "STRPTIME() found no time specified within the string\n");
1647 } else {
1648 struct timeval when;
1649 when = ast_mktime(&tm, args.timezone);
1650 snprintf(buf, buflen, "%d", (int) when.tv_sec);
1651 }
1652
1653 return 0;
1654}
#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 1240 of file func_strings.c.

1242{
1244 AST_APP_ARG(var)[100];
1245 );
1247 AST_APP_ARG(val)[100];
1248 );
1249 char *origvar = "", *value2, varname[256];
1250 int i, ishash = 0;
1251
1252 if (!var) {
1253 return -1;
1254 }
1255 value2 = ast_strdupa(value);
1256
1257 if (!strcmp(cmd, "HASH")) {
1258 const char *var2 = pbx_builtin_getvar_helper(chan, "~ODBCFIELDS~");
1259 origvar = var;
1260 if (var2)
1261 var = ast_strdupa(var2);
1262 else {
1263 if (chan)
1265 return -1;
1266 }
1267 ishash = 1;
1268 }
1269
1270 /* The functions this will generally be used with are SORT and ODBC_*, which
1271 * both return comma-delimited lists. However, if somebody uses literal lists,
1272 * their commas will be translated to vertical bars by the load, and I don't
1273 * want them to be surprised by the result. Hence, we prefer commas as the
1274 * delimiter, but we'll fall back to vertical bars if commas aren't found.
1275 */
1276 ast_debug(1, "array (%s=%s)\n", var, S_OR(value2, ""));
1278
1279 AST_STANDARD_APP_ARGS(arg2, value2);
1280
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) {
1285 if (ishash) {
1286 if (origvar[0] == '_') {
1287 if (origvar[1] == '_') {
1288 snprintf(varname, sizeof(varname), "__" HASH_FORMAT, origvar + 2, arg1.var[i]);
1289 } else {
1290 snprintf(varname, sizeof(varname), "_" HASH_FORMAT, origvar + 1, arg1.var[i]);
1291 }
1292 } else {
1293 snprintf(varname, sizeof(varname), HASH_FORMAT, origvar, arg1.var[i]);
1294 }
1295
1296 pbx_builtin_setvar_helper(chan, varname, arg2.val[i]);
1297 } else {
1298 pbx_builtin_setvar_helper(chan, arg1.var[i], arg2.val[i]);
1299 }
1300 } else {
1301 /* We could unset the variable, by passing a NULL, but due to
1302 * pushvar semantics, that could create some undesired behavior. */
1303 if (ishash) {
1304 snprintf(varname, sizeof(varname), HASH_FORMAT, origvar, arg1.var[i]);
1305 pbx_builtin_setvar_helper(chan, varname, "");
1306 } else {
1307 pbx_builtin_setvar_helper(chan, arg1.var[i], "");
1308 }
1309 }
1310 }
1311
1312 return 0;
1313}
#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 2393 of file func_strings.c.

◆ clearvar_prefix()

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

Definition at line 1219 of file func_strings.c.

1220{
1221 struct ast_var_t *var;
1222 int len = strlen(prefix);
1224 if (strncmp(prefix, ast_var_name(var), len) == 0) {
1226 ast_free(var);
1227 }
1228 }
1230}
#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::@211 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 1532 of file func_strings.c.

1533{
1534 char *bufptr = buf, *dataptr = data;
1535
1536 if (len < 3) { /* at least two for quotes and one for binary zero */
1537 ast_log(LOG_ERROR, "Not enough buffer\n");
1538 return -1;
1539 }
1540
1541 if (ast_strlen_zero(data)) {
1542 ast_copy_string(buf, "\"\"", len);
1543 return 0;
1544 }
1545
1546 *bufptr++ = '"';
1547 for (; bufptr < buf + len - 3; dataptr++){
1548 if (*dataptr == '"') {
1549 *bufptr++ = '"';
1550 *bufptr++ = '"';
1551 } else if (*dataptr == '\0') {
1552 break;
1553 } else {
1554 *bufptr++ = *dataptr;
1555 }
1556 }
1557 *bufptr++ = '"';
1558 *bufptr='\0';
1559 return 0;
1560}
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 1232 of file func_strings.c.

1233{
1234 char prefix[80];
1235 snprintf(prefix, sizeof(prefix), HASH_PREFIX, data ? (char *)data : "null");
1236 clearvar_prefix(chan, prefix);
1237 return 0;
1238}
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 807 of file func_strings.c.

809{
811 AST_APP_ARG(allowed);
812 AST_APP_ARG(string);
813 );
814 char *outbuf = buf;
815 unsigned char ac;
816 char allowed[256] = "";
817 size_t allowedlen = 0;
818 int32_t bitfield[8] = { 0, }; /* 256 bits */
819
821
822 if (!args.string) {
823 ast_log(LOG_ERROR, "Usage: FILTER(<allowed-chars>,<string>)\n");
824 return -1;
825 }
826
827 if (args.allowed[0] == '"' && !ast_opt_dont_warn) {
828 ast_log(LOG_WARNING, "FILTER allowed characters includes the quote (\") character. This may not be what you want.\n");
829 }
830
831 /* Expand ranges */
832 for (; *(args.allowed);) {
833 char c1 = 0, c2 = 0;
834 size_t consumed = 0;
835
836 if (ast_get_encoded_char(args.allowed, &c1, &consumed))
837 return -1;
838 args.allowed += consumed;
839
840 if (*(args.allowed) == '-') {
841 if (ast_get_encoded_char(args.allowed + 1, &c2, &consumed))
842 c2 = c1;
843 args.allowed += consumed + 1;
844
845 if ((unsigned char) c2 < (unsigned char) c1 && !ast_opt_dont_warn) {
846 ast_log(LOG_WARNING, "Range wrapping in FILTER(%s,%s). This may not be what you want.\n", parse, args.string);
847 }
848
849 /*!\note
850 * Looks a little strange, until you realize that we can overflow
851 * the size of a char.
852 */
853 for (ac = (unsigned char) c1; ac != (unsigned char) c2; ac++) {
854 bitfield[ac / 32] |= 1 << (ac % 32);
855 }
856 bitfield[ac / 32] |= 1 << (ac % 32);
857
858 ast_debug(4, "c1=%d, c2=%d\n", c1, c2);
859 } else {
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);
863 }
864 }
865
866 for (ac = 1; ac != 0; ac++) {
867 if (bitfield[ac / 32] & (1 << (ac % 32))) {
868 allowed[allowedlen++] = ac;
869 }
870 }
871
872 ast_debug(1, "Allowed: %s\n", allowed);
873
874 for (; *(args.string) && (buf + len - 1 > outbuf); (args.string)++) {
875 if (strchr(allowed, *(args.string)))
876 *outbuf++ = *(args.string);
877 }
878 *outbuf = '\0';
879
880 return 0;
881}
int int32_t
Definition: db.h:60
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:3077
#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 1661 of file func_strings.c.

1663{
1664 if (ast_strlen_zero(data)) {
1665 ast_log(LOG_WARNING, "EVAL requires an argument: EVAL(<string>)\n");
1666 return -1;
1667 }
1668
1669 pbx_substitute_variables_helper(chan, data, buf, buflen - 1);
1670
1671 return 0;
1672}
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 1674 of file func_strings.c.

1676{
1677 if (ast_strlen_zero(data)) {
1678 ast_log(LOG_WARNING, "EVAL requires an argument: EVAL(<string>)\n");
1679 return -1;
1680 }
1681
1682 ast_str_substitute_variables(buf, buflen, chan, data);
1683
1684 return 0;
1685}
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 662 of file func_strings.c.

664{
665 return function_fieldnum_helper(chan, cmd, parse, buf, NULL, len);
666}
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:601

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 601 of file func_strings.c.

603{
604 char *varsubst, *field;
606 int fieldindex = 0, res = 0;
608 AST_APP_ARG(varname);
609 AST_APP_ARG(delim);
610 AST_APP_ARG(field);
611 );
612 char delim[2] = "";
613 size_t delim_used;
614
615 if (!str) {
616 return -1;
617 }
618
620
621 if (args.argc < 3) {
622 ast_log(LOG_ERROR, "Usage: FIELDNUM(<listname>,<delimiter>,<fieldvalue>)\n");
623 res = -1;
624 } else {
625 varsubst = ast_alloca(strlen(args.varname) + 4);
626 sprintf(varsubst, "${%s}", args.varname);
627
628 ast_str_substitute_variables(&str, 0, chan, varsubst);
629
630 if (ast_str_strlen(str) == 0 || ast_strlen_zero(args.delim)) {
631 fieldindex = 0;
632 } else if (ast_get_encoded_char(args.delim, delim, &delim_used) == -1) {
633 res = -1;
634 } else {
635 char *varval = ast_str_buffer(str);
636
637 while ((field = strsep(&varval, delim)) != NULL) {
638 fieldindex++;
639
640 if (!strcasecmp(field, args.field)) {
641 break;
642 }
643 }
644
645 if (!field) {
646 fieldindex = 0;
647 }
648
649 res = 0;
650 }
651 }
652
653 if (sbuf) {
654 ast_str_set(sbuf, len, "%d", fieldindex);
655 } else {
656 snprintf(buf, len, "%d", fieldindex);
657 }
658
659 return res;
660}
const char * str
Definition: app_jack.c:147
#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 * strsep(char **str, const char *delims)
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 668 of file func_strings.c.

670{
671 return function_fieldnum_helper(chan, cmd, parse, NULL, buf, len);
672}

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 583 of file func_strings.c.

585{
586 return function_fieldqty_helper(chan, cmd, parse, buf, NULL, len);
587}
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:538

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 538 of file func_strings.c.

540{
541 char *varsubst;
543 int fieldcount = 0;
545 AST_APP_ARG(varname);
546 AST_APP_ARG(delim);
547 );
548 char delim[2] = "";
549 size_t delim_used;
550
551 if (!str) {
552 return -1;
553 }
554
556 if (args.delim) {
557 ast_get_encoded_char(args.delim, delim, &delim_used);
558
559 varsubst = ast_alloca(strlen(args.varname) + 4);
560
561 sprintf(varsubst, "${%s}", args.varname);
562 ast_str_substitute_variables(&str, 0, chan, varsubst);
563 if (ast_str_strlen(str) == 0) {
564 fieldcount = 0;
565 } else {
566 char *varval = ast_str_buffer(str);
567 while (strsep(&varval, delim)) {
568 fieldcount++;
569 }
570 }
571 } else {
572 fieldcount = 1;
573 }
574 if (sbuf) {
575 ast_str_set(sbuf, len, "%d", fieldcount);
576 } else {
577 snprintf(buf, len, "%d", fieldcount);
578 }
579
580 return 0;
581}

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 589 of file func_strings.c.

591{
592 return function_fieldqty_helper(chan, cmd, parse, NULL, buf, len);
593}

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 1121 of file func_strings.c.

1122{
1123 char *c;
1124
1125 if (ast_strlen_zero(data)) {
1126 return -1;
1127 }
1128
1129 c = data;
1130 ltrim(c);
1131
1133
1134 return 0;
1135}
#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 1137 of file func_strings.c.

1138{
1139 char *c;
1140
1141 if (ast_strlen_zero(data)) {
1142 return -1;
1143 }
1144
1145 c = ast_strdupa(data);
1146 rtrim(c);
1147
1149
1150 return 0;
1151}
#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 1104 of file func_strings.c.

1105{
1106 char *c;
1107
1108 if (ast_strlen_zero(data)) {
1109 return -1;
1110 }
1111
1112 c = ast_strdupa(data);
1113 ltrim(c);
1114 rtrim(c);
1115
1117
1118 return 0;
1119}

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 1315 of file func_strings.c.

1316{
1317 const char *prefix_name = ast_str_buffer(prefix);
1318 const char *var_name = ast_var_name(var);
1319 int prefix_len;
1320 int var_len;
1321
1322 if (ast_strlen_zero(var_name)) {
1323 return NULL;
1324 }
1325
1326 prefix_len = ast_str_strlen(prefix);
1327 var_len = strlen(var_name);
1328
1329 /*
1330 * Make sure we only match on non-empty, hash function created keys. If valid
1331 * then return a pointer to the variable that's just after the prefix.
1332 */
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;
1335}

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 1425 of file func_strings.c.

1426{
1427 char varname[256];
1428 const char *varvalue;
1430 AST_APP_ARG(hashname);
1431 AST_APP_ARG(hashkey);
1432 );
1433
1434 AST_STANDARD_APP_ARGS(arg, data);
1435 if (arg.argc == 2) {
1436 snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg.hashkey);
1437 varvalue = pbx_builtin_getvar_helper(chan, varname);
1438 if (varvalue)
1439 ast_copy_string(buf, varvalue, len);
1440 else
1441 *buf = '\0';
1442 } else if (arg.argc == 1) {
1443 char colnames[4096];
1444 int i;
1446 AST_APP_ARG(col)[100];
1447 );
1448
1449 if (!chan) {
1450 ast_log(LOG_WARNING, "No channel and only 1 parameter was provided to %s function.\n", cmd);
1451 return -1;
1452 }
1453
1454 /* Get column names, in no particular order */
1455 hashkeys_read(chan, "HASHKEYS", arg.hashname, colnames, sizeof(colnames));
1456 pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", colnames);
1457
1458 AST_STANDARD_APP_ARGS(arg2, colnames);
1459 *buf = '\0';
1460
1461 /* Now get the corresponding column values, in exactly the same order */
1462 for (i = 0; i < arg2.argc; i++) {
1463 snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg2.col[i]);
1464 varvalue = pbx_builtin_getvar_helper(chan, varname);
1465 strncat(buf, varvalue, len - strlen(buf) - 1);
1466 strncat(buf, ",", len - strlen(buf) - 1);
1467 }
1468
1469 /* Strip trailing comma */
1470 buf[strlen(buf) - 1] = '\0';
1471 }
1472
1473 return 0;
1474}
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 1397 of file func_strings.c.

1398{
1399 char varname[256];
1401 AST_APP_ARG(hashname);
1402 AST_APP_ARG(hashkey);
1403 );
1404
1405 if (!strchr(var, ',')) {
1406 /* Single argument version */
1407 return array(chan, "HASH", var, value);
1408 }
1409
1411 if (arg.hashname[0] == '_') {
1412 if (arg.hashname[1] == '_') {
1413 snprintf(varname, sizeof(varname), "__" HASH_FORMAT, arg.hashname + 2, arg.hashkey);
1414 } else {
1415 snprintf(varname, sizeof(varname), "_" HASH_FORMAT, arg.hashname + 1, arg.hashkey);
1416 }
1417 } else {
1418 snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg.hashkey);
1419 }
1420 pbx_builtin_setvar_helper(chan, varname, value);
1421
1422 return 0;
1423}
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 1337 of file func_strings.c.

1338{
1339 struct ast_var_t *newvar;
1340 struct ast_str *prefix = ast_str_alloca(80);
1341 size_t buf_len;
1342
1343 if (!chan) {
1344 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1345 return -1;
1346 }
1347
1348 ast_str_set(&prefix, -1, HASH_PREFIX, data);
1349 memset(buf, 0, len);
1350
1351 AST_LIST_TRAVERSE(ast_channel_varshead(chan), newvar, entries) {
1352 const char *key = get_key(prefix, newvar);
1353
1354 if (key) {
1355 strncat(buf, key, len - strlen(buf) - 1);
1356 /* Replace the trailing ~ */
1357 buf[strlen(buf) - 1] = ',';
1358 }
1359 }
1360 /* Trim the trailing comma */
1361 buf_len = strlen(buf);
1362 if (buf_len) {
1363 buf[buf_len - 1] = '\0';
1364 }
1365 return 0;
1366}
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 1368 of file func_strings.c.

1369{
1370 struct ast_var_t *newvar;
1371 struct ast_str *prefix = ast_str_alloca(80);
1372
1373 if (!chan) {
1374 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1375 return -1;
1376 }
1377
1378 ast_str_set(&prefix, -1, HASH_PREFIX, data);
1379
1380 AST_LIST_TRAVERSE(ast_channel_varshead(chan), newvar, entries) {
1381 const char *key = get_key(prefix, newvar);
1382
1383 if (key) {
1384 char *tmp;
1385
1386 ast_str_append(buf, len, "%s", key);
1387 /* Replace the trailing ~ */
1389 tmp[ast_str_strlen(*buf) - 1] = ',';
1390 }
1391 }
1392
1393 ast_str_truncate(*buf, -1);
1394 return 0;
1395}
static int tmp()
Definition: bt_open.c:389
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, prefix, and tmp().

◆ keypadhash()

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

Definition at line 1693 of file func_strings.c.

1694{
1695 char *bufptr, *dataptr;
1696
1697 for (bufptr = buf, dataptr = data; bufptr < buf + buflen - 1; dataptr++) {
1698 if (*dataptr == '\0') {
1699 *bufptr++ = '\0';
1700 break;
1701 } else if (*dataptr == '1') {
1702 *bufptr++ = '1';
1703 } else if (strchr("AaBbCc2", *dataptr)) {
1704 *bufptr++ = '2';
1705 } else if (strchr("DdEeFf3", *dataptr)) {
1706 *bufptr++ = '3';
1707 } else if (strchr("GgHhIi4", *dataptr)) {
1708 *bufptr++ = '4';
1709 } else if (strchr("JjKkLl5", *dataptr)) {
1710 *bufptr++ = '5';
1711 } else if (strchr("MmNnOo6", *dataptr)) {
1712 *bufptr++ = '6';
1713 } else if (strchr("PpQqRrSs7", *dataptr)) {
1714 *bufptr++ = '7';
1715 } else if (strchr("TtUuVv8", *dataptr)) {
1716 *bufptr++ = '8';
1717 } else if (strchr("WwXxYyZz9", *dataptr)) {
1718 *bufptr++ = '9';
1719 } else if (*dataptr == '0') {
1720 *bufptr++ = '0';
1721 }
1722 }
1723 buf[buflen - 1] = '\0';
1724
1725 return 0;
1726}

References buf.

◆ len()

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

Definition at line 1567 of file func_strings.c.

1568{
1569 int length = 0;
1570
1571 if (data)
1572 length = strlen(data);
1573
1574 snprintf(buf, buflen, "%d", length);
1575
1576 return 0;
1577}

References buf.

Referenced by __analog_ss_thread(), __ast_cli_register(), __ast_cli_register_multiple(), __ast_dsp_call_progress(), __ast_dsp_silence_noise(), __ast_frdup(), __big_return(), __bt_defcmp(), __bt_defpfx(), __call_hash(), OrderedDict::__eq__(), OrderedDict::__init__(), __rec_fmap(), __rec_fpipe(), __rec_vpipe(), __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_audiosocket_receive_frame(), 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_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(), 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(), collect_data(), collect_key(), 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(), 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(), dbm_open(), 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(), expand_gosub_args(), expr2_token_subst(), ext_cmp_exten_strlen(), ext_strncpy(), 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_characters(), 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(), hashfunc(), 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(), init_stmt(), 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 680 of file func_strings.c.

681{
683 AST_APP_ARG(listname);
684 AST_APP_ARG(delimiter);
685 AST_APP_ARG(fieldvalue);
686 );
687 struct ast_str *orig_list = ast_str_thread_get(&tmp_buf, 16);
688 const char *begin, *cur, *next;
689 int dlen, flen, first = 1;
690 struct ast_str *result, **result_ptr = &result;
691 char *delim, *varsubst;
692
694
695 if (buf) {
696 if (!(result = ast_str_thread_get(&result_buf, 16))) {
697 return -1;
698 }
699 } else {
700 /* Place the result directly into the output buffer */
701 result_ptr = bufstr;
702 }
703
704 if (args.argc < 3) {
705 ast_log(LOG_ERROR, "Usage: LISTFILTER(<listname>,<delimiter>,<fieldvalue>)\n");
706 return -1;
707 }
708
709 varsubst = ast_alloca(strlen(args.listname) + 4);
710 sprintf(varsubst, "${%s}", args.listname);
711
712 /* If we don't lock the channel, the variable could disappear out from underneath us. */
713 if (chan) {
714 ast_channel_lock(chan);
715 }
716 ast_str_substitute_variables(&orig_list, 0, chan, varsubst);
717 if (!ast_str_strlen(orig_list)) {
718 if (chan) {
719 ast_channel_unlock(chan);
720 }
721 return -1;
722 }
723
724 /* If the string isn't there, just copy out the string and be done with it. */
725 if (!strstr(ast_str_buffer(orig_list), args.fieldvalue)) {
726 if (buf) {
728 } else {
729 ast_str_set(result_ptr, len, "%s", ast_str_buffer(orig_list));
730 }
731 if (chan) {
732 ast_channel_unlock(chan);
733 }
734 return 0;
735 }
736
737 dlen = strlen(args.delimiter);
738 delim = ast_alloca(dlen + 1);
739 ast_get_encoded_str(args.delimiter, delim, dlen + 1);
740
741 if ((dlen = strlen(delim)) == 0) {
742 delim = ",";
743 dlen = 1;
744 }
745
746 flen = strlen(args.fieldvalue);
747
748 ast_str_reset(*result_ptr);
749 /* Enough space for any result */
750 if (len > -1) {
751 ast_str_make_space(result_ptr, len ? len : ast_str_strlen(orig_list) + 1);
752 }
753
754 begin = ast_str_buffer(orig_list);
755 next = strstr(begin, delim);
756
757 do {
758 /* Find next boundary */
759 if (next) {
760 cur = next;
761 next = strstr(cur + dlen, delim);
762 } else {
763 cur = strchr(begin + dlen, '\0');
764 }
765
766 if (flen == cur - begin && !strncmp(begin, args.fieldvalue, flen)) {
767 /* Skip field */
768 begin += flen + dlen;
769 } else {
770 /* Copy field to output */
771 if (!first) {
772 ast_str_append(result_ptr, len, "%s", delim);
773 }
774
775 ast_str_append_substr(result_ptr, len, begin, cur - begin);
776 first = 0;
777 begin = cur + dlen;
778 }
779 } while (*cur != '\0');
780 if (chan) {
781 ast_channel_unlock(chan);
782 }
783
784 if (buf) {
786 }
787
788 return 0;
789}
struct sla_ringing_trunk * first
Definition: app_sla.c:332
static PGresult * result
Definition: cel_pgsql.c:84
#define ast_channel_lock(chan)
Definition: channel.h:2922
#define ast_channel_unlock(chan)
Definition: channel.h:2923
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:3152
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 791 of file func_strings.c.

792{
793 return listfilter(chan, cmd, parse, buf, NULL, len);
794}
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:680

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 796 of file func_strings.c.

797{
798 return listfilter(chan, cmd, parse, NULL, buf, len);
799}

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

◆ load_module()

static int load_module ( void  )
static

Definition at line 2350 of file func_strings.c.

2351{
2352 int res = 0;
2353
2354 AST_TEST_REGISTER(test_FIELDNUM);
2355 AST_TEST_REGISTER(test_REPLACE);
2356 AST_TEST_REGISTER(test_FILTER);
2357 AST_TEST_REGISTER(test_STRREPLACE);
2358 AST_TEST_REGISTER(test_STRBETWEEN);
2359 AST_TEST_REGISTER(test_TRIM);
2389
2390 return res;
2391}
static struct ast_custom_function fieldqty_function
Definition: func_strings.c:595
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:674
static struct ast_custom_function filter_function
Definition: func_strings.c:883
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
Definition: func_strings.c:952
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:801
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:626
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1558
#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 1915 of file func_strings.c.

1916{
1917 ast_str_set(buf, len, "%s", data);
1918 return 0;
1919}

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 1493 of file func_strings.c.

1494{
1495 char *bufptr = buf, *dataptr = data;
1496
1497 if (len < 3){ /* at least two for quotes and one for binary zero */
1498 ast_log(LOG_ERROR, "Not enough buffer\n");
1499 return -1;
1500 }
1501
1502 if (ast_strlen_zero(data)) {
1503 ast_log(LOG_WARNING, "No argument specified!\n");
1504 ast_copy_string(buf, "\"\"", len);
1505 return 0;
1506 }
1507
1508 *bufptr++ = '"';
1509 for (; bufptr < buf + len - 3; dataptr++) {
1510 if (*dataptr == '\\') {
1511 *bufptr++ = '\\';
1512 *bufptr++ = '\\';
1513 } else if (*dataptr == '"') {
1514 *bufptr++ = '\\';
1515 *bufptr++ = '"';
1516 } else if (*dataptr == '\0') {
1517 break;
1518 } else {
1519 *bufptr++ = *dataptr;
1520 }
1521 }
1522 *bufptr++ = '"';
1523 *bufptr = '\0';
1524 return 0;
1525}

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 1171 of file func_strings.c.

1173{
1175 AST_APP_ARG(null);
1176 AST_APP_ARG(reg);
1178 );
1179 int errcode;
1180 regex_t regexbuf;
1181
1182 buf[0] = '\0';
1183
1184 AST_NONSTANDARD_APP_ARGS(args, parse, '"');
1185
1186 if (args.argc != 3) {
1187 ast_log(LOG_ERROR, "Unexpected arguments: should have been in the form '\"<regex>\" <string>'\n");
1188 return -1;
1189 }
1190 if ((*args.str == ' ') || (*args.str == '\t'))
1191 args.str++;
1192
1193 ast_debug(1, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str);
1194
1195 if ((errcode = regcomp(&regexbuf, args.reg, REG_EXTENDED | REG_NOSUB))) {
1196 regerror(errcode, &regexbuf, buf, len);
1197 ast_log(LOG_WARNING, "Malformed input %s(%s): %s\n", cmd, parse, buf);
1198 return -1;
1199 }
1200
1201 strcpy(buf, regexec(&regexbuf, args.str, 0, NULL, 0) ? "0" : "1");
1202
1203 regfree(&regexbuf);
1204
1205 return 0;
1206}
#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 888 of file func_strings.c.

889{
891 AST_APP_ARG(varname);
892 AST_APP_ARG(find);
894 );
895 char *strptr, *varsubst;
896 RAII_VAR(struct ast_str *, str, ast_str_create(16), ast_free);
897 char find[256]; /* Only 256 characters possible */
898 char replace[2] = "";
899 size_t unused;
900
902
903 if (!str) {
904 return -1;
905 }
906
907 if (args.argc < 2) {
908 ast_log(LOG_ERROR, "Usage: %s(<varname>,<search-chars>[,<replace-char>])\n", cmd);
909 return -1;
910 }
911
912 /* Decode escapes */
913 ast_get_encoded_str(args.find, find, sizeof(find));
914 ast_get_encoded_char(args.replace, replace, &unused);
915
916 if (ast_strlen_zero(find) || ast_strlen_zero(args.varname)) {
917 ast_log(LOG_ERROR, "The characters to search for and the variable name must not be empty.\n");
918 return -1;
919 }
920
921 varsubst = ast_alloca(strlen(args.varname) + 4);
922 sprintf(varsubst, "${%s}", args.varname);
923 ast_str_substitute_variables(&str, 0, chan, varsubst);
924
925 if (!ast_str_strlen(str)) {
926 /* Blank, nothing to replace */
927 return -1;
928 }
929
930 ast_debug(3, "String to search: (%s)\n", ast_str_buffer(str));
931 ast_debug(3, "Characters to find: (%s)\n", find);
932 ast_debug(3, "Character to replace with: (%s)\n", replace);
933
934 for (strptr = ast_str_buffer(str); *strptr; strptr++) {
935 /* buf is already a mutable buffer, so we construct the result
936 * directly there */
937 if (strchr(find, *strptr)) {
939 memmove(strptr, strptr + 1, strlen(strptr + 1) + 1);
940 strptr--;
941 } else {
942 /* Replace character */
943 *strptr = *replace;
944 }
945 }
946 }
947
949 return 0;
950}
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:888
#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(), 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 1791 of file func_strings.c.

1792{
1793#define beginning (cmd[0] == 'S') /* SHIFT */
1794 char *after, delimiter[2] = ",", *varsubst;
1795 size_t unused;
1796 struct ast_str *before = ast_str_thread_get(&result_buf, 16);
1797 char *(*search_func)(const char *s, int c) = (beginning ? strchr : strrchr);
1800 AST_APP_ARG(delimiter);
1801 );
1802
1803 if (!before) {
1804 return -1;
1805 }
1806
1808
1809 if (ast_strlen_zero(args.var)) {
1810 ast_log(LOG_WARNING, "%s requires a variable name\n", cmd);
1811 return -1;
1812 }
1813
1814 varsubst = ast_alloca(strlen(args.var) + 4);
1815 sprintf(varsubst, "${%s}", args.var);
1816 ast_str_substitute_variables(&before, 0, chan, varsubst);
1817
1818 if (args.argc > 1 && !ast_strlen_zero(args.delimiter)) {
1819 ast_get_encoded_char(args.delimiter, delimiter, &unused);
1820 }
1821
1822 if (!ast_str_strlen(before)) {
1823 /* Nothing to pop */
1824 return -1;
1825 }
1826
1827 if (!(after = search_func(ast_str_buffer(before), delimiter[0]))) {
1828 /* Only one entry in array */
1829 ast_str_set(buf, len, "%s", ast_str_buffer(before));
1830 pbx_builtin_setvar_helper(chan, args.var, "");
1831 } else {
1832 *after++ = '\0';
1833 ast_str_set(buf, len, "%s", beginning ? ast_str_buffer(before) : after);
1834 pbx_builtin_setvar_helper(chan, args.var, beginning ? after : ast_str_buffer(before));
1835 }
1836
1837 return 0;
1838#undef beginning
1839}
#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 1046 of file func_strings.c.

1047{
1048 int c, origsize;
1049 char *varsubstr, *origstr;
1050 struct ast_str *str = ast_str_thread_get(&result_buf, 16); /* Holds the data obtained from varname */
1051
1053 AST_APP_ARG(varname);
1054 AST_APP_ARG(insert_string);
1055 AST_APP_ARG(other); /* Any remining unused arguments */
1056 );
1057
1059
1060 if (!str) {
1061 ast_log(LOG_ERROR, "Couldn't obtain string\n");
1062 return -1;
1063 }
1064
1066
1067 if (args.argc != 2 || ast_strlen_zero(args.varname)) {
1068 ast_log(LOG_ERROR, "Usage: %s(<varname>,<insert-string>)\n", cmd);
1069 return -1;
1070 }
1071
1072 varsubstr = ast_alloca(strlen(args.varname) + 4);
1073 sprintf(varsubstr, "${%s}", args.varname);
1074 ast_str_substitute_variables(&str, 0, chan, varsubstr);
1075 origstr = ast_str_buffer(str);
1076 origsize = strlen(origstr);
1077 for (c = 0; c < origsize; c++) {
1078 ast_str_append(buf, len, "%c", origstr[c]);
1079 /* no insert after the last character */
1080 if (c < (origsize - 1)) {
1081 ast_str_append(buf, len, "%s", args.insert_string);
1082 }
1083 }
1084
1085 return 0;
1086}

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 1762 of file func_strings.c.

1763{
1764 char *bufptr = buf, *dataptr = data;
1765
1766 while ((bufptr < buf + buflen - 1) && (*bufptr++ = tolower(*dataptr++)));
1767
1768 return 0;
1769}

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 1771 of file func_strings.c.

1772{
1773 char *bufptr, *dataptr = data;
1774
1775 if (buflen > -1) {
1776 ast_str_make_space(buf, buflen > 0 ? buflen : strlen(data) + 1);
1777 }
1778 bufptr = ast_str_buffer(*buf);
1779 while ((bufptr < ast_str_buffer(*buf) + ast_str_size(*buf) - 1) && (*bufptr++ = tolower(*dataptr++)));
1781
1782 return 0;
1783}
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 1733 of file func_strings.c.

1734{
1735 char *bufptr = buf, *dataptr = data;
1736
1737 while ((bufptr < buf + buflen - 1) && (*bufptr++ = toupper(*dataptr++)));
1738
1739 return 0;
1740}

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 1742 of file func_strings.c.

1743{
1744 char *bufptr, *dataptr = data;
1745
1746 if (buflen > -1) {
1747 ast_str_make_space(buf, buflen > 0 ? buflen : strlen(data) + 1);
1748 }
1749 bufptr = ast_str_buffer(*buf);
1750 while ((bufptr < ast_str_buffer(*buf) + ast_str_size(*buf) - 1) && (*bufptr++ = toupper(*dataptr++)));
1752
1753 return 0;
1754}

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 957 of file func_strings.c.

958{
959 char *varsubstr; /* substring for input var */
960 char *start; /* Starting pos of substring search. */
961 char *end; /* Ending pos of substring search. */
962 int find_size; /* length of given find-string */
963 unsigned max_matches; /* number of matches we find before terminating search */
964 unsigned count; /* loop counter */
965 struct ast_str *str = ast_str_thread_get(&result_buf, 16); /* Holds the data obtained from varname */
966
968 AST_APP_ARG(varname);
969 AST_APP_ARG(find_string);
970 AST_APP_ARG(replace_string);
971 AST_APP_ARG(max_replacements);
972 AST_APP_ARG(other); /* Any remining unused arguments */
973 );
974
975 /* Guarantee output string is empty to start with. */
977
978 if (!str) {
979 /* We failed to allocate str, forget it. We failed. */
980 return -1;
981 }
982
983 /* Parse the arguments. */
985
986 if (args.argc < 2) {
987 /* Didn't receive enough arguments to do anything */
989 "Usage: %s(<varname>,<find-string>[,<replace-string>,[<max-replacements>]])\n",
990 cmd);
991 return -1;
992 }
993
994 /* No var name specified. Return failure, string is already empty. */
995 if (ast_strlen_zero(args.varname)) {
996 return -1;
997 }
998
999 /* Zero length find strings are a no-no. Kill the function if we run into one. */
1000 if (ast_strlen_zero(args.find_string)) {
1001 ast_log(LOG_ERROR, "No <find-string> specified\n");
1002 return -1;
1003 }
1004 find_size = strlen(args.find_string);
1005
1006 /* set varsubstr to the matching variable */
1007 varsubstr = ast_alloca(strlen(args.varname) + 4);
1008 sprintf(varsubstr, "${%s}", args.varname);
1009 ast_str_substitute_variables(&str, 0, chan, varsubstr);
1010
1011 /* Determine how many replacements are allowed. */
1012 if (!args.max_replacements
1013 || (max_matches = atoi(args.max_replacements)) <= 0) {
1014 /* Unlimited replacements are allowed. */
1015 max_matches = -1;
1016 }
1017
1018 /* Generate the search and replaced string. */
1019 start = ast_str_buffer(str);
1020 for (count = 0; count < max_matches; ++count) {
1021 end = strstr(start, args.find_string);
1022 if (!end) {
1023 /* Did not find a matching substring in the remainder. */
1024 break;
1025 }
1026
1027 /* Replace the found substring. */
1028 *end = '\0';
1029 ast_str_append(buf, len, "%s", start);
1030 if (args.replace_string) {
1031 /* Append the replacement string */
1032 ast_str_append(buf, len, "%s", args.replace_string);
1033 }
1034 start = end + find_size;
1035 }
1036 ast_str_append(buf, len, "%s", start);
1037
1038 return 0;
1039}
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 2307 of file func_strings.c.

2308{
2309 int res = 0;
2310
2311 AST_TEST_UNREGISTER(test_FIELDNUM);
2312 AST_TEST_UNREGISTER(test_REPLACE);
2313 AST_TEST_UNREGISTER(test_FILTER);
2314 AST_TEST_UNREGISTER(test_STRREPLACE);
2315 AST_TEST_UNREGISTER(test_STRBETWEEN);
2316 AST_TEST_UNREGISTER(test_TRIM);
2346
2347 return res;
2348}
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 1851 of file func_strings.c.

1852{
1853#define beginning (cmd[0] == 'U') /* UNSHIFT */
1854 char delimiter[2] = ",", *varsubst;
1855 size_t unused;
1856 struct ast_str *buf, *previous_value;
1859 AST_APP_ARG(delimiter);
1860 );
1861 const char *stripped_var;
1862
1863 if (!(buf = ast_str_thread_get(&result_buf, 16)) ||
1864 !(previous_value = ast_str_thread_get(&tmp_buf, 16))) {
1865 return -1;
1866 }
1867
1869
1870 if (ast_strlen_zero(args.var)) {
1871 ast_log(LOG_WARNING, "%s requires a variable name\n", cmd);
1872 return -1;
1873 }
1874
1875 if (args.argc > 1 && !ast_strlen_zero(args.delimiter)) {
1876 ast_get_encoded_char(args.delimiter, delimiter, &unused);
1877 }
1878
1879 /* UNSHIFT and PUSH act as ways of setting a variable, so we need to be
1880 * sure to skip leading underscores if they appear. However, we only want
1881 * to skip up to two since that is the maximum number that can be used to
1882 * indicate variable inheritance. Any further underscores are part of the
1883 * variable name.
1884 */
1885 stripped_var = args.var + MIN(strspn(args.var, "_"), 2);
1886 varsubst = ast_alloca(strlen(stripped_var) + 4);
1887 sprintf(varsubst, "${%s}", stripped_var);
1888 ast_str_substitute_variables(&previous_value, 0, chan, varsubst);
1889
1890 if (!ast_str_strlen(previous_value)) {
1891 ast_str_set(&buf, 0, "%s", new_value);
1892 } else {
1893 ast_str_set(&buf, 0, "%s%c%s",
1894 beginning ? new_value : ast_str_buffer(previous_value),
1895 delimiter[0],
1896 beginning ? ast_str_buffer(previous_value) : new_value);
1897 }
1898
1900
1901 return 0;
1902#undef beginning
1903}
#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 2393 of file func_strings.c.

◆ app_clearhash

char* app_clearhash = "ClearHash"
static

Definition at line 1216 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 1488 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 2393 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 1562 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 1687 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:668
static int function_fieldnum(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition: func_strings.c:662

Definition at line 674 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:589
static int function_fieldqty(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition: func_strings.c:583

Definition at line 595 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:807

Definition at line 883 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 1476 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 1482 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 1728 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 1579 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:796
static int listfilter_read(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition: func_strings.c:791

Definition at line 801 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 1161 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 1921 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 1846 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 1905 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 1527 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 1208 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 952 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 1166 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 1841 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 1088 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 1614 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 1656 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: func_strings.c:957

Definition at line 1041 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 1785 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 1756 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 1156 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 1910 of file func_strings.c.

Referenced by load_module(), and unload_module().