Wed Jan 8 2020 09:50:13

Asterisk developer's documentation


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"

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~"
 

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)
 
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 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 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 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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
 
static char * app_clearhash = "ClearHash"
 
static struct ast_custom_function array_function
 
static 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 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 shift_function
 
static struct ast_custom_function strftime_function
 
static struct ast_custom_function strptime_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 unshift_function
 

Detailed Description

String manipulation dialplan functions.

Author
Tilghman Lesher
Anothony Minessale II

Definition in file func_strings.c.

Macro Definition Documentation

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

Referenced by shift_pop(), and unshift_push().

#define beginning   (cmd[0] == 'U') /* UNSHIFT */
#define HASH_FORMAT   HASH_PREFIX "%s~"

Definition at line 887 of file func_strings.c.

Referenced by array(), hash_read(), and hash_write().

#define HASH_PREFIX   "~HASH~%s~"

Definition at line 886 of file func_strings.c.

Referenced by exec_clearhash(), hashkeys_read(), and hashkeys_read2().

Function Documentation

static void __init_result_buf ( void  )
static

Definition at line 47 of file func_strings.c.

426 {
static void __init_tmp_buf ( void  )
static

Definition at line 48 of file func_strings.c.

426 {
static void __reg_module ( void  )
static

Definition at line 1820 of file func_strings.c.

static void __unreg_module ( void  )
static

Definition at line 1820 of file func_strings.c.

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

Definition at line 1230 of file func_strings.c.

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

1232 {
1234  AST_APP_ARG(epoch);
1235  AST_APP_ARG(timezone);
1237  );
1238  struct timeval when;
1239  struct ast_tm tm;
1240 
1241  buf[0] = '\0';
1242 
1244 
1245  ast_get_timeval(args.epoch, &when, ast_tvnow(), NULL);
1246  ast_localtime(&when, &tm, args.timezone);
1247 
1248  if (!args.format)
1249  args.format = "%c";
1250 
1251  if (ast_strftime(buf, buflen, args.format, &tm) <= 0)
1252  ast_log(LOG_WARNING, "C function strftime() output nothing?!!\n");
1253 
1254  buf[buflen - 1] = '\0';
1255 
1256  return 0;
1257 }
#define LOG_WARNING
Definition: logger.h:144
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:1570
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int ast_get_timeval(const char *src, struct timeval *tv, struct timeval _default, int *consumed)
get values from config variables.
Definition: utils.c:2091
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
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:2351
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static snd_pcm_format_t format
Definition: chan_alsa.c:93
static int acf_strptime ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  buflen 
)
static

Definition at line 1264 of file func_strings.c.

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

1266 {
1268  AST_APP_ARG(timestring);
1269  AST_APP_ARG(timezone);
1271  );
1272  struct ast_tm tm;
1273 
1274  buf[0] = '\0';
1275 
1276  if (!data) {
1278  "Asterisk function STRPTIME() requires an argument.\n");
1279  return -1;
1280  }
1281 
1282  AST_STANDARD_APP_ARGS(args, data);
1283 
1284  if (ast_strlen_zero(args.format)) {
1286  "No format supplied to STRPTIME(<timestring>,<timezone>,<format>)");
1287  return -1;
1288  }
1289 
1290  if (!ast_strptime(args.timestring, args.format, &tm)) {
1291  ast_log(LOG_WARNING, "STRPTIME() found no time specified within the string\n");
1292  } else {
1293  struct timeval when;
1294  when = ast_mktime(&tm, args.timezone);
1295  snprintf(buf, buflen, "%d", (int) when.tv_sec);
1296  }
1297 
1298  return 0;
1299 }
#define LOG_WARNING
Definition: logger.h:144
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
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. Also, unlike strptime(3), ast_strptime() initializes its memory prior to use.
Definition: localtime.c:2377
#define LOG_ERROR
Definition: logger.h:155
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
struct timeval ast_mktime(struct ast_tm *const tmp, const char *zone)
Timezone-independent version of mktime(3).
Definition: localtime.c:2185
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static snd_pcm_format_t format
Definition: chan_alsa.c:93
static int array ( struct ast_channel chan,
const char *  cmd,
char *  var,
const char *  value 
)
static

Definition at line 913 of file func_strings.c.

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, and var.

Referenced by hash_write().

915 {
917  AST_APP_ARG(var)[100];
918  );
920  AST_APP_ARG(val)[100];
921  );
922  char *origvar = "", *value2, varname[256];
923  int i, ishash = 0;
924 
925  if (!var) {
926  return -1;
927  }
928  value2 = ast_strdupa(value);
929 
930  if (!strcmp(cmd, "HASH")) {
931  const char *var2 = pbx_builtin_getvar_helper(chan, "~ODBCFIELDS~");
932  origvar = var;
933  if (var2)
934  var = ast_strdupa(var2);
935  else {
936  if (chan)
937  ast_autoservice_stop(chan);
938  return -1;
939  }
940  ishash = 1;
941  }
942 
943  /* The functions this will generally be used with are SORT and ODBC_*, which
944  * both return comma-delimited lists. However, if somebody uses literal lists,
945  * their commas will be translated to vertical bars by the load, and I don't
946  * want them to be surprised by the result. Hence, we prefer commas as the
947  * delimiter, but we'll fall back to vertical bars if commas aren't found.
948  */
949  ast_debug(1, "array (%s=%s)\n", var, S_OR(value2, ""));
950  AST_STANDARD_APP_ARGS(arg1, var);
951 
952  AST_STANDARD_APP_ARGS(arg2, value2);
953 
954  for (i = 0; i < arg1.argc; i++) {
955  ast_debug(1, "array set value (%s=%s)\n", arg1.var[i],
956  S_OR(arg2.val[i], ""));
957  if (i < arg2.argc) {
958  if (ishash) {
959  if (origvar[0] == '_') {
960  if (origvar[1] == '_') {
961  snprintf(varname, sizeof(varname), "__" HASH_FORMAT, origvar + 2, arg1.var[i]);
962  } else {
963  snprintf(varname, sizeof(varname), "_" HASH_FORMAT, origvar + 1, arg1.var[i]);
964  }
965  } else {
966  snprintf(varname, sizeof(varname), HASH_FORMAT, origvar, arg1.var[i]);
967  }
968 
969  pbx_builtin_setvar_helper(chan, varname, arg2.val[i]);
970  } else {
971  pbx_builtin_setvar_helper(chan, arg1.var[i], arg2.val[i]);
972  }
973  } else {
974  /* We could unset the variable, by passing a NULL, but due to
975  * pushvar semantics, that could create some undesired behavior. */
976  if (ishash) {
977  snprintf(varname, sizeof(varname), HASH_FORMAT, origvar, arg1.var[i]);
978  pbx_builtin_setvar_helper(chan, varname, "");
979  } else {
980  pbx_builtin_setvar_helper(chan, arg1.var[i], "");
981  }
982  }
983  }
984 
985  return 0;
986 }
Definition: ast_expr2.c:325
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
#define var
Definition: ast_expr2f.c:606
#define HASH_FORMAT
Definition: func_strings.c:887
int value
Definition: syslog.c:39
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
Definition: pbx.c:10475
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:238
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
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...
Definition: pbx.c:10546
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static void clearvar_prefix ( struct ast_channel chan,
const char *  prefix 
)
static

