Remove some unnecessary inclusions of <sys/cdefs.h> across the tree.
[dragonfly.git] / lib / libc / gen / fnmatch.3
1 .\" Copyright (c) 1989, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Guido van Rossum.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\" 4. Neither the name of the University nor the names of its contributors
15 .\"    may be used to endorse or promote products derived from this software
16 .\"    without specific prior written permission.
17 .\"
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" SUCH DAMAGE.
29 .\"
30 .\"     @(#)fnmatch.3   8.3 (Berkeley) 4/28/95
31 .\" $FreeBSD: src/lib/libc/gen/fnmatch.3,v 1.19 2007/01/09 00:27:53 imp Exp $
32 .\" $DragonFly: src/lib/libc/gen/fnmatch.3,v 1.3 2006/05/26 19:39:36 swildner Exp $
33 .\"
34 .Dd July 18, 2004
35 .Dt FNMATCH 3
36 .Os
37 .Sh NAME
38 .Nm fnmatch
39 .Nd test whether a filename or pathname matches a shell-style pattern
40 .Sh LIBRARY
41 .Lb libc
42 .Sh SYNOPSIS
43 .In fnmatch.h
44 .Ft int
45 .Fn fnmatch "const char *pattern" "const char *string" "int flags"
46 .Sh DESCRIPTION
47 The
48 .Fn fnmatch
49 function
50 matches patterns according to the rules used by the shell.
51 It checks the string specified by the
52 .Fa string
53 argument to see if it matches the pattern specified by the
54 .Fa pattern
55 argument.
56 .Pp
57 The
58 .Fa flags
59 argument modifies the interpretation of
60 .Fa pattern
61 and
62 .Fa string .
63 The value of
64 .Fa flags
65 is the bitwise inclusive
66 .Tn OR
67 of any of the following
68 constants, which are defined in the include file
69 .In fnmatch.h .
70 .Bl -tag -width FNM_PATHNAME
71 .It Dv FNM_NOESCAPE
72 Normally, every occurrence of a backslash
73 .Pq Ql \e
74 followed by a character in
75 .Fa pattern
76 is replaced by that character.
77 This is done to negate any special meaning for the character.
78 If the
79 .Dv FNM_NOESCAPE
80 flag is set, a backslash character is treated as an ordinary character.
81 .It Dv FNM_PATHNAME
82 Slash characters in
83 .Fa string
84 must be explicitly matched by slashes in
85 .Fa pattern .
86 If this flag is not set, then slashes are treated as regular characters.
87 .It Dv FNM_PERIOD
88 Leading periods in
89 .Fa string
90 must be explicitly matched by periods in
91 .Fa pattern .
92 If this flag is not set, then leading periods are treated as regular
93 characters.
94 The definition of
95 .Dq leading
96 is related to the specification of
97 .Dv FNM_PATHNAME .
98 A period is always
99 .Dq leading
100 if it is the first character in
101 .Fa string .
102 Additionally, if
103 .Dv FNM_PATHNAME
104 is set,
105 a period is
106 leading
107 if it immediately follows a slash.
108 .It Dv FNM_LEADING_DIR
109 Ignore
110 .Dq Li /*
111 rest after successful
112 .Fa pattern
113 matching.
114 .It Dv FNM_CASEFOLD
115 Ignore case distinctions in both the
116 .Fa pattern
117 and the
118 .Fa string .
119 .El
120 .Sh RETURN VALUES
121 The
122 .Fn fnmatch
123 function returns zero if
124 .Fa string
125 matches the pattern specified by
126 .Fa pattern ,
127 otherwise, it returns the value
128 .Dv FNM_NOMATCH .
129 .Sh SEE ALSO
130 .Xr sh 1 ,
131 .Xr glob 3 ,
132 .Xr regex 3
133 .Sh STANDARDS
134 The current implementation of the
135 .Fn fnmatch
136 function
137 .Em does not
138 conform to
139 .St -p1003.2 .
140 Collating symbol expressions, equivalence class expressions and
141 character class expressions are not supported.
142 .Sh HISTORY
143 The
144 .Fn fnmatch
145 function first appeared in
146 .Bx 4.4 .
147 .Sh BUGS
148 The pattern
149 .Ql *
150 matches the empty string, even if
151 .Dv FNM_PATHNAME
152 is specified.