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

Go to the source code of this file.
Defines | |
| #define | HASH_FORMAT HASH_PREFIX "%s~" |
| #define | HASH_PREFIX "~HASH~%s~" |
Functions | |
| static void | __init_result_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 int | array_insert (struct ast_channel *chan, const char *cmd, char *var, const char *val, int beginning) |
| static int | array_remove (struct ast_channel *chan, const char *cmd, char *var, char *buf, size_t len, int beginning) |
| 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_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 | pop (struct ast_channel *chan, const char *cmd, char *var, char *buf, size_t len) |
| static int | push (struct ast_channel *chan, const char *cmd, char *var, const char *val) |
| 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 | shift (struct ast_channel *chan, const char *cmd, char *var, char *buf, size_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 (struct ast_channel *chan, const char *cmd, char *var, const char *val) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "String handling dialplan functions" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } |
| static char * | app_clearhash = "ClearHash" |
| static struct ast_custom_function | array_function |
| static struct ast_module_info * | ast_module_info = &__mod_info |
| static struct ast_custom_function | csv_quote_function |
| static struct ast_custom_function | eval_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 | 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_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_custom_function | tolower_function |
| static struct ast_custom_function | toupper_function |
| static struct ast_custom_function | unshift_function |
Definition in file func_strings.c.
| #define HASH_FORMAT HASH_PREFIX "%s~" |
Definition at line 655 of file func_strings.c.
Referenced by array(), hash_read(), and hash_write().
| #define HASH_PREFIX "~HASH~%s~" |
Definition at line 654 of file func_strings.c.
Referenced by exec_clearhash(), hashkeys_read(), and hashkeys_read2().
| static void __init_result_buf | ( | void | ) | [static] |
Definition at line 42 of file func_strings.c.
00059 : If ${example} contains <literal>ex-amp-le</literal>, then ${FIELDQTY(example,-)} returns 3.</para>
| static void __reg_module | ( | void | ) | [static] |
Definition at line 1364 of file func_strings.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 1364 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 966 of file func_strings.c.
References 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.
00968 { 00969 AST_DECLARE_APP_ARGS(args, 00970 AST_APP_ARG(epoch); 00971 AST_APP_ARG(timezone); 00972 AST_APP_ARG(format); 00973 ); 00974 struct timeval when; 00975 struct ast_tm tm; 00976 00977 buf[0] = '\0'; 00978 00979 AST_STANDARD_APP_ARGS(args, parse); 00980 00981 ast_get_timeval(args.epoch, &when, ast_tvnow(), NULL); 00982 ast_localtime(&when, &tm, args.timezone); 00983 00984 if (!args.format) 00985 args.format = "%c"; 00986 00987 if (ast_strftime(buf, buflen, args.format, &tm) <= 0) 00988 ast_log(LOG_WARNING, "C function strftime() output nothing?!!\n"); 00989 00990 buf[buflen - 1] = '\0'; 00991 00992 return 0; 00993 }
| static int acf_strptime | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | buflen | |||
| ) | [static] |
Definition at line 1000 of file func_strings.c.
References 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.
01002 { 01003 AST_DECLARE_APP_ARGS(args, 01004 AST_APP_ARG(timestring); 01005 AST_APP_ARG(timezone); 01006 AST_APP_ARG(format); 01007 ); 01008 struct ast_tm tm; 01009 01010 buf[0] = '\0'; 01011 01012 if (!data) { 01013 ast_log(LOG_ERROR, 01014 "Asterisk function STRPTIME() requires an argument.\n"); 01015 return -1; 01016 } 01017 01018 AST_STANDARD_APP_ARGS(args, data); 01019 01020 if (ast_strlen_zero(args.format)) { 01021 ast_log(LOG_ERROR, 01022 "No format supplied to STRPTIME(<timestring>,<timezone>,<format>)"); 01023 return -1; 01024 } 01025 01026 if (!ast_strptime(args.timestring, args.format, &tm)) { 01027 ast_log(LOG_WARNING, "STRPTIME() found no time specified within the string\n"); 01028 } else { 01029 struct timeval when; 01030 when = ast_mktime(&tm, args.timezone); 01031 snprintf(buf, buflen, "%d", (int) when.tv_sec); 01032 } 01033 01034 return 0; 01035 }
| static int array | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | var, | |||
| const char * | value | |||
| ) | [static] |
Definition at line 681 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(), and pbx_builtin_setvar_helper().
Referenced by hash_write().
00683 { 00684 AST_DECLARE_APP_ARGS(arg1, 00685 AST_APP_ARG(var)[100]; 00686 ); 00687 AST_DECLARE_APP_ARGS(arg2, 00688 AST_APP_ARG(val)[100]; 00689 ); 00690 char *origvar = "", *value2, varname[256]; 00691 int i, ishash = 0; 00692 00693 value2 = ast_strdupa(value); 00694 if (!var || !value2) 00695 return -1; 00696 00697 if (!strcmp(cmd, "HASH")) { 00698 const char *var2 = pbx_builtin_getvar_helper(chan, "~ODBCFIELDS~"); 00699 origvar = var; 00700 if (var2) 00701 var = ast_strdupa(var2); 00702 else { 00703 if (chan) 00704 ast_autoservice_stop(chan); 00705 return -1; 00706 } 00707 ishash = 1; 00708 } 00709 00710 /* The functions this will generally be used with are SORT and ODBC_*, which 00711 * both return comma-delimited lists. However, if somebody uses literal lists, 00712 * their commas will be translated to vertical bars by the load, and I don't 00713 * want them to be surprised by the result. Hence, we prefer commas as the 00714 * delimiter, but we'll fall back to vertical bars if commas aren't found. 00715 */ 00716 ast_debug(1, "array (%s=%s)\n", var, value2); 00717 AST_STANDARD_APP_ARGS(arg1, var); 00718 00719 AST_STANDARD_APP_ARGS(arg2, value2); 00720 00721 for (i = 0; i < arg1.argc; i++) { 00722 ast_debug(1, "array set value (%s=%s)\n", arg1.var[i], 00723 arg2.val[i]); 00724 if (i < arg2.argc) { 00725 if (ishash) { 00726 snprintf(varname, sizeof(varname), HASH_FORMAT, origvar, arg1.var[i]); 00727 pbx_builtin_setvar_helper(chan, varname, arg2.val[i]); 00728 } else { 00729 pbx_builtin_setvar_helper(chan, arg1.var[i], arg2.val[i]); 00730 } 00731 } else { 00732 /* We could unset the variable, by passing a NULL, but due to 00733 * pushvar semantics, that could create some undesired behavior. */ 00734 if (ishash) { 00735 snprintf(varname, sizeof(varname), HASH_FORMAT, origvar, arg1.var[i]); 00736 pbx_builtin_setvar_helper(chan, varname, ""); 00737 } else { 00738 pbx_builtin_setvar_helper(chan, arg1.var[i], ""); 00739 } 00740 } 00741 } 00742 00743 return 0; 00744 }
| static int array_insert | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | var, | |||
| const char * | val, | |||
| int | beginning | |||
| ) | [static] |
Definition at line 1241 of file func_strings.c.
References AST_APP_ARG, ast_channel_lock, ast_channel_unlock, AST_DECLARE_APP_ARGS, ast_free, ast_log(), AST_STANDARD_APP_ARGS, ast_str_append(), ast_str_buffer(), ast_str_create(), ast_str_set(), ast_strlen_zero(), buf, LOG_ERROR, LOG_WARNING, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), and S_OR.
Referenced by push(), and unshift().
01242 { 01243 const char *tmp; 01244 struct ast_str *buf; 01245 AST_DECLARE_APP_ARGS(args, 01246 AST_APP_ARG(var); 01247 AST_APP_ARG(delimiter); 01248 ); 01249 01250 if (!chan) { 01251 ast_log(LOG_WARNING, "%s requires a channel\n", cmd); 01252 return -1; 01253 } 01254 01255 AST_STANDARD_APP_ARGS(args, var); 01256 01257 if (ast_strlen_zero(args.var) || ast_strlen_zero(val)) { 01258 ast_log(LOG_WARNING, "%s requires a variable, and at least one value\n", cmd); 01259 return -1; 01260 } 01261 01262 if (args.delimiter && strlen(args.delimiter) != 1) { 01263 ast_log(LOG_WARNING, "%s delimeters should be a single character\n", cmd); 01264 return -1; 01265 } 01266 01267 if (!(buf = ast_str_create(32))) { 01268 ast_log(LOG_ERROR, "Unable to allocate memory for buffer!\n"); 01269 return -1; 01270 } 01271 01272 ast_channel_lock(chan); 01273 if (!(tmp = pbx_builtin_getvar_helper(chan, args.var))) { 01274 ast_str_set(&buf, 0, "%s", val); 01275 } else { 01276 ast_str_append(&buf, 0, "%s%s%s", beginning ? val : tmp, S_OR(args.delimiter, ","), beginning ? tmp : val); 01277 } 01278 ast_channel_unlock(chan); 01279 01280 pbx_builtin_setvar_helper(chan, args.var, ast_str_buffer(buf)); 01281 ast_free(buf); 01282 01283 return 0; 01284 }
| static int array_remove | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | var, | |||
| char * | buf, | |||
| size_t | len, | |||
| int | beginning | |||
| ) | [static] |
Definition at line 1172 of file func_strings.c.
References AST_APP_ARG, ast_channel_lock, ast_channel_unlock, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), LOG_WARNING, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), s, and S_OR.
Referenced by pop(), and shift().
01173 { 01174 const char *tmp; 01175 char *after, *before; 01176 char *(*search_func)(const char *s, int c) = beginning ? strchr : strrchr; 01177 AST_DECLARE_APP_ARGS(args, 01178 AST_APP_ARG(var); 01179 AST_APP_ARG(delimiter); 01180 ); 01181 01182 if (!chan) { 01183 ast_log(LOG_WARNING, "%s requires a channel\n", cmd); 01184 return -1; 01185 } 01186 01187 AST_STANDARD_APP_ARGS(args, var); 01188 01189 if (ast_strlen_zero(args.var)) { 01190 ast_log(LOG_WARNING, "%s requires a channel variable name\n", cmd); 01191 return -1; 01192 } 01193 01194 if (args.delimiter && strlen(args.delimiter) != 1) { 01195 ast_log(LOG_WARNING, "%s delimeters should be a single character\n", cmd); 01196 return -1; 01197 } 01198 01199 ast_channel_lock(chan); 01200 if (ast_strlen_zero(tmp = pbx_builtin_getvar_helper(chan, args.var))) { 01201 ast_channel_unlock(chan); 01202 return 0; 01203 } 01204 01205 before = ast_strdupa(tmp); 01206 ast_channel_unlock(chan); 01207 01208 /* Only one entry in array */ 01209 if (!(after = search_func(before, S_OR(args.delimiter, ",")[0]))) { 01210 ast_copy_string(buf, before, len); 01211 pbx_builtin_setvar_helper(chan, args.var, ""); 01212 } else { 01213 *after++ = '\0'; 01214 ast_copy_string(buf, beginning ? before : after, len); 01215 pbx_builtin_setvar_helper(chan, args.var, beginning ? after : before); 01216 } 01217 01218 return 0; 01219 01220 }
| static void clearvar_prefix | ( | struct ast_channel * | chan, | |
| const char * | prefix | |||
| ) | [static] |
Definition at line 660 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().
00661 { 00662 struct ast_var_t *var; 00663 int len = strlen(prefix); 00664 AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->varshead, var, entries) { 00665 if (strncasecmp(prefix, ast_var_name(var), len) == 0) { 00666 AST_LIST_REMOVE_CURRENT(entries); 00667 ast_free(var); 00668 } 00669 } 00670 AST_LIST_TRAVERSE_SAFE_END 00671 }
| static int csv_quote | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 912 of file func_strings.c.
References ast_copy_string(), ast_log(), ast_strlen_zero(), LOG_ERROR, and LOG_WARNING.
00913 { 00914 char *bufptr = buf, *dataptr = data; 00915 00916 if (len < 3){ /* at least two for quotes and one for binary zero */ 00917 ast_log(LOG_ERROR, "Not enough buffer"); 00918 return -1; 00919 } 00920 00921 if (ast_strlen_zero(data)) { 00922 ast_log(LOG_WARNING, "No argument specified!\n"); 00923 ast_copy_string(buf,"\"\"",len); 00924 return 0; 00925 } 00926 00927 *bufptr++ = '"'; 00928 for (; bufptr < buf + len - 3; dataptr++){ 00929 if (*dataptr == '"') { 00930 *bufptr++ = '"'; 00931 *bufptr++ = '"'; 00932 } else if (*dataptr == '\0') { 00933 break; 00934 } else { 00935 *bufptr++ = *dataptr; 00936 } 00937 } 00938 *bufptr++ = '"'; 00939 *bufptr='\0'; 00940 return 0; 00941 }
| static int exec_clearhash | ( | struct ast_channel * | chan, | |
| const char * | data | |||
| ) | [static] |
Definition at line 673 of file func_strings.c.
References clearvar_prefix(), HASH_PREFIX, and prefix.
Referenced by load_module().
00674 { 00675 char prefix[80]; 00676 snprintf(prefix, sizeof(prefix), HASH_PREFIX, data ? (char *)data : "null"); 00677 clearvar_prefix(chan, prefix); 00678 return 0; 00679 }
| static int filter | ( | 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 AST_APP_ARG, ast_debug, AST_DECLARE_APP_ARGS, ast_get_encoded_char(), ast_log(), AST_STANDARD_APP_ARGS, and LOG_ERROR.
Referenced by realtime_ldap_base_ap(), set_egress_subscription(), update2_ldap(), and update_ldap().
00550 { 00551 AST_DECLARE_APP_ARGS(args, 00552 AST_APP_ARG(allowed); 00553 AST_APP_ARG(string); 00554 ); 00555 char *outbuf = buf, ac; 00556 char allowed[256] = ""; 00557 size_t allowedlen = 0; 00558 00559 AST_STANDARD_APP_ARGS(args, parse); 00560 00561 if (!args.string) { 00562 ast_log(LOG_ERROR, "Usage: FILTER(<allowed-chars>,<string>)\n"); 00563 return -1; 00564 } 00565 00566 /* Expand ranges */ 00567 for (; *(args.allowed) && allowedlen < sizeof(allowed); ) { 00568 char c1 = 0, c2 = 0; 00569 size_t consumed = 0; 00570 00571 if (ast_get_encoded_char(args.allowed, &c1, &consumed)) 00572 return -1; 00573 args.allowed += consumed; 00574 00575 if (*(args.allowed) == '-') { 00576 if (ast_get_encoded_char(args.allowed + 1, &c2, &consumed)) 00577 c2 = -1; 00578 args.allowed += consumed + 1; 00579 00580 /*!\note 00581 * Looks a little strange, until you realize that we can overflow 00582 * the size of a char. 00583 */ 00584 for (ac = c1; ac != c2 && allowedlen < sizeof(allowed) - 1; ac++) 00585 allowed[allowedlen++] = ac; 00586 allowed[allowedlen++] = ac; 00587 00588 ast_debug(4, "c1=%d, c2=%d\n", c1, c2); 00589 00590 /* Decrement before the loop increment */ 00591 (args.allowed)--; 00592 } else 00593 allowed[allowedlen++] = c1; 00594 } 00595 00596 ast_debug(1, "Allowed: %s\n", allowed); 00597 00598 for (; *(args.string) && (buf + len - 1 > outbuf); (args.string)++) { 00599 if (strchr(allowed, *(args.string))) 00600 *outbuf++ = *(args.string); 00601 } 00602 *outbuf = '\0'; 00603 00604 return 0; 00605 }
| static int function_eval | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | buflen | |||
| ) | [static] |
Definition at line 1042 of file func_strings.c.
References ast_log(), ast_strlen_zero(), LOG_WARNING, and pbx_substitute_variables_helper().
01044 { 01045 if (ast_strlen_zero(data)) { 01046 ast_log(LOG_WARNING, "EVAL requires an argument: EVAL(<string>)\n"); 01047 return -1; 01048 } 01049 01050 pbx_substitute_variables_helper(chan, data, buf, buflen - 1); 01051 01052 return 0; 01053 }
| static int function_eval2 | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| struct ast_str ** | buf, | |||
| ssize_t | buflen | |||
| ) | [static] |
Definition at line 1055 of file func_strings.c.
References ast_log(), ast_str_substitute_variables(), ast_strlen_zero(), and LOG_WARNING.
01057 { 01058 if (ast_strlen_zero(data)) { 01059 ast_log(LOG_WARNING, "EVAL requires an argument: EVAL(<string>)\n"); 01060 return -1; 01061 } 01062 01063 ast_str_substitute_variables(buf, buflen, chan, data); 01064 01065 return 0; 01066 }
| static int function_fieldqty | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | parse, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 408 of file func_strings.c.
References function_fieldqty_helper().
00410 { 00411 return function_fieldqty_helper(chan, cmd, parse, buf, NULL, len); 00412 }
| 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 362 of file func_strings.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_free, ast_get_encoded_char(), AST_STANDARD_APP_ARGS, ast_str_buffer(), ast_str_create(), ast_str_set(), ast_str_strlen(), ast_str_substitute_variables(), str, and strsep().
Referenced by function_fieldqty(), and function_fieldqty_str().
00364 { 00365 char *varsubst; 00366 struct ast_str *str = ast_str_create(16); 00367 int fieldcount = 0; 00368 AST_DECLARE_APP_ARGS(args, 00369 AST_APP_ARG(varname); 00370 AST_APP_ARG(delim); 00371 ); 00372 char delim[2] = ""; 00373 size_t delim_used; 00374 00375 if (!str) { 00376 return -1; 00377 } 00378 00379 AST_STANDARD_APP_ARGS(args, parse); 00380 if (args.delim) { 00381 ast_get_encoded_char(args.delim, delim, &delim_used); 00382 00383 varsubst = alloca(strlen(args.varname) + 4); 00384 00385 sprintf(varsubst, "${%s}", args.varname); 00386 ast_str_substitute_variables(&str, 0, chan, varsubst); 00387 if (ast_str_strlen(str) == 0) { 00388 fieldcount = 0; 00389 } else { 00390 char *varval = ast_str_buffer(str); 00391 while (strsep(&varval, delim)) { 00392 fieldcount++; 00393 } 00394 } 00395 } else { 00396 fieldcount = 1; 00397 } 00398 if (sbuf) { 00399 ast_str_set(sbuf, len, "%d", fieldcount); 00400 } else { 00401 snprintf(buf, len, "%d", fieldcount); 00402 } 00403 00404 ast_free(str); 00405 return 0; 00406 }
| 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 414 of file func_strings.c.
References function_fieldqty_helper().
00416 { 00417 return function_fieldqty_helper(chan, cmd, parse, NULL, buf, len); 00418 }
| static int hash_read | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 810 of file func_strings.c.
References AST_APP_ARG, ast_copy_string(), AST_DECLARE_APP_ARGS, AST_STANDARD_APP_ARGS, HASH_FORMAT, hashkeys_read(), pbx_builtin_getvar_helper(), and pbx_builtin_setvar_helper().
00811 { 00812 char varname[256]; 00813 const char *varvalue; 00814 AST_DECLARE_APP_ARGS(arg, 00815 AST_APP_ARG(hashname); 00816 AST_APP_ARG(hashkey); 00817 ); 00818 00819 AST_STANDARD_APP_ARGS(arg, data); 00820 if (arg.argc == 2) { 00821 snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg.hashkey); 00822 varvalue = pbx_builtin_getvar_helper(chan, varname); 00823 if (varvalue) 00824 ast_copy_string(buf, varvalue, len); 00825 else 00826 *buf = '\0'; 00827 } else if (arg.argc == 1) { 00828 char colnames[4096]; 00829 int i; 00830 AST_DECLARE_APP_ARGS(arg2, 00831 AST_APP_ARG(col)[100]; 00832 ); 00833 00834 /* Get column names, in no particular order */ 00835 hashkeys_read(chan, "HASHKEYS", arg.hashname, colnames, sizeof(colnames)); 00836 pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", colnames); 00837 00838 AST_STANDARD_APP_ARGS(arg2, colnames); 00839 *buf = '\0'; 00840 00841 /* Now get the corresponding column values, in exactly the same order */ 00842 for (i = 0; i < arg2.argc; i++) { 00843 snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg2.col[i]); 00844 varvalue = pbx_builtin_getvar_helper(chan, varname); 00845 strncat(buf, varvalue, len - strlen(buf) - 1); 00846 strncat(buf, ",", len - strlen(buf) - 1); 00847 } 00848 00849 /* Strip trailing comma */ 00850 buf[strlen(buf) - 1] = '\0'; 00851 } 00852 00853 return 0; 00854 }
| static int hash_write | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | var, | |||
| const char * | value | |||
| ) | [static] |
Definition at line 790 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().
00791 { 00792 char varname[256]; 00793 AST_DECLARE_APP_ARGS(arg, 00794 AST_APP_ARG(hashname); 00795 AST_APP_ARG(hashkey); 00796 ); 00797 00798 if (!strchr(var, ',')) { 00799 /* Single argument version */ 00800 return array(chan, "HASH", var, value); 00801 } 00802 00803 AST_STANDARD_APP_ARGS(arg, var); 00804 snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg.hashkey); 00805 pbx_builtin_setvar_helper(chan, varname, value); 00806 00807 return 0; 00808 }
| static int hashkeys_read | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 746 of file func_strings.c.
References AST_LIST_TRAVERSE, ast_str_alloca, ast_str_buffer(), ast_str_set(), ast_str_strlen(), ast_var_name(), HASH_PREFIX, prefix, and ast_channel::varshead.
Referenced by hash_read().
00747 { 00748 struct ast_var_t *newvar; 00749 struct ast_str *prefix = ast_str_alloca(80); 00750 00751 ast_str_set(&prefix, -1, HASH_PREFIX, data); 00752 memset(buf, 0, len); 00753 00754 AST_LIST_TRAVERSE(&chan->varshead, newvar, entries) { 00755 if (strncasecmp(ast_str_buffer(prefix), ast_var_name(newvar), ast_str_strlen(prefix)) == 0) { 00756 /* Copy everything after the prefix */ 00757 strncat(buf, ast_var_name(newvar) + ast_str_strlen(prefix), len - strlen(buf) - 1); 00758 /* Trim the trailing ~ */ 00759 buf[strlen(buf) - 1] = ','; 00760 } 00761 } 00762 /* Trim the trailing comma */ 00763 buf[strlen(buf) - 1] = '\0'; 00764 return 0; 00765 }
| static int hashkeys_read2 | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| struct ast_str ** | buf, | |||
| ssize_t | len | |||
| ) | [static] |
Definition at line 767 of file func_strings.c.
References AST_LIST_TRAVERSE, ast_str_alloca, ast_str_append(), ast_str_buffer(), ast_str_set(), ast_str_strlen(), ast_var_name(), HASH_PREFIX, prefix, and ast_channel::varshead.
00768 { 00769 struct ast_var_t *newvar; 00770 struct ast_str *prefix = ast_str_alloca(80); 00771 char *tmp; 00772 00773 ast_str_set(&prefix, -1, HASH_PREFIX, data); 00774 00775 AST_LIST_TRAVERSE(&chan->varshead, newvar, entries) { 00776 if (strncasecmp(ast_str_buffer(prefix), ast_var_name(newvar), ast_str_strlen(prefix)) == 0) { 00777 /* Copy everything after the prefix */ 00778 ast_str_append(buf, len, "%s", ast_var_name(newvar) + ast_str_strlen(prefix)); 00779 /* Trim the trailing ~ */ 00780 tmp = ast_str_buffer(*buf); 00781 tmp[ast_str_strlen(*buf) - 1] = ','; 00782 } 00783 } 00784 /* Trim the trailing comma */ 00785 tmp = ast_str_buffer(*buf); 00786 tmp[ast_str_strlen(*buf) - 1] = '\0'; 00787 return 0; 00788 }
| static int keypadhash | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | buflen | |||
| ) | [static] |
Definition at line 1074 of file func_strings.c.
01075 { 01076 char *bufptr, *dataptr; 01077 01078 for (bufptr = buf, dataptr = data; bufptr < buf + buflen - 1; dataptr++) { 01079 if (*dataptr == '\0') { 01080 *bufptr++ = '\0'; 01081 break; 01082 } else if (*dataptr == '1') { 01083 *bufptr++ = '1'; 01084 } else if (strchr("AaBbCc2", *dataptr)) { 01085 *bufptr++ = '2'; 01086 } else if (strchr("DdEeFf3", *dataptr)) { 01087 *bufptr++ = '3'; 01088 } else if (strchr("GgHhIi4", *dataptr)) { 01089 *bufptr++ = '4'; 01090 } else if (strchr("JjKkLl5", *dataptr)) { 01091 *bufptr++ = '5'; 01092 } else if (strchr("MmNnOo6", *dataptr)) { 01093 *bufptr++ = '6'; 01094 } else if (strchr("PpQqRrSs7", *dataptr)) { 01095 *bufptr++ = '7'; 01096 } else if (strchr("TtUuVv8", *dataptr)) { 01097 *bufptr++ = '8'; 01098 } else if (strchr("WwXxYyZz9", *dataptr)) { 01099 *bufptr++ = '9'; 01100 } else if (*dataptr == '0') { 01101 *bufptr++ = '0'; 01102 } 01103 } 01104 buf[buflen - 1] = '\0'; 01105 01106 return 0; 01107 }
| static int len | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | buflen | |||
| ) | [static] |
Definition at line 948 of file func_strings.c.
Referenced by __analog_ss_thread(), __ast_cli_register(), __get_header(), _parse(), add_sdp(), ael_token_subst(), aes_helper(), aji_io_recv(), aji_recv(), aji_send_header(), aji_send_raw(), aji_start_sasl(), alsa_write(), analog_ss_thread(), append_interface(), append_var_and_value_to_filter(), ast_agi_register_multiple(), ast_agi_unregister_multiple(), ast_app_group_set_channel(), ast_callerid_vmwi_generate(), ast_cdr_appenduserfield(), ast_cli_complete(), ast_codec_get_len(), ast_complete_source_filename(), ast_dsp_noise(), ast_dsp_process(), ast_dsp_silence(), ast_event_cb(), ast_frdup(), ast_getformatname_multiple(), ast_http_send(), ast_http_uri_link(), ast_mkdir(), ast_read_image(), ast_rtcp_read(), ast_rtcp_write_rr(), ast_rtcp_write_sr(), ast_rtp_read(), ast_say_number_full_ka(), ast_smoother_read(), ast_str_buffer(), ast_str_substitute_variables_full(), ast_translate(), ast_udptl_read(), ast_udptl_write(), auth_exec(), authenticate(), build_device(), build_facility(), builtin_automixmonitor(), builtin_automonitor(), callerid_generate(), cleaned_basedn(), clearvar_prefix(), cli_console_sendtext(), complete_agent_logoff_cmd(), 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(), complete_peer_helper(), conf_play(), config_jitterbuffer(), copy(), create_video_frame(), dahdi_sendtext(), dahdi_setoption(), devstate_write(), dialgroup_refreshdb(), dictate_exec(), dundi_encrypt(), dundi_parse_ies(), dundi_send(), enc_ie_facility(), evt_event_deliver_cb(), expr2_token_subst(), feature_request_and_dial(), ffmpeg_decode(), 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_devstate_change(), handle_commandmatchesarray(), handle_output(), handle_response(), help1(), iax_parse_ies(), iax_str2flags(), launch_monitor_thread(), load_file(), local_call(), lpc10tolin_framein(), message_template_parse_emailbody(), mgcp_ss(), mgcpsock_read(), misdn_read(), monmp3thread(), mpeg4_encap(), newpvt(), ogg_vorbis_read(), parse_ie(), ParseBookmark(), pbx_load_users(), pbx_substitute_variables_helper_full(), phoneprov_callback(), process_sdp(), readfile_exec(), red_t140_to_red(), reschedule_precache(), run_agi(), set(), set_egress_subscription(), skinny_ss(), sms_messagetx(), socket_read(), static_callback(), strndup(), strnlen(), term_filter_escapes(), transfer_exec(), udptl_build_packet(), unistim_sp(), unquote(), and wav_write().
00949 { 00950 int length = 0; 00951 00952 if (data) 00953 length = strlen(data); 00954 00955 snprintf(buf, buflen, "%d", length); 00956 00957 return 0; 00958 }
| 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 426 of file func_strings.c.
References 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_thread_get(), first, LOG_ERROR, ast_custom_function::next, pbx_builtin_getvar_helper(), and result_buf.
Referenced by listfilter_read(), and listfilter_read2().
00427 { 00428 AST_DECLARE_APP_ARGS(args, 00429 AST_APP_ARG(listname); 00430 AST_APP_ARG(delimiter); 00431 AST_APP_ARG(fieldvalue); 00432 ); 00433 const char *orig_list, *ptr; 00434 const char *begin, *cur, *next; 00435 int dlen, flen, first = 1; 00436 struct ast_str *result, **result_ptr = &result; 00437 char *delim; 00438 00439 AST_STANDARD_APP_ARGS(args, parse); 00440 00441 if (buf) { 00442 result = ast_str_thread_get(&result_buf, 16); 00443 } else { 00444 /* Place the result directly into the output buffer */ 00445 result_ptr = bufstr; 00446 } 00447 00448 if (args.argc < 3) { 00449 ast_log(LOG_ERROR, "Usage: LISTFILTER(<listname>,<delimiter>,<fieldvalue>)\n"); 00450 return -1; 00451 } 00452 00453 /* If we don't lock the channel, the variable could disappear out from underneath us. */ 00454 if (chan) { 00455 ast_channel_lock(chan); 00456 } 00457 if (!(orig_list = pbx_builtin_getvar_helper(chan, args.listname))) { 00458 ast_log(LOG_ERROR, "List variable '%s' not found\n", args.listname); 00459 if (chan) { 00460 ast_channel_unlock(chan); 00461 } 00462 return -1; 00463 } 00464 00465 /* If the string isn't there, just copy out the string and be done with it. */ 00466 if (!(ptr = strstr(orig_list, args.fieldvalue))) { 00467 if (buf) { 00468 ast_copy_string(buf, orig_list, len); 00469 } else { 00470 ast_str_set(result_ptr, len, "%s", orig_list); 00471 } 00472 if (chan) { 00473 ast_channel_unlock(chan); 00474 } 00475 return 0; 00476 } 00477 00478 dlen = strlen(args.delimiter); 00479 delim = alloca(dlen + 1); 00480 ast_get_encoded_str(args.delimiter, delim, dlen + 1); 00481 00482 if ((dlen = strlen(delim)) == 0) { 00483 delim = ","; 00484 dlen = 1; 00485 } 00486 00487 flen = strlen(args.fieldvalue); 00488 00489 ast_str_reset(result); 00490 /* Enough space for any result */ 00491 if (len > -1) { 00492 ast_str_make_space(result_ptr, len ? len : strlen(orig_list) + 1); 00493 } 00494 00495 begin = orig_list; 00496 next = strstr(begin, delim); 00497 00498 do { 00499 /* Find next boundary */ 00500 if (next) { 00501 cur = next; 00502 next = strstr(cur + dlen, delim); 00503 } else { 00504 cur = strchr(begin + dlen, '\0'); 00505 } 00506 00507 if (flen == cur - begin && !strncmp(begin, args.fieldvalue, flen)) { 00508 /* Skip field */ 00509 begin += flen + dlen; 00510 } else { 00511 /* Copy field to output */ 00512 if (!first) { 00513 ast_str_append(result_ptr, len, "%s", delim); 00514 } 00515 00516 ast_str_append_substr(result_ptr, len, begin, cur - begin + 1); 00517 first = 0; 00518 begin = cur + dlen; 00519 } 00520 } while (*cur != '\0'); 00521 if (chan) { 00522 ast_channel_unlock(chan); 00523 } 00524 00525 if (buf) { 00526 ast_copy_string(buf, ast_str_buffer(result), len); 00527 } 00528 00529 return 0; 00530 }
| static int listfilter_read | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | parse, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 532 of file func_strings.c.
References listfilter().
00533 { 00534 return listfilter(chan, cmd, parse, buf, NULL, len); 00535 }
| static int listfilter_read2 | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | parse, | |||
| struct ast_str ** | buf, | |||
| ssize_t | len | |||
| ) | [static] |
Definition at line 537 of file func_strings.c.
References listfilter().
00538 { 00539 return listfilter(chan, cmd, parse, NULL, buf, len); 00540 }
| static int load_module | ( | void | ) | [static] |
Definition at line 1335 of file func_strings.c.
References ast_custom_function_register, ast_register_application_xml, and exec_clearhash().
01336 { 01337 int res = 0; 01338 01339 res |= ast_custom_function_register(&fieldqty_function); 01340 res |= ast_custom_function_register(&filter_function); 01341 res |= ast_custom_function_register(&listfilter_function); 01342 res |= ast_custom_function_register(®ex_function); 01343 res |= ast_custom_function_register(&array_function); 01344 res |= ast_custom_function_register("e_function); 01345 res |= ast_custom_function_register(&csv_quote_function); 01346 res |= ast_custom_function_register(&len_function); 01347 res |= ast_custom_function_register(&strftime_function); 01348 res |= ast_custom_function_register(&strptime_function); 01349 res |= ast_custom_function_register(&eval_function); 01350 res |= ast_custom_function_register(&keypadhash_function); 01351 res |= ast_custom_function_register(&hashkeys_function); 01352 res |= ast_custom_function_register(&hash_function); 01353 res |= ast_register_application_xml(app_clearhash, exec_clearhash); 01354 res |= ast_custom_function_register(&toupper_function); 01355 res |= ast_custom_function_register(&tolower_function); 01356 res |= ast_custom_function_register(&shift_function); 01357 res |= ast_custom_function_register(&pop_function); 01358 res |= ast_custom_function_register(&push_function); 01359 res |= ast_custom_function_register(&unshift_function); 01360 01361 return res; 01362 }
| static int pop | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | var, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 1231 of file func_strings.c.
References array_remove().
01232 { 01233 return array_remove(chan, cmd, var, buf, len, 0); 01234 }
| static int push | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | var, | |||
| const char * | val | |||
| ) | [static] |
Definition at line 1286 of file func_strings.c.
References array_insert().
01287 { 01288 return array_insert(chan, cmd, var, val, 0); 01289 }
| static int quote | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 873 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().
00874 { 00875 char *bufptr = buf, *dataptr = data; 00876 00877 if (len < 3){ /* at least two for quotes and one for binary zero */ 00878 ast_log(LOG_ERROR, "Not enough buffer"); 00879 return -1; 00880 } 00881 00882 if (ast_strlen_zero(data)) { 00883 ast_log(LOG_WARNING, "No argument specified!\n"); 00884 ast_copy_string(buf, "\"\"", len); 00885 return 0; 00886 } 00887 00888 *bufptr++ = '"'; 00889 for (; bufptr < buf + len - 3; dataptr++) { 00890 if (*dataptr == '\\') { 00891 *bufptr++ = '\\'; 00892 *bufptr++ = '\\'; 00893 } else if (*dataptr == '"') { 00894 *bufptr++ = '\\'; 00895 *bufptr++ = '"'; 00896 } else if (*dataptr == '\0') { 00897 break; 00898 } else { 00899 *bufptr++ = *dataptr; 00900 } 00901 } 00902 *bufptr++ = '"'; 00903 *bufptr = '\0'; 00904 return 0; 00905 }
| static int regex | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | parse, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 612 of file func_strings.c.
References AST_APP_ARG, ast_debug, AST_DECLARE_APP_ARGS, ast_log(), AST_NONSTANDARD_APP_ARGS, LOG_ERROR, LOG_WARNING, and str.
00614 { 00615 AST_DECLARE_APP_ARGS(args, 00616 AST_APP_ARG(null); 00617 AST_APP_ARG(reg); 00618 AST_APP_ARG(str); 00619 ); 00620 int errcode; 00621 regex_t regexbuf; 00622 00623 buf[0] = '\0'; 00624 00625 AST_NONSTANDARD_APP_ARGS(args, parse, '"'); 00626 00627 if (args.argc != 3) { 00628 ast_log(LOG_ERROR, "Unexpected arguments: should have been in the form '\"<regex>\" <string>'\n"); 00629 return -1; 00630 } 00631 if ((*args.str == ' ') || (*args.str == '\t')) 00632 args.str++; 00633 00634 ast_debug(1, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str); 00635 00636 if ((errcode = regcomp(®exbuf, args.reg, REG_EXTENDED | REG_NOSUB))) { 00637 regerror(errcode, ®exbuf, buf, len); 00638 ast_log(LOG_WARNING, "Malformed input %s(%s): %s\n", cmd, parse, buf); 00639 return -1; 00640 } 00641 00642 strcpy(buf, regexec(®exbuf, args.str, 0, NULL, 0) ? "0" : "1"); 00643 00644 regfree(®exbuf); 00645 00646 return 0; 00647 }
| static int shift | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | var, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 1222 of file func_strings.c.
References array_remove().
01223 { 01224 return array_remove(chan, cmd, var, buf, len, 1); 01225 }
| static int string_tolower | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | buflen | |||
| ) | [static] |
Definition at line 1143 of file func_strings.c.
01144 { 01145 char *bufptr = buf, *dataptr = data; 01146 01147 while ((bufptr < buf + buflen - 1) && (*bufptr++ = tolower(*dataptr++))); 01148 01149 return 0; 01150 }
| static int string_tolower2 | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| struct ast_str ** | buf, | |||
| ssize_t | buflen | |||
| ) | [static] |
Definition at line 1152 of file func_strings.c.
References ast_str_buffer(), ast_str_make_space(), ast_str_size(), and ast_str_update().
01153 { 01154 char *bufptr, *dataptr = data; 01155 01156 if (buflen > -1) { 01157 ast_str_make_space(buf, buflen > 0 ? buflen : strlen(data) + 1); 01158 } 01159 bufptr = ast_str_buffer(*buf); 01160 while ((bufptr < ast_str_buffer(*buf) + ast_str_size(*buf) - 1) && (*bufptr++ = tolower(*dataptr++))); 01161 ast_str_update(*buf); 01162 01163 return 0; 01164 }
| static int string_toupper | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | buflen | |||
| ) | [static] |
Definition at line 1114 of file func_strings.c.
01115 { 01116 char *bufptr = buf, *dataptr = data; 01117 01118 while ((bufptr < buf + buflen - 1) && (*bufptr++ = toupper(*dataptr++))); 01119 01120 return 0; 01121 }
| static int string_toupper2 | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| struct ast_str ** | buf, | |||
| ssize_t | buflen | |||
| ) | [static] |
Definition at line 1123 of file func_strings.c.
References ast_str_buffer(), ast_str_make_space(), ast_str_size(), and ast_str_update().
01124 { 01125 char *bufptr, *dataptr = data; 01126 01127 if (buflen > -1) { 01128 ast_str_make_space(buf, buflen > 0 ? buflen : strlen(data) + 1); 01129 } 01130 bufptr = ast_str_buffer(*buf); 01131 while ((bufptr < ast_str_buffer(*buf) + ast_str_size(*buf) - 1) && (*bufptr++ = toupper(*dataptr++))); 01132 ast_str_update(*buf); 01133 01134 return 0; 01135 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 1306 of file func_strings.c.
References ast_custom_function_unregister(), and ast_unregister_application().
01307 { 01308 int res = 0; 01309 01310 res |= ast_custom_function_unregister(&fieldqty_function); 01311 res |= ast_custom_function_unregister(&filter_function); 01312 res |= ast_custom_function_unregister(&listfilter_function); 01313 res |= ast_custom_function_unregister(®ex_function); 01314 res |= ast_custom_function_unregister(&array_function); 01315 res |= ast_custom_function_unregister("e_function); 01316 res |= ast_custom_function_unregister(&csv_quote_function); 01317 res |= ast_custom_function_unregister(&len_function); 01318 res |= ast_custom_function_unregister(&strftime_function); 01319 res |= ast_custom_function_unregister(&strptime_function); 01320 res |= ast_custom_function_unregister(&eval_function); 01321 res |= ast_custom_function_unregister(&keypadhash_function); 01322 res |= ast_custom_function_unregister(&hashkeys_function); 01323 res |= ast_custom_function_unregister(&hash_function); 01324 res |= ast_unregister_application(app_clearhash); 01325 res |= ast_custom_function_unregister(&toupper_function); 01326 res |= ast_custom_function_unregister(&tolower_function); 01327 res |= ast_custom_function_unregister(&shift_function); 01328 res |= ast_custom_function_unregister(&pop_function); 01329 res |= ast_custom_function_unregister(&push_function); 01330 res |= ast_custom_function_unregister(&unshift_function); 01331 01332 return res; 01333 }
| static int unshift | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | var, | |||
| const char * | val | |||
| ) | [static] |
Definition at line 1296 of file func_strings.c.
References array_insert().
01297 { 01298 return array_insert(chan, cmd, var, val, 1); 01299 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "String handling dialplan functions" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
Definition at line 1364 of file func_strings.c.
char* app_clearhash = "ClearHash" [static] |
Definition at line 657 of file func_strings.c.
struct ast_custom_function array_function [static] |
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 1364 of file func_strings.c.
struct ast_custom_function csv_quote_function [static] |
Initial value:
{
.name = "CSV_QUOTE",
.read = csv_quote,
}
Definition at line 943 of file func_strings.c.
struct ast_custom_function eval_function [static] |
Initial value:
{
.name = "EVAL",
.read = function_eval,
.read2 = function_eval2,
}
Definition at line 1068 of file func_strings.c.
struct ast_custom_function fieldqty_function [static] |
Initial value:
{
.name = "FIELDQTY",
.read = function_fieldqty,
.read2 = function_fieldqty_str,
}
Definition at line 420 of file func_strings.c.
struct ast_custom_function filter_function [static] |
struct ast_custom_function hash_function [static] |
Initial value:
{
.name = "HASH",
.write = hash_write,
.read = hash_read,
}
Definition at line 856 of file func_strings.c.
struct ast_custom_function hashkeys_function [static] |
Initial value:
{
.name = "HASHKEYS",
.read = hashkeys_read,
.read2 = hashkeys_read2,
}
Definition at line 862 of file func_strings.c.
struct ast_custom_function keypadhash_function [static] |
Initial value:
{
.name = "KEYPADHASH",
.read = keypadhash,
}
Definition at line 1109 of file func_strings.c.
struct ast_custom_function len_function [static] |
Initial value:
{
.name = "LEN",
.read = len,
.read_max = 12,
}
Definition at line 960 of file func_strings.c.
struct ast_custom_function listfilter_function [static] |
Initial value:
{
.name = "LISTFILTER",
.read = listfilter_read,
.read2 = listfilter_read2,
}
Definition at line 542 of file func_strings.c.
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_threadstorage result_buf = { .once = PTHREAD_ONCE_INIT, .key_init = __init_result_buf , .custom_init = NULL , } [static] |
Definition at line 42 of file func_strings.c.
struct ast_custom_function shift_function [static] |
struct ast_custom_function strftime_function [static] |
Initial value:
{
.name = "STRFTIME",
.read = acf_strftime,
}
Definition at line 995 of file func_strings.c.
struct ast_custom_function strptime_function [static] |
Initial value:
{
.name = "STRPTIME",
.read = acf_strptime,
}
Definition at line 1037 of file func_strings.c.
struct ast_custom_function tolower_function [static] |
Initial value:
{
.name = "TOLOWER",
.read = string_tolower,
.read2 = string_tolower2,
}
Definition at line 1166 of file func_strings.c.
struct ast_custom_function toupper_function [static] |
Initial value:
{
.name = "TOUPPER",
.read = string_toupper,
.read2 = string_toupper2,
}
Definition at line 1137 of file func_strings.c.
struct ast_custom_function unshift_function [static] |
Initial value:
{
.name = "UNSHIFT",
.write = unshift,
}
Definition at line 1301 of file func_strings.c.
1.5.6