Open System Services Library Calls Reference Manual (G06.27+, H06.04+)
OSS Library Calls (e - f) fnmatch(3)
NAME
fnmatch - Matches filename patterns
LIBRARY
G-series native OSS processes: /G/system/sysnn/zossesrl
H-series OSS processes: /G/system/zdllnnn/zossedll
SYNOPSIS
#include <fnmatch.h>
int fnmatch(
const char * pattern,
const char * string,
int flags);
PARAMETERS
pattern Contains the pattern that the string parameter is compared to.
string Contains the string to be compared to the pattern parameter.
flags Contains a bit flag specifying the configurable attributes of the comparison to be
performed by the fnmatch( ) function.
DESCRIPTION
The fnmatch() function checks the string specified by the string parameter to see whether it
matches the pattern specified by the pattern parameter. This routine follows the path match cri-
teria of the glob() function.
The fnmatch() function is useful when a program needs to perform pattern matching, such as
when a directory is to be searched for a particular string (as is the case with the find command).
A program like the pax command can also use the fnmatch() function to perform its pattern-
matching operations.
The flags parameter modifies the interpretation of the pattern and string parameters. It is the bit-
wise inclusive OR (|) of 0 (zero) or more of the following flags, which are defined in the
fnmatch.h header file:
FNM_NOESCAPE
If FNM_NOESCAPE is not set, preceding a character in pattern with a \
(backslash) causes the fnmatch() function to match that character in string.For
example, \\ matches a backslash in string.
If FNM_NOESCAPE is set, \ (backslash) is interpreted as an ordinary character.
FNM_PATHNAME
If FNM_PATHNAME is set, a / (slash) in the string parameter is explicitly
matched by a / in the pattern parameter. It is not matched by either the * (aster-
isk) or ? (question mark) special characters, nor by a bracket expression.
If FNM_PATHNAME is not set, the / is treated as an ordinary character.
FNM_PERIOD
If FNM_PERIOD is set, then a leading period in the string parameter matches
only a period in the pattern parameter; it is not matched by either the asterisk or
question-mark special characters, nor by a bracket expression.
If FNM_PERIOD is not set, no special restrictions are placed on matching a
period.
527187-004 Hewlett-Packard Company 2−49