source: Daodan/MinGW/include/glob.h@ 1095

Last change on this file since 1095 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 5.6 KB
Line 
1#ifndef _GLOB_H
2/*
3 * glob.h
4 *
5 * Header file supporting a MinGW implementation of an (approximately)
6 * POSIX conforming glob() and globfree() API.
7 *
8 * $Id: glob.h,v 21b61b814e54 2016/07/10 21:38:45 keithmarshall $
9 *
10 * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
11 * Copyright (C) 2011, 2012, 2014, 2016, MinGW.org Project.
12 *
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
20 *
21 * The above copyright notice, this permission notice, and the following
22 * disclaimer shall be included in all copies or substantial portions of
23 * the Software.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
26 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
31 * DEALINGS IN THE SOFTWARE.
32 *
33 */
34#define _GLOB_H 1
35#include <_mingw.h>
36#pragma GCC system_header
37
38#ifndef RC_INVOKED
39/* POSIX requires glob.h to define the size_t type; we need to
40 * get this from GCC, just as sys/types.h does.
41 */
42#define __need_size_t
43#include <stddef.h>
44
45typedef
46struct glob_t
47{ /* The structure, in which glob() returns the list of file system
48 * entities which it has matched.
49 */
50 void * gl_magic; /* reserved field; pointer to a glob signature */
51 size_t gl_pathc; /* counter for paths matched */
52 char ** gl_pathv; /* list of matching path names */
53 size_t gl_offs; /* number of initial unused slots in gl_pathv */
54} glob_t;
55
56/* A macro to facilitate definition of the flags which are used to
57 * control the operation of glob().
58 */
59#define __GLOB_FLAG__(NAME) (1 << __GLOB_##NAME##_OFFSET)
60enum {
61 /* Identify the zero-based offset values which are used to specify
62 * the individual bit positions for each __GLOB_FLAG; the initial
63 * list specifies the standard set of flags required by POSIX.
64 */
65 __GLOB_APPEND_OFFSET = 0,
66 __GLOB_DOOFFS_OFFSET,
67 __GLOB_ERR_OFFSET,
68 __GLOB_MARK_OFFSET,
69 __GLOB_NOCHECK_OFFSET,
70 __GLOB_NOESCAPE_OFFSET,
71 __GLOB_NOSORT_OFFSET,
72 /*
73 * GNU's implementation of glob() supports a supplementary set of
74 * options, none of which are required by POSIX. We include these
75 * for reference, and to reserve the flag identities for a possible
76 * future implementation; the current MinGW implementation does not
77 * support them.
78 */
79 __GLOB_TILDE_OFFSET,
80 __GLOB_TILDE_CHECK_OFFSET,
81 __GLOB_PERIOD_OFFSET,
82 __GLOB_BRACE_OFFSET,
83 __GLOB_ONLYDIR_OFFSET,
84 __GLOB_ALTDIRFUNC_OFFSET,
85 __GLOB_NOMAGIC_OFFSET,
86 /*
87 * This MinGW implementation DOES add support for the following
88 * custom options, which offer improved handling of MS-Windows
89 * specific peculiarities:--
90 *
91 * GLOB_CASEMATCH makes glob() respect case sensitivity
92 * in path name matches; this is similar
93 * to default behaviour on POSIX systems,
94 * but to better support the MS-Windows
95 * file system, the MinGW implementation
96 * of glob() performs a CASE INSENSITIVE
97 * character match by default, (except
98 * when matching within character group
99 * patterns, which are ALWAYS assumed to
100 * require CASE SENSITIVE matching).
101 */
102 __GLOB_CASEMATCH_OFFSET,
103 /*
104 * The following is a convenience, to mark the end of the enumeration;
105 * it is NEVER used to locate any user visible __GLOB_FLAG__, but it
106 * MUST remain as the final entry in the enumerated list.
107 */
108 __GLOB_FLAG_OFFSET_HIGH_WATER_MARK
109};
110
111/* Definitions of the mandatory flags, as specified by POSIX.
112 */
113#define GLOB_APPEND __GLOB_FLAG__(APPEND)
114#define GLOB_DOOFFS __GLOB_FLAG__(DOOFFS)
115#define GLOB_ERR __GLOB_FLAG__(ERR)
116#define GLOB_MARK __GLOB_FLAG__(MARK)
117#define GLOB_NOCHECK __GLOB_FLAG__(NOCHECK)
118#define GLOB_NOESCAPE __GLOB_FLAG__(NOESCAPE)
119#define GLOB_NOSORT __GLOB_FLAG__(NOSORT)
120
121/* Additional flags definitions, for MinGW specific extensions.
122 */
123#define GLOB_CASEMATCH __GLOB_FLAG__(CASEMATCH)
124
125_BEGIN_C_DECLS
126/*
127 * Function prototypes. Formally POSIX mandates:
128 *
129 * int glob( const char *, int, int (*)( const char *, int ), glob_t * );
130 * void globfree( glob_t * );
131 *
132 * However, our actual function implementations are provided via this
133 * pair of reserved function names...
134 */
135int __mingw_glob (const char *, int, int (*)(const char *, int), glob_t *);
136void __mingw_globfree (glob_t *);
137
138/* ...to which the standard names are then mapped as aliases,
139 * via __CRT_ALIAS inline function expansion.
140 */
141__CRT_ALIAS __JMPSTUB__(( FUNCTION = glob ))
142# define __ERRFUNC_P (*__errfunc) (const char *, int)
143int glob (const char *__pattern, int __flags, int __ERRFUNC_P, glob_t *__data)
144{ return __mingw_glob (__pattern, __flags, __errfunc, __data); }
145# undef __ERRFUNC_P
146
147__CRT_ALIAS __JMPSTUB__(( FUNCTION = globfree ))
148void globfree (glob_t *__data){ return __mingw_globfree (__data); }
149
150_END_C_DECLS
151
152/* Manifest definitions for the possible status values
153 * which glob() may return.
154 */
155#define GLOB_SUCCESS (0)
156#define GLOB_ABORTED (1)
157#define GLOB_NOMATCH (2)
158#define GLOB_NOSPACE (3)
159
160#endif /* ! RC_INVOKED */
161#endif /* ! defined _GLOB_H */
Note: See TracBrowser for help on using the repository browser.