Lines Matching refs:pattern
6 * Simple pattern matching, with '*' and '?' as wildcards.
50 * 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 pattern++;
66 /* If at end of pattern, accept immediately. */
67 if (!*pattern)
70 /* If next character in pattern is known, optimize. */
71 if (*pattern != '?' && *pattern != '*') {
74 * pattern, and try to match starting from
78 if (*s == *pattern &&
79 match_pattern(s + 1, pattern + 1))
89 if (match_pattern(s, pattern))
102 if (*pattern != '?' && *pattern != *s)
105 /* Move to the next character, both in string and in pattern. */
107 pattern++;
119 match_pattern_list(const char *string, const char *pattern, int dolower)
124 u_int i, subi, len = strlen(pattern);
129 if (pattern[i] == '!') {
140 i < len && subi < sizeof(sub) - 1 && pattern[i] != ',';
142 sub[subi] = dolower && isupper((u_char)pattern[i]) ?
143 tolower((u_char)pattern[i]) : pattern[i];
149 if (i < len && pattern[i] == ',')
178 match_hostname(const char *host, const char *pattern)
180 return match_pattern_list(host, pattern, 1);
210 * match user, user@host_or_ip, user@host_or_ip_list against pattern
214 const char *pattern)
219 if ((p = strchr(pattern,'@')) == NULL)
220 return match_pattern(user, pattern);
222 pat = xstrdup(pattern);