Definition at line 892 of file func_strings.c.

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

Referenced by exec_clearhash().

893 {
894  struct ast_var_t *var;
895  int len = strlen(prefix);
897  if (strncasecmp(prefix, ast_var_name(var), len) == 0) {
899  ast_free(var);
900  }
901  }
903 }
const char * ast_var_name(const struct ast_var_t *var)
Definition: chanvars.c:69
#define var
Definition: ast_expr2f.c:606
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:600
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:554
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
struct ast_var_t::@158 entries
#define ast_free(a)
Definition: astmm.h:97
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
struct varshead varshead
Definition: channel.h:817
static char prefix[MAX_PREFIX]
Definition: http.c:107
static int csv_quote ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1177 of file func_strings.c.

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

1178 {
1179  char *bufptr = buf, *dataptr = data;
1180 
1181  if (len < 3) { /* at least two for quotes and one for binary zero */
1182  ast_log(LOG_ERROR, "Not enough buffer\n");
1183  return -1;
1184  }
1185 
1186  if (ast_strlen_zero(data)) {
1187  ast_copy_string(buf, "\"\"", len);
1188  return 0;
1189  }
1190 
1191  *bufptr++ = '"';
1192  for (; bufptr < buf + len - 3; dataptr++){
1193  if (*dataptr == '"') {
1194  *bufptr++ = '"';
1195  *bufptr++ = '"';
1196  } else if (*dataptr == '\0') {
1197  break;
1198  } else {
1199  *bufptr++ = *dataptr;
1200  }
1201  }
1202  *bufptr++ = '"';
1203  *bufptr='\0';
1204  return 0;
1205 }
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define LOG_ERROR
Definition: logger.h:155
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
static int exec_clearhash ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 905 of file func_strings.c.

References clearvar_prefix(), HASH_PREFIX, and prefix.

Referenced by load_module().

906 {
907  char prefix[80];
908  snprintf(prefix, sizeof(prefix), HASH_PREFIX, data ? (char *)data : "null");
909  clearvar_prefix(chan, prefix);
910  return 0;
911 }
static void clearvar_prefix(struct ast_channel *chan, const char *prefix)
Definition: func_strings.c:892
#define HASH_PREFIX
Definition: func_strings.c:886
static char prefix[MAX_PREFIX]
Definition: http.c:107
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 694 of file func_strings.c.

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, LOG_ERROR, and LOG_WARNING.

Referenced by __ast_data_add(), data_filter_destructor(), data_filter_generate(), data_result_generate(), data_result_generate_node(), manager_data_get(), realtime_ldap_base_ap(), set_egress_subscription(), update2_ldap(), and update_ldap().

696 {
698  AST_APP_ARG(allowed);
699  AST_APP_ARG(string);
700  );
701  char *outbuf = buf;
702  unsigned char ac;
703  char allowed[256] = "";
704  size_t allowedlen = 0;
705  int32_t bitfield[8] = { 0, }; /* 256 bits */
706 
708 
709  if (!args.string) {
710  ast_log(LOG_ERROR, "Usage: FILTER(<allowed-chars>,<string>)\n");
711  return -1;
712  }
713 
714  if (args.allowed[0] == '"' && !ast_opt_dont_warn) {
715  ast_log(LOG_WARNING, "FILTER allowed characters includes the quote (\") character. This may not be what you want.\n");
716  }
717 
718  /* Expand ranges */
719  for (; *(args.allowed);) {
720  char c1 = 0, c2 = 0;
721  size_t consumed = 0;
722 
723  if (ast_get_encoded_char(args.allowed, &c1, &consumed))
724  return -1;
725  args.allowed += consumed;
726 
727  if (*(args.allowed) == '-') {
728  if (ast_get_encoded_char(args.allowed + 1, &c2, &consumed))
729  c2 = c1;
730  args.allowed += consumed + 1;
731 
732  if ((unsigned char) c2 < (unsigned char) c1 && !ast_opt_dont_warn) {
733  ast_log(LOG_WARNING, "Range wrapping in FILTER(%s,%s). This may not be what you want.\n", parse, args.string);
734  }
735 
736  /*!\note
737  * Looks a little strange, until you realize that we can overflow
738  * the size of a char.
739  */
740  for (ac = (unsigned char) c1; ac != (unsigned char) c2; ac++) {
741  bitfield[ac / 32] |= 1 << (ac % 32);
742  }
743  bitfield[ac / 32] |= 1 << (ac % 32);
744 
745  ast_debug(4, "c1=%d, c2=%d\n", c1, c2);
746  } else {
747  ac = (unsigned char) c1;
748  ast_debug(4, "c1=%d, consumed=%d, args.allowed=%s\n", c1, (int) consumed, args.allowed - consumed);
749  bitfield[ac / 32] |= 1 << (ac % 32);
750  }
751  }
752 
753  for (ac = 1; ac != 0; ac++) {
754  if (bitfield[ac / 32] & (1 << (ac % 32))) {
755  allowed[allowedlen++] = ac;
756  }
757  }
758 
759  ast_debug(1, "Allowed: %s\n", allowed);
760 
761  for (; *(args.string) && (buf + len - 1 > outbuf); (args.string)++) {
762  if (strchr(allowed, *(args.string)))
763  *outbuf++ = *(args.string);
764  }
765  *outbuf = '\0';
766 
767  return 0;
768 }
#define LOG_WARNING
Definition: logger.h:144
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
#define ast_opt_dont_warn
Definition: options.h:121
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define LOG_ERROR
Definition: logger.h:155
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
Definition: app.c:2122
static struct @350 args
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
#define AST_STANDARD_RAW_ARGS(args, parse)
Definition: app.h:606
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
static int function_eval ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  buflen 
)
static

Definition at line 1306 of file func_strings.c.

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

1308 {
1309  if (ast_strlen_zero(data)) {
1310  ast_log(LOG_WARNING, "EVAL requires an argument: EVAL(<string>)\n");
1311  return -1;
1312  }
1313 
1314  pbx_substitute_variables_helper(chan, data, buf, buflen - 1);
1315 
1316  return 0;
1317 }
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
Definition: pbx.c:4676
#define LOG_WARNING
Definition: logger.h:144
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static int function_eval2 ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  buflen 
)
static

Definition at line 1319 of file func_strings.c.

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

1321 {
1322  if (ast_strlen_zero(data)) {
1323  ast_log(LOG_WARNING, "EVAL requires an argument: EVAL(<string>)\n");
1324  return -1;
1325  }
1326 
1327  ast_str_substitute_variables(buf, buflen, chan, data);
1328 
1329  return 0;
1330 }
#define LOG_WARNING
Definition: logger.h:144
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
Definition: pbx.c:4468
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static int function_fieldnum ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buf,
size_t  len 
)
static

