--- funcs/func_strings.c.orig 2005-06-04 11:44:49.000000000 +0200 +++ funcs/func_strings.c 2005-06-04 11:44:00.000000000 +0200 @@ -203,3 +203,45 @@ .read = function_eval, }; +static char *function_strstr(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) +{ + char *args = ast_strdupa(data); + char *argv[2],*strpos; + int argc,position; + + if (!data || ast_strlen_zero(data)) { + ast_log(LOG_WARNING, "STRSTR requires an argument: STRSTR(,)\n"); + return buf; + } + + argc = ast_separate_app_args(args, '|', argv, sizeof(argv) / sizeof(argv[0])); + if (argc > 1) { + strpos = strstr(argv[1],argv[0]); + if (strpos) { + position = strpos - argv[1]; + sprintf(buf,"%i",position); + } else { + strcpy(buf,"-1"); + } + return buf; + } else { + ast_log(LOG_WARNING, "STRSTR requires an argument: STRSTR(,)\n"); + return buf; + } + return buf; +} + +#ifndef BUILTIN_FUNC +static +#endif +struct ast_custom_function strstr_function = { + .name = "STRSTR", + .synopsis = "Determines The Position In A Substr In A String.", + .syntax = "STRSTR(,)", + .desc = "This function will look in the supplied string haystack\n" + "for the substring needle returning the position.\n" + "Returns the position of the substring or -1 if not found.\n", + .read = function_strstr, +}; + +