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"
Go to the source code of this file.
Defines | |
| #define | HASH_FORMAT HASH_PREFIX "%s~" |
| #define | HASH_PREFIX "~HASH~%s~" |
Functions | |
| 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) |
| AST_THREADSTORAGE_CUSTOM_SCOPE (result_buf, NULL, ast_free_ptr, static) | |
| 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, void *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_fieldqty (struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_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 | 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, size_t len) |
| static int | load_module (void) |
| 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 | string_tolower (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen) |
| static int | string_toupper (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen) |
| static int | unload_module (void) |
Variables | |
| static struct ast_module_info __MODULE_INFO_SECTION | __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "String handling dialplan functions" , .key = ASTERISK_GPL_KEY , .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 | quote_function |
| static struct ast_custom_function | regex_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 |
String manipulation dialplan functions.
Definition in file func_strings.c.
| #define HASH_FORMAT HASH_PREFIX "%s~" |
Definition at line 551 of file func_strings.c.
Referenced by array(), hash_read(), and hash_write().
| #define HASH_PREFIX "~HASH~%s~" |
Definition at line 550 of file func_strings.c.
Referenced by exec_clearhash(), and hashkeys_read().
| static void __reg_module | ( | void | ) | [static] |
Definition at line 1050 of file func_strings.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 1050 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 838 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.
{
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(epoch);
AST_APP_ARG(timezone);
AST_APP_ARG(format);
);
struct timeval when;
struct ast_tm tm;
buf[0] = '\0';
AST_STANDARD_APP_ARGS(args, parse);
ast_get_timeval(args.epoch, &when, ast_tvnow(), NULL);
ast_localtime(&when, &tm, args.timezone);
if (!args.format)
args.format = "%c";
if (ast_strftime(buf, buflen, args.format, &tm) <= 0)
ast_log(LOG_WARNING, "C function strftime() output nothing?!!\n");
buf[buflen - 1] = '\0';
return 0;
}
| static int acf_strptime | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | data, | ||
| char * | buf, | ||
| size_t | buflen | ||
| ) | [static] |
Definition at line 872 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.
{
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(timestring);
AST_APP_ARG(timezone);
AST_APP_ARG(format);
);
struct ast_tm tm;
buf[0] = '\0';
if (!data) {
ast_log(LOG_ERROR,
"Asterisk function STRPTIME() requires an argument.\n");
return -1;
}
AST_STANDARD_APP_ARGS(args, data);
if (ast_strlen_zero(args.format)) {
ast_log(LOG_ERROR,
"No format supplied to STRPTIME(<timestring>,<timezone>,<format>)");
return -1;
}
if (!ast_strptime(args.timestring, args.format, &tm)) {
ast_log(LOG_WARNING, "STRPTIME() found no time specified within the string\n");
} else {
struct timeval when;
when = ast_mktime(&tm, args.timezone);
snprintf(buf, buflen, "%d", (int) when.tv_sec);
}
return 0;
}
| static int array | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | var, | ||
| const char * | value | ||
| ) | [static] |
Definition at line 577 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().
{
AST_DECLARE_APP_ARGS(arg1,
AST_APP_ARG(var)[100];
);
AST_DECLARE_APP_ARGS(arg2,
AST_APP_ARG(val)[100];
);
char *origvar = "", *value2, varname[256];
int i, ishash = 0;
value2 = ast_strdupa(value);
if (!var || !value2)
return -1;
if (!strcmp(cmd, "HASH")) {
const char *var2 = pbx_builtin_getvar_helper(chan, "~ODBCFIELDS~");
origvar = var;
if (var2)
var = ast_strdupa(var2);
else {
if (chan)
ast_autoservice_stop(chan);
return -1;
}
ishash = 1;
}
/* The functions this will generally be used with are SORT and ODBC_*, which
* both return comma-delimited lists. However, if somebody uses literal lists,
* their commas will be translated to vertical bars by the load, and I don't
* want them to be surprised by the result. Hence, we prefer commas as the
* delimiter, but we'll fall back to vertical bars if commas aren't found.
*/
ast_debug(1, "array (%s=%s)\n", var, S_OR(value2, ""));
AST_STANDARD_APP_ARGS(arg1, var);
AST_STANDARD_APP_ARGS(arg2, value2);
for (i = 0; i < arg1.argc; i++) {
ast_debug(1, "array set value (%s=%s)\n", arg1.var[i],
S_OR(arg2.val[i], ""));
if (i < arg2.argc) {
if (ishash) {
snprintf(varname, sizeof(varname), HASH_FORMAT, origvar, arg1.var[i]);
pbx_builtin_setvar_helper(chan, varname, arg2.val[i]);
} else {
pbx_builtin_setvar_helper(chan, arg1.var[i], arg2.val[i]);
}
} else {
/* We could unset the variable, by passing a NULL, but due to
* pushvar semantics, that could create some undesired behavior. */
if (ishash) {
snprintf(varname, sizeof(varname), HASH_FORMAT, origvar, arg1.var[i]);
pbx_builtin_setvar_helper(chan, varname, "");
} else {
pbx_builtin_setvar_helper(chan, arg1.var[i], "");
}
}
}
return 0;
}
| AST_THREADSTORAGE_CUSTOM_SCOPE | ( | result_buf | , |
| NULL | , | ||
| ast_free_ptr | , | ||
| static | |||
| ) |
| static void clearvar_prefix | ( | struct ast_channel * | chan, |
| const char * | prefix | ||
| ) | [static] |
Definition at line 556 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().
{
struct ast_var_t *var;
int len = strlen(prefix);
AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->varshead, var, entries) {
if (strncasecmp(prefix, ast_var_name(var), len) == 0) {
AST_LIST_REMOVE_CURRENT(entries);
ast_free(var);
}
}
AST_LIST_TRAVERSE_SAFE_END
}
| static int csv_quote | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | data, | ||
| char * | buf, | ||
| size_t | len | ||
| ) | [static] |
Definition at line 785 of file func_strings.c.
References ast_copy_string(), ast_log(), ast_strlen_zero(), buf, LOG_ERROR, and LOG_WARNING.
{
char *bufptr = buf, *dataptr = data;
if (len < 3){ /* at least two for quotes and one for binary zero */
ast_log(LOG_ERROR, "Not enough buffer");
return -1;
}
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "No argument specified!\n");
ast_copy_string(buf,"\"\"",len);
return 0;
}
*bufptr++ = '"';
for (; bufptr < buf + len - 3; dataptr++){
if (*dataptr == '"') {
*bufptr++ = '"';
*bufptr++ = '"';
} else if (*dataptr == '\0') {
break;
} else {
*bufptr++ = *dataptr;
}
}
*bufptr++ = '"';
*bufptr='\0';
return 0;
}
| static int exec_clearhash | ( | struct ast_channel * | chan, |
| void * | data | ||
| ) | [static] |
Definition at line 569 of file func_strings.c.
References clearvar_prefix(), HASH_PREFIX, and prefix.
Referenced by load_module().
{
char prefix[80];
snprintf(prefix, sizeof(prefix), HASH_PREFIX, data ? (char *)data : "null");
clearvar_prefix(chan, prefix);
return 0;
}
| static int filter | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | parse, | ||
| char * | buf, | ||
| size_t | len | ||
| ) | [static] |
Definition at line 427 of file func_strings.c.
References AST_APP_ARG, ast_debug, AST_DECLARE_APP_ARGS, ast_get_encoded_char(), ast_log(), ast_opt_dont_warn, AST_STANDARD_RAW_ARGS, buf, LOG_ERROR, and LOG_WARNING.
Referenced by realtime_ldap_base_ap(), set_egress_subscription(), update2_ldap(), and update_ldap().
{
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(allowed);
AST_APP_ARG(string);
);
char *outbuf = buf;
unsigned char ac;
char allowed[256] = "";
size_t allowedlen = 0;
int32_t bitfield[8] = { 0, }; /* 256 bits */
AST_STANDARD_RAW_ARGS(args, parse);
if (!args.string) {
ast_log(LOG_ERROR, "Usage: FILTER(<allowed-chars>,<string>)\n");
return -1;
}
if (args.allowed[0] == '"' && !ast_opt_dont_warn) {
ast_log(LOG_WARNING, "FILTER allowed characters includes the quote (\") character. This may not be what you want.\n");
}
/* Expand ranges */
for (; *(args.allowed);) {
char c1 = 0, c2 = 0;
size_t consumed = 0;
if (ast_get_encoded_char(args.allowed, &c1, &consumed))
return -1;
args.allowed += consumed;
if (*(args.allowed) == '-') {
if (ast_get_encoded_char(args.allowed + 1, &c2, &consumed))
c2 = c1;
args.allowed += consumed + 1;
if ((unsigned char) c2 < (unsigned char) c1 && !ast_opt_dont_warn) {
ast_log(LOG_WARNING, "Range wrapping in FILTER(%s,%s). This may not be what you want.\n", parse, args.string);
}
/*!\note
* Looks a little strange, until you realize that we can overflow
* the size of a char.
*/
for (ac = (unsigned char) c1; ac != (unsigned char) c2; ac++) {
bitfield[ac / 32] |= 1 << (ac % 32);
}
bitfield[ac / 32] |= 1 << (ac % 32);
ast_debug(4, "c1=%d, c2=%d\n", c1, c2);
} else {
ac = (unsigned char) c1;
ast_debug(4, "c1=%d, consumed=%d, args.allowed=%s\n", c1, (int) consumed, args.allowed - consumed);
bitfield[ac / 32] |= 1 << (ac % 32);
}
}
for (ac = 1; ac != 0; ac++) {
if (bitfield[ac / 32] & (1 << (ac % 32))) {
allowed[allowedlen++] = ac;
}
}
ast_debug(1, "Allowed: %s\n", allowed);
for (; *(args.string) && (buf + len - 1 > outbuf); (args.string)++) {
if (strchr(allowed, *(args.string)))
*outbuf++ = *(args.string);
}
*outbuf = '\0';
return 0;
}
| static int function_eval | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | data, | ||
| char * | buf, | ||
| size_t | buflen | ||
| ) | [static] |
Definition at line 914 of file func_strings.c.
References ast_log(), ast_strlen_zero(), LOG_WARNING, and pbx_substitute_variables_helper().
{
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "EVAL requires an argument: EVAL(<string>)\n");
return -1;
}
pbx_substitute_variables_helper(chan, data, buf, buflen - 1);
return 0;
}
| static int function_fieldqty | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | parse, | ||
| char * | buf, | ||
| size_t | len | ||
| ) | [static] |
Definition at line 292 of file func_strings.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_get_encoded_char(), AST_STANDARD_APP_ARGS, ast_strlen_zero(), pbx_substitute_variables_helper(), and strsep().
{
char *varsubst, varval[8192], *varval2 = varval;
int fieldcount = 0;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(varname);
AST_APP_ARG(delim);
);
char delim[2] = "";
size_t delim_used;
AST_STANDARD_APP_ARGS(args, parse);
if (args.delim) {
ast_get_encoded_char(args.delim, delim, &delim_used);
varsubst = alloca(strlen(args.varname) + 4);
sprintf(varsubst, "${%s}", args.varname);
pbx_substitute_variables_helper(chan, varsubst, varval, sizeof(varval) - 1);
if (ast_strlen_zero(varval2))
fieldcount = 0;
else {
while (strsep(&varval2, delim))
fieldcount++;
}
} else {
fieldcount = 1;
}
snprintf(buf, len, "%d", fieldcount);
return 0;
}
| static int hash_read | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | data, | ||
| char * | buf, | ||
| size_t | len | ||
| ) | [static] |
Definition at line 684 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().
{
char varname[256];
const char *varvalue;
AST_DECLARE_APP_ARGS(arg,
AST_APP_ARG(hashname);
AST_APP_ARG(hashkey);
);
AST_STANDARD_APP_ARGS(arg, data);
if (arg.argc == 2) {
snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg.hashkey);
varvalue = pbx_builtin_getvar_helper(chan, varname);
if (varvalue)
ast_copy_string(buf, varvalue, len);
else
*buf = '\0';
} else if (arg.argc == 1) {
char colnames[4096];
int i;
AST_DECLARE_APP_ARGS(arg2,
AST_APP_ARG(col)[100];
);
/* Get column names, in no particular order */
hashkeys_read(chan, "HASHKEYS", arg.hashname, colnames, sizeof(colnames));
pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", colnames);
AST_STANDARD_APP_ARGS(arg2, colnames);
*buf = '\0';
/* Now get the corresponding column values, in exactly the same order */
for (i = 0; i < arg2.argc; i++) {
snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg2.col[i]);
varvalue = pbx_builtin_getvar_helper(chan, varname);
strncat(buf, varvalue, len - strlen(buf) - 1);
strncat(buf, ",", len - strlen(buf) - 1);
}
/* Strip trailing comma */
buf[strlen(buf) - 1] = '\0';
}
return 0;
}
| static int hash_write | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | var, | ||
| const char * | value | ||
| ) | [static] |
Definition at line 664 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().
{
char varname[256];
AST_DECLARE_APP_ARGS(arg,
AST_APP_ARG(hashname);
AST_APP_ARG(hashkey);
);
if (!strchr(var, ',')) {
/* Single argument version */
return array(chan, "HASH", var, value);
}
AST_STANDARD_APP_ARGS(arg, var);
snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg.hashkey);
pbx_builtin_setvar_helper(chan, varname, value);
return 0;
}
| static int hashkeys_read | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | data, | ||
| char * | buf, | ||
| size_t | len | ||
| ) | [static] |
Definition at line 642 of file func_strings.c.
References AST_LIST_TRAVERSE, ast_var_name(), ast_var_t::entries, HASH_PREFIX, prefix, and ast_channel::varshead.
Referenced by hash_read().
{
struct ast_var_t *newvar;
int plen;
char prefix[80];
snprintf(prefix, sizeof(prefix), HASH_PREFIX, data);
plen = strlen(prefix);
memset(buf, 0, len);
AST_LIST_TRAVERSE(&chan->varshead, newvar, entries) {
if (strncasecmp(prefix, ast_var_name(newvar), plen) == 0) {
/* Copy everything after the prefix */
strncat(buf, ast_var_name(newvar) + plen, len - strlen(buf) - 1);
/* Trim the trailing ~ */
buf[strlen(buf) - 1] = ',';
}
}
/* Trim the trailing comma */
buf[strlen(buf) - 1] = '\0';
return 0;
}
| static int keypadhash | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | data, | ||
| char * | buf, | ||
| size_t | buflen | ||
| ) | [static] |
Definition at line 932 of file func_strings.c.
{
char *bufptr, *dataptr;
for (bufptr = buf, dataptr = data; bufptr < buf + buflen - 1; dataptr++) {
if (*dataptr == '\0') {
*bufptr++ = '\0';
break;
} else if (*dataptr == '1') {
*bufptr++ = '1';
} else if (strchr("AaBbCc2", *dataptr)) {
*bufptr++ = '2';
} else if (strchr("DdEeFf3", *dataptr)) {
*bufptr++ = '3';
} else if (strchr("GgHhIi4", *dataptr)) {
*bufptr++ = '4';
} else if (strchr("JjKkLl5", *dataptr)) {
*bufptr++ = '5';
} else if (strchr("MmNnOo6", *dataptr)) {
*bufptr++ = '6';
} else if (strchr("PpQqRrSs7", *dataptr)) {
*bufptr++ = '7';
} else if (strchr("TtUuVv8", *dataptr)) {
*bufptr++ = '8';
} else if (strchr("WwXxYyZz9", *dataptr)) {
*bufptr++ = '9';
} else if (*dataptr == '0') {
*bufptr++ = '0';
}
}
buf[buflen - 1] = '\0';
return 0;
}
| static int len | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | data, | ||
| char * | buf, | ||
| size_t | buflen | ||
| ) | [static] |
Definition at line 821 of file func_strings.c.
Referenced by __ast_cli_register(), __ast_dsp_call_progress(), __ast_dsp_silence_noise(), __ast_str_helper(), __get_header(), _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(), anti_injection(), 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_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_uri_link(), ast_join(), ast_mkdir(), ast_read_image(), ast_rtcp_read(), ast_rtcp_write_rr(), ast_rtcp_write_sr(), ast_rtp_lookup_mime_multiple(), ast_rtp_read(), ast_say_number_full_ka(), ast_smoother_read(), ast_str_buffer(), ast_tdd_gen_ecdisa(), ast_translate(), ast_udptl_read(), ast_udptl_write(), auth_exec(), authenticate(), build_device(), build_facility(), builtin_automixmonitor(), builtin_automonitor(), calc_energy(), callerid_feed(), callerid_feed_jp(), 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_digit_begin(), dahdi_sendtext(), dahdi_setoption(), decimals2int(), decode_length(), decode_open_type(), devstate_write(), dialgroup_refreshdb(), dictate_exec(), do_tone(), dump_prefs(), dump_raw(), dump_string(), dundi_encrypt(), dundi_parse_ies(), dundi_send(), encode_length(), evt_event_deliver_cb(), expr2_token_subst(), fax_generator_generate(), fbuf_append(), feature_request_and_dial(), ffmpeg_decode(), file_read(), flip_buf_bits(), fsk_serial(), gen_tone(), gen_tones(), 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(), handle_subscribe(), help1(), iax_parse_ies(), iax_str2flags(), iconv_read(), jpeg_read_image(), launch_monitor_thread(), listener(), load_file(), local_call(), lpc10tolin_framein(), make_tone_burst(), manager_rpt_status(), memcpy_decrypt(), memcpy_encrypt(), message_template_parse_emailbody(), 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(), ogg_vorbis_read(), parse_ie(), ParseBookmark(), pbx_load_users(), pbx_substitute_variables_helper_full(), phone_write_buf(), phoneprov_callback(), playtones_generator(), plc_fillin(), plc_rx(), process_sdp(), readfile_exec(), reschedule_precache(), run_agi(), save_history(), schedule_delivery(), send_morse(), set(), set_egress_subscription(), skinny_ss(), sms_messagetx(), socket_process_meta(), socket_read(), ss_thread(), static_callback(), strndup(), strnlen(), strnncpy(), tdd_feed(), term_filter_escapes(), tonepair_generator(), transfer_exec(), try_firmware(), udptl_build_packet(), unistim_sp(), unquote(), vmwi_generate(), and wav_write().
{
int length = 0;
if (data)
length = strlen(data);
snprintf(buf, buflen, "%d", length);
return 0;
}
| static int listfilter | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | parse, | ||
| char * | buf, | ||
| size_t | len | ||
| ) | [static] |
Definition at line 331 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_thread_get(), first, LOG_ERROR, and pbx_builtin_getvar_helper().
{
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(listname);
AST_APP_ARG(delimiter);
AST_APP_ARG(fieldvalue);
);
const char *orig_list, *ptr;
const char *begin, *cur, *next;
int dlen, flen, first = 1;
struct ast_str *result = ast_str_thread_get(&result_buf, 16);
char *delim;
AST_STANDARD_APP_ARGS(args, parse);
if (args.argc < 3) {
ast_log(LOG_ERROR, "Usage: LISTFILTER(<listname>,<delimiter>,<fieldvalue>)\n");
return -1;
}
/* If we don't lock the channel, the variable could disappear out from underneath us. */
if (chan) {
ast_channel_lock(chan);
}
if (!(orig_list = pbx_builtin_getvar_helper(chan, args.listname))) {
ast_log(LOG_ERROR, "List variable '%s' not found\n", args.listname);
if (chan) {
ast_channel_unlock(chan);
}
return -1;
}
/* If the string isn't there, just copy out the string and be done with it. */
if (!(ptr = strstr(orig_list, args.fieldvalue))) {
ast_copy_string(buf, orig_list, len);
if (chan) {
ast_channel_unlock(chan);
}
return 0;
}
dlen = strlen(args.delimiter);
delim = alloca(dlen + 1);
ast_get_encoded_str(args.delimiter, delim, dlen + 1);
if ((dlen = strlen(delim)) == 0) {
delim = ",";
dlen = 1;
}
flen = strlen(args.fieldvalue);
ast_str_reset(result);
/* Enough space for any result */
ast_str_make_space(&result, strlen(orig_list) + 1);
begin = orig_list;
next = strstr(begin, delim);
do {
/* Find next boundary */
if (next) {
cur = next;
next = strstr(cur + dlen, delim);
} else {
cur = strchr(begin + dlen, '\0');
}
if (flen == cur - begin && !strncmp(begin, args.fieldvalue, flen)) {
/* Skip field */
begin += flen + dlen;
} else {
/* Copy field to output */
if (!first) {
ast_str_append(&result, 0, "%s", delim);
}
ast_str_append_substr(&result, 0, begin, cur - begin);
first = 0;
begin = cur + dlen;
}
} while (*cur != '\0');
if (chan) {
ast_channel_unlock(chan);
}
ast_copy_string(buf, ast_str_buffer(result), len);
return 0;
}
| static int load_module | ( | void | ) | [static] |
Definition at line 1025 of file func_strings.c.
References ast_custom_function_register, ast_register_application_xml, and exec_clearhash().
{
int res = 0;
res |= ast_custom_function_register(&fieldqty_function);
res |= ast_custom_function_register(&filter_function);
res |= ast_custom_function_register(&listfilter_function);
res |= ast_custom_function_register(®ex_function);
res |= ast_custom_function_register(&array_function);
res |= ast_custom_function_register("e_function);
res |= ast_custom_function_register(&csv_quote_function);
res |= ast_custom_function_register(&len_function);
res |= ast_custom_function_register(&strftime_function);
res |= ast_custom_function_register(&strptime_function);
res |= ast_custom_function_register(&eval_function);
res |= ast_custom_function_register(&keypadhash_function);
res |= ast_custom_function_register(&hashkeys_function);
res |= ast_custom_function_register(&hash_function);
res |= ast_register_application_xml(app_clearhash, exec_clearhash);
res |= ast_custom_function_register(&toupper_function);
res |= ast_custom_function_register(&tolower_function);
return res;
}
| static int quote | ( | 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_copy_string(), ast_log(), ast_strlen_zero(), buf, LOG_ERROR, and LOG_WARNING.
{
char *bufptr = buf, *dataptr = data;
if (len < 3){ /* at least two for quotes and one for binary zero */
ast_log(LOG_ERROR, "Not enough buffer");
return -1;
}
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "No argument specified!\n");
ast_copy_string(buf, "\"\"", len);
return 0;
}
*bufptr++ = '"';
for (; bufptr < buf + len - 3; dataptr++) {
if (*dataptr == '\\') {
*bufptr++ = '\\';
*bufptr++ = '\\';
} else if (*dataptr == '"') {
*bufptr++ = '\\';
*bufptr++ = '"';
} else if (*dataptr == '\0') {
break;
} else {
*bufptr++ = *dataptr;
}
}
*bufptr++ = '"';
*bufptr = '\0';
return 0;
}
| static int regex | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | parse, | ||
| char * | buf, | ||
| size_t | len | ||
| ) | [static] |
Definition at line 508 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.
{
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(null);
AST_APP_ARG(reg);
AST_APP_ARG(str);
);
int errcode;
regex_t regexbuf;
buf[0] = '\0';
AST_NONSTANDARD_APP_ARGS(args, parse, '"');
if (args.argc != 3) {
ast_log(LOG_ERROR, "Unexpected arguments: should have been in the form '\"<regex>\" <string>'\n");
return -1;
}
if ((*args.str == ' ') || (*args.str == '\t'))
args.str++;
ast_debug(1, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str);
if ((errcode = regcomp(®exbuf, args.reg, REG_EXTENDED | REG_NOSUB))) {
regerror(errcode, ®exbuf, buf, len);
ast_log(LOG_WARNING, "Malformed input %s(%s): %s\n", cmd, parse, buf);
return -1;
}
strcpy(buf, regexec(®exbuf, args.str, 0, NULL, 0) ? "0" : "1");
regfree(®exbuf);
return 0;
}
| static int string_tolower | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | data, | ||
| char * | buf, | ||
| size_t | buflen | ||
| ) | [static] |
Definition at line 986 of file func_strings.c.
References buf.
| static int string_toupper | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | data, | ||
| char * | buf, | ||
| size_t | buflen | ||
| ) | [static] |
Definition at line 972 of file func_strings.c.
References buf.
| static int unload_module | ( | void | ) | [static] |
Definition at line 1000 of file func_strings.c.
References ast_custom_function_unregister(), and ast_unregister_application().
{
int res = 0;
res |= ast_custom_function_unregister(&fieldqty_function);
res |= ast_custom_function_unregister(&filter_function);
res |= ast_custom_function_unregister(&listfilter_function);
res |= ast_custom_function_unregister(®ex_function);
res |= ast_custom_function_unregister(&array_function);
res |= ast_custom_function_unregister("e_function);
res |= ast_custom_function_unregister(&csv_quote_function);
res |= ast_custom_function_unregister(&len_function);
res |= ast_custom_function_unregister(&strftime_function);
res |= ast_custom_function_unregister(&strptime_function);
res |= ast_custom_function_unregister(&eval_function);
res |= ast_custom_function_unregister(&keypadhash_function);
res |= ast_custom_function_unregister(&hashkeys_function);
res |= ast_custom_function_unregister(&hash_function);
res |= ast_unregister_application(app_clearhash);
res |= ast_custom_function_unregister(&toupper_function);
res |= ast_custom_function_unregister(&tolower_function);
return res;
}
struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "String handling dialplan functions" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
Definition at line 1050 of file func_strings.c.
char* app_clearhash = "ClearHash" [static] |
Definition at line 553 of file func_strings.c.
struct ast_custom_function array_function [static] |
{
.name = "ARRAY",
.write = array,
}
Definition at line 741 of file func_strings.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 1050 of file func_strings.c.
struct ast_custom_function csv_quote_function [static] |
{
.name = "CSV_QUOTE",
.read = csv_quote,
}
Definition at line 816 of file func_strings.c.
struct ast_custom_function eval_function [static] |
{
.name = "EVAL",
.read = function_eval,
}
Definition at line 927 of file func_strings.c.
struct ast_custom_function fieldqty_function [static] |
{
.name = "FIELDQTY",
.read = function_fieldqty,
}
Definition at line 326 of file func_strings.c.
struct ast_custom_function filter_function [static] |
{
.name = "FILTER",
.read = filter,
}
Definition at line 503 of file func_strings.c.
struct ast_custom_function hash_function [static] |
{
.name = "HASH",
.write = hash_write,
.read = hash_read,
}
Definition at line 730 of file func_strings.c.
struct ast_custom_function hashkeys_function [static] |
{
.name = "HASHKEYS",
.read = hashkeys_read,
}
Definition at line 736 of file func_strings.c.
struct ast_custom_function keypadhash_function [static] |
{
.name = "KEYPADHASH",
.read = keypadhash,
}
Definition at line 967 of file func_strings.c.
struct ast_custom_function len_function [static] |
{
.name = "LEN",
.read = len,
}
Definition at line 833 of file func_strings.c.
struct ast_custom_function listfilter_function [static] |
{
.name = "LISTFILTER",
.read = listfilter,
}
Definition at line 422 of file func_strings.c.
struct ast_custom_function quote_function [static] |
{
.name = "QUOTE",
.read = quote,
}
Definition at line 780 of file func_strings.c.
struct ast_custom_function regex_function [static] |
{
.name = "REGEX",
.read = regex,
}
Definition at line 545 of file func_strings.c.
struct ast_custom_function strftime_function [static] |
{
.name = "STRFTIME",
.read = acf_strftime,
}
Definition at line 867 of file func_strings.c.
struct ast_custom_function strptime_function [static] |
{
.name = "STRPTIME",
.read = acf_strptime,
}
Definition at line 909 of file func_strings.c.
struct ast_custom_function tolower_function [static] |
{
.name = "TOLOWER",
.read = string_tolower,
}
Definition at line 995 of file func_strings.c.
struct ast_custom_function toupper_function [static] |
{
.name = "TOUPPER",
.read = string_toupper,
}
Definition at line 981 of file func_strings.c.