Definition at line 548 of file func_strings.c.

References function_fieldnum_helper().

550 {
551  return function_fieldnum_helper(chan, cmd, parse, buf, NULL, len);
552 }
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
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:487
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 487 of file func_strings.c.

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(), LOG_ERROR, result_buf, str, and strsep().

Referenced by function_fieldnum(), and function_fieldnum_str().

489 {
490  char *varsubst, *field;
491  struct ast_str *str = ast_str_thread_get(&result_buf, 16);
492  int fieldindex = 0, res = 0;
494  AST_APP_ARG(varname);
495  AST_APP_ARG(delim);
496  AST_APP_ARG(field);
497  );
498  char delim[2] = "";
499  size_t delim_used;
500 
501  if (!str) {
502  return -1;
503  }
504 
506 
507  if (args.argc < 3) {
508  ast_log(LOG_ERROR, "Usage: FIELDNUM(<listname>,<delimiter>,<fieldvalue>)\n");
509  res = -1;
510  } else {
511  varsubst = ast_alloca(strlen(args.varname) + 4);
512  sprintf(varsubst, "${%s}", args.varname);
513 
514  ast_str_substitute_variables(&str, 0, chan, varsubst);
515 
516  if (ast_str_strlen(str) == 0 || ast_strlen_zero(args.delim)) {
517  fieldindex = 0;
518  } else if (ast_get_encoded_char(args.delim, delim, &delim_used) == -1) {
519  res = -1;
520  } else {
521  char *varval = ast_str_buffer(str);
522 
523  while ((field = strsep(&varval, delim)) != NULL) {
524  fieldindex++;
525 
526  if (!strcasecmp(field, args.field)) {
527  break;
528  }
529  }
530 
531  if (!field) {
532  fieldindex = 0;
533  }
534 
535  res = 0;
536  }
537  }
538 
539  if (sbuf) {
540  ast_str_set(sbuf, len, "%d", fieldindex);
541  } else {
542  snprintf(buf, len, "%d", fieldindex);
543  }
544 
545  return res;
546 }
char * strsep(char **str, const char *delims)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: utils.h:653
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
Definition: pbx.c:4468
const char * str
Definition: app_jack.c:144
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:874
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static struct ast_threadstorage result_buf
Definition: func_strings.c:47
#define LOG_ERROR
Definition: logger.h:155
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
Definition: app.c:2122
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
static struct @350 args
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:471
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
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:669
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
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 554 of file func_strings.c.

References function_fieldnum_helper().

556 {
557  return function_fieldnum_helper(chan, cmd, parse, NULL, buf, len);
558 }
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
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:487
static int function_fieldqty ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buf,
size_t  len 
)
static

Definition at line 469 of file func_strings.c.

References function_fieldqty_helper().

471 {
472  return function_fieldqty_helper(chan, cmd, parse, buf, NULL, len);
473 }
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:424
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
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 424 of file func_strings.c.

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(), result_buf, str, and strsep().

Referenced by function_fieldqty(), and function_fieldqty_str().

426 {
427  char *varsubst;
428  struct ast_str *str = ast_str_thread_get(&result_buf, 16);
429  int fieldcount = 0;
431  AST_APP_ARG(varname);
432  AST_APP_ARG(delim);
433  );
434  char delim[2] = "";
435  size_t delim_used;
436 
437  if (!str) {
438  return -1;
439  }
440 
442  if (args.delim) {
443  ast_get_encoded_char(args.delim, delim, &delim_used);
444 
445  varsubst = ast_alloca(strlen(args.varname) + 4);
446 
447  sprintf(varsubst, "${%s}", args.varname);
448  ast_str_substitute_variables(&str, 0, chan, varsubst);
449  if (ast_str_strlen(str) == 0) {
450  fieldcount = 0;
451  } else {
452  char *varval = ast_str_buffer(str);
453  while (strsep(&varval, delim)) {
454  fieldcount++;
455  }
456  }
457  } else {
458  fieldcount = 1;
459  }
460  if (sbuf) {
461  ast_str_set(sbuf, len, "%d", fieldcount);
462  } else {
463  snprintf(buf, len, "%d", fieldcount);
464  }
465 
466  return 0;
467 }
char * strsep(char **str, const char *delims)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: utils.h:653
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
Definition: pbx.c:4468
const char * str
Definition: app_jack.c:144
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:874
static struct ast_threadstorage result_buf
Definition: func_strings.c:47
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
Definition: app.c:2122
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
static struct @350 args
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:471
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
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:669
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
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 475 of file func_strings.c.

References function_fieldqty_helper().

477 {
478  return function_fieldqty_helper(chan, cmd, parse, NULL, buf, len);
479 }
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:424
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
static int hash_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1070 of file func_strings.c.

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

1071 {
1072  char varname[256];
1073  const char *varvalue;
1075  AST_APP_ARG(hashname);
1076  AST_APP_ARG(hashkey);
1077  );
1078 
1079  AST_STANDARD_APP_ARGS(arg, data);
1080  if (arg.argc == 2) {
1081  snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg.hashkey);
1082  varvalue = pbx_builtin_getvar_helper(chan, varname);
1083  if (varvalue)
1084  ast_copy_string(buf, varvalue, len);
1085  else
1086  *buf = '\0';
1087  } else if (arg.argc == 1) {
1088  char colnames[4096];
1089  int i;
1090  AST_DECLARE_APP_ARGS(arg2,
1091  AST_APP_ARG(col)[100];
1092  );
1093 
1094  if (!chan) {
1095  ast_log(LOG_WARNING, "No channel and only 1 parameter was provided to %s function.\n", cmd);
1096  return -1;
1097  }
1098 
1099  /* Get column names, in no particular order */
1100  hashkeys_read(chan, "HASHKEYS", arg.hashname, colnames, sizeof(colnames));
1101  pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", colnames);
1102 
1103  AST_STANDARD_APP_ARGS(arg2, colnames);
1104  *buf = '\0';
1105 
1106  /* Now get the corresponding column values, in exactly the same order */
1107  for (i = 0; i < arg2.argc; i++) {
1108  snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg2.col[i]);
1109  varvalue = pbx_builtin_getvar_helper(chan, varname);
1110  strncat(buf, varvalue, len - strlen(buf) - 1);
1111  strncat(buf, ",", len - strlen(buf) - 1);
1112  }
1113 
1114  /* Strip trailing comma */
1115  buf[strlen(buf) - 1] = '\0';
1116  }
1117 
1118  return 0;
1119 }
#define LOG_WARNING
Definition: logger.h:144
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
#define HASH_FORMAT
Definition: func_strings.c:887
static int hashkeys_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
Definition: func_strings.c:988
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
Definition: pbx.c:10475
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
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...
Definition: pbx.c:10546
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static int hash_write ( struct ast_channel chan,
const char *  cmd,
char *  var,
const char *  value 
)
static

Definition at line 1042 of file func_strings.c.

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

