.\" @(#)scandir.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD: src/lib/libc/gen/scandir.3,v 1.9 2007/01/09 00:27:55 imp Exp $
.\"
-.Dd June 4, 1993
+.Dd May 20, 2008
.Dt SCANDIR 3
.Os
.Sh NAME
.Nm scandir ,
+#ifdef UNIFDEF_BLOCKS
+.Nm scandir_b ,
+#endif
.Nm alphasort
.Nd scan a directory
-.Sh LIBRARY
-.Lb libc
.Sh SYNOPSIS
.In sys/types.h
.In dirent.h
.Ft int
-.Fn scandir "const char *dirname" "struct dirent ***namelist" "int \\*(lp*select\\*(rp\\*(lpstruct dirent *\\*(rp" "int \\*(lp*compar\\*(rp\\*(lpconst void *, const void *\\*(rp"
+.Fn scandir "const char *dirname" "struct dirent ***namelist" "int \\*(lp*select\\*(rp\\*(lpconst struct dirent *\\*(rp" "int \\*(lp*compar\\*(rp\\*(lpconst struct dirent **, const struct dirent **\\*(rp"
.Ft int
-.Fn alphasort "const void *d1" "const void *d2"
+.Fn alphasort "const struct dirent **d1" "const struct dirent **d2"
+#ifdef UNIFDEF_BLOCKS
+.Ft int
+.Fn scandir_b "const char *dirname" "struct dirent ***namelist" "int \\*(lp^select\\*(rp\\*(lpconst struct dirent *\\*(rp" "int \\*(lp^compar\\*(rp\\*(lpconst struct dirent **, const struct dirent **\\*(rp"
+#endif
.Sh DESCRIPTION
The
.Fn scandir
It returns the number of entries in the array.
A pointer to the array of directory entries is stored in the location
referenced by
-.Fa namelist .
+.Fa namelist
+(even if the number of entries is 0).
.Pp
The
.Fa select
The memory allocated for the array can be deallocated with
.Xr free 3 ,
by freeing each pointer in the array and then the array itself.
+#ifdef UNIFDEF_BLOCKS
+.Pp
+The
+.Fn scandir_b
+function works the same way as the
+.Fn scandir
+function, except that
+.Fa select
+and
+.Fa compar
+are blocks instead of subroutines.
+#endif
.Sh DIAGNOSTICS
Returns \-1 if the directory cannot be opened for reading or if
.Xr malloc 3
.Fn alphasort
functions appeared in
.Bx 4.2 .
+#ifdef UNIFDEF_BLOCKS
+The
+.Fn scandir_b
+function appeared in Mac OS X 10.6.
+#endif