? funcs/func_odbc.c Index: funcs/Makefile =================================================================== RCS file: /usr/cvsroot/asterisk/funcs/Makefile,v retrieving revision 1.11 diff -u -r1.11 Makefile --- funcs/Makefile 5 Oct 2005 00:17:57 -0000 1.11 +++ funcs/Makefile 5 Oct 2005 03:08:15 -0000 @@ -31,7 +31,7 @@ FUNC_SOURCES=$(BUILTINS:.o=.c) -FUNC_STRUCTS=$(shell grep 'struct ast_custom_function' $(FUNC_SOURCES) | awk '{print $$3};') +FUNC_STRUCTS=$(shell grep 'struct ast_custom_function' $(FUNC_SOURCES) | awk '{print $$3};' | sort) CFLAGS+=-fPIC Index: funcs/func_callerid.c =================================================================== RCS file: /usr/cvsroot/asterisk/funcs/func_callerid.c,v retrieving revision 1.6 diff -u -r1.6 func_callerid.c --- funcs/func_callerid.c 14 Sep 2005 20:46:50 -0000 1.6 +++ funcs/func_callerid.c 5 Oct 2005 03:08:15 -0000 @@ -41,32 +41,50 @@ static char *callerid_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { - if (!strncasecmp("all", data, 3)) { - snprintf(buf, len, "\"%s\" <%s>", chan->cid.cid_name ? chan->cid.cid_name : "", chan->cid.cid_num ? chan->cid.cid_num : ""); - } else if (!strncasecmp("name", data, 4)) { - if (chan->cid.cid_name) { - ast_copy_string(buf, chan->cid.cid_name, len); - } - } else if (!strncasecmp("num", data, 3) || !strncasecmp("number", data, 6)) { - if (chan->cid.cid_num) { - ast_copy_string(buf, chan->cid.cid_num, len); - } - } else if (!strncasecmp("ani", data, 3)) { - if (chan->cid.cid_ani) { - ast_copy_string(buf, chan->cid.cid_ani, len); - } - } else if (!strncasecmp("dnid", data, 4)) { - if (chan->cid.cid_dnid) { - ast_copy_string(buf, chan->cid.cid_dnid, len); - } - } else if (!strncasecmp("rdnis", data, 5)) { - if (chan->cid.cid_rdnis) { - ast_copy_string(buf, chan->cid.cid_rdnis, len); + char *opt = data; + + if (strchr(opt, '|')) { + char name[80], num[80]; + + data = strsep(&opt, "|"); + ast_callerid_split(opt, name, sizeof(name), num, sizeof(num)); + + if (!strncasecmp("all", data, 3)) { + snprintf(buf, len, "\"%s\" <%s>", name, num); + } else if (!strncasecmp("name", data, 4)) { + ast_copy_string(buf, name, len); + } else if (!strncasecmp("num", data, 3) || !strncasecmp("number", data, 6)) { + ast_copy_string(buf, num, len); + } else { + ast_log(LOG_ERROR, "Unknown callerid data type.\n"); } } else { - ast_log(LOG_ERROR, "Unknown callerid data type.\n"); + if (!strncasecmp("all", data, 3)) { + snprintf(buf, len, "\"%s\" <%s>", chan->cid.cid_name ? chan->cid.cid_name : "", chan->cid.cid_num ? chan->cid.cid_num : ""); + } else if (!strncasecmp("name", data, 4)) { + if (chan->cid.cid_name) { + ast_copy_string(buf, chan->cid.cid_name, len); + } + } else if (!strncasecmp("num", data, 3) || !strncasecmp("number", data, 6)) { + if (chan->cid.cid_num) { + ast_copy_string(buf, chan->cid.cid_num, len); + } + } else if (!strncasecmp("ani", data, 3)) { + if (chan->cid.cid_ani) { + ast_copy_string(buf, chan->cid.cid_ani, len); + } + } else if (!strncasecmp("dnid", data, 4)) { + if (chan->cid.cid_dnid) { + ast_copy_string(buf, chan->cid.cid_dnid, len); + } + } else if (!strncasecmp("rdnis", data, 5)) { + if (chan->cid.cid_rdnis) { + ast_copy_string(buf, chan->cid.cid_rdnis, len); + } + } else { + ast_log(LOG_ERROR, "Unknown callerid data type.\n"); + } } - return buf; } @@ -107,9 +125,10 @@ struct ast_custom_function callerid_function = { .name = "CALLERID", .synopsis = "Gets or sets Caller*ID data on the channel.", - .syntax = "CALLERID(datatype)", + .syntax = "CALLERID(datatype[,])", .desc = "Gets or sets Caller*ID data on the channel. The allowable datatypes\n" - "are \"all\", \"name\", \"num\", \"ANI\", \"DNID\", \"RDNIS\".\n", + "are \"all\", \"name\", \"num\", \"ANI\", \"DNID\", \"RDNIS\".\n" + "Uses channel callerid by default or optional callerid, if specified.\n", .read = callerid_read, .write = callerid_write, }; Index: funcs/func_strings.c =================================================================== RCS file: /usr/cvsroot/asterisk/funcs/func_strings.c,v retrieving revision 1.8 diff -u -r1.8 func_strings.c --- funcs/func_strings.c 25 Sep 2005 20:47:00 -0000 1.8 +++ funcs/func_strings.c 5 Oct 2005 03:08:15 -0000 @@ -67,6 +67,44 @@ .read = function_fieldqty, }; +static char *builtin_function_filter(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) +{ + char *allowed, *string, *outbuf=buf; + + string = ast_strdupa(data); + if (!string) { + ast_log(LOG_ERROR, "Out of memory"); + return ""; + } + + allowed = strsep(&string, "|"); + + if (!string) { + ast_log(LOG_ERROR, "Usage: FILTER(,)\n"); + return ""; + } + + for ( ; *string && (buf + len - 1 > outbuf); string++) { + if (strchr(allowed, *string)) { + *outbuf = *string; + outbuf++; + } + } + *outbuf = '\0'; + + return buf; +} + +#ifndef BUILTIN_FUNC +static +#endif +struct ast_custom_function filter_function = { + .name = "FILTER", + .synopsis = "Filter the string to include only the allowed characters", + .syntax = "FILTER(,)", + .read = builtin_function_filter, +}; + static char *builtin_function_regex(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { char *ret_true = "1", *ret_false = "0", *ret;