1043 {
1044  char varname[256];
1046  AST_APP_ARG(hashname);
1047  AST_APP_ARG(hashkey);
1048  );
1049 
1050  if (!strchr(var, ',')) {
1051  /* Single argument version */
1052  return array(chan, "HASH", var, value);
1053  }
1054 
1055  AST_STANDARD_APP_ARGS(arg, var);
1056  if (arg.hashname[0] == '_') {
1057  if (arg.hashname[1] == '_') {
1058  snprintf(varname, sizeof(varname), "__" HASH_FORMAT, arg.hashname + 2, arg.hashkey);
1059  } else {
1060  snprintf(varname, sizeof(varname), "_" HASH_FORMAT, arg.hashname + 1, arg.hashkey);
1061  }
1062  } else {
1063  snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg.hashkey);
1064  }
1065  pbx_builtin_setvar_helper(chan, varname, value);
1066 
1067  return 0;
1068 }
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
#define var
Definition: ast_expr2f.c:606
#define HASH_FORMAT
Definition: func_strings.c:887
int value
Definition: syslog.c:39
static int array(struct ast_channel *chan, const char *cmd, char *var, const char *value)
Definition: func_strings.c:913
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...
Definition: pbx.c:10546
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static int hashkeys_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 988 of file func_strings.c.

References AST_LIST_TRAVERSE, ast_log(), ast_str_alloca, ast_str_buffer(), ast_str_set(), ast_str_strlen(), ast_var_name(), HASH_PREFIX, LOG_WARNING, prefix, and ast_channel::varshead.

Referenced by hash_read().

989 {
990  struct ast_var_t *newvar;
991  struct ast_str *prefix = ast_str_alloca(80);
992 
993  if (!chan) {
994  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
995  return -1;
996  }
997 
998  ast_str_set(&prefix, -1, HASH_PREFIX, data);
999  memset(buf, 0, len);
1000 
1001  AST_LIST_TRAVERSE(&chan->varshead, newvar, entries) {
1002  if (strncasecmp(ast_str_buffer(prefix), ast_var_name(newvar), ast_str_strlen(prefix)) == 0) {
1003  /* Copy everything after the prefix */
1004  strncat(buf, ast_var_name(newvar) + ast_str_strlen(prefix), len - strlen(buf) - 1);
1005  /* Trim the trailing ~ */
1006  buf[strlen(buf) - 1] = ',';
1007  }
1008  }
1009  /* Trim the trailing comma */
1010  buf[strlen(buf) - 1] = '\0';
1011  return 0;
1012 }
const char * ast_var_name(const struct ast_var_t *var)
Definition: chanvars.c:69
#define LOG_WARNING
Definition: logger.h:144
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
#define ast_str_alloca(init_len)
Definition: strings.h:608
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:874
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:471
struct varshead varshead
Definition: channel.h:817
#define HASH_PREFIX
Definition: func_strings.c:886
static char prefix[MAX_PREFIX]
Definition: http.c:107
static int hashkeys_read2 ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 1014 of file func_strings.c.

References AST_LIST_TRAVERSE, ast_log(), ast_str_alloca, ast_str_append(), ast_str_buffer(), ast_str_set(), ast_str_strlen(), ast_var_name(), HASH_PREFIX, LOG_WARNING, prefix, and ast_channel::varshead.

1015 {
1016  struct ast_var_t *newvar;
1017  struct ast_str *prefix = ast_str_alloca(80);
1018  char *tmp;
1019 
1020  if (!chan) {
1021  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1022  return -1;
1023  }
1024 
1025  ast_str_set(&prefix, -1, HASH_PREFIX, data);
1026 
1027  AST_LIST_TRAVERSE(&chan->varshead, newvar, entries) {
1028  if (strncasecmp(ast_str_buffer(prefix), ast_var_name(newvar), ast_str_strlen(prefix)) == 0) {
1029  /* Copy everything after the prefix */
1030  ast_str_append(buf, len, "%s", ast_var_name(newvar) + ast_str_strlen(prefix));
1031  /* Trim the trailing ~ */
1032  tmp = ast_str_buffer(*buf);
1033  tmp[ast_str_strlen(*buf) - 1] = ',';
1034  }
1035  }
1036  /* Trim the trailing comma */
1037  tmp = ast_str_buffer(*buf);
1038  tmp[ast_str_strlen(*buf) - 1] = '\0';
1039  return 0;
1040 }
const char * ast_var_name(const struct ast_var_t *var)
Definition: chanvars.c:69
#define LOG_WARNING
Definition: logger.h:144
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
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:900
#define ast_str_alloca(init_len)
Definition: strings.h:608
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:874
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:471
struct varshead varshead
Definition: channel.h:817
#define HASH_PREFIX
Definition: func_strings.c:886
static char prefix[MAX_PREFIX]
Definition: http.c:107
static int keypadhash ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  buflen 
)
static

Definition at line 1338 of file func_strings.c.

1339 {
1340  char *bufptr, *dataptr;
1341 
1342  for (bufptr = buf, dataptr = data; bufptr < buf + buflen - 1; dataptr++) {
1343  if (*dataptr == '\0') {
1344  *bufptr++ = '\0';
1345  break;
1346  } else if (*dataptr == '1') {
1347  *bufptr++ = '1';
1348  } else if (strchr("AaBbCc2", *dataptr)) {
1349  *bufptr++ = '2';
1350  } else if (strchr("DdEeFf3", *dataptr)) {
1351  *bufptr++ = '3';
1352  } else if (strchr("GgHhIi4", *dataptr)) {
1353  *bufptr++ = '4';
1354  } else if (strchr("JjKkLl5", *dataptr)) {
1355  *bufptr++ = '5';
1356  } else if (strchr("MmNnOo6", *dataptr)) {
1357  *bufptr++ = '6';
1358  } else if (strchr("PpQqRrSs7", *dataptr)) {
1359  *bufptr++ = '7';
1360  } else if (strchr("TtUuVv8", *dataptr)) {
1361  *bufptr++ = '8';
1362  } else if (strchr("WwXxYyZz9", *dataptr)) {
1363  *bufptr++ = '9';
1364  } else if (*dataptr == '0') {
1365  *bufptr++ = '0';
1366  }
1367  }
1368  buf[buflen - 1] = '\0';
1369 
1370  return 0;
1371 }
static int len ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  buflen 
)
static

Definition at line 1212 of file func_strings.c.

