#include <glob.h>

glob.h

(!_POSIX_C_SOURCE || _DARWIN_C_SOURCE)
includes: _types.h, sys/cdefs.h, _bounds.h, Availability.h, sys/_types/_size_t.h
21 macros · 3 functions · 1 struct · 1 typedef

structglob_t

size 88, align 8
size_tgl_pathcCount of total paths so far.
intgl_matchcCount of paths matching pattern.
size_tgl_offsReserved at beginning of gl_pathv.
intgl_flagsCopy of flags parameter to glob.
char **gl_pathvList of paths matching pattern.
void (*)(void *)gl_closedirAlternate filesystem access methods for glob; replacement versions of closedir(3), readdir(3), opendir(3), stat(2) and lstat(2).
struct dirent *(*)(void *)gl_readdir
void *(*)(const char *)gl_opendir
int (*)(const char *, struct stat *)gl_lstat
int (*)(const char *, struct stat *)gl_stat

typedefglob_t

typedef struct glob_t glob_t;

macroGLOB_APPEND

Believed to have been introduced in 1003.2-1992
#define GLOB_APPEND 0x0001
Append to output from previous call.

macroGLOB_DOOFFS

#define GLOB_DOOFFS 0x0002
Use gl_offs.

macroGLOB_ERR

#define GLOB_ERR 0x0004
Return on error.

macroGLOB_MARK

#define GLOB_MARK 0x0008
Append / to matching directories.

macroGLOB_NOCHECK

#define GLOB_NOCHECK 0x0010
Return pattern itself if nothing matches.

macroGLOB_NOSORT

#define GLOB_NOSORT 0x0020
Don't sort.

macroGLOB_NOESCAPE

#define GLOB_NOESCAPE 0x2000
Disable backslash escaping.

macroGLOB_NOSPACE

Error values returned by glob(3)
#define GLOB_NOSPACE (-1)
Malloc call failed.

macroGLOB_ABORTED

#define GLOB_ABORTED (-2)
Unignored error.

macroGLOB_NOMATCH

#define GLOB_NOMATCH (-3)
No match and GLOB_NOCHECK was not set.

macroGLOB_NOSYS

#define GLOB_NOSYS (-4)
Obsolete: source comptability only.

macroGLOB_ALTDIRFUNC

#define GLOB_ALTDIRFUNC 0x0040
Use alternately specified directory funcs.

macroGLOB_BRACE

#define GLOB_BRACE 0x0080
Expand braces ala csh.

macroGLOB_MAGCHAR

#define GLOB_MAGCHAR 0x0100
Pattern had globbing characters.

macroGLOB_NOMAGIC

#define GLOB_NOMAGIC 0x0200
GLOB_NOCHECK without magic chars (csh).

macroGLOB_QUOTE

#define GLOB_QUOTE 0x0400
Quote special chars with \.

macroGLOB_TILDE

#define GLOB_TILDE 0x0800
Expand tilde names from the passwd file.

macroGLOB_LIMIT

#define GLOB_LIMIT 0x1000
limit number of returned paths

macro_GLOB_ERR_BLOCK

#define _GLOB_ERR_BLOCK 0x80000000
(internal) error callback is a block

macroGLOB_MAXPATH

source compatibility, these are the old names
#define GLOB_MAXPATH GLOB_LIMIT

macroGLOB_ABEND

#define GLOB_ABEND GLOB_ABORTED

functionglob

__DARWIN_INODE64(glob)
int glob(const char * __restrict, int, int (*)(const char *, int), glob_t * __restrict)
man page · June 23, 2025
glob(3) — generate pathnames matching a pattern

functionglob_b

__DARWIN_INODE64(glob_b) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
int glob_b(
	const char * __restrict,
	int,
	int (^)(const char *, int) __glob_noescape,
	glob_t * __restrict
)
man page · June 23, 2025
glob_b(3) — generate pathnames matching a pattern

functionglobfree

void globfree(glob_t *)
man page · June 23, 2025
globfree(3) — generate pathnames matching a pattern