|
Lines 59-64
Link Here
|
| 59 |
*/ |
59 |
*/ |
| 60 |
|
60 |
|
| 61 |
#include "includes.h" |
61 |
#include "includes.h" |
|
|
62 |
#include "glob.h" |
| 62 |
|
63 |
|
| 63 |
#include <sys/types.h> |
64 |
#include <sys/types.h> |
| 64 |
#include <sys/stat.h> |
65 |
#include <sys/stat.h> |
|
Lines 150-172
struct glob_path_stat {
Link Here
|
| 150 |
static int compare(const void *, const void *); |
151 |
static int compare(const void *, const void *); |
| 151 |
static int compare_gps(const void *, const void *); |
152 |
static int compare_gps(const void *, const void *); |
| 152 |
static int g_Ctoc(const Char *, char *, u_int); |
153 |
static int g_Ctoc(const Char *, char *, u_int); |
| 153 |
static int g_lstat(Char *, struct stat *, glob_t *); |
154 |
static int g_lstat(Char *, struct stat *, compat_glob_t *); |
| 154 |
static DIR *g_opendir(Char *, glob_t *); |
155 |
static DIR *g_opendir(Char *, compat_glob_t *); |
| 155 |
static Char *g_strchr(const Char *, int); |
156 |
static Char *g_strchr(const Char *, int); |
| 156 |
static int g_strncmp(const Char *, const char *, size_t); |
157 |
static int g_strncmp(const Char *, const char *, size_t); |
| 157 |
static int g_stat(Char *, struct stat *, glob_t *); |
158 |
static int g_stat(Char *, struct stat *, compat_glob_t *); |
| 158 |
static int glob0(const Char *, glob_t *, struct glob_lim *); |
159 |
static int glob0(const Char *, compat_glob_t *, struct glob_lim *); |
| 159 |
static int glob1(Char *, Char *, glob_t *, struct glob_lim *); |
160 |
static int glob1(Char *, Char *, compat_glob_t *, struct glob_lim *); |
| 160 |
static int glob2(Char *, Char *, Char *, Char *, Char *, Char *, |
161 |
static int glob2(Char *, Char *, Char *, Char *, Char *, Char *, |
| 161 |
glob_t *, struct glob_lim *); |
162 |
compat_glob_t *, struct glob_lim *); |
| 162 |
static int glob3(Char *, Char *, Char *, Char *, Char *, |
163 |
static int glob3(Char *, Char *, Char *, Char *, Char *, |
| 163 |
Char *, Char *, glob_t *, struct glob_lim *); |
164 |
Char *, Char *, compat_glob_t *, struct glob_lim *); |
| 164 |
static int globextend(const Char *, glob_t *, struct glob_lim *, |
165 |
static int globextend(const Char *, compat_glob_t *, struct glob_lim *, |
| 165 |
struct stat *); |
166 |
struct stat *); |
| 166 |
static const Char * |
167 |
static const Char * |
| 167 |
globtilde(const Char *, Char *, size_t, glob_t *); |
168 |
globtilde(const Char *, Char *, size_t, compat_glob_t *); |
| 168 |
static int globexp1(const Char *, glob_t *, struct glob_lim *); |
169 |
static int globexp1(const Char *, compat_glob_t *, struct glob_lim *); |
| 169 |
static int globexp2(const Char *, const Char *, glob_t *, |
170 |
static int globexp2(const Char *, const Char *, compat_glob_t *, |
| 170 |
struct glob_lim *); |
171 |
struct glob_lim *); |
| 171 |
static int match(Char *, Char *, Char *, int); |
172 |
static int match(Char *, Char *, Char *, int); |
| 172 |
#ifdef DEBUG |
173 |
#ifdef DEBUG |
|
Lines 174-181
static void qprintf(const char *, Char *);
Link Here
|
| 174 |
#endif |
175 |
#endif |
| 175 |
|
176 |
|
| 176 |
int |
177 |
int |
| 177 |
glob(const char *pattern, int flags, int (*errfunc)(const char *, int), |
178 |
__compat_glob(const char *pattern, int flags, int (*errfunc)(const char *, int), |
| 178 |
glob_t *pglob) |
179 |
compat_glob_t *pglob) |
| 179 |
{ |
180 |
{ |
| 180 |
const u_char *patnext; |
181 |
const u_char *patnext; |
| 181 |
int c; |
182 |
int c; |
|
Lines 233-239
glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
Link Here
|
| 233 |
* characters |
234 |
* characters |
| 234 |
*/ |
235 |
*/ |
| 235 |
static int |
236 |
static int |
| 236 |
globexp1(const Char *pattern, glob_t *pglob, struct glob_lim *limitp) |
237 |
globexp1(const Char *pattern, compat_glob_t *pglob, struct glob_lim *limitp) |
| 237 |
{ |
238 |
{ |
| 238 |
const Char* ptr = pattern; |
239 |
const Char* ptr = pattern; |
| 239 |
|
240 |
|
|
Lines 254-260
globexp1(const Char *pattern, glob_t *pglob, struct glob_lim *limitp)
Link Here
|
| 254 |
* If it fails then it tries to glob the rest of the pattern and returns. |
255 |
* If it fails then it tries to glob the rest of the pattern and returns. |
| 255 |
*/ |
256 |
*/ |
| 256 |
static int |
257 |
static int |
| 257 |
globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, |
258 |
globexp2(const Char *ptr, const Char *pattern, compat_glob_t *pglob, |
| 258 |
struct glob_lim *limitp) |
259 |
struct glob_lim *limitp) |
| 259 |
{ |
260 |
{ |
| 260 |
int i, rv; |
261 |
int i, rv; |
|
Lines 359-365
globexp2(const Char *ptr, const Char *pattern, glob_t *pglob,
Link Here
|
| 359 |
* expand tilde from the passwd file. |
360 |
* expand tilde from the passwd file. |
| 360 |
*/ |
361 |
*/ |
| 361 |
static const Char * |
362 |
static const Char * |
| 362 |
globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob) |
363 |
globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, compat_glob_t *pglob) |
| 363 |
{ |
364 |
{ |
| 364 |
struct passwd *pwd; |
365 |
struct passwd *pwd; |
| 365 |
char *h; |
366 |
char *h; |
|
Lines 468-474
g_charclass(const Char **patternp, Char **bufnextp)
Link Here
|
| 468 |
* to find no matches. |
469 |
* to find no matches. |
| 469 |
*/ |
470 |
*/ |
| 470 |
static int |
471 |
static int |
| 471 |
glob0(const Char *pattern, glob_t *pglob, struct glob_lim *limitp) |
472 |
glob0(const Char *pattern, compat_glob_t *pglob, struct glob_lim *limitp) |
| 472 |
{ |
473 |
{ |
| 473 |
const Char *qpatnext; |
474 |
const Char *qpatnext; |
| 474 |
int c, err, oldpathc; |
475 |
int c, err, oldpathc; |
|
Lines 606-612
compare_gps(const void *_p, const void *_q)
Link Here
|
| 606 |
} |
607 |
} |
| 607 |
|
608 |
|
| 608 |
static int |
609 |
static int |
| 609 |
glob1(Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp) |
610 |
glob1(Char *pattern, Char *pattern_last, compat_glob_t *pglob, struct glob_lim *limitp) |
| 610 |
{ |
611 |
{ |
| 611 |
Char pathbuf[MAXPATHLEN]; |
612 |
Char pathbuf[MAXPATHLEN]; |
| 612 |
|
613 |
|
|
Lines 625-631
glob1(Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp)
Link Here
|
| 625 |
*/ |
626 |
*/ |
| 626 |
static int |
627 |
static int |
| 627 |
glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last, |
628 |
glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last, |
| 628 |
Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp) |
629 |
Char *pattern, Char *pattern_last, compat_glob_t *pglob, struct glob_lim *limitp) |
| 629 |
{ |
630 |
{ |
| 630 |
struct stat sb; |
631 |
struct stat sb; |
| 631 |
Char *p, *q; |
632 |
Char *p, *q; |
|
Lines 693-699
glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
Link Here
|
| 693 |
|
694 |
|
| 694 |
static int |
695 |
static int |
| 695 |
glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last, |
696 |
glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last, |
| 696 |
Char *pattern, Char *restpattern, Char *restpattern_last, glob_t *pglob, |
697 |
Char *pattern, Char *restpattern, Char *restpattern_last, compat_glob_t *pglob, |
| 697 |
struct glob_lim *limitp) |
698 |
struct glob_lim *limitp) |
| 698 |
{ |
699 |
{ |
| 699 |
struct dirent *dp; |
700 |
struct dirent *dp; |
|
Lines 792-798
glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
Link Here
|
| 792 |
* gl_pathv points to (gl_offs + gl_pathc + 1) items. |
793 |
* gl_pathv points to (gl_offs + gl_pathc + 1) items. |
| 793 |
*/ |
794 |
*/ |
| 794 |
static int |
795 |
static int |
| 795 |
globextend(const Char *path, glob_t *pglob, struct glob_lim *limitp, |
796 |
globextend(const Char *path, compat_glob_t *pglob, struct glob_lim *limitp, |
| 796 |
struct stat *sb) |
797 |
struct stat *sb) |
| 797 |
{ |
798 |
{ |
| 798 |
char **pathv; |
799 |
char **pathv; |
|
Lines 956-962
match(Char *name, Char *pat, Char *patend, int recur)
Link Here
|
| 956 |
|
957 |
|
| 957 |
/* Free allocated data belonging to a glob_t structure. */ |
958 |
/* Free allocated data belonging to a glob_t structure. */ |
| 958 |
void |
959 |
void |
| 959 |
globfree(glob_t *pglob) |
960 |
__compat_globfree(compat_glob_t *pglob) |
| 960 |
{ |
961 |
{ |
| 961 |
int i; |
962 |
int i; |
| 962 |
char **pp; |
963 |
char **pp; |
|
Lines 980-986
globfree(glob_t *pglob)
Link Here
|
| 980 |
} |
981 |
} |
| 981 |
|
982 |
|
| 982 |
static DIR * |
983 |
static DIR * |
| 983 |
g_opendir(Char *str, glob_t *pglob) |
984 |
g_opendir(Char *str, compat_glob_t *pglob) |
| 984 |
{ |
985 |
{ |
| 985 |
char buf[MAXPATHLEN]; |
986 |
char buf[MAXPATHLEN]; |
| 986 |
|
987 |
|
|
Lines 998-1004
g_opendir(Char *str, glob_t *pglob)
Link Here
|
| 998 |
} |
999 |
} |
| 999 |
|
1000 |
|
| 1000 |
static int |
1001 |
static int |
| 1001 |
g_lstat(Char *fn, struct stat *sb, glob_t *pglob) |
1002 |
g_lstat(Char *fn, struct stat *sb, compat_glob_t *pglob) |
| 1002 |
{ |
1003 |
{ |
| 1003 |
char buf[MAXPATHLEN]; |
1004 |
char buf[MAXPATHLEN]; |
| 1004 |
|
1005 |
|
|
Lines 1010-1016
g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
Link Here
|
| 1010 |
} |
1011 |
} |
| 1011 |
|
1012 |
|
| 1012 |
static int |
1013 |
static int |
| 1013 |
g_stat(Char *fn, struct stat *sb, glob_t *pglob) |
1014 |
g_stat(Char *fn, struct stat *sb, compat_glob_t *pglob) |
| 1014 |
{ |
1015 |
{ |
| 1015 |
char buf[MAXPATHLEN]; |
1016 |
char buf[MAXPATHLEN]; |
| 1016 |
|
1017 |
|