static int _gf_set_dict_iter2 (char *val, void *data) { void **dataa = data; gf_boolean_t *boo = dataa[0]; char *comp = dataa[1]; if (match_comp (val, comp)) *boo = _gf_true; return 0; }
static int _gf_set_dict_iter1 (char *val, void *data) { void **dataa = data; struct gf_set_descriptor *sd = dataa[0]; char **curs = dataa[1]; gf_boolean_t priv = _gf_true; while (*curs) { if (match_comp (val, *curs)) { priv = _gf_false; sd->common = _gf_true; } curs++; } if (priv) sd->priv[0] = _gf_true; return 0; }
static int _fnmatch_unsigned (const unsigned char *mask, const unsigned char *name, unsigned flags) { int m_drive, n_drive, rc; /* Call _nls_init() if not yet called. */ #ifndef MWDD32 if (!_nls_init_flag) _nls_init(); #endif /* Match and skip the drive name if present. */ m_drive = ((isalpha (mask[0]) && mask[1] == ':') ? mask[0] : -1); n_drive = ((isalpha (name[0]) && name[1] == ':') ? name[0] : -1); if (m_drive != n_drive) { if (m_drive == -1 || n_drive == -1) return FNM_NOMATCH; if (!(flags & _FNM_IGNORECASE)) return FNM_NOMATCH; if (_nls_tolower (m_drive) != _nls_tolower (n_drive)) return FNM_NOMATCH; } if (m_drive != -1) mask += 2; if (n_drive != -1) name += 2; /* Colons are not allowed in path names, except for the drive name, which was skipped above. */ if (strchr (mask, ':') != NULL) return _FNM_ERR; if (strchr (name, ':') != NULL) return FNM_NOMATCH; /* The name "\\server\path" should not be matched by mask "\*\server\path". Ditto for /. */ switch (flags & _FNM_STYLE_MASK) { case _FNM_OS2: case _FNM_DOS: if (IS_OS2_COMP_SEP (name[0]) && IS_OS2_COMP_SEP (name[1])) { if (!(IS_OS2_COMP_SEP (mask[0]) && IS_OS2_COMP_SEP (mask[1]))) return FNM_NOMATCH; name += 2; mask += 2; } break; case _FNM_POSIX: if (name[0] == '/' && name[1] == '/') { int i; name += 2; for (i = 0; i < 2; ++i) if (mask[0] == '/') ++mask; else if (mask[0] == '\\' && mask[1] == '/') mask += 2; else return FNM_NOMATCH; } /* In Unix styles, treating ? and * w.r.t. components is simple. No need to do matching component by component. */ return match_unix (mask, name, flags, name); } /* Now compare all the components of the path name, one by one. Note that the path separator must not be enclosed in brackets. */ while (*mask != 0 || *name != 0) { /* If _FNM_PATHPREFIX is set, the names match if the end of MASK is reached even if there are components left in NAME. */ if (*mask == 0 && (flags & _FNM_PATHPREFIX)) return _FNM_MATCH; /* Compare a single component of the path name. */ rc = match_comp (mask, name, flags); if (rc != _FNM_MATCH) return rc; /* Skip to the next component or to the end of the path name. */ mask = skip_comp_os2 (mask); name = skip_comp_os2 (name); } /* If we reached the ends of both strings, the names match. */ if (*mask == 0 && *name == 0) return _FNM_MATCH; /* The names do not match. */ return FNM_NOMATCH; }