• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/postfix-255/postfix/src/util/

Lines Matching refs:pattern

5 /*	simple string or host pattern matching
9 /* int match_string(list, string, pattern)
12 /* const char *pattern;
14 /* int match_hostname(list, name, pattern)
17 /* const char *pattern;
19 /* int match_hostaddr(list, addr, pattern)
22 /* const char *pattern;
25 /* matching. The matching process is case insensitive. If a pattern
29 /* match_string() matches the string against the pattern, requiring
33 /* the pattern exactly, or when the pattern matches a parent domain
37 /* The hostname pattern foo.com matches itself and any name below
47 /* match_hostaddr() matches a host address when the pattern is
48 /* identical to the host address, or when the pattern is a net/mask
50 /* bits in the network part of the pattern. The flags argument is
85 #define MATCH_DICTIONARY(pattern) \
86 ((pattern)[0] != '[' && strchr((pattern), ':') != 0)
112 int match_string(MATCH_LIST *list, const char *string, const char *pattern)
118 msg_info("%s: %s ~? %s", myname, string, pattern);
123 if (MATCH_DICTIONARY(pattern)) {
124 if ((dict = dict_handle(pattern)) == 0)
125 msg_panic("%s: unknown dictionary: %s", myname, pattern);
137 if (strcasecmp(string, pattern) == 0) {
149 int match_hostname(MATCH_LIST *list, const char *name, const char *pattern)
159 msg_info("%s: %s ~? %s", myname, name, pattern);
166 if (MATCH_DICTIONARY(pattern)) {
167 if ((dict = dict_handle(pattern)) == 0)
168 msg_panic("%s: unknown dictionary: %s", myname, pattern);
194 if (strcasecmp(name, pattern) == 0) {
199 * See if the pattern is a parent domain of the hostname.
203 pd = name + strlen(name) - strlen(pattern);
204 if (pd > name && pd[-1] == '.' && strcasecmp(pd, pattern) == 0)
206 } else if (pattern[0] == '.') {
207 pd = name + strlen(name) - strlen(pattern);
208 if (pd > name && strcasecmp(pd, pattern) == 0)
217 int match_hostaddr(MATCH_LIST *list, const char *addr, const char *pattern)
227 msg_info("%s: %s ~? %s", myname, addr, pattern);
238 if (MATCH_DICTIONARY(pattern)) {
239 if ((dict = dict_handle(pattern)) == 0)
240 msg_panic("%s: unknown dictionary: %s", myname, pattern);
252 if (pattern[0] != '[') {
253 if (strcasecmp(addr, pattern) == 0)
258 if (strncasecmp(addr, pattern + 1, addr_len) == 0
259 && strcmp(pattern + 1 + addr_len, "]") == 0)
271 * - Don't bother unless the pattern is either an IPv6 address or net/mask.
283 if (!strchr(addr, ':') != !strchr(pattern, ':')
284 || pattern[strcspn(pattern, ":/")] == 0
285 || pattern[strspn(pattern, V4_ADDR_STRING_CHARS)] == 0
286 || pattern[strspn(pattern, V6_ADDR_STRING_CHARS "[]/")] != 0)
291 * pattern, or we have an address that can have multiple valid
293 * to find out if the address matches the pattern is to transform
296 saved_patt = mystrdup(pattern);