X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Fos_regex%2Fos_match.c;h=3687523e969d1b4d2967c8365ff40357ddc253e5;hb=6ef2f786c6c8ead94841b5f93baf9f43421f08c8;hp=4de0e7548687cff3da077583068122eb76654a3c;hpb=914feba5d54f979cd5d7e69c349c3d01f630042a;p=ossec-hids.git diff --git a/src/os_regex/os_match.c b/src/os_regex/os_match.c index 4de0e75..3687523 100755 --- a/src/os_regex/os_match.c +++ b/src/os_regex/os_match.c @@ -5,7 +5,7 @@ * * This program is a free software; you can redistribute it * and/or modify it under the terms of the GNU General Public - * License (version 3) as published by the FSF - Free Software + * License (version 2) as published by the FSF - Free Software * Foundation */ @@ -13,10 +13,10 @@ #include #include #include - #include "os_regex.h" + /** int OS_Match2(char *pattern, char *str) v0.4 * * This function is a wrapper around the compile/execute @@ -39,9 +39,50 @@ int OS_Match2(char *pattern, char *str) OSMatch_FreePattern(®); } - + + return(r_code); +} + + +#ifdef NOTHINGEMPTY +/** int OS_Match3(char *pattern, char *str) v2.6 + * + * This function is used + * to match any values from a delimited string + * e.g. match pattern "abc" from string "123,abc,xyz" + */ +int OS_Match3(char *pattern, char *str, char *delimiter) +{ + int r_code = 0; + char *token = NULL; + char *dupstr = NULL; + char *saveptr = NULL; + + /* debug2("1. str [%s], dupstr [%s], token[%s], delim [%s]", str, dupstr, token, delimiter); */ + + os_strdup(str, dupstr); + /* debug2("2. str [%s], dupstr [%s], token[%s], delim [%s]", str, dupstr, token, delimiter); */ + + token = strtok_r(dupstr, delimiter, &saveptr); + /* debug2("3. str [%s], dupstr [%s], token[%s], delim [%s]", str, dupstr, token, delimiter); */ + + while (token != NULL) + { + debug2("Matching [%s] with [%s]", pattern, token); + if (!strcmp(pattern, token)) + { + r_code = 1; + break; + } + + token = strtok_r(NULL, delimiter, &saveptr); + } + + /* debug2("4. str [%s], dupstr [%s], token[%s], delim [%s]", str, dupstr, token, delimiter); */ + free(dupstr); return(r_code); } +#endif /* EOF */