Lines Matching refs:code

63 @var{pattern}.  It returns @code{0} if they do match; otherwise, it
64 returns the nonzero value @code{FNM_NOMATCH}. The arguments
70 In @theglibc{}, @code{fnmatch} might sometimes report ``errors'' by
71 returning nonzero values that are not equal to @code{FNM_NOMATCH}.
76 @vtable @code
86 This is an alias for @code{FNM_FILE_NAME}; it comes from POSIX.2. We
96 If you set both @code{FNM_PERIOD} and @code{FNM_FILE_NAME}, then the
99 @code{FNM_PERIOD} and @code{FNM_FILE_NAME} flags together for matching
110 If you use @code{FNM_NOESCAPE}, then @samp{\} is an ordinary character.
131 explained in the following table where @var{pattern-list} is a @code{|}
134 @table @code
165 You could do this using @code{fnmatch}, by reading the directory entries
166 one by one and testing each one with @code{fnmatch}. But that would be
170 The library provides a function @code{glob} to make this particular use
171 of wildcards convenient. @code{glob} and the other symbols in this
175 * Calling Glob:: Basic use of @code{glob}.
176 * Flags for Globbing:: Flags that enable various options in @code{glob}.
177 * More Flags for Globbing:: GNU specific extensions to @code{glob}.
181 @subsection Calling @code{glob}
184 this vector, @code{glob} uses a special data type, @code{glob_t}, which
185 is a structure. You pass @code{glob} the address of the structure, and
195 @table @code
201 The address of the vector. This field has type @w{@code{char **}}.
205 address in the @code{gl_pathv} field. Unlike the other fields, this
206 is always an input to @code{glob}, rather than an output from it.
209 the vector are left empty. (The @code{glob} function fills them with
212 The @code{gl_offs} field is meaningful only if you use the
213 @code{GLOB_DOOFFS} flag. Otherwise, the offset is always zero
218 The address of an alternative implementation of the @code{closedir}
219 function. It is used if the @code{GLOB_ALTDIRFUNC} bit is set in
221 @w{@code{void (*) (void *)}}.
226 The address of an alternative implementation of the @code{readdir}
228 @code{GLOB_ALTDIRFUNC} bit is set in the flag parameter. The type of
229 this field is @w{@code{struct dirent *(*) (void *)}}.
231 An implementation of @code{gl_readdir} needs to initialize the following
232 members of the @code{struct dirent} object:
234 @table @code
237 Otherwise, the value @code{DT_UNKNOWN} can be used. The @code{glob}
242 This member needs to be non-zero, otherwise @code{glob} may skip the
243 current entry and call the @code{gl_readdir} callback function again to
251 The example below shows how to allocate a @code{struct dirent} object
258 The @code{glob} function reads the @code{struct dirent} members listed
259 above and makes a copy of the file name in the @code{d_name} member
260 immediately after the @code{gl_readdir} callback function returns.
263 @code{glob} function to allocate and deallocate the buffer, around the
264 call to @code{glob} or using the callback functions. For example, an
265 application could allocate the buffer in the @code{gl_readdir} callback
266 function, and deallocate it in the @code{gl_closedir} callback function.
268 The @code{gl_readdir} member is a GNU extension.
271 The address of an alternative implementation of the @code{opendir}
272 function. It is used if the @code{GLOB_ALTDIRFUNC} bit is set in
274 @w{@code{void *(*) (const char *)}}.
279 The address of an alternative implementation of the @code{stat} function
281 @code{GLOB_ALTDIRFUNC} bit is set in the flag parameter. The type of
282 this field is @w{@code{int (*) (const char *, struct stat *)}}.
287 The address of an alternative implementation of the @code{lstat}
289 following symbolic links. It is used if the @code{GLOB_ALTDIRFUNC} bit
290 is set in the flag parameter. The type of this field is @code{@w{int
296 The flags used when @code{glob} was called. In addition, @code{GLOB_MAGCHAR}
303 For use in the @code{glob64} function @file{glob.h} contains another
304 definition for a very similar type. @code{glob64_t} differs from
305 @code{glob_t} only in the types of the members @code{gl_readdir},
306 @code{gl_stat}, and @code{gl_lstat}.
315 @table @code
321 The address of the vector. This field has type @w{@code{char **}}.
325 address in the @code{gl_pathv} field. Unlike the other fields, this
326 is always an input to @code{glob}, rather than an output from it.
329 the vector are left empty. (The @code{glob} function fills them with
332 The @code{gl_offs} field is meaningful only if you use the
333 @code{GLOB_DOOFFS} flag. Otherwise, the offset is always zero
338 The address of an alternative implementation of the @code{closedir}
339 function. It is used if the @code{GLOB_ALTDIRFUNC} bit is set in
341 @w{@code{void (*) (void *)}}.
346 The address of an alternative implementation of the @code{readdir64}
348 @code{GLOB_ALTDIRFUNC} bit is set in the flag parameter. The type of
349 this field is @w{@code{struct dirent64 *(*) (void *)}}.
354 The address of an alternative implementation of the @code{opendir}
355 function. It is used if the @code{GLOB_ALTDIRFUNC} bit is set in
357 @w{@code{void *(*) (const char *)}}.
362 The address of an alternative implementation of the @code{stat64} function
364 @code{GLOB_ALTDIRFUNC} bit is set in the flag parameter. The type of
365 this field is @w{@code{int (*) (const char *, struct stat64 *)}}.
370 The address of an alternative implementation of the @code{lstat64}
372 following symbolic links. It is used if the @code{GLOB_ALTDIRFUNC} bit
373 is set in the flag parameter. The type of this field is @code{@w{int
379 The flags used when @code{glob} was called. In addition, @code{GLOB_MAGCHAR}
386 …{flags}, int (*@var{errfunc}) (const char *@var{filename}, int @var{error-code}), glob_t *@var{vec…
445 The function @code{glob} does globbing using the pattern @var{pattern}
448 @code{*@var{vector-ptr}}. The argument @var{flags} is a combination of
452 @code{glob} allocates a string for each resulting word, then
453 allocates a vector of type @code{char **} to store the addresses of
457 To return this vector, @code{glob} stores both its address and its
459 into @code{*@var{vector-ptr}}.
461 Normally, @code{glob} sorts the file names alphabetically before
462 returning them. You can turn this off with the flag @code{GLOB_NOSORT}
464 a good idea to let @code{glob} sort them---if you process the files in
468 If @code{glob} succeeds, it returns 0. Otherwise, it returns one
471 @vtable @code
475 @code{GLOB_ERR} or your specified @var{errfunc} returned a nonzero
483 for an explanation of the @code{GLOB_ERR} flag and @var{errfunc}.
488 @code{GLOB_NOCHECK} flag, then you never get this error code, because
489 that flag tells @code{glob} to @emph{pretend} that the pattern matched
497 In the event of an error, @code{glob} stores information in
498 @code{*@var{vector-ptr}} about all the matches it has found so far.
500 It is important to notice that the @code{glob} function will not fail if
502 LFS interfaces. The implementation of @code{glob} is supposed to use
505 own directory handling and @code{stat} functions complicates things a
507 is encountered @code{glob} @emph{can} fail.
510 …{flags}, int (*@var{errfunc}) (const char *@var{filename}, int @var{error-code}), glob64_t *@var{v…
513 @c Same code as glob, but with glob64_t #defined as glob_t.
514 The @code{glob64} function was added as part of the Large File Summit
516 this is simple: it is not necessary. The necessity for a @code{glob64}
517 function is added by the extensions of the GNU @code{glob}
519 and @code{stat} functions. The @code{readdir} and @code{stat} functions
520 do depend on the choice of @code{_FILE_OFFSET_BITS} since the definition
521 of the types @code{struct dirent} and @code{struct stat} will change
524 Besides this difference, @code{glob64} works just like @code{glob} in
534 @var{flags} argument to @code{glob}. Choose the flags you want,
535 and combine them with the C bitwise OR operator @code{|}.
539 @vtable @code
543 previous calls to @code{glob}. This way you can effectively expand
547 word vector structure between calls to @code{glob}. And, if you set
548 @code{GLOB_DOOFFS} in the first call to @code{glob}, you must also
551 Note that the pointer stored in @code{gl_pathv} may no longer be valid
552 after you call @code{glob} the second time, because @code{glob} might
553 have relocated the vector. So always fetch @code{gl_pathv} from the
554 @code{glob_t} structure after each @code{glob} call; @strong{never} save
560 The @code{gl_offs} field says how many slots to leave.
568 have the requisite access. Normally, @code{glob} tries its best to keep
572 error-handler function @var{errfunc} when you call @code{glob}. If
573 @var{errfunc} is not a null pointer, then @code{glob} doesn't give up
578 (*@var{errfunc}) (@var{filename}, @var{error-code})
583 @code{glob} couldn't open or couldn't read, and @var{error-code} is the
584 @code{errno} value that was reported to @code{glob}.
586 If the error handler function returns nonzero, then @code{glob} gives up
598 pattern doesn't match anything, @code{glob} returns that there were no
609 If you use @code{GLOB_NOESCAPE}, then @samp{\} is an ordinary character.
611 @code{glob} does its work by calling the function @code{fnmatch}
612 repeatedly. It handles the flag @code{GLOB_NOESCAPE} by turning on the
613 @code{FNM_NOESCAPE} flag in calls to @code{fnmatch}.
626 @code{glob} allows a few more flags which are also defined in the
630 @vtable @code
633 The @code{.} character (period) is treated special. It cannot be
634 matched by wildcards. @xref{Wildcard Matching}, @code{FNM_PERIOD}.
638 The @code{GLOB_MAGCHAR} value is not to be given to @code{glob} in the
639 @var{flags} parameter. Instead, @code{glob} sets this bit in the
646 filesystem the @code{glob} implementation uses the user-supplied
663 expressions by splitting at @code{,} (comma) characters. The commas
694 If this flag is used the character @code{~} (tilde) is handled specially
698 If @code{~} is the only character in pattern or it is followed by a
699 @code{/} (slash), the home directory of the process owner is
700 substituted. Using @code{getlogin} and @code{getpwnam} the information
701 is read from the system databases. As an example take user @code{bart}
713 @code{homer}'s @file{bin} directory can be retrieved by
721 result. I.e., if in the last example @code{home} is not available the
722 tilde expansion yields to @code{"~homer/bin/*"} and @code{glob} is not
723 looking for a directory named @code{~homer}.
726 @code{nonomatch} flag is set.
730 If this flag is used @code{glob} behaves as if @code{GLOB_TILDE} is
733 an error. @code{glob} will return @code{GLOB_NOMATCH} instead of using
737 the @code{nonomatch} flag is not set.
748 This functionality is only available with the GNU @code{glob}
754 Calling @code{glob} will in most cases allocate resources which are used
756 type @code{glob_t} is used in multiple call to @code{glob} the resources
758 the time when all @code{glob} calls are done.
765 The @code{globfree} function frees all resources allocated by previous
766 calls to @code{glob} associated with the object pointed to by
768 @code{glob_t} typed object isn't used anymore.
774 This function is equivalent to @code{globfree} but it frees records of
775 type @code{glob64_t} which were allocated by @code{glob64}.
787 If you define @w{@code{_POSIX_C_SOURCE}}, then only the POSIX.2
792 * POSIX Regexp Compilation:: Using @code{regcomp} to prepare to match.
793 * Flags for POSIX Regexps:: Syntax variations for @code{regcomp}.
794 * Matching POSIX Regexps:: Using @code{regexec} to match the compiled
795 pattern that you get from @code{regcomp}.
819 @table @code
829 After you create a @code{regex_t} object, you can compile a regular
830 expression into it by calling @code{regcomp}.
1078 The function @code{regcomp} ``compiles'' a regular expression into a
1079 data structure that you can use with @code{regexec} to match against a
1081 efficient matching. @code{regcomp} stores it into @code{*@var{compiled}}.
1083 It's up to you to allocate an object of type @code{regex_t} and pass its
1084 address to @code{regcomp}.
1090 If you use the flag @code{REG_NOSUB}, then @code{regcomp} omits from
1093 pass @code{0} for the @var{matchptr} and @var{nmatch} arguments when
1094 you call @code{regexec}.
1096 If you don't use @code{REG_NOSUB}, then the compiled regular expression
1098 @code{regcomp} tells you how many subexpressions @var{pattern} has, by
1099 storing the number in @code{@var{compiled}->re_nsub}. You can use that
1103 @code{regcomp} returns @code{0} if it succeeds in compiling the regular
1104 expression; otherwise, it returns a nonzero error code (see the table
1105 below). You can use @code{regerror} to produce an error message string
1110 Here are the possible nonzero values that @code{regcomp} can return:
1112 @vtable @code
1166 @code{regcomp} ran out of memory.
1173 compiling a regular expression with @code{regcomp}.
1175 @vtable @code
1204 @code{regexec}. A match anywhere inside the string counts as success,
1452 @code{*@var{compiled}} against @var{string}.
1454 @code{regexec} returns @code{0} if the regular expression matches;
1456 what nonzero values mean. You can use @code{regerror} to produce an
1465 @var{matchptr} and @var{nmatch}. Otherwise, pass @code{0} for
1466 @var{nmatch}, and @code{NULL} for @var{matchptr}. @xref{Regexp
1473 The function @code{regexec} accepts the following flags in the
1476 @vtable @code
1489 Here are the possible nonzero values that @code{regexec} can return:
1491 @vtable @code
1498 @code{regexec} ran out of memory.
1504 When @code{regexec} matches parenthetical subexpressions of
1507 elements are structures of type @code{regmatch_t}. The first element of
1508 the array (index @code{0}) records the part of the string that matched
1516 @code{regexec}. It contains two structure fields, as follows:
1518 @table @code
1530 @code{regoff_t} is an alias for another signed integer type.
1531 The fields of @code{regmatch_t} have type @code{regoff_t}.
1534 The @code{regmatch_t} elements correspond to subexpressions
1535 positionally; the first element (index @code{1}) records where the first
1540 When you call @code{regexec}, you specify how long the @var{matchptr}
1541 array is, with the @var{nmatch} argument. This tells @code{regexec} how
1547 If you don't want @code{regexec} to return any information about where
1548 the subexpressions matched, you can either supply @code{0} for
1549 @var{nmatch}, or use the flag @code{REG_NOSUB} when you compile the
1550 pattern with @code{regcomp}.
1559 example, the offsets are both @code{1}.
1564 this happens, @code{regexec} stores @code{-1} in both fields of the
1570 matches three times. When this happens, @code{regexec} usually stores
1573 @code{6} and @code{8}.
1584 @code{regexec} reports nonuse of the ``na'' subexpression.
1595 repetition, the ``na'' subexpression is not used. So @code{regexec}
1602 free the storage it uses by calling @code{regfree}.
1609 Calling @code{regfree} frees all the storage that @code{*@var{compiled}}
1610 points to. This includes various internal fields of the @code{regex_t}
1613 @code{regfree} does not free the object @code{*@var{compiled}} itself.
1616 You should always free the space in a @code{regex_t} structure with
1617 @code{regfree} before using the structure to compile another regular
1620 When @code{regcomp} or @code{regexec} reports an error, you can use
1621 the function @code{regerror} to turn it into an error message string.
1627 This function produces an error message string for the error code
1630 same compiled regular expression structure that @code{regcomp} or
1631 @code{regexec} was working with when it got the error. Alternatively,
1632 you can supply @code{NULL} for @var{compiled}; you will still get a
1636 terminating null character), then @code{regerror} truncates it.
1637 The string that @code{regerror} stores is always null-terminated
1640 The return value of @code{regerror} is the minimum length needed to
1643 should call @code{regerror} again with a larger buffer.
1645 Here is a function which uses @code{regerror}, but always dynamically
1682 calling the library function @code{wordexp}.
1686 * Calling Wordexp:: How to call @code{wordexp}.
1687 * Flags for Wordexp:: Options you can enable in @code{wordexp}.
1750 @subsection Calling @code{wordexp}
1756 vector, @code{wordexp} uses a special data type, @code{wordexp_t}, which
1757 is a structure. You pass @code{wordexp} the address of the structure,
1765 @table @code
1770 The address of the vector. This field has type @w{@code{char **}}.
1774 address in the @code{we_wordv} field. Unlike the other fields, this
1775 is always an input to @code{wordexp}, rather than an output from it.
1778 the vector are left empty. (The @code{wordexp} function fills them with
1781 The @code{we_offs} field is meaningful only if you use the
1782 @code{WRDE_DOOFFS} flag. Otherwise, the offset is always zero
1930 into @code{*@var{word-vector-ptr}}. The argument @var{flags} is a
1936 these characters unquoted, you will get the @code{WRDE_BADCHAR} error
1937 code. Don't use parentheses or braces unless they are quoted or part of
1942 @code{wordexp} allocates a string for each resulting word, then
1943 allocates a vector of type @code{char **} to store the addresses of
1947 To return this vector, @code{wordexp} stores both its address and its
1949 into @code{*@var{word-vector-ptr}}.
1951 If @code{wordexp} succeeds, it returns 0. Otherwise, it returns one
1954 @vtable @code
1963 @code{WRDE_UNDEF} to forbid such references.
1968 @code{WRDE_NOCMD} to forbid command substitution.
1973 @code{wordexp} can store part of the results---as much as it could
1979 quoting character is a syntax error. This error code is also used to
1990 @code{*@var{word-vector-ptr}} points to. This does not free the
1991 structure @code{*@var{word-vector-ptr}} itself---only the other
1999 @var{flags} argument to @code{wordexp}. Choose the flags you want,
2000 and combine them with the C operator @code{|}.
2002 @vtable @code
2006 previous calls to @code{wordexp}. This way you can effectively expand
2010 word vector structure between calls to @code{wordexp}. And, if you set
2011 @code{WRDE_DOOFFS} in the first call to @code{wordexp}, you must also
2017 The @code{we_offs} field says how many slots to leave.
2027 Reuse a word vector made by a previous call to @code{wordexp}.
2028 Instead of allocating a new vector of words, this call to @code{wordexp}
2032 and use it again after calling @code{wordexp}. You must fetch
2033 @code{we_pathv} anew after each call.
2039 stream of the current process. By default, @code{wordexp} gives these
2049 @subsection @code{wordexp} Example
2051 Here is an example of using @code{wordexp} to expand several strings
2053 @code{WRDE_APPEND} to concatenate the expansions and of @code{wordfree}
2054 to free the space allocated by @code{wordexp}.
2070 /* @r{If the error was @code{WRDE_NOSPACE},}
2122 Plain @samp{~} uses the value of the environment variable @code{HOME}
2124 uses @code{getpwname} to look up that user in the user database, and
2127 the value of @code{HOME} is not really your home directory.
2139 @table @code
2151 name. Thus, @samp{$foo-bar} refers to the variable @code{foo} and expands
2158 @table @code
2182 @table @code
2196 @table @code