.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" SUCH DAMAGE.
.\"
.\" @(#)glob.3 8.3 (Berkeley) 4/16/94
-.\" $FreeBSD: src/lib/libc/gen/glob.3,v 1.32 2007/01/09 00:27:54 imp Exp $
+.\" $FreeBSD$
.\"
-.Dd May 20, 2008
+.Dd June 11, 2017
.Dt GLOB 3
.Os
.Sh NAME
.Nm glob ,
-#ifdef UNIFDEF_BLOCKS
.Nm glob_b ,
-#endif
.Nm globfree
.Nd generate pathnames matching a pattern
.Sh SYNOPSIS
.In glob.h
.Ft int
-.Fo glob
-.Fa "const char *restrict pattern"
-.Fa "int flags"
-.Fa "int (*errfunc)(const char *epath, int errno)"
-.Fa "glob_t *restrict pglob"
-.Fc
-#ifdef UNIFDEF_BLOCKS
+.Fn glob "const char * restrict pattern" "int flags" "int (*errfunc)(const char *epath, int errno)" "glob_t * restrict pglob"
.Ft int
-.Fo glob_b
-.Fa "const char *restrict pattern"
-.Fa "int flags"
-.Fa "int (^errblk)(const char *epath, int errno)"
-.Fa "glob_t *restrict pglob"
-.Fc
-#endif
+.Fn glob_b "const char * restrict pattern" "int flags" "int (^errblk)(const char *epath, int errno)" "glob_t * restrict pglob"
.Ft void
-.Fo globfree
-.Fa "glob_t *pglob"
-.Fc
+.Fn globfree "glob_t *pglob"
.Sh DESCRIPTION
The
.Fn glob
is set, backslash escaping is disabled.
.It Dv GLOB_NOSORT
By default, the pathnames are sorted in ascending
-.Tn ASCII
+collation
order;
this flag prevents that sorting (speeding up
.Fn glob ) .
or
.Fa errfunc
returns zero, the error is ignored.
-#ifdef UNIFDEF_BLOCKS
.Pp
The
.Fn glob_b
.Fn glob
except that the error callback is a block pointer instead of a function
pointer.
-#endif
.Pp
The
.Fn globfree
function frees any space associated with
.Fa pglob
from a previous call(s) to
-#ifdef UNIFDEF_BLOCKS
.Fn glob
or
.Fn glob_b .
-#else
-.Fn glob .
-#endif
.Sh RETURN VALUES
On successful completion,
.Fn glob
-#ifdef UNIFDEF_BLOCKS
and
.Fn glob_b
return zero.
-#else
-returns zero.
-#endif
In addition, the fields of
.Fa pglob
contain the values described below:
contains the total number of matched pathnames so far.
This includes other matches from previous invocations of
.Fn glob
-#ifdef UNIFDEF_BLOCKS
or
.Fn glob_b
-#endif
if
.Dv GLOB_APPEND
was specified.
.It Fa gl_matchc
contains the number of matched pathnames in the current invocation of
-#ifdef UNIFDEF_BLOCKS
.Fn glob
or
.Fn glob_b .
-#else
-.Fn glob .
-#endif
.It Fa gl_flags
contains a copy of the
.Fa flags
.Pp
If
.Fn glob
-#ifdef UNIFDEF_BLOCKS
or
.Fn glob_b
-#endif
terminates due to an error, it sets errno and returns one of the
following non-zero constants, which are defined in the include
file
.It Dv GLOB_NOSPACE
An attempt to allocate memory failed, or if
.Fa errno
-was 0
+was E2BIG,
.Dv GLOB_LIMIT
was specified in the flags and
.Fa pglob\->gl_matchc
.Sh CAVEATS
The
.Fn glob
-#ifdef UNIFDEF_BLOCKS
and
.Fn glob_b
functions
-#else
-function
-#endif
will not match filenames that begin with a period
unless this is specifically requested (e.g., by ".*").
.Sh SEE ALSO
.Fn globfree
functions first appeared in
.Bx 4.4 .
-#ifdef UNIFDEF_BLOCKS
The
.Fn glob_b
function first appeared in Mac OS X 10.6.
-#endif
.Sh BUGS
Patterns longer than
.Dv MAXPATHLEN
.Pp
The
.Fn glob
-#ifdef UNIFDEF_BLOCKS
and
.Fn glob_b
functions
-#else
-function
-#endif
may fail and set errno for any of the errors specified for the
library routines
.Xr stat 2 ,