Append pathnames generated to the ones from a previous call (or calls) to glob. The value of gl_pathc will be the total matches found by this call and the previous call(s). The pathnames are appended to, not merged with the pathnames returned by the previous call(s). Between calls, the caller must not change the setting of the GLOB_DOOFFS flag, nor change the value of gl_offs when GLOB_DOOFFS is set, nor (obviously) call globfree for pglob.

GLOB_DOOFFS

Make use of the gl_offs field. If this flag is set, gl_offs is used to specify how many NULL pointers to prepend to the beginning of the gl_pathv field. In other words, gl_pathv will point to gl_offs NULL pointers, followed by gl_pathc pathname pointers, followed by a NULL pointer.

GLOB_ERR

Causes glob to return when it encounters a directory that it cannot open or read. Ordinarily, glob continues to find matches.

GLOB_MARK

Each pathname that is a directory that matches pattern has a slash appended.

GLOB_NOCHECK

If pattern does not match any pathname, then glob returns a list consisting of only pattern, with the number of total pathnames set to 1, and the number of matched pathnames set to 0. The effect of backslash escaping is present in the pattern returned.

GLOB_NOESCAPE

By default, a backslash (\) character is used to escape the following character in the pattern, avoiding any special interpretation of the character. If GLOB_NOESCAPE is set, backslash escaping is disabled.

GLOB_NOSORT

By default, the pathnames are sorted in ascending ASCII order; this flag prevents that sorting (speeding up glob).

The following values may also be included in flags, however, they are non-standard extensions to -p1003.2.

GLOB_ALTDIRFUNC

The following additional fields in the pglob structure have been initialized with alternate functions for glob to use to open, read, and close directories and to get stat information on names found in those directories.
void *(*gl_opendir)(const char * name);
struct dirent *(*gl_readdir)(void *);
void (*gl_closedir)(void *);
int (*gl_lstat)(const char *name, struct stat *st);
int (*gl_stat)(const char *name, struct stat *st);

This extension is provided to allow programs such as restore(8) to provide globbing from directories stored on tape.

GLOB_BRACE

Pre-process the pattern string to expand {pat,pat,...} strings like csh(1). The pattern {} is left unexpanded for historical reasons (and csh(1) does the same thing to ease typing of find(1) patterns).

GLOB_MAGCHAR

Set by the glob function if the pattern included globbing characters. See the description of the usage of the gl_matchc structure member for more details.

GLOB_NOMAGIC

Is the same as GLOB_NOCHECK but it only appends the pattern if it does not contain any of the special characters *, ? or [. GLOB_NOMAGIC is provided to simplify implementing the historic csh(1) globbing behavior and should probably not be used anywhere else.

GLOB_TILDE

Expand patterns that start with ~ to user name home directories.

GLOB_LIMIT

Limit the total number of returned pathnames to the value provided in gl_matchc (default ARG_MAX). This option should be set for programs that can be coerced into a denial of service attack via patterns that expand to a very large number of matches, such as a long string of */../*/...

If, during the search, a directory is encountered that cannot be opened or read and errfunc is non- NULL, glob calls *errfunc( path, errno). This may be unintuitive: a pattern like */Makefile will try to stat(2) foo/Makefile even if foo is not a directory, resulting in a call to errfunc. The error routine can suppress this action by testing for ENOENT and ENOTDIR; however, the GLOB_ERR flag will still cause an immediate return when this happens.

If errfunc returns non-zero, glob stops the scan and returns GLOB_ABORTED after setting gl_pathc and gl_pathv to reflect any paths already matched. This also happens if an error is encountered and GLOB_ERR is set in flags, regardless of the return value of errfunc, if called. If GLOB_ERR is not set and either errfunc is NULL or errfunc returns zero, the error is ignored.

The globfree function frees any space associated with pglob from a previous call(s) to glob.