- struct name *cursor = namelist;
-
- if (!cursor)
- return 0;
-
- for (; cursor; cursor = cursor->next)
- {
- /* If first chars don't match, quick skip. */
-
- if (cursor->firstch && cursor->name[0] != path[0])
- continue;
-
- if (cursor->regexp
- ? fnmatch (cursor->name, path, FNM_LEADING_DIR) == 0
- : (cursor->length <= length
- && (path[cursor->length] == '\0'
- || path[cursor->length] == '/')
- && memcmp (path, cursor->name, cursor->length) == 0))
- return cursor; /* we got a match */
- }