Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | --- glob.3.orig 2011-01-26 13:57:29.000000000 -0800 +++ glob.3 2011-01-26 14:02:29.000000000 -0800 @@ -30,21 +30,38 @@ .\" @(#)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 $ .\" -.Dd September 1, 2004 +.Dd May 20, 2008 .Dt GLOB 3 .Os .Sh NAME .Nm glob , +#ifdef UNIFDEF_BLOCKS +.Nm glob_b , +#endif .Nm globfree .Nd generate pathnames matching a pattern -.Sh LIBRARY -.Lb libc .Sh SYNOPSIS .In glob.h .Ft int -.Fn glob "const char *pattern" "int flags" "int (*errfunc)(const char *, int)" "glob_t *pglob" +.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 +.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 .Ft void -.Fn globfree "glob_t *pglob" +.Fo globfree +.Fa "glob_t *pglob" +.Fc .Sh DESCRIPTION The .Fn glob @@ -60,7 +77,7 @@ .Bd -literal typedef struct { size_t gl_pathc; /* count of total paths so far */ - size_t gl_matchc; /* count of paths matching pattern */ + int gl_matchc; /* count of paths matching pattern */ size_t gl_offs; /* reserved at beginning of gl_pathv */ int gl_flags; /* returned flags */ char **gl_pathv; /* list of paths matching pattern */ @@ -322,18 +339,39 @@ or .Fa errfunc returns zero, the error is ignored. +#ifdef UNIFDEF_BLOCKS +.Pp +The +.Fn glob_b +function is like +.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. -In addition the fields of +#endif +In addition, the fields of .Fa pglob contain the values described below: .Bl -tag -width GLOB_NOCHECK @@ -341,12 +379,22 @@ 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 @@ -369,6 +417,10 @@ .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 @@ -414,6 +466,18 @@ g.gl_pathv[1] = "-l"; execvp("ls", g.gl_pathv); .Ed +.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 .Xr sh 1 , .Xr fnmatch 3 , @@ -452,6 +516,11 @@ .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 @@ -459,7 +528,13 @@ .Pp The .Fn glob -argument +#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 , |