Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fnmatch(3C) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

glob(3C)

wordexp(3C)

fnmatch(5)

fnmatch(3C)                                                     fnmatch(3C)

NAME
     fnmatch - match filename or pathname

SYNOPSIS
     #include <fnmatch.h>

     int fnmatch(const char *pattern, const char *string, int flags);

DESCRIPTION
     The fnmatch() function matches patterns. It checks the string speci-
     fied by the string argument to see if it matches the pattern specified
     by the pattern argument.

     The fnmatch() function has two major uses. It could be used by an
     application or utility that needs to read a directory and apply a pat-
     tern against each entry. The find utility is an example of this.

     The name fnmatch() is intended to imply filename match, rather than
     pathname match. The default action of this function is to match
     filenames, rather than pathnames, since it gives no special signifi-
     cance to the slash character. With the FNMPATHNAME flag, fnmatch()
     does match pathnames, but without tilde expansion, parameter expan-
     sion, or special treatment for period at the beginning of a filename.

     The flags argument modifies the interpretation of pattern and string.
     It is the bitwise inclusive OR of zero or more of the flags defined in
     the header fnmatch.h. If the FNMPATHNAME flag is set in flags, then a
     slash character in string will be explicitly matched by a slash in
     pattern; it will not be matched by either the asterisk or question-
     mark special characters, nor by a bracket expression. If the
     FNMPATHNAME flag is not set, the slash character is treated as an
     ordinary character.

     If FNMNOESCAPE is not set in flags, a backslash character (\) in pat-
     tern followed by any other character will match that second character
     in string. In particular \\ will match a backslash in string. If
     FNMNOESCAPE is set, a backslash character will be treated as an ordi-
     nary character.

     If FNMPERIOD is set in flags, then a leading period in string will
     match a period in pattern. The location of "leading" is indicated by
     the value of FNMPATHNAME:

     -  If FNMPATHNAME is set, a period is "leading" if it is the first
        character in string or if it immediate follows a slash.

     -  If FNMPATHNAME is not set, a period is "leading" only if it is the
        first character of string.

     If FNMPERIOD is not set, then no special restrictions are placed on
     matching a period.




Page 1                       Reliant UNIX 5.44                Printed 11/98

fnmatch(3C)                                                     fnmatch(3C)

     The interpretation of range specifications in pattern is influenced by
     the following flags:

     -  If FNMRANGEOK is set, a range specification in the format [m-n-r]
        is interpreted as [m-r].

     -  If FNMRANGEERR is set, the range specification [m-n-r] returns an
        error value.

     -  FNMCLRANGEERR initiates the return of an error value for a range
        specification in the format [[=m=]-r]. If FMNCLRANGEERR is not
        set, the minus sign - is treated as a normal character.

RESULT
     If string matches the pattern specified by pattern, then fnmatch()
     returns zero. If there is no match, fnmatch() returns FNMNOMATCH. If
     an unknown pattern or flag is specified, fnmatch() returns FNMBADPAT.
     Both error values are defined in the include file fnmatch.h. If
     another error occurs, fnmatch() returns another non-zero value.

SEE ALSO
     glob(3C), wordexp(3C), fnmatch(5).
































Page 2                       Reliant UNIX 5.44                Printed 11/98

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026