125  *  0   no-match
 126  * -1   no-match, error (illseq, too many wildcards in pattern, ...)
 127  *
 128  * Note that both the pattern and the string are in multi-byte form.
 129  *
 130  * The implementation of this is quite tricky.  First note that it
 131  * can call itself recursively, though it limits the recursion depth.
 132  * Each switch case in the while loop can basically do one of three
 133  * things: (a) return "Yes, match", (b) return "not a match", or
 134  * continue processing the match pattern.  The cases for wildcards
 135  * that may match a variable number of characters ('*' and '<') do
 136  * recursive calls, looking for a match of the remaining pattern,
 137  * starting at the current and later positions in the string.
 138  */
 139 static int
 140 smb_match_private(const char *pat, const char *str, struct match_priv *priv)
 141 {
 142         const char      *limit;
 143         char            pc;             /* current pattern char */
 144         int             rc;
 145         smb_wchar_t     wcpat, wcstr;   /* current wchar in pat, str */
 146         int             nbpat, nbstr;   /* multi-byte length of it */
 147 
 148         if (priv->depth >= SMB_MATCH_DEPTH_MAX)
 149                 return (-1);
 150 
 151         /*
 152          * Advance over one multi-byte char, used in cases like
 153          * '?' or '>' where "match one character" needs to be
 154          * interpreted as "match one multi-byte sequence".
 155          *
 156          * This macro needs to consume the semicolon following
 157          * each place it appears, so this is carefully written
 158          * as an if/else with a missing semicolon at the end.
 159          */
 160 #define ADVANCE(str) \
 161         if ((nbstr = smb_mbtowc(NULL, str, MTS_MB_CHAR_MAX)) < 1) \
 162                 return (-1); \
 163         else \
 164                 str += nbstr    /* no ; */
 165 
 
 | 
 
 
 125  *  0   no-match
 126  * -1   no-match, error (illseq, too many wildcards in pattern, ...)
 127  *
 128  * Note that both the pattern and the string are in multi-byte form.
 129  *
 130  * The implementation of this is quite tricky.  First note that it
 131  * can call itself recursively, though it limits the recursion depth.
 132  * Each switch case in the while loop can basically do one of three
 133  * things: (a) return "Yes, match", (b) return "not a match", or
 134  * continue processing the match pattern.  The cases for wildcards
 135  * that may match a variable number of characters ('*' and '<') do
 136  * recursive calls, looking for a match of the remaining pattern,
 137  * starting at the current and later positions in the string.
 138  */
 139 static int
 140 smb_match_private(const char *pat, const char *str, struct match_priv *priv)
 141 {
 142         const char      *limit;
 143         char            pc;             /* current pattern char */
 144         int             rc;
 145         uint32_t        wcpat, wcstr;   /* current wchar in pat, str */
 146         int             nbpat, nbstr;   /* multi-byte length of it */
 147 
 148         if (priv->depth >= SMB_MATCH_DEPTH_MAX)
 149                 return (-1);
 150 
 151         /*
 152          * Advance over one multi-byte char, used in cases like
 153          * '?' or '>' where "match one character" needs to be
 154          * interpreted as "match one multi-byte sequence".
 155          *
 156          * This macro needs to consume the semicolon following
 157          * each place it appears, so this is carefully written
 158          * as an if/else with a missing semicolon at the end.
 159          */
 160 #define ADVANCE(str) \
 161         if ((nbstr = smb_mbtowc(NULL, str, MTS_MB_CHAR_MAX)) < 1) \
 162                 return (-1); \
 163         else \
 164                 str += nbstr    /* no ; */
 165 
 
 |