shpat_match - match filename or pathname #include <shpat_match.h> int shpat_match(const char *pattern, const char *string, int flags); int shpat_match_hasglobchar(const char *pattern); The shpat_match(3) function matches patterns according to the rules used by the shell. It checks the string specified by the string argument to see if it matches the pattern specified by the pattern argument.

Shell Patterns
A pattern consists of normal characters, which match themselves, and meta-characters (aka glob chars). The meta-characters are ``!'', ``*'', ``?'', and ``[''. These characters lose their special meanings if they are quoted with a backslash (``\''). An asterisk (``*'') matches any string of characters. A question mark (``?'') matches any single character. A left bracket (``['') introduces a character class. The end of the character class is indicated by a ``]''; if the ``]'' is missing then the ``['' matches a ``['' rather than introducing a character class. A character class matches any of the characters between the square brackets. A range of characters may be specified using a minus sign (``-''). The character class may be complemented/negated by making an exclamation point (``!'') the first character of the character class. To include a ``]'' in a character class, make it the first character listed (after the ``!'', if any). To include a minus sign, make it the first or last character listed.

Matching Interpretation
The flags argument modifies the interpretation of pattern and string The value of flags is the bitwise inclusive OR of any of the following constants, which are defined in the include file shpat_match.h. Normally, every occurrence of a backslash (``\'') followed by a character in pattern is replaced by that character. This is done to negate any special meaning for the character. If the FNM_NOESCAPE flag is set, a backslash character is treated as an ordinary character. Slash characters in string must be explicitly matched by slashes in pattern If this flag is not set, then slashes are treated as regular characters. Leading periods in string must be explicitly matched by periods in pattern If this flag is not set, then leading periods are treated as regular characters. The definition of ``leading'' is related to the specification of FNM_PATHNAME A period is always ``leading'' if it is the first character in string Additionally, if FNM_PATHNAME is set, a period is ``leading'' if it immediately follows a slash. Ignore ``/*'' rest after successful pattern matching. Ignore case distinctions in both the pattern and the string. The shpat_match(3) function returns zero if string matches the pattern specified by pattern, otherwise, it returns the value FNM_NOMATCH. The pattern ``*'' matches the empty string, even if FNM_PATHNAME is specified. sh(1), shpat_glob(3). The shpat_match(3) function conforms to IEEE Std1003.2 (``POSIX.2'') The shpat_match(3) function is derived from the fnmatch(3) function of FreeBSD 3.1 which itself derived it from 4.4BSD. The shpat_match_hasglobchar(3) function is derived from the ap_is_fnmatch(3) function of Apache 1.3.