xref: /csrg-svn/lib/libc/gen/fnmatch.3 (revision 69096)
162875Sbostic.\" Copyright (c) 1989, 1991, 1993
262875Sbostic.\"	The Regents of the University of California.  All rights reserved.
339735Sbostic.\"
439735Sbostic.\" This code is derived from software contributed to Berkeley by
539735Sbostic.\" Guido van Rossum.
643571Strent.\" %sccs.include.redist.man%
739735Sbostic.\"
8*69096Sbostic.\"     @(#)fnmatch.3	8.3 (Berkeley) 04/28/95
939735Sbostic.\"
1048352Scael.Dd
1148352Scael.Dt FNMATCH 3
1248352Scael.Os
1348352Scael.Sh NAME
1448352Scael.Nm fnmatch
1548352Scael.Nd match filename or pathname
1648352Scael.Sh SYNOPSIS
1754534Sbostic.Fd #include <fnmatch.h>
1848352Scael.Ft int
1948352Scael.Fn fnmatch "const char *pattern" "const char *string" "int flags"
2048352Scael.Sh DESCRIPTION
2148352ScaelThe
2248352Scael.Fn fnmatch
2348352Scaelfunction
2439735Sbosticmatches patterns according to the rules used by the shell.
2539735SbosticIt checks the string specified by the
2648352Scael.Fa string
2739735Sbosticargument to see if it matches the pattern specified by the
2848352Scael.Fa pattern
2939735Sbosticargument.
3048352Scael.Pp
3139735SbosticThe
3248352Scael.Fa flags
3339735Sbosticargument modifies the interpretation of
3448352Scael.Fa pattern
3539735Sbosticand
3648352Scael.Fa string .
3739735SbosticThe value of
3848352Scael.Fa flags
3948352Scaelis the bitwise inclusive
4048352Scael.Tn OR
4148352Scaelof any of the following
4239735Sbosticconstants, which are defined in the include file
4354534Sbostic.Pa fnmatch.h .
4448352Scael.Bl -tag -width FNM_PATHNAME
4554534Sbostic.It Dv FNM_NOESCAPE
4654534SbosticNormally, every occurrence of a backslash
4754534Sbostic.Pq Ql \e
4854534Sbosticfollowed by a character in
4954534Sbostic.Fa pattern
5054534Sbosticis replaced by that character.
5154534SbosticThis is done to negate any special meaning for the character.
5254534SbosticIf the
5354534Sbostic.Dv FNM_NOESCAPE
5454534Sbosticflag is set, a backslash character is treated as an ordinary character.
5548352Scael.It Dv FNM_PATHNAME
5639735SbosticSlash characters in
5748352Scael.Fa string
5839735Sbosticmust be explicitly matched by slashes in
5948352Scael.Fa pattern .
6039735SbosticIf this flag is not set, then slashes are treated as regular characters.
6154534Sbostic.It Dv FNM_PERIOD
6254534SbosticLeading periods in strings match periods in patterns.
6354534SbosticThe definition of ``leading'' is related to the specification of
6454534Sbostic.Dv FNM_PATHNAME.
6554534SbosticA period is always ``leading'' if it is the first character in
6654534Sbostic.Ar string .
6754534SbosticAdditionally, if
6854534Sbostic.Dv FNM_PATHNAME
6954534Sbosticis set,
7054534Sbostica period is ``leading'' if it immediately follows a slash.
7148352Scael.El
7248352Scael.Sh RETURN VALUES
7354534SbosticThe
7454534Sbostic.Fn fnmatch
7554534Sbosticfunction returns zero if
7648352Scael.Fa string
7739735Sbosticmatches the pattern specified by
7848352Scael.Fa pattern ,
7954534Sbosticotherwise, it returns the value
8054534Sbostic.Dv FNM_NOMATCH .
8148352Scael.Sh SEE ALSO
8248352Scael.Xr sh 1 ,
8348352Scael.Xr glob 3 ,
84*69096Sbostic.Xr regex 3
8566839Sbostic.Sh STANDARDS
8666839SbosticThe
8766839Sbostic.Fn fnmatch
8866839Sbosticfunction conforms to
8966839Sbostic.St -p1003.2 .
9048352Scael.Sh HISTORY
9148352ScaelThe
9248352Scael.Fn fnmatch
9366839Sbosticfunction first appeared in
9466839Sbostic.Bx 4.4 .
9548352Scael.Sh BUGS
9648352ScaelThe pattern
9748352Scael.Ql *
9848352Scaelmatches the empty string, even if
9948352Scael.Dv FNM_PATHNAME
10039735Sbosticis specified.
101