1 FNMATCH(3C)              Standard C Library Functions              FNMATCH(3C)
   2 
   3 
   4 
   5 NAME
   6        fnmatch - match filename or path name
   7 
   8 SYNOPSIS
   9        #include <fnmatch.h>
  10 
  11        int fnmatch(const char *pattern, const char *string, int flags);
  12 
  13 
  14 DESCRIPTION
  15        The fnmatch() function matches patterns as described on the fnmatch(5)
  16        manual page.  It checks the string argument to see if it matches the
  17        pattern argument.
  18 
  19 
  20        The flags argument modifies the interpretation of pattern and string.
  21        It is the bitwise inclusive OR of zero or more of the following flags
  22        defined in the header <fnmatch.h>.
  23 
  24        FNM_PATHNAME
  25                          If set, a slash (/) character in string will be
  26                          explicitly matched by a slash in pattern; it will not
  27                          be matched by either the asterisk (*) or question-mark
  28                          (?) special characters, nor by a bracket ([])
  29                          expression.
  30 
  31                          If not set, the slash character is treated as an
  32                          ordinary character.
  33 
  34 
  35        FNM_IGNORECASE
  36                          If set, the string will be transliterated to lower
  37                          case before doing the actual match. This
  38                          transliteration is done using towlower_l(3C), using
  39                          the locale of the current thread. If no locale is
  40                          set, then the global locale is used instead.
  41 
  42                          If not set, the match will use string with no
  43                          changes, making the match case-sensitive.
  44 
  45 
  46        FNM_NOESCAPE
  47                          If not set, a backslash character (\) in pattern
  48                          followed by any other character will match that
  49                          second character in string. In particular, "\\" will
  50                          match a backslash in string.
  51 
  52                          If set, a backslash character will be treated as an
  53                          ordinary character.
  54 
  55 
  56        FNM_PERIOD
  57                          If set, a leading period in string will match a
  58                          period in pattern; where the location of "leading" is
  59                          indicated by the value of FNM_PATHNAME:
  60 
  61                              o      If FNM_PATHNAME is set, a period is
  62                                     "leading" if it is the first character in
  63                                     string or if it immediately follows a
  64                                     slash.
  65 
  66                              o      If FNM_PATHNAME is not set, a period is
  67                                     "leading" only if it is the first
  68                                     character of string.
  69 
  70 
  71                          If not set, no special restrictions are placed on
  72                          matching a period.
  73 
  74 RETURN VALUES
  75        If string matches the pattern specified by pattern, then fnmatch()
  76        returns 0. If there is no match, fnmatch() returns FNM_NOMATCH, which
  77        is defined in the header <fnmatch.h>. If   an error occurs, fnmatch()
  78        returns another non-zero value.
  79 
  80 USAGE
  81        The fnmatch() function has two major uses. It could be used by an
  82        application or utility that needs to read a directory and apply a
  83        pattern against each entry. The find(1) utility is an example of this.
  84        It can also be used by the pax(1) utility to process its pattern
  85        operands, or by applications that need to match strings in a similar
  86        manner.
  87 
  88 
  89        The name fnmatch() is intended to imply filename match, rather than
  90        pathname match. The default action of this function is to match
  91        filenames, rather than path names, since it gives no special
  92        significance to the slash character. With the FNM_PATHNAME flag,
  93        fnmatch() does match path names, but without tilde expansion, parameter
  94        expansion, or special treatment for period at the beginning of a
  95        filename.
  96 
  97 
  98        The fnmatch() function can be used safely in multithreaded
  99        applications, as long as setlocale(3C) is not being called to change
 100        the locale.
 101 
 102 ATTRIBUTES
 103        See attributes(5) for descriptions of the following attributes:
 104 
 105 
 106 
 107 
 108        +--------------------+-------------------------+
 109        |  ATTRIBUTE TYPE    |     ATTRIBUTE VALUE     |
 110        +--------------------+-------------------------+
 111        |CSI                 | Enabled                 |
 112        +--------------------+-------------------------+
 113        |Interface Stability | Standard                |
 114        +--------------------+-------------------------+
 115        |MT-Level            | MT-Safe with exceptions |
 116        +--------------------+-------------------------+
 117 
 118 SEE ALSO
 119        find(1), pax(1), glob(3C), setlocale(3C), wordexp(3C), attributes(5),
 120        fnmatch(5), standards(5)
 121 
 122 
 123 
 124                                  June 6, 2015                      FNMATCH(3C)