Referenced by __analog_ss_thread(), __ast_cli_register(), __ast_dsp_call_progress(), __ast_dsp_silence_noise(), __ast_str_helper(), __get_header(), __rtp_recvfrom(), __rtp_sendto(), _parse(), acf_escape(), add_sdp(), adsi_careful_send(), ael_token_subst(), aji_io_recv(), aji_recv(), aji_send_header(), aji_send_raw(), aji_start_sasl(), alsa_write(), amdf_pitch(), analog_ss_thread(), anti_injection(), aoc_parse_ie(), append_interface(), append_var_and_value_to_filter(), ast_agi_register_multiple(), ast_agi_unregister_multiple(), ast_app_group_set_channel(), ast_app_options2str64(), ast_callerid_vmwi_generate(), ast_cdr_appenduserfield(), ast_cli_complete(), ast_cli_register_multiple(), ast_cli_unregister_multiple(), ast_codec_get_len(), ast_complete_source_filename(), ast_dsp_noise(), ast_dsp_process(), ast_dsp_silence(), ast_event_cb(), ast_format_str_reduce(), ast_frdup(), ast_getformatname_multiple(), ast_http_send(), ast_http_uri_link(), ast_join(), ast_mkdir(), ast_pri_pack_hex_string(), ast_read_image(), ast_rtcp_write_rr(), ast_rtcp_write_sr(), ast_rtp_read(), ast_say_number_full_ka(), ast_smoother_read(), ast_srtp_protect(), ast_srtp_unprotect(), ast_str_buffer(), ast_str_substitute_variables_full(), ast_tdd_gen_ecdisa(), ast_translate(), ast_udptl_write(), ast_xml_escape(), ast_xmldoc_printable(), auth_exec(), authenticate(), build_device(), build_facility(), build_route(), builtin_automixmonitor(), builtin_automonitor(), calc_energy(), callerid_feed(), callerid_feed_jp(), callerid_generate(), CB_ADD_LEN(), cleaned_basedn(), clearvar_prefix(), cli_console_sendtext(), complete_agent_logoff_cmd(), complete_confno(), complete_dialplan_add_extension(), complete_dialplan_add_ignorepat(), complete_dialplan_add_include(), complete_dialplan_remove_extension(), complete_dialplan_remove_ignorepat(), complete_dialplan_remove_include(), complete_meetmecmd_list(), complete_meetmecmd_mute_kick(), complete_peer_helper(), complete_trans_path_choice(), complete_userno(), conf_play(), config_jitterbuffer(), cops_getmsg(), copy(), create_video_frame(), dahdi_sendtext(), dahdi_setoption(), decode_length(), decode_open_type(), devstate_write(), dialgroup_refreshdb(), dictate_exec(), do_pktccops(), do_tone(), dump_prefs(), dump_raw(), dump_string(), dundi_encrypt(), dundi_parse_ies(), dundi_send(), enc_ie_facility(), encode_length(), evt_event_deliver_cb(), expand_gosub_args(), expr2_token_subst(), ext_cmp_exten_strlen(), fax_generator_generate(), fbuf_append(), fetch_response_reader(), ffmpeg_decode(), find_by_part(), flip_buf_bits(), fsk_serial(), gen_tone(), gen_tones(), get_body(), get_ip_and_port_from_sdp(), get_msg_text(), get_sdp(), get_sdp_iterate(), get_to_address(), gsm_write(), gsmtolin_framein(), h261_encap(), h263_encap(), h263_read(), h263_write(), h263p_encap(), h264_read(), h264_write(), handle_cli_core_show_translation(), handle_cli_devstate_change(), handle_commandmatchesarray(), handle_incoming(), handle_message(), handle_output(), handle_response(), handle_show_sysinfo(), handle_subscribe(), help1(), iax_parse_ies(), iax_str2flags(), iconv_read(), jpeg_read_image(), launch_monitor_thread(), listener(), local_call(), lpc10tolin_framein(), lws2sws(), make_tone_burst(), memcpy_decrypt(), memcpy_encrypt(), message_template_parse_emailbody(), method_match(), mgcp_postrequest(), mgcp_ss(), mgcpsock_read(), milliwatt_generate(), misdn_jb_empty(), misdn_jb_fill(), misdn_lib_tx2misdn_frm(), misdn_read(), misdn_tx_jitter(), monmp3thread(), mpeg4_encap(), my_dahdi_write(), newpvt(), parse_ie(), ParseBookmark(), pbx_substitute_variables_helper_full(), phone_write_buf(), playtones_generator(), plc_fillin(), plc_rx(), pri_dchannel(), pri_ss_thread(), process_sdp(), read_credentials(), readfile_exec(), red_t140_to_red(), reschedule_precache(), run_agi(), save_history(), scan_thread(), schedule_delivery(), set_egress_subscription(), sig_pri_digit_begin(), sig_pri_set_subaddress(), sip_addheader(), sip_show_channel(), sip_show_history(), sip_tcptls_write(), skinny_ss(), sms_messagetx(), socket_process_meta(), socket_read(), static_callback(), strnncpy(), tdd_feed(), term_filter_escapes(), tonepair_generator(), transfer_exec(), try_firmware(), udptl_build_packet(), unistim_sp(), unquote(), wav_write(), xmldoc_get_syntax_fun(), and xmldoc_setpostbr().

1213 {
1214  int length = 0;
1215 
1216  if (data)
1217  length = strlen(data);
1218 
1219  snprintf(buf, buflen, "%d", length);
1220 
1221  return 0;
1222 }
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 566 of file func_strings.c.

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(), first, LOG_ERROR, result_buf, and tmp_buf.

Referenced by listfilter_read(), and listfilter_read2().

567 {
569  AST_APP_ARG(listname);
570  AST_APP_ARG(delimiter);
571  AST_APP_ARG(fieldvalue);
572  );
573  struct ast_str *orig_list = ast_str_thread_get(&tmp_buf, 16);
574  const char *begin, *cur, *next;
575  int dlen, flen, first = 1;
576  struct ast_str *result, **result_ptr = &result;
577  char *delim, *varsubst;
578 
580 
581  if (buf) {
582  if (!(result = ast_str_thread_get(&result_buf, 16))) {
583  return -1;
584  }
585  } else {
586  /* Place the result directly into the output buffer */
587  result_ptr = bufstr;
588  }
589 
590  if (args.argc < 3) {
591  ast_log(LOG_ERROR, "Usage: LISTFILTER(<listname>,<delimiter>,<fieldvalue>)\n");
592  return -1;
593  }
594 
595  varsubst = ast_alloca(strlen(args.listname) + 4);
596  sprintf(varsubst, "${%s}", args.listname);
597 
598  /* If we don't lock the channel, the variable could disappear out from underneath us. */
599  if (chan) {
600  ast_channel_lock(chan);
601  }
602  ast_str_substitute_variables(&orig_list, 0, chan, varsubst);
603  if (!ast_str_strlen(orig_list)) {
604  ast_log(LOG_ERROR, "List variable '%s' not found\n", args.listname);
605  if (chan) {
606  ast_channel_unlock(chan);
607  }
608  return -1;
609  }
610 
611  /* If the string isn't there, just copy out the string and be done with it. */
612  if (!strstr(ast_str_buffer(orig_list), args.fieldvalue)) {
613  if (buf) {
614  ast_copy_string(buf, ast_str_buffer(orig_list), len);
615  } else {
616  ast_str_set(result_ptr, len, "%s", ast_str_buffer(orig_list));
617  }
618  if (chan) {
619  ast_channel_unlock(chan);
620  }
621  return 0;
622  }
623 
624  dlen = strlen(args.delimiter);
625  delim = ast_alloca(dlen + 1);
626  ast_get_encoded_str(args.delimiter, delim, dlen + 1);
627 
628  if ((dlen = strlen(delim)) == 0) {
629  delim = ",";
630  dlen = 1;
631  }
632 
633  flen = strlen(args.fieldvalue);
634 
635  ast_str_reset(*result_ptr);
636  /* Enough space for any result */
637  if (len > -1) {
638  ast_str_make_space(result_ptr, len ? len : ast_str_strlen(orig_list) + 1);
639  }
640 
641  begin = ast_str_buffer(orig_list);
642  next = strstr(begin, delim);
643 
644  do {
645  /* Find next boundary */
646  if (next) {
647  cur = next;
648  next = strstr(cur + dlen, delim);
649  } else {
650  cur = strchr(begin + dlen, '\0');
651  }
652 
653  if (flen == cur - begin && !strncmp(begin, args.fieldvalue, flen)) {
654  /* Skip field */
655  begin += flen + dlen;
656  } else {
657  /* Copy field to output */
658  if (!first) {
659  ast_str_append(result_ptr, len, "%s", delim);
660  }
661 
662  ast_str_append_substr(result_ptr, len, begin, cur - begin);
663  first = 0;
664  begin = cur + dlen;
665  }
666  } while (*cur != '\0');
667  if (chan) {
668  ast_channel_unlock(chan);
669  }
670 
671  if (buf) {
672  ast_copy_string(buf, ast_str_buffer(result), len);
673  }
674 
675  return 0;
676 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: utils.h:653
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: app.c:2197
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
Definition: pbx.c:4468
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:900
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:874
static struct ast_threadstorage tmp_buf
Definition: func_strings.c:48
int ast_str_make_space(struct ast_str **buf, size_t new_len)
Definition: strings.h:588
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:823
static struct ast_threadstorage result_buf
Definition: func_strings.c:47
#define LOG_ERROR
Definition: logger.h:155
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
static struct @350 args
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
struct sla_ringing_trunk * first
Definition: app_meetme.c:965
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
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:436
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:471
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
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:669
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static int listfilter_read ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buf,
size_t  len 
)
static

