]>
Commit | Line | Data |
---|---|---|
1 | --- scandir.3.orig 2009-05-12 11:21:55.000000000 -0700 | |
2 | +++ scandir.3 2009-05-20 15:41:07.000000000 -0700 | |
3 | @@ -32,15 +32,16 @@ | |
4 | .\" @(#)scandir.3 8.1 (Berkeley) 6/4/93 | |
5 | .\" $FreeBSD: src/lib/libc/gen/scandir.3,v 1.8 2002/12/19 09:40:21 ru Exp $ | |
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 | |
23 | @@ -48,6 +49,10 @@ | |
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 | |
34 | @@ -80,6 +85,13 @@ | |
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 | |
48 | @@ -91,6 +103,18 @@ | |
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 | |
67 | @@ -107,3 +131,8 @@ | |
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 |