mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
Bug 5327 - new function FILTER and optional argument to CALLERID
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7614 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -68,6 +68,44 @@ struct ast_custom_function fieldqty_function = {
|
||||
.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(<allowed-chars>,<string>)\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(<allowed-chars>,<string>)",
|
||||
.read = builtin_function_filter,
|
||||
};
|
||||
|
||||
static char *builtin_function_regex(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||
{
|
||||
char *arg, *earg = NULL, *tmp, errstr[256] = "";
|
||||
|
Reference in New Issue
Block a user