Definition at line 678 of file func_strings.c.

References listfilter().

679 {
680  return listfilter(chan, cmd, parse, buf, NULL, len);
681 }
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:566
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
static int listfilter_read2 ( struct ast_channel chan,
const char *  cmd,
char *  parse,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 683 of file func_strings.c.

References listfilter().

684 {
685  return listfilter(chan, cmd, parse, NULL, buf, len);
686 }
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:566
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
static int load_module ( void  )
static

Definition at line 1785 of file func_strings.c.

References ast_custom_function_register, ast_register_application_xml, AST_TEST_REGISTER, and exec_clearhash().

1786 {
1787  int res = 0;
1788 
1789  AST_TEST_REGISTER(test_FIELDNUM);
1790  AST_TEST_REGISTER(test_REPLACE);
1791  AST_TEST_REGISTER(test_FILTER);
1816 
1817  return res;
1818 }
static struct ast_custom_function hashkeys_function
static struct ast_custom_function len_function
static struct ast_custom_function shift_function
static struct ast_custom_function strftime_function
static struct ast_custom_function passthru_function
#define AST_TEST_REGISTER(cb)
Definition: test.h:127
static struct ast_custom_function eval_function
static struct ast_custom_function fieldnum_function
Definition: func_strings.c:560
static struct ast_custom_function push_function
static struct ast_custom_function unshift_function
static struct ast_custom_function replace_function
Definition: func_strings.c:839
static struct ast_custom_function quote_function
static int exec_clearhash(struct ast_channel *chan, const char *data)
Definition: func_strings.c:905
static struct ast_custom_function listfilter_function
Definition: func_strings.c:688
static char * app_clearhash
Definition: func_strings.c:889
static struct ast_custom_function toupper_function
static struct ast_custom_function csv_quote_function
static struct ast_custom_function filter_function
Definition: func_strings.c:770
static struct ast_custom_function regex_function
Definition: func_strings.c:881
static struct ast_custom_function array_function
static struct ast_custom_function fieldqty_function
Definition: func_strings.c:481
static struct ast_custom_function keypadhash_function
static struct ast_custom_function hash_function
static struct ast_custom_function pop_function
static struct ast_custom_function tolower_function
static struct ast_custom_function strptime_function
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1164
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
static int passthru ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 1560 of file func_strings.c.

References ast_str_set().

1561 {
1562  ast_str_set(buf, len, "%s", data);
1563  return 0;
1564 }
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:874
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int quote ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1138 of file func_strings.c.

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

Referenced by __ast_app_separate_args(), and parse_options().

1139 {
1140  char *bufptr = buf, *dataptr = data;
1141 
1142  if (len < 3){ /* at least two for quotes and one for binary zero */
1143  ast_log(LOG_ERROR, "Not enough buffer\n");
1144  return -1;
1145  }
1146 
1147  if (ast_strlen_zero(data)) {
1148  ast_log(LOG_WARNING, "No argument specified!\n");
1149  ast_copy_string(buf, "\"\"", len);
1150  return 0;
1151  }
1152 
1153  *bufptr++ = '"';
1154  for (; bufptr < buf + len - 3; dataptr++) {
1155  if (*dataptr == '\\') {
1156  *bufptr++ = '\\';
1157  *bufptr++ = '\\';
1158  } else if (*dataptr == '"') {
1159  *bufptr++ = '\\';
1160  *bufptr++ = '"';
1161  } else if (*dataptr == '\0') {
1162  break;
1163  } else {
1164  *bufptr++ = *dataptr;
1165  }
1166  }
1167  *bufptr++ = '"';
1168  *bufptr = '\0';
1169  return 0;
1170 }
#define LOG_WARNING
Definition: logger.h:144
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define LOG_ERROR
Definition: logger.h:155
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
static int regex ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buf,
size_t  len 
)
static

Definition at line 844 of file func_strings.c.

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

846 {
848  AST_APP_ARG(null);
849  AST_APP_ARG(reg);
850  AST_APP_ARG(str);
851  );
852  int errcode;
853  regex_t regexbuf;
854 
855  buf[0] = '\0';
856 
858 
859  if (args.argc != 3) {
860  ast_log(LOG_ERROR, "Unexpected arguments: should have been in the form '\"<regex>\" <string>'\n");
861  return -1;
862  }
863  if ((*args.str == ' ') || (*args.str == '\t'))
864  args.str++;
865 
866  ast_debug(1, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str);
867 
868  if ((errcode = regcomp(&regexbuf, args.reg, REG_EXTENDED | REG_NOSUB))) {
869  regerror(errcode, &regexbuf, buf, len);
870  ast_log(LOG_WARNING, "Malformed input %s(%s): %s\n", cmd, parse, buf);
871  return -1;
872  }
873 
874  strcpy(buf, regexec(&regexbuf, args.str, 0, NULL, 0) ? "0" : "1");
875 
876  regfree(&regexbuf);
877 
878  return 0;
879 }
#define LOG_WARNING
Definition: logger.h:144
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
const char * str
Definition: app_jack.c:144
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define LOG_ERROR
Definition: logger.h:155
static struct @350 args
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
Definition: app.h:619
static int replace ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 775 of file func_strings.c.

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(), LOG_ERROR, RAII_VAR, and str.

