]>
Commit | Line | Data |
---|---|---|
1f2f436a A |
1 | --- scandir.3.orig 2009-11-07 14:51:38.000000000 -0800 |
2 | +++ scandir.3 2009-11-07 14:51:40.000000000 -0800 | |
3 | @@ -28,15 +28,16 @@ | |
34e8f829 | 4 | .\" @(#)scandir.3 8.1 (Berkeley) 6/4/93 |
1f2f436a | 5 | .\" $FreeBSD: src/lib/libc/gen/scandir.3,v 1.9 2007/01/09 00:27:55 imp Exp $ |
34e8f829 A |
6 | .\" |
7 | -.Dd June 4, 1993 | |
8 | +.Dd May 20, 2008 | |
9 | .Dt SCANDIR 3 | |
10 | .Os | |
11 | .Sh NAME | |
12 | .Nm scandir , | |
13 | +#ifdef UNIFDEF_BLOCKS | |
14 | +.Nm scandir_b , | |
15 | +#endif | |
16 | .Nm alphasort | |
17 | .Nd scan a directory | |
18 | -.Sh LIBRARY | |
19 | -.Lb libc | |
20 | .Sh SYNOPSIS | |
21 | .In sys/types.h | |
22 | .In dirent.h | |
1f2f436a | 23 | @@ -44,6 +45,10 @@ |
34e8f829 A |
24 | .Fn scandir "const char *dirname" "struct dirent ***namelist" "int \\*(lp*select\\*(rp\\*(lpstruct dirent *\\*(rp" "int \\*(lp*compar\\*(rp\\*(lpconst void *, const void *\\*(rp" |
25 | .Ft int | |
26 | .Fn alphasort "const void *d1" "const void *d2" | |
27 | +#ifdef UNIFDEF_BLOCKS | |
28 | +.Ft int | |
29 | +.Fn scandir_b "const char *dirname" "struct dirent ***namelist" "int \\*(lp^select\\*(rp\\*(lpstruct dirent *\\*(rp" "int \\*(lp^compar\\*(rp\\*(lpconst void *, const void *\\*(rp" | |
30 | +#endif | |
31 | .Sh DESCRIPTION | |
32 | The | |
33 | .Fn scandir | |
1f2f436a | 34 | @@ -76,6 +81,13 @@ argument is a pointer to a user supplied |
34e8f829 A |
35 | .Xr qsort 3 |
36 | to sort the completed array. | |
37 | If this pointer is null, the array is not sorted. | |
38 | +Note that from within the | |
39 | +.Fa compar | |
40 | +subroutine, the two arguments are of type | |
41 | +.Ft const struct dirent ** , | |
42 | +so that a double-dereference is needed to access the fields in the | |
43 | +.Ft dirent | |
44 | +structure. | |
45 | .Pp | |
46 | The | |
47 | .Fn alphasort | |
1f2f436a | 48 | @@ -87,6 +99,18 @@ argument to sort the array alphabeticall |
34e8f829 A |
49 | The memory allocated for the array can be deallocated with |
50 | .Xr free 3 , | |
51 | by freeing each pointer in the array and then the array itself. | |
52 | +#ifdef UNIFDEF_BLOCKS | |
53 | +.Pp | |
54 | +The | |
55 | +.Fn scandir_b | |
56 | +function works the same way as the | |
57 | +.Fn scandir | |
58 | +function, except that | |
59 | +.Fa select | |
60 | +and | |
61 | +.Fa compar | |
62 | +are blocks instead of subroutines. | |
63 | +#endif | |
64 | .Sh DIAGNOSTICS | |
65 | Returns \-1 if the directory cannot be opened for reading or if | |
66 | .Xr malloc 3 | |
1f2f436a | 67 | @@ -103,3 +127,8 @@ and |
34e8f829 A |
68 | .Fn alphasort |
69 | functions appeared in | |
70 | .Bx 4.2 . | |
71 | +#ifdef UNIFDEF_BLOCKS | |
72 | +The | |
73 | +.Fn scandir_b | |
74 | +function appeared in Mac OS X 10.6. | |
75 | +#endif |