]>
git.ipfire.org Git - thirdparty/bird.git/blob - lib/patmatch.c
2 * BIRD Library -- Generic Shell-Like Pattern Matching (currently only '?' and '*')
4 * (c) 1998--2000 Martin Mares <mj@ucw.cz>
8 #include "lib/string.h"
10 #ifndef MATCH_FUNC_NAME
11 #define MATCH_FUNC_NAME patmatch
19 MATCH_FUNC_NAME(byte
*p
, byte
*s
)
31 if (z
== '\\' && p
[2])
36 while (*s
&& Convert(*s
) != z
)
40 if (MATCH_FUNC_NAME(p
+1, s
))
47 if (*p
== '\\' && p
[1])
49 if (Convert(*p
++) != Convert(*s
++))
58 * patmatch - match shell-like patterns
62 * patmatch() returns whether given string @s matches the given shell-like
63 * pattern @p. The patterns consist of characters (which are matched literally),
64 * question marks which match any single character, asterisks which match any
65 * (possibly empty) string of characters and backslashes which are used to
66 * escape any special characters and force them to be treated literally.
68 * The matching process is not optimized with respect to time, so please
69 * avoid using this function for complex patterns.
72 patmatch(byte
*p
, byte
*s
)