Referenced by process_text_line().

776 {
778  AST_APP_ARG(varname);
779  AST_APP_ARG(find);
781  );
782  char *strptr, *varsubst;
783  RAII_VAR(struct ast_str *, str, ast_str_create(16), ast_free);
784  char find[256]; /* Only 256 characters possible */
785  char replace[2] = "";
786  size_t unused;
787 
789 
790  if (!str) {
791  return -1;
792  }
793 
794  if (args.argc < 2) {
795  ast_log(LOG_ERROR, "Usage: %s(<varname>,<search-chars>[,<replace-char>])\n", cmd);
796  return -1;
797  }
798 
799  /* Decode escapes */
800  ast_get_encoded_str(args.find, find, sizeof(find));
801  ast_get_encoded_char(args.replace, replace, &unused);
802 
803  if (ast_strlen_zero(find) || ast_strlen_zero(args.varname)) {
804  ast_log(LOG_ERROR, "The characters to search for and the variable name must not be empty.\n");
805  return -1;
806  }
807 
808  varsubst = ast_alloca(strlen(args.varname) + 4);
809  sprintf(varsubst, "${%s}", args.varname);
810  ast_str_substitute_variables(&str, 0, chan, varsubst);
811 
812  if (!ast_str_strlen(str)) {
813  /* Blank, nothing to replace */
814  return -1;
815  }
816 
817  ast_debug(3, "String to search: (%s)\n", ast_str_buffer(str));
818  ast_debug(3, "Characters to find: (%s)\n", find);
819  ast_debug(3, "Character to replace with: (%s)\n", replace);
820 
821  for (strptr = ast_str_buffer(str); *strptr; strptr++) {
822  /* buf is already a mutable buffer, so we construct the result
823  * directly there */
824  if (strchr(find, *strptr)) {
825  if (ast_strlen_zero(replace)) {
826  memmove(strptr, strptr + 1, strlen(strptr + 1) + 1);
827  strptr--;
828  } else {
829  /* Replace character */
830  *strptr = *replace;
831  }
832  }
833  }
834 
835  ast_str_set(buf, len, "%s", ast_str_buffer(str));
836  return 0;
837 }
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: utils.h:653
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: app.c:2197
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
Definition: pbx.c:4468
struct ast_str * ast_str_create(size_t init_len)
Create a malloc&#39;ed dynamic length string.
Definition: strings.h:420
const char * str
Definition: app_jack.c:144
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:874
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#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:915
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define LOG_ERROR
Definition: logger.h:155
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
Definition: app.c:2122
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
static struct @350 args
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_free(a)
Definition: astmm.h:97
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:775
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:471
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static int shift_pop ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 1436 of file func_strings.c.

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, LOG_WARNING, pbx_builtin_setvar_helper(), result_buf, and var.

1437 {
1438 #define beginning (cmd[0] == 'S') /* SHIFT */
1439  char *after, delimiter[2] = ",", *varsubst;
1440  size_t unused;
1441  struct ast_str *before = ast_str_thread_get(&result_buf, 16);
1442  char *(*search_func)(const char *s, int c) = (beginning ? strchr : strrchr);
1444  AST_APP_ARG(var);
1445  AST_APP_ARG(delimiter);
1446  );
1447 
1448  if (!before) {
1449  return -1;
1450  }
1451 
1452  AST_STANDARD_APP_ARGS(args, data);
1453 
1454  if (ast_strlen_zero(args.var)) {
1455  ast_log(LOG_WARNING, "%s requires a variable name\n", cmd);
1456  return -1;
1457  }
1458 
1459  varsubst = ast_alloca(strlen(args.var) + 4);
1460  sprintf(varsubst, "${%s}", args.var);
1461  ast_str_substitute_variables(&before, 0, chan, varsubst);
1462 
1463  if (args.argc > 1 && !ast_strlen_zero(args.delimiter)) {
1464  ast_get_encoded_char(args.delimiter, delimiter, &unused);
1465  }
1466 
1467  if (!ast_str_strlen(before)) {
1468  /* Nothing to pop */
1469  return -1;
1470  }
1471 
1472  if (!(after = search_func(ast_str_buffer(before), delimiter[0]))) {
1473  /* Only one entry in array */
1474  ast_str_set(buf, len, "%s", ast_str_buffer(before));
1475  pbx_builtin_setvar_helper(chan, args.var, "");
1476  } else {
1477  *after++ = '\0';
1478  ast_str_set(buf, len, "%s", beginning ? ast_str_buffer(before) : after);
1479  pbx_builtin_setvar_helper(chan, args.var, beginning ? after : ast_str_buffer(before));
1480  }
1481 
1482  return 0;
1483 #undef beginning
1484 }
#define beginning
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: utils.h:653
#define LOG_WARNING
Definition: logger.h:144
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
#define var
Definition: ast_expr2f.c:606
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
Definition: pbx.c:4468
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:874
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static struct ast_threadstorage result_buf
Definition: func_strings.c:47
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
Definition: app.c:2122
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
static struct @350 args
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
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...
Definition: pbx.c:10546
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:471
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
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:669
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static int string_tolower ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  buflen 
)
static

Definition at line 1407 of file func_strings.c.

1408 {
1409  char *bufptr = buf, *dataptr = data;
1410 
1411  while ((bufptr < buf + buflen - 1) && (*bufptr++ = tolower(*dataptr++)));
1412 
1413  return 0;
1414 }
static int string_tolower2 ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  buflen 
)
static

Definition at line 1416 of file func_strings.c.

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

1417 {
1418  char *bufptr, *dataptr = data;
1419 
1420  if (buflen > -1) {
1421  ast_str_make_space(buf, buflen > 0 ? buflen : strlen(data) + 1);
1422  }
1423  bufptr = ast_str_buffer(*buf);
1424  while ((bufptr < ast_str_buffer(*buf) + ast_str_size(*buf) - 1) && (*bufptr++ = tolower(*dataptr++)));
1425  ast_str_update(*buf);
1426 
1427  return 0;
1428 }
size_t ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
Definition: strings.h:482
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
int ast_str_make_space(struct ast_str **buf, size_t new_len)
Definition: strings.h:588
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:446
static int string_toupper ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  buflen 
)
static

Definition at line 1378 of file func_strings.c.

1379 {
1380  char *bufptr = buf, *dataptr = data;
1381 
1382  while ((bufptr < buf + buflen - 1) && (*bufptr++ = toupper(*dataptr++)));
1383 
1384  return 0;
1385 }
static int string_toupper2 ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  buflen 
)
static

Definition at line 1387 of file func_strings.c.

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

1388 {
1389  char *bufptr, *dataptr = data;
1390 
1391  if (buflen > -1) {
1392  ast_str_make_space(buf, buflen > 0 ? buflen : strlen(data) + 1);
1393  }
1394  bufptr = ast_str_buffer(*buf);
1395  while ((bufptr < ast_str_buffer(*buf) + ast_str_size(*buf) - 1) && (*bufptr++ = toupper(*dataptr++)));
1396  ast_str_update(*buf);
1397 
1398  return 0;
1399 }
size_t ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
Definition: strings.h:482
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
int ast_str_make_space(struct ast_str **buf, size_t new_len)
Definition: strings.h:588
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:446
static int unload_module ( void  )
static

