--- func_strings.c.orig 2006-01-14 20:06:44.000000000 +0100 +++ func_strings.c 2006-03-07 13:50:03.000000000 +0100 @@ -27,6 +27,7 @@ #include #include #include +#include #include "asterisk.h" @@ -227,3 +228,68 @@ .read = function_eval, }; +static char *function_lcase(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) +{ + int i = 0; + while (data[i]) + { + if (data[i] & 0x80) + { + unsigned char c = data[i]; + if (c >= 192 && c <= 223) + { + c += 32; + data[i] = (char)c; + } + } + else + { + data[i] = tolower(data[i]); + } + i++; + } + return data; +} + +#ifndef BUILTIN_FUNC +static +#endif +struct ast_custom_function lcase_function = { + .name = "LCASE", + .synopsis = "Returns the string in lowercase", + .syntax = "LCASE()", + .read = function_lcase, +}; + +static char *function_ucase(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) +{ + int i = 0; + while (data[i]) + { + if (data[i] & 0x80) + { + unsigned char c = data[i]; + if (c >= 224) + { + c -= 32; + data[i] = (char)c; + } + } + else + { + data[i] = toupper(data[i]); + } + i++; + } + return data; +} + +#ifndef BUILTIN_FUNC +static +#endif +struct ast_custom_function ucase_function = { + .name = "UCASE", + .synopsis = "Returns the string in uppercase", + .syntax = "UCASE()", + .read = function_ucase, +};