1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
24 * posix glob interface definitions with gnu extensions
30 #define GLOB_VERSION 20060717L
40 typedef struct _glob_ glob_t
;
41 typedef struct _globlist_ globlist_t
;
47 unsigned char gl_flags
;
59 /* GLOB_DISC data -- memset(&gl,0,sizeof(gl)) before using! */
61 const char* gl_fignore
;
62 const char* gl_suffix
;
63 unsigned char* gl_intr
;
68 void* (*gl_diropen
)(glob_t
*, const char*);
69 char* (*gl_dirnext
)(glob_t
*, void*);
70 void (*gl_dirclose
)(glob_t
*, void*);
71 int (*gl_type
)(glob_t
*, const char*, int);
72 int (*gl_attr
)(glob_t
*, const char*, int);
74 /* gnu extensions -- but how do you synthesize dirent and stat? */
76 void* (*gl_opendir
)(const char*);
77 struct dirent
* (*gl_readdir
)(void*);
78 void (*gl_closedir
)(void*);
79 int (*gl_stat
)(const char*, struct stat
*);
80 int (*gl_lstat
)(const char*, struct stat
*);
84 char* (*gl_nextdir
)(glob_t
*, char*);
85 unsigned long gl_status
;
86 unsigned long gl_version
;
87 unsigned short gl_extra
;
97 /* standard interface */
98 #define GLOB_APPEND 0x0001 /* append to previous */
99 #define GLOB_DOOFFS 0x0002 /* gl_offs defines argv offset */
100 #define GLOB_ERR 0x0004 /* abort on error */
101 #define GLOB_MARK 0x0008 /* append / to directories */
102 #define GLOB_NOCHECK 0x0010 /* nomatch is original pattern */
103 #define GLOB_NOESCAPE 0x0020 /* don't treat \ specially */
104 #define GLOB_NOSORT 0x0040 /* don't sort the list */
106 /* extended interface */
107 #define GLOB_STARSTAR 0x0080 /* enable [/]**[/] expansion */
108 #define GLOB_BRACE 0x0100 /* enable {...} expansion */
109 #define GLOB_ICASE 0x0200 /* ignore case on match */
110 #define GLOB_COMPLETE 0x0400 /* shell file completeion */
111 #define GLOB_AUGMENTED 0x0800 /* augmented shell patterns */
112 #define GLOB_STACK 0x1000 /* allocate on current stack */
113 #define GLOB_LIST 0x2000 /* just create gl_list */
114 #define GLOB_ALTDIRFUNC 0x4000 /* gnu discipline functions */
115 #define GLOB_DISC 0x8000 /* discipline initialized */
118 #define GLOB_NOTDIR 0x0001 /* last gl_dirnext() not a dir */
121 #define GLOB_NOTFOUND 0 /* does not exist */
122 #define GLOB_DEV 1 /* exists but not DIR EXE REG */
123 #define GLOB_DIR 2 /* directory */
124 #define GLOB_EXE 3 /* executable regular file */
125 #define GLOB_REG 4 /* regular file */
127 /* error return values */
128 #define GLOB_ABORTED 1
129 #define GLOB_NOMATCH 2
130 #define GLOB_NOSPACE 3
132 #define GLOB_APPERR 5
135 #if _BLD_ast && defined(__EXPORT__)
136 #define extern __EXPORT__
139 extern int glob(const char*, int, int(*)(const char*,int), glob_t
*);
140 extern void globfree(glob_t
*);