Definition at line 1750 of file func_strings.c.

References ast_custom_function_unregister(), AST_TEST_UNREGISTER, and ast_unregister_application().

1751 {
1752  int res = 0;
1753 
1754  AST_TEST_UNREGISTER(test_FIELDNUM);
1755  AST_TEST_UNREGISTER(test_REPLACE);
1756  AST_TEST_UNREGISTER(test_FILTER);
1781 
1782  return res;
1783 }
static struct ast_custom_function hashkeys_function
static struct ast_custom_function len_function
static struct ast_custom_function shift_function
static struct ast_custom_function strftime_function
static struct ast_custom_function passthru_function
static struct ast_custom_function eval_function
static struct ast_custom_function fieldnum_function
Definition: func_strings.c:560
static struct ast_custom_function push_function
static struct ast_custom_function unshift_function
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
Definition: pbx.c:3814
static struct ast_custom_function replace_function
Definition: func_strings.c:839
static struct ast_custom_function quote_function
static struct ast_custom_function listfilter_function
Definition: func_strings.c:688
static char * app_clearhash
Definition: func_strings.c:889
static struct ast_custom_function toupper_function
static struct ast_custom_function csv_quote_function
static struct ast_custom_function filter_function
Definition: func_strings.c:770
static struct ast_custom_function regex_function
Definition: func_strings.c:881
#define AST_TEST_UNREGISTER(cb)
Definition: test.h:128
static struct ast_custom_function array_function
static struct ast_custom_function fieldqty_function
Definition: func_strings.c:481
static struct ast_custom_function keypadhash_function
static struct ast_custom_function hash_function
static struct ast_custom_function pop_function
static struct ast_custom_function tolower_function
static struct ast_custom_function strptime_function
static int unshift_push ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  new_value 
)
static

Definition at line 1496 of file func_strings.c.

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, LOG_WARNING, MIN, pbx_builtin_setvar_helper(), result_buf, tmp_buf, and var.

1497 {
1498 #define beginning (cmd[0] == 'U') /* UNSHIFT */
1499  char delimiter[2] = ",", *varsubst;
1500  size_t unused;
1501  struct ast_str *buf, *previous_value;
1503  AST_APP_ARG(var);
1504  AST_APP_ARG(delimiter);
1505  );
1506  const char *stripped_var;
1507 
1508  if (!(buf = ast_str_thread_get(&result_buf, 16)) ||
1509  !(previous_value = ast_str_thread_get(&tmp_buf, 16))) {
1510  return -1;
1511  }
1512 
1513  AST_STANDARD_APP_ARGS(args, data);
1514 
1515  if (ast_strlen_zero(args.var)) {
1516  ast_log(LOG_WARNING, "%s requires a variable name\n", cmd);
1517  return -1;
1518  }
1519 
1520  if (args.argc > 1 && !ast_strlen_zero(args.delimiter)) {
1521  ast_get_encoded_char(args.delimiter, delimiter, &unused);
1522  }
1523 
1524  /* UNSHIFT and PUSH act as ways of setting a variable, so we need to be
1525  * sure to skip leading underscores if they appear. However, we only want
1526  * to skip up to two since that is the maximum number that can be used to
1527  * indicate variable inheritance. Any further underscores are part of the
1528  * variable name.
1529  */
1530  stripped_var = args.var + MIN(strspn(args.var, "_"), 2);
1531  varsubst = ast_alloca(strlen(stripped_var) + 4);
1532  sprintf(varsubst, "${%s}", stripped_var);
1533  ast_str_substitute_variables(&previous_value, 0, chan, varsubst);
1534 
1535  if (!ast_str_strlen(previous_value)) {
1536  ast_str_set(&buf, 0, "%s", new_value);
1537  } else {
1538  ast_str_set(&buf, 0, "%s%c%s",
1539  beginning ? new_value : ast_str_buffer(previous_value),
1540  delimiter[0],
1541  beginning ? ast_str_buffer(previous_value) : new_value);
1542  }
1543 
1545 
1546  return 0;
1547 #undef beginning
1548 }
#define beginning
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: utils.h:653
#define LOG_WARNING
Definition: logger.h:144
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
#define var
Definition: ast_expr2f.c:606
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
Definition: pbx.c:4468
#define MIN(a, b)
Definition: utils.h:226
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:874
static struct ast_threadstorage tmp_buf
Definition: func_strings.c:48
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static struct ast_threadstorage result_buf
Definition: func_strings.c:47
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
Definition: app.c:2122
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
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...
Definition: pbx.c:10546
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:471
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
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:669
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604

Variable Documentation

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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static

Definition at line 1820 of file func_strings.c.

char* app_clearhash = "ClearHash"
static

Definition at line 889 of file func_strings.c.

struct ast_custom_function array_function
static
Initial value:
= {
.name = "ARRAY",
.write = array,
}
static int array(struct ast_channel *chan, const char *cmd, char *var, const char *value)
Definition: func_strings.c:913

Definition at line 1133 of file func_strings.c.

Definition at line 1820 of file func_strings.c.

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

struct ast_custom_function eval_function
static
Initial value:
= {
.name = "EVAL",
.read = function_eval,
.read2 = function_eval2,
}
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)

Definition at line 1332 of file func_strings.c.

struct ast_custom_function fieldnum_function
static
Initial value:
= {
.name = "FIELDNUM",
}
static int function_fieldnum(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition: func_strings.c:548
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:554

Definition at line 560 of file func_strings.c.

struct ast_custom_function fieldqty_function
static
Initial value:
= {
.name = "FIELDQTY",
}
static int function_fieldqty(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition: func_strings.c:469
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:475

Definition at line 481 of file func_strings.c.

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:694

Definition at line 770 of file func_strings.c.

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

Definition at line 1121 of file func_strings.c.

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

Definition at line 1127 of file func_strings.c.

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

struct ast_custom_function len_function
static
Initial value:
= {
.name = "LEN",
.read = len,
.read_max = 12,
}
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

Definition at line 1224 of file func_strings.c.

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

Definition at line 688 of file func_strings.c.

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

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

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

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

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: func_strings.c:844

Definition at line 881 of file func_strings.c.

struct ast_custom_function replace_function
static
Initial value:
= {
.name = "REPLACE",
.read2 = replace,
}
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:775

Definition at line 839 of file func_strings.c.

struct ast_threadstorage result_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_result_buf , .custom_init = NULL , }
static
struct ast_custom_function shift_function
static
Initial value:
= {
.name = "SHIFT",
.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 1486 of file func_strings.c.

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

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

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 listfilter(), and unshift_push().

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

Definition at line 1430 of file func_strings.c.

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

Definition at line 1401 of file func_strings.c.

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

Definition at line 1555 of file func_strings.c.