Lines Matching defs:pattern
6 * Simple pattern matching, with '*' and '?' as wildcards.
51 * Returns true if the given string matches the pattern (which may contain ?
55 match_pattern(const char *s, const char *pattern)
58 /* If at end of pattern, accept if also at end of string. */
59 if (!*pattern)
62 if (*pattern == '*') {
64 while (*pattern == '*')
65 pattern++;
67 /* If at end of pattern, accept immediately. */
68 if (!*pattern)
71 /* If next character in pattern is known, optimize. */
72 if (*pattern != '?' && *pattern != '*') {
75 * pattern, and try to match starting from
79 if (*s == *pattern &&
80 match_pattern(s + 1, pattern + 1))
90 if (match_pattern(s, pattern))
103 if (*pattern != '?' && *pattern != *s)
106 /* Move to the next character, both in string and in pattern. */
108 pattern++;
120 match_pattern_list(const char *string, const char *pattern, int dolower)
125 u_int i, subi, len = strlen(pattern);
130 if (pattern[i] == '!') {
141 i < len && subi < sizeof(sub) - 1 && pattern[i] != ',';
143 sub[subi] = dolower && isupper((u_char)pattern[i]) ?
144 tolower((u_char)pattern[i]) : pattern[i];
150 if (i < len && pattern[i] == ',')
174 match_usergroup_pattern_list(const char *string, const char *pattern)
177 return match_pattern_list(string, pattern, 0);
187 match_hostname(const char *host, const char *pattern)
193 r = match_pattern_list(hostcopy, pattern, 1);
212 return 0; /* negative ip address match, or testing pattern */
224 * Match user, user@host_or_ip, user@host_or_ip_list against pattern.
225 * If user, host and ipaddr are all NULL then validate pattern/
226 * Returns -1 on invalid pattern, 0 on no match, 1 on match.
230 const char *pattern)
237 if ((p = strrchr(pattern, '@')) != NULL &&
246 if (strrchr(pattern, '@') == NULL)
247 return match_pattern(user, pattern);
249 pat = xstrdup(pattern);
307 * Filter proposal using pattern-list filter.
344 * the 'filter' pattern list. Caller must free returned string.
354 * the 'filter' pattern list. Caller must free returned string.