Print this page
1097 glob(3c) needs to support non-POSIX options
3341 The sftp command should use the native glob()
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/glob.h
+++ new/usr/src/head/glob.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 +
22 23 /*
23 - * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 - * Use is subject to license terms.
24 + * Copyright 1985, 1992 by Mortice Kern Systems Inc. All rights reserved.
25 25 */
26 26
27 27 /*
28 - * Copyright 1985, 1992 by Mortice Kern Systems Inc. All rights reserved.
28 + * Copyright (c) 1989, 1993
29 + * The Regents of the University of California. All rights reserved.
30 + *
31 + * This code is derived from software contributed to Berkeley by
32 + * Guido van Rossum.
33 + *
34 + * Redistribution and use in source and binary forms, with or without
35 + * modification, are permitted provided that the following conditions
36 + * are met:
37 + * 1. Redistributions of source code must retain the above copyright
38 + * notice, this list of conditions and the following disclaimer.
39 + * 2. Redistributions in binary form must reproduce the above copyright
40 + * notice, this list of conditions and the following disclaimer in the
41 + * documentation and/or other materials provided with the distribution.
42 + * 3. Neither the name of the University nor the names of its contributors
43 + * may be used to endorse or promote products derived from this software
44 + * without specific prior written permission.
45 + *
46 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
47 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
50 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 + * SUCH DAMAGE.
57 + *
58 + * @(#)glob.h 8.1 (Berkeley) 6/2/93
29 59 */
30 60
61 +/*
62 + * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
63 + * Use is subject to license terms.
64 + * Copyright (c) 2013 Gary Mills
65 + */
66 +
31 67 #ifndef _GLOB_H
32 68 #define _GLOB_H
33 69
34 -#pragma ident "%Z%%M% %I% %E% SMI"
35 -
36 70 #include <sys/feature_tests.h>
37 71 #include <sys/types.h>
72 +#include <sys/stat.h>
73 +#include <dirent.h>
38 74
39 75 #ifdef __cplusplus
40 76 extern "C" {
41 77 #endif
42 78
43 79 typedef struct glob_t {
44 - size_t gl_pathc; /* Count of paths matched by pattern */
45 - char **gl_pathv; /* List of matched pathnames */
46 - size_t gl_offs; /* # of slots reserved in gl_pathv */
47 - /* following are internal to the implementation */
48 - char **gl_pathp; /* gl_pathv + gl_offs */
49 - int gl_pathn; /* # of elements allocated */
80 + /*
81 + * Members specified by POSIX
82 + */
83 + size_t gl_pathc; /* Total count of paths matched by pattern */
84 + char **gl_pathv; /* List of matched pathnames */
85 + size_t gl_offs; /* # of slots reserved in gl_pathv */
86 +
87 + /*
88 + * Internal-use members:
89 + *
90 + * NB: The next two members are carried in both the
91 + * libc backward compatibility wrapper functions and
92 + * the extended functions.
93 + */
94 + char **gl_pathp; /* gl_pathv + gl_offs */
95 + int gl_pathn; /* # of elements allocated */
96 +
97 + /*
98 + * Non-POSIX extensions
99 + *
100 + * NB: The following members are not carried in
101 + * the libc backward compatibility wrapper functions.
102 + */
103 + int gl_matchc; /* Count of paths matching pattern. */
104 + int gl_flags; /* Copy of flags parameter to glob. */
105 + struct stat **gl_statv; /* Stat entries corresponding to gl_pathv */
106 +
107 + /*
108 + * Alternate filesystem access methods for glob; replacement
109 + * versions of closedir(3), readdir(3), opendir(3), stat(2)
110 + * and lstat(2).
111 + */
112 + void (*gl_closedir)(void *);
113 + struct dirent *(*gl_readdir)(void *);
114 + void *(*gl_opendir)(const char *);
115 + int (*gl_lstat)(const char *, struct stat *);
116 + int (*gl_stat)(const char *, struct stat *);
50 117 } glob_t;
51 118
52 119 /*
53 - * "flags" argument to glob function.
120 + * POSIX "flags" argument to glob function.
54 121 */
55 122 #define GLOB_ERR 0x0001 /* Don't continue on directory error */
56 123 #define GLOB_MARK 0x0002 /* Mark directories with trailing / */
57 124 #define GLOB_NOSORT 0x0004 /* Don't sort pathnames */
58 125 #define GLOB_NOCHECK 0x0008 /* Return unquoted arg if no match */
59 126 #define GLOB_DOOFFS 0x0010 /* Ignore gl_offs unless set */
60 127 #define GLOB_APPEND 0x0020 /* Append to previous glob_t */
61 128 #define GLOB_NOESCAPE 0x0040 /* Backslashes do not quote M-chars */
62 129
63 130 /*
131 + * Non-POSIX "flags" argument to glob function, from OpenBSD.
132 + */
133 +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
134 +#define GLOB_POSIX 0x007F /* All POSIX flags */
135 +#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */
136 +#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */
137 +#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */
138 +#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */
139 +#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */
140 +#define GLOB_LIMIT 0x2000 /* Limit pattern match output to ARG_MAX */
141 +#define GLOB_KEEPSTAT 0x4000 /* Retain stat data for paths in gl_statv. */
142 +#define GLOB_ALTDIRFUNC 0x8000 /* Use alternately specified directory funcs. */
143 +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
144 +
145 +/*
64 146 * Error returns from "glob"
65 147 */
66 148 #define GLOB_NOSYS (-4) /* function not supported (XPG4) */
67 149 #define GLOB_NOMATCH (-3) /* Pattern does not match */
68 150 #define GLOB_NOSPACE (-2) /* Not enough memory */
69 151 #define GLOB_ABORTED (-1) /* GLOB_ERR set or errfunc return!=0 */
152 +#define GLOB_ABEND GLOB_ABORTED /* backward compatibility */
70 153
154 +#ifdef __PRAGMA_REDEFINE_EXTNAME
155 +#pragma redefine_extname glob _glob_ext
156 +#pragma redefine_extname globfree _globfree_ext
157 +#else /* __PRAGMA_REDEFINE_EXTNAME */
158 +#define glob _glob_ext
159 +#define globfree _globfree_ext
160 +#endif /* __PRAGMA_REDEFINE_EXTNAME */
161 +
71 162 #if defined(__STDC__)
163 +
72 164 extern int glob(const char *_RESTRICT_KYWD, int, int(*)(const char *, int),
73 165 glob_t *_RESTRICT_KYWD);
74 166 extern void globfree(glob_t *);
75 -#else
167 +
168 +#else /* __STDC__ */
169 +
76 170 extern int glob();
77 171 extern void globfree();
78 -#endif
79 172
173 +#endif /* __STDC__ */
174 +
80 175 #ifdef __cplusplus
81 176 }
82 177 #endif
83 178
84 179 #endif /* _GLOB_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX