]> git.pld-linux.org Git - packages/proftpd.git/blame - proftpd-glob.patch
- LSB conformance
[packages/proftpd.git] / proftpd-glob.patch
CommitLineData
153bd57c
AM
1diff -urN proftpd-1.2.1/Make.rules.in proftpd-1.2/Make.rules.in
2--- proftpd-1.2.1/Make.rules.in Thu Feb 22 05:51:10 2001
3+++ proftpd-1.2/Make.rules.in Mon Mar 19 23:11:35 2001
4@@ -63,7 +63,7 @@
5 src/support.o src/inet.o src/log.o src/io.o src/ident.o \
6 src/data.o src/modules.o src/auth.o src/fs.o
7
8-LIB_OBJS=getopt.o getopt1.o pr_fnmatch.o strsep.o vsnprintf.o glob.o pwgrent.o
9+LIB_OBJS=getopt.o getopt1.o pr_fnmatch.o strsep.o vsnprintf.o glibc-glob.o pwgrent.o
10
11 FTPCOUNT_OBJS=ftpcount.o pool.o log.o utils.o
12 BUILD_FTPCOUNT_OBJS=src/ftpcount.o src/pool.o src/log.o src/utils.o
13diff -urN proftpd-1.2.1/acconfig.h proftpd-1.2/acconfig.h
14--- proftpd-1.2.1/acconfig.h Wed Feb 14 05:12:48 2001
15+++ proftpd-1.2/acconfig.h Mon Mar 19 23:11:35 2001
16@@ -18,12 +18,6 @@
17 /* Define if you have BSD sendfile() semantics */
18 #undef HAVE_BSD_SENDFILE
19
20-/* Define if you have the <glob.h> header file. */
21-#undef HAVE_GLOB_H
22-
23-/* Define if your <glob.h> defines GLOB_PERIOD macro. */
24-#undef HAVE_GLOB_PERIOD
25-
26 /* Define if you have Linux sendfile() semantics */
27 #undef HAVE_LINUX_SENDFILE
28
29diff -urN proftpd-1.2.1/config.h.in proftpd-1.2/config.h.in
30--- proftpd-1.2.1/config.h.in Fri Feb 23 03:47:26 2001
31+++ proftpd-1.2/config.h.in Mon Mar 19 23:11:35 2001
32@@ -19,12 +19,6 @@
33 /* Define if you have BSD sendfile() semantics */
34 #undef HAVE_BSD_SENDFILE
35
36-/* Define if you have the <glob.h> header file. */
37-#undef HAVE_GLOB_H
38-
39-/* Define if your <glob.h> defines GLOB_PERIOD macro. */
40-#undef HAVE_GLOB_PERIOD
41-
42 /* Define if you have Linux sendfile() semantics */
43 #undef HAVE_LINUX_SENDFILE
44
45@@ -210,9 +204,6 @@
46 /* Define if you have the gettimeofday function. */
47 #undef HAVE_GETTIMEOFDAY
48
49-/* Define if you have the glob function. */
50-#undef HAVE_GLOB
51-
52 /* Define if you have the inet_aton function. */
53 #undef HAVE_INET_ATON
54
55@@ -320,6 +311,9 @@
56
57 /* Define if you have the <libutil.h> header file. */
58 #undef HAVE_LIBUTIL_H
59+
60+/* Define if you have the <limits.h> header file. */
61+#undef HAVE_LIMITS_H
62
63 /* Define if you have the <memory.h> header file. */
64 #undef HAVE_MEMORY_H
65diff -urN proftpd-1.2.1/configure.in proftpd-1.2/configure.in
66--- proftpd-1.2.1/configure.in Thu Mar 1 04:18:43 2001
67+++ proftpd-1.2/configure.in Mon Mar 19 23:11:35 2001
68@@ -300,14 +300,13 @@
69
70 fi
71
72-AC_CHECK_HEADERS(ctype.h getopt.h crypt.h bstring.h strings.h)
73+AC_CHECK_HEADERS(ctype.h getopt.h crypt.h bstring.h strings.h limits.h)
74 AC_CHECK_HEADERS(sys/types.h sys/param.h sys/file.h sys/uio.h)
75 AC_CHECK_HEADERS(netdb.h netinet/in.h netinet/tcp.h arpa/inet.h sys/stat.h)
76 AC_CHECK_HEADERS(errno.h sys/socket.h sys/termios.h sys/termio.h)
77 AC_CHECK_HEADERS(sys/statvfs.h sys/vfs.h sys/select.h)
78 AC_CHECK_HEADERS(utmpx.h)
79 AC_CHECK_HEADERS(regex.h)
80-AC_CHECK_HEADER(glob.h,have_glob_h="yes",)
81 AC_CHECK_HEADER(syslog.h,have_syslog_h="yes",)
82
83 dnl Checks for typedefs, structures, and compiler characteristics.
84@@ -362,35 +361,6 @@
85 fi
86 fi
87
88-if test "$have_glob_h" = "yes"; then
89- dnl See if we have GLOB_PERIOD
90- AC_CACHE_CHECK(whether your glob.h defines GLOB_PERIOD,
91- pr_cv_header_glob_period,
92- AC_EGREP_CPP(yes,[
93-#include <glob.h>
94-#ifdef GLOB_PERIOD
95- yes
96-#endif
97- ],pr_cv_header_glob_period="yes",pr_cv_header_glob_period="no"))
98-
99- dnl See if we have GLOB_ALTDIRFUNC
100- if test "$pr_cv_header_glob_period" = "yes"; then
101- AC_CACHE_CHECK(whether your glob.h defines GLOB_ALTDIRFUNC,
102- pr_cv_header_glob_altdirfunc,
103- AC_EGREP_CPP(yes,[
104-#include <glob.h>
105-#ifdef GLOB_ALTDIRFUNC
106- yes
107-#endif
108- ],pr_cv_header_glob_altdirfunc="yes",pr_cv_header_glob_altdirfunc="no"))
109-
110- if test "$pr_cv_header_glob_altdirfunc" = "yes"; then
111- AC_DEFINE(HAVE_GLOB_H)
112- AC_DEFINE(HAVE_GLOB_PERIOD)
113- fi
114- fi
115-fi
116-
117 dnl See if various LOG_ macros are defined
118 if test "$have_syslog_h" = "yes"; then
119 AC_DEFINE(HAVE_SYSLOG_H)
120@@ -538,13 +508,6 @@
121 AC_DEFINE(HAVE_BSD_SENDFILE)
122 ;;
123 esac
124-fi
125-
126-dnl Only check for glob if we have glob.h, GLOB_PERIOD, and GLOB_ALTDIRFUNC
127-if test "$have_glob_h" = "yes" && \
128- test "$pr_cv_header_glob_period" = "yes" && \
129- test "$pr_cv_header_glob_altdirfunc" = "yes"; then
130- AC_CHECK_FUNCS(glob)
131 fi
132
133 dnl Check for various argv[] replacing functions on various OSs
134diff -urN proftpd-1.2.1/include/conf.h proftpd-1.2/include/conf.h
135--- proftpd-1.2.1/include/conf.h Sun Aug 13 17:19:39 2000
136+++ proftpd-1.2/include/conf.h Mon Mar 19 23:11:35 2001
137@@ -38,7 +38,7 @@
138 */
139
140 /* Generic configuration and standard header file includes.
141- * $Id$
142+ * $Id$
143 */
144
145 #ifndef __CONF_H
146@@ -156,10 +156,6 @@
147
148 #ifdef HAVE_SYSLOG_H
149 # include <syslog.h>
150-#endif
151-
152-#ifdef HAVE_GLOB
153-# include <glob.h>
154 #endif
155
156 #ifdef HAVE_DIRENT_H
157diff -urN proftpd-1.2.1/include/glibc-glob.h proftpd-1.2/include/glibc-glob.h
158--- proftpd-1.2.1/include/glibc-glob.h Thu Jan 1 01:00:00 1970
159+++ proftpd-1.2/include/glibc-glob.h Thu Mar 22 14:43:36 2001
160@@ -0,0 +1,221 @@
161+/* Copyright (C) 1991,92,95,96,97,98,2000,2001 Free Software Foundation, Inc.
162+
163+ The GNU C Library is free software; you can redistribute it and/or
164+ modify it under the terms of the GNU Library General Public License as
165+ published by the Free Software Foundation; either version 2 of the
166+ License, or (at your option) any later version.
167+
168+ The GNU C Library is distributed in the hope that it will be useful,
169+ but WITHOUT ANY WARRANTY; without even the implied warranty of
170+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
171+ Library General Public License for more details.
172+
173+ You should have received a copy of the GNU Library General Public
174+ License along with the GNU C Library; see the file COPYING.LIB. If not,
175+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
176+ Boston, MA 02111-1307, USA. */
177+
178+#ifndef _GLOB_H
179+#define _GLOB_H 1
180+
181+#ifdef __cplusplus
182+extern "C" {
183+#endif
184+
185+#undef __ptr_t
186+#if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32
187+# if !defined __GLIBC__ || !defined __P
188+# undef __P
189+# undef __PMT
190+# define __P(protos) protos
191+# define __PMT(protos) protos
192+# if !defined __GNUC__ || __GNUC__ < 2
193+# undef __const
194+# define __const const
195+# endif
196+# endif
197+# define __ptr_t void *
198+#else /* Not C++ or ANSI C. */
199+# undef __P
200+# undef __PMT
201+# define __P(protos) ()
202+# define __PMT(protos) ()
203+# undef __const
204+# define __const
205+# define __ptr_t char *
206+#endif /* C++ or ANSI C. */
207+
208+/* We need `size_t' for the following definitions. */
209+#ifndef __size_t
210+# if defined __GNUC__ && __GNUC__ >= 2
211+typedef __SIZE_TYPE__ __size_t;
212+# ifdef _XOPEN_SOURCE
213+typedef __SIZE_TYPE__ size_t;
214+# endif
215+# else
216+/* This is a guess. */
217+typedef unsigned long int __size_t;
218+# endif
219+#else
220+/* The GNU CC stddef.h version defines __size_t as empty. We need a real
221+ definition. */
222+# undef __size_t
223+# define __size_t size_t
224+#endif
225+
226+/* Bits set in the FLAGS argument to `glob'. */
227+#define GLOB_ERR (1 << 0)/* Return on read errors. */
228+#define GLOB_MARK (1 << 1)/* Append a slash to each name. */
229+#define GLOB_NOSORT (1 << 2)/* Don't sort the names. */
230+#define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */
231+#define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */
232+#define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */
233+#define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */
234+#define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */
235+
236+#if (!defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _BSD_SOURCE \
237+ || defined _GNU_SOURCE)
238+# define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */
239+# define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */
240+# define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */
241+# define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */
242+# define GLOB_TILDE (1 << 12)/* Expand ~user and ~ to home directories. */
243+# define GLOB_ONLYDIR (1 << 13)/* Match only directories. */
244+# define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error
245+ if the user name is not available. */
246+# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
247+ GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
248+ GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \
249+ GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
250+#else
251+# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
252+ GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
253+ GLOB_PERIOD)
254+#endif
255+
256+/* Error returns from `glob'. */
257+#define GLOB_NOSPACE 1 /* Ran out of memory. */
258+#define GLOB_ABORTED 2 /* Read error. */
259+#define GLOB_NOMATCH 3 /* No matches found. */
260+#define GLOB_NOSYS 4 /* Not implemented. */
261+#ifdef _GNU_SOURCE
262+/* Previous versions of this file defined GLOB_ABEND instead of
263+ GLOB_ABORTED. Provide a compatibility definition here. */
264+# define GLOB_ABEND GLOB_ABORTED
265+#endif
266+
267+/* Structure describing a globbing run. */
268+#if !defined _AMIGA && !defined VMS /* Buggy compiler. */
269+# ifdef _GNU_SOURCE
270+struct stat;
271+# endif
272+#endif
273+typedef struct
274+ {
275+ __size_t gl_pathc; /* Count of paths matched by the pattern. */
276+ char **gl_pathv; /* List of matched pathnames. */
277+ __size_t gl_offs; /* Slots to reserve in `gl_pathv'. */
278+ int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
279+
280+ /* If the GLOB_ALTDIRFUNC flag is set, the following functions
281+ are used instead of the normal file access functions. */
282+ void (*gl_closedir) __PMT ((void *));
283+#ifdef _GNU_SOURCE
284+ struct dirent *(*gl_readdir) __PMT ((void *));
285+#else
286+ void *(*gl_readdir) __PMT ((void *));
287+#endif
288+ __ptr_t (*gl_opendir) __PMT ((__const char *));
289+#ifdef _GNU_SOURCE
290+ int (*gl_lstat) __PMT ((__const char *,
291+ struct stat *));
292+ int (*gl_stat) __PMT ((__const char *, struct stat *));
293+#else
294+ int (*gl_lstat) __PMT ((__const char *, void *));
295+ int (*gl_stat) __PMT ((__const char *, void *));
296+#endif
297+ } glob_t;
298+
299+#ifdef _LARGEFILE64_SOURCE
300+# ifdef _GNU_SOURCE
301+struct stat64;
302+# endif
303+typedef struct
304+ {
305+ __size_t gl_pathc;
306+ char **gl_pathv;
307+ __size_t gl_offs;
308+ int gl_flags;
309+
310+ /* If the GLOB_ALTDIRFUNC flag is set, the following functions
311+ are used instead of the normal file access functions. */
312+ void (*gl_closedir) __PMT ((void *));
313+# ifdef _GNU_SOURCE
314+ struct dirent64 *(*gl_readdir) __PMT ((void *));
315+# else
316+ void *(*gl_readdir) __PMT ((void *));
317+# endif
318+ __ptr_t (*gl_opendir) __PMT ((__const char *));
319+# ifdef _GNU_SOURCE
320+ int (*gl_lstat) __PMT ((__const char *,
321+ struct stat64 *));
322+ int (*gl_stat) __PMT ((__const char *,
323+ struct stat64 *));
324+# else
325+ int (*gl_lstat) __PMT ((__const char *, void *));
326+ int (*gl_stat) __PMT ((__const char *, void *));
327+# endif
328+ } glob64_t;
329+#endif
330+
331+#if _FILE_OFFSET_BITS == 64 && __GNUC__ < 2
332+# define glob glob64
333+# define globfree globfree64
334+#endif
335+
336+/* Do glob searching for PATTERN, placing results in PGLOB.
337+ The bits defined above may be set in FLAGS.
338+ If a directory cannot be opened or read and ERRFUNC is not nil,
339+ it is called with the pathname that caused the error, and the
340+ `errno' value from the failing call; if it returns non-zero
341+ `glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
342+ If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
343+ Otherwise, `glob' returns zero. */
344+#if _FILE_OFFSET_BITS != 64 || __GNUC__ < 2
345+extern int glob __P ((__const char *__pattern, int __flags,
346+ int (*__errfunc) (__const char *, int),
347+ glob_t *__pglob));
348+
349+/* Free storage allocated in PGLOB by a previous `glob' call. */
350+extern void globfree __P ((glob_t *__pglob));
351+#else
352+extern int glob __P ((__const char *__pattern, int __flags,
353+ int (*__errfunc) (__const char *, int),
354+ glob_t *__pglob));
355+
356+extern void globfree __P ((glob_t *__pglob));
357+#endif
358+
359+#ifdef _LARGEFILE64_SOURCE
360+extern int glob64 __P ((__const char *__pattern, int __flags,
361+ int (*__errfunc) (__const char *, int),
362+ glob64_t *__pglob));
363+
364+extern void globfree64 __P ((glob64_t *__pglob));
365+#endif
366+
367+
368+#ifdef _GNU_SOURCE
369+/* Return nonzero if PATTERN contains any metacharacters.
370+ Metacharacters can be quoted with backslashes if QUOTE is nonzero.
371+
372+ This function is not part of the interface specified by POSIX.2
373+ but several programs want to use it. */
374+extern int glob_pattern_p __P ((__const char *__pattern, int __quote));
375+#endif
376+
377+#ifdef __cplusplus
378+}
379+#endif
380+
381+#endif /* glob.h */
382diff -urN proftpd-1.2.1/include/libsupp.h proftpd-1.2/include/libsupp.h
383--- proftpd-1.2.1/include/libsupp.h Wed Aug 2 07:25:24 2000
384+++ proftpd-1.2/include/libsupp.h Mon Mar 19 23:11:35 2001
385@@ -23,66 +23,10 @@
386
387 /* ProFTPD support library definitions.
388 *
389- * $Id$
390+ * $Id$
391 */
392
393-#if !defined HAVE_GLOB && !defined __PROFTPD_SUPPORT_LIBRARY
394-
395-#ifndef __P
396-#define __P(x) x
397-#endif
398-
399-/* Bits set in the FLAGS argument to `glob'. */
400-#define GLOB_ERR (1 << 0)/* Return on read errors. */
401-#define GLOB_MARK (1 << 1)/* Append a slash to each name. */
402-#define GLOB_NOSORT (1 << 2)/* Don't sort the names. */
403-#define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */
404-#define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */
405-#define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */
406-#define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */
407-#define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */
408-# define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */
409-# define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */
410-# define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */
411-# define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */
412-# define GLOB_TILDE (1 << 12)/* Expand ~user and ~ to home directories. */
413-# define GLOB_ONLYDIR (1 << 13)/* Match only directories. */
414-# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
415- GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
416- GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \
417- GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR)
418-#define GLOB_NOSPACE 1 /* Ran out of memory. */
419-#define GLOB_ABORTED 2 /* Read error. */
420-#define GLOB_NOMATCH 3 /* No matches found. */
421-
422-/* Structure describing a globbing run. */
423-#if !defined _AMIGA && !defined VMS /* Buggy compiler. */
424-struct stat;
425-#endif
426-typedef struct
427- {
428- int gl_pathc; /* Count of paths matched by the pattern. */
429- char **gl_pathv; /* List of matched pathnames. */
430- int gl_offs; /* Slots to reserve in `gl_pathv'. */
431- int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
432-
433- /* If the GLOB_ALTDIRFUNC flag is set, the following functions
434- are used instead of the normal file access functions. */
435- void (*gl_closedir) __P ((void *));
436- struct dirent *(*gl_readdir) __P ((void *));
437- void *(*gl_opendir) __P ((const char *));
438- int (*gl_lstat) __P ((const char *, struct stat *));
439- int (*gl_stat) __P ((const char *, struct stat *));
440- } glob_t;
441-
442-extern int glob (const char *__pattern, int __flags,
443- int (*__errfunc)(const char *, int),
444- glob_t *__pglob);
445-extern void globfree (glob_t *__pglob);
446-extern int __glob_pattern_p (const char *__pattern, int __quote);
447-extern int glob_pattern_p (const char *__pattern, int __quote);
448-
449-#endif /* HAVE_GLOB */
450+#include <glibc-glob.h>
451
452 /* Bits set in the FLAGS argument to `pr_fnmatch'. */
453 #define PR_FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
454diff -urN proftpd-1.2.1/lib/Makefile.in proftpd-1.2/lib/Makefile.in
455--- proftpd-1.2.1/lib/Makefile.in Thu Mar 1 17:02:10 2001
456+++ proftpd-1.2/lib/Makefile.in Sun Feb 25 00:09:19 2001
457@@ -32,15 +32,15 @@
458 # Dependancies written below
459 # DO NOT DELETE
460
461+pr_fnmatch.o: ../include/conf.h ../include/version.h ../config.h
462+pr_fnmatch.o: ../include/default_paths.h ../include/options.h
463+pr_fnmatch.o: ../include/libsupp.h pr_fnmatch_loop.c
464 getopt.o: ../include/conf.h ../include/version.h ../config.h
465 getopt.o: ../include/default_paths.h ../include/options.h getopt.h
466 getopt1.o: ../include/conf.h ../include/version.h ../config.h
467 getopt1.o: ../include/default_paths.h ../include/options.h getopt.h
468 glob.o: ../include/conf.h ../include/version.h ../config.h
469 glob.o: ../include/default_paths.h ../include/options.h ../include/libsupp.h
470-pr_fnmatch.o: ../include/conf.h ../include/version.h ../config.h
471-pr_fnmatch.o: ../include/default_paths.h ../include/options.h
472-pr_fnmatch.o: ../include/libsupp.h pr_fnmatch_loop.c
473 pwgrent.o: ../include/conf.h ../include/version.h ../config.h
474 pwgrent.o: ../include/default_paths.h ../include/options.h
475 strsep.o: ../include/conf.h ../include/version.h ../config.h
476diff -urN proftpd-1.2.1/lib/glibc-glob.c proftpd-1.2/lib/glibc-glob.c
477--- proftpd-1.2.1/lib/glibc-glob.c Thu Jan 1 01:00:00 1970
478+++ proftpd-1.2/lib/glibc-glob.c Sat Mar 17 21:34:31 2001
479@@ -0,0 +1,1544 @@
480+/* Copyright (C) 1991-1999, 2000, 2001 Free Software Foundation, Inc.
481+
482+ This library is free software; you can redistribute it and/or
483+ modify it under the terms of the GNU Library General Public License as
484+ published by the Free Software Foundation; either version 2 of the
485+ License, or (at your option) any later version.
486+
487+ This library is distributed in the hope that it will be useful,
488+ but WITHOUT ANY WARRANTY; without even the implied warranty of
489+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
490+ Library General Public License for more details.
491+
492+ You should have received a copy of the GNU Library General Public
493+ License along with this library; see the file COPYING.LIB. If not,
494+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
495+ Boston, MA 02111-1307, USA. */
496+
497+/* AIX requires this to be the first thing in the file. */
498+
499+#if defined _AIX && !defined __GNUC__
500+ #pragma alloca
501+#endif
502+
503+#include <config.h>
504+
505+#define MAX_RECURSION 8
506+#define MAX_RESULTS 100000UL
507+
508+/* Enable GNU extensions in glob.h. */
509+#ifndef _GNU_SOURCE
510+# define _GNU_SOURCE 1
511+#endif
512+
513+#include <errno.h>
514+#include <sys/types.h>
515+#include <sys/stat.h>
516+
517+/* Outcomment the following line for production quality code. */
518+/* #define NDEBUG 1 */
519+#include <assert.h>
520+
521+#include <stdio.h> /* Needed on stupid SunOS for assert. */
522+
523+
524+/* Comment out all this code if we are using the GNU C Library, and are not
525+ actually compiling the library itself. This code is part of the GNU C
526+ Library, but also included in many other GNU distributions. Compiling
527+ and linking in this code is a waste when using the GNU C library
528+ (especially if it is a shared library). Rather than having every GNU
529+ program understand `configure --with-gnu-libc' and omit the object files,
530+ it is simpler to just do this in the source for each such file. */
531+
532+/* Proftpd modification: always undefine __GNU_LIBRARY__ because we are not
533+ * compiling as part of glibc.
534+ * jss - 3/17/2001
535+ */
536+
537+#undef __GNU_LIBRARY__
538+
539+#define GLOB_INTERFACE_VERSION 1
540+#if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
541+# include <gnu-versions.h>
542+# if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION
543+# define ELIDE_CODE
544+# endif
545+#endif
546+
547+#undef ELIDE_CODE
548+#define __alloca alloca
549+#define __readdir readdir
550+
551+#ifndef ELIDE_CODE
552+#if !defined _LIBC || !defined GLOB_ONLY_P
553+
554+#if defined STDC_HEADERS || defined __GNU_LIBRARY__
555+# include <stddef.h>
556+#endif
557+
558+#if defined HAVE_UNISTD_H || defined _LIBC
559+# include <unistd.h>
560+# ifndef POSIX
561+# ifdef _POSIX_VERSION
562+# define POSIX
563+# endif
564+# endif
565+#endif
566+
567+#if !defined _AMIGA && !defined VMS && !defined WINDOWS32
568+# include <pwd.h>
569+#endif
570+
571+#if !defined __GNU_LIBRARY__ && !defined STDC_HEADERS
572+extern int errno;
573+#endif
574+#ifndef __set_errno
575+# define __set_errno(val) errno = (val)
576+#endif
577+
578+#ifndef NULL
579+# define NULL 0
580+#endif
581+
582+#if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__
583+# include <dirent.h>
584+# define NAMLEN(dirent) strlen((dirent)->d_name)
585+#else
586+# define dirent direct
587+# define NAMLEN(dirent) (dirent)->d_namlen
588+# ifdef HAVE_SYS_NDIR_H
589+# include <sys/ndir.h>
590+# endif
591+# ifdef HAVE_SYS_DIR_H
592+# include <sys/dir.h>
593+# endif
594+# ifdef HAVE_NDIR_H
595+# include <ndir.h>
596+# endif
597+# ifdef HAVE_VMSDIR_H
598+# include "vmsdir.h"
599+# endif /* HAVE_VMSDIR_H */
600+#endif
601+
602+
603+/* In GNU systems, <dirent.h> defines this macro for us. */
604+#ifdef _D_NAMLEN
605+# undef NAMLEN
606+# define NAMLEN(d) _D_NAMLEN(d)
607+#endif
608+
609+/* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available
610+ if the `d_type' member for `struct dirent' is available. */
611+#ifdef _DIRENT_HAVE_D_TYPE
612+# define HAVE_D_TYPE 1
613+#endif
614+
615+#if _LIBC
616+# define HAVE_DIRENT64 1
617+#endif
618+
619+/* If the system has the `struct dirent64' type we use it internally. */
620+#if defined HAVE_DIRENT64 && !defined COMPILE_GLOB64
621+# if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__
622+# define CONVERT_D_NAMLEN(d64, d32)
623+# else
624+# define CONVERT_D_NAMLEN(d64, d32) \
625+ (d64)->d_namlen = (d32)->d_namlen;
626+# endif
627+
628+# if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__
629+# define CONVERT_D_INO(d64, d32)
630+# else
631+# define CONVERT_D_INO(d64, d32) \
632+ (d64)->d_ino = (d32)->d_ino;
633+# endif
634+
635+# ifdef HAVE_D_TYPE
636+# define CONVERT_D_TYPE(d64, d32) \
637+ (d64)->d_type = (d32)->d_type;
638+# else
639+# define CONVERT_D_TYPE(d64, d32)
640+# endif
641+
642+# define CONVERT_DIRENT_DIRENT64(d64, d32) \
643+ memcpy ((d64)->d_name, (d32)->d_name, NAMLEN (d32) + 1); \
644+ CONVERT_D_NAMLEN (d64, d32) \
645+ CONVERT_D_INO (d64, d32) \
646+ CONVERT_D_TYPE (d64, d32)
647+#endif
648+
649+
650+#if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__
651+/* Posix does not require that the d_ino field be present, and some
652+ systems do not provide it. */
653+# define REAL_DIR_ENTRY(dp) 1
654+#else
655+# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
656+#endif /* POSIX */
657+
658+#if defined STDC_HEADERS || defined __GNU_LIBRARY__
659+# include <stdlib.h>
660+# include <string.h>
661+# define ANSI_STRING
662+#else /* No standard headers. */
663+
664+extern char *getenv ();
665+
666+# ifdef HAVE_STRING_H
667+# include <string.h>
668+# define ANSI_STRING
669+# else
670+# include <strings.h>
671+# endif
672+# ifdef HAVE_MEMORY_H
673+# include <memory.h>
674+# endif
675+
676+extern char *malloc (), *realloc ();
677+extern void free ();
678+
679+extern void qsort ();
680+extern void abort (), exit ();
681+
682+#endif /* Standard headers. */
683+
684+#ifndef ANSI_STRING
685+
686+# ifndef bzero
687+extern void bzero ();
688+# endif
689+# ifndef bcopy
690+extern void bcopy ();
691+# endif
692+
693+# define memcpy(d, s, n) bcopy ((s), (d), (n))
694+# define strrchr rindex
695+/* memset is only used for zero here, but let's be paranoid. */
696+# define memset(s, better_be_zero, n) \
697+ ((void) ((better_be_zero) == 0 ? (bzero((s), (n)), 0) : (abort(), 0)))
698+#endif /* Not ANSI_STRING. */
699+
700+#if !defined HAVE_STRCOLL && !defined _LIBC
701+# define strcoll strcmp
702+#endif
703+
704+#if !defined HAVE_MEMPCPY && __GLIBC__ - 0 == 2 && __GLIBC_MINOR__ >= 1
705+# define HAVE_MEMPCPY 1
706+# undef mempcpy
707+# define mempcpy(Dest, Src, Len) __mempcpy (Dest, Src, Len)
708+#endif
709+
710+static unsigned long nbresults;
711+
712+#ifndef __GNU_LIBRARY__
713+# ifdef __GNUC__
714+__inline
715+# endif
716+# ifndef __SASC
717+# ifdef WINDOWS32
718+static void *
719+# else
720+static char *
721+# endif
722+my_realloc (p, n)
723+ char *p;
724+ unsigned int n;
725+{
726+ /* These casts are the for sake of the broken Ultrix compiler,
727+ which warns of illegal pointer combinations otherwise. */
728+ if (p == NULL)
729+ return (char *) malloc (n);
730+ return (char *) realloc (p, n);
731+}
732+# define realloc my_realloc
733+# endif /* __SASC */
734+#endif /* __GNU_LIBRARY__ */
735+
736+
737+#if !defined __alloca && !defined __GNU_LIBRARY__
738+
739+# ifdef __GNUC__
740+# undef alloca
741+# define alloca(n) __builtin_alloca (n)
742+# else /* Not GCC. */
743+# ifdef HAVE_ALLOCA_H
744+# include <alloca.h>
745+# else /* Not HAVE_ALLOCA_H. */
746+# ifndef _AIX
747+# ifdef WINDOWS32
748+# include <malloc.h>
749+# else
750+extern char *alloca ();
751+# endif /* WINDOWS32 */
752+# endif /* Not _AIX. */
753+# endif /* sparc or HAVE_ALLOCA_H. */
754+# endif /* GCC. */
755+
756+# define __alloca alloca
757+
758+#endif
759+
760+#ifndef __GNU_LIBRARY__
761+# define __stat stat
762+# ifdef STAT_MACROS_BROKEN
763+# undef S_ISDIR
764+# endif
765+# ifndef S_ISDIR
766+# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
767+# endif
768+#endif
769+
770+#ifdef _LIBC
771+# undef strdup
772+# define strdup(str) __strdup (str)
773+# define sysconf(id) __sysconf (id)
774+# define closedir(dir) __closedir (dir)
775+# define opendir(name) __opendir (name)
776+# define readdir(str) __readdir64 (str)
777+# define getpwnam_r(name, bufp, buf, len, res) \
778+ __getpwnam_r (name, bufp, buf, len, res)
779+# ifndef __stat64
780+# define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
781+# endif
782+# define HAVE_STAT64 1
783+#endif
784+
785+#ifndef HAVE_STAT64
786+# define __stat64(fname, buf) __stat (fname, buf)
787+/* This is the variable name we are using. */
788+# define st64 st
789+#endif
790+
791+#if !(defined STDC_HEADERS || defined __GNU_LIBRARY__)
792+# undef size_t
793+# define size_t unsigned int
794+#endif
795+
796+/* Some system header files erroneously define these.
797+ We want our own definitions from <fnmatch.h> to take precedence. */
798+#ifndef __GNU_LIBRARY__
799+# undef FNM_PATHNAME
800+# undef FNM_NOESCAPE
801+# undef FNM_PERIOD
802+#endif
803+#include <fnmatch.h>
804+
805+/* Some system header files erroneously define these.
806+ We want our own definitions from <glob.h> to take precedence. */
807+#ifndef __GNU_LIBRARY__
808+# undef GLOB_ERR
809+# undef GLOB_MARK
810+# undef GLOB_NOSORT
811+# undef GLOB_DOOFFS
812+# undef GLOB_NOCHECK
813+# undef GLOB_APPEND
814+# undef GLOB_NOESCAPE
815+# undef GLOB_PERIOD
816+#endif
817+#include <glibc-glob.h>
818+
819+#ifdef HAVE_GETLOGIN_R
820+extern int getlogin_r __P ((char *, size_t));
821+#else
822+extern char *getlogin __P ((void));
823+#endif
824+\f
825+static
826+#if __GNUC__ - 0 >= 2
827+inline
828+#endif
829+const char *next_brace_sub __P ((const char *begin));
830+
831+#endif /* GLOB_ONLY_P */
832+
833+static int glob_in_dir __P ((const char *pattern, const char *directory,
834+ int flags,
835+ int (*errfunc) (const char *, int),
836+ glob_t *pglob));
837+
838+/* Prototype __glob_pattern_p to avoid compiler warning.
839+ * jss - 3/17/2001
840+ */
841+#if !defined _LIBC || !defined NO_GLOB_PATTERN_P
842+/* Return nonzero if PATTERN contains any metacharacters.
843+ Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
844+int __glob_pattern_p (const char *pattern, int quote);
845+#endif /* NO_GLOB_PATTERN_P */
846+
847+#if !defined _LIBC || !defined GLOB_ONLY_P
848+static int prefix_array __P ((const char *prefix, char **array, size_t n));
849+static int collated_compare __P ((const __ptr_t, const __ptr_t));
850+
851+
852+/* Find the end of the sub-pattern in a brace expression. We define
853+ this as an inline function if the compiler permits. */
854+static
855+#if __GNUC__ - 0 >= 2
856+inline
857+#endif
858+const char *
859+next_brace_sub (begin)
860+ const char *begin;
861+{
862+ unsigned int depth = 0;
863+ const char *cp = begin;
864+
865+ while (1)
866+ {
867+ if (depth == 0)
868+ {
869+ if (*cp != ',' && *cp != '}' && *cp != '\0')
870+ {
871+ if (*cp == '{')
872+ ++depth;
873+ ++cp;
874+ continue;
875+ }
876+ }
877+ else
878+ {
879+ while (*cp != '\0' && (*cp != '}' || depth > 0))
880+ {
881+ if (*cp == '}')
882+ --depth;
883+ ++cp;
884+ }
885+ if (*cp == '\0')
886+ /* An incorrectly terminated brace expression. */
887+ return NULL;
888+
889+ continue;
890+ }
891+ break;
892+ }
893+
894+ return cp;
895+}
896+
897+#endif /* !GLOB_ONLY_P */
898+
899+
900+/* Do glob searching for PATTERN, placing results in PGLOB.
901+ The bits defined above may be set in FLAGS.
902+ If a directory cannot be opened or read and ERRFUNC is not nil,
903+ it is called with the pathname that caused the error, and the
904+ `errno' value from the failing call; if it returns non-zero
905+ `glob' returns GLOB_ABORTED; if it returns zero, the error is ignored.
906+ If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
907+ Otherwise, `glob' returns zero. */
908+static int
909+glob_limited (depth, pattern, flags, errfunc, pglob)
910+ unsigned int depth;
911+ const char *pattern;
912+ int flags;
913+ int (*errfunc) __P ((const char *, int));
914+ glob_t *pglob;
915+{
916+ const char *filename;
917+ const char *dirname;
918+ size_t dirlen;
919+ int status;
920+ size_t oldcount;
921+
922+ if (depth > MAX_RECURSION) {
923+ return GLOB_NOSPACE;
924+ }
925+ if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0)
926+ {
927+ __set_errno (EINVAL);
928+ return -1;
929+ }
930+
931+ if (!(flags & GLOB_DOOFFS))
932+ /* Have to do this so `globfree' knows where to start freeing. It
933+ also makes all the code that uses gl_offs simpler. */
934+ pglob->gl_offs = 0;
935+
936+ if (flags & GLOB_BRACE)
937+ {
938+ const char *begin = strchr (pattern, '{');
939+ if (begin != NULL)
940+ {
941+ /* Allocate working buffer large enough for our work. Note that
942+ we have at least an opening and closing brace. */
943+ size_t firstc;
944+ char *alt_start;
945+ const char *p;
946+ const char *next;
947+ const char *rest;
948+ size_t rest_len;
949+#ifdef __GNUC__
950+ char onealt[strlen (pattern) - 1];
951+#else
952+ char *onealt = (char *) malloc (strlen (pattern) - 1);
953+ if (onealt == NULL)
954+ {
955+ if (!(flags & GLOB_APPEND))
956+ globfree (pglob);
957+ return GLOB_NOSPACE;
958+ }
959+#endif
960+
961+ /* We know the prefix for all sub-patterns. */
962+#ifdef HAVE_MEMPCPY
963+ alt_start = mempcpy (onealt, pattern, begin - pattern);
964+#else
965+ memcpy (onealt, pattern, begin - pattern);
966+ alt_start = &onealt[begin - pattern];
967+#endif
968+
969+ /* Find the first sub-pattern and at the same time find the
970+ rest after the closing brace. */
971+ next = next_brace_sub (begin + 1);
972+ if (next == NULL)
973+ {
974+ /* It is an illegal expression. */
975+#ifndef __GNUC__
976+ free (onealt);
977+#endif
978+ return glob_limited (depth + 1U, pattern, flags & ~GLOB_BRACE, errfunc, pglob);
979+ }
980+
981+ /* Now find the end of the whole brace expression. */
982+ rest = next;
983+ while (*rest != '}')
984+ {
985+ rest = next_brace_sub (rest + 1);
986+ if (rest == NULL)
987+ {
988+ /* It is an illegal expression. */
989+#ifndef __GNUC__
990+ free (onealt);
991+#endif
992+ return glob_limited (depth + 1U, pattern, flags & ~GLOB_BRACE, errfunc, pglob);
993+ }
994+ }
995+ /* Please note that we now can be sure the brace expression
996+ is well-formed. */
997+ rest_len = strlen (++rest) + 1;
998+
999+ /* We have a brace expression. BEGIN points to the opening {,
1000+ NEXT points past the terminator of the first element, and END
1001+ points past the final }. We will accumulate result names from
1002+ recursive runs for each brace alternative in the buffer using
1003+ GLOB_APPEND. */
1004+
1005+ if (!(flags & GLOB_APPEND))
1006+ {
1007+ /* This call is to set a new vector, so clear out the
1008+ vector so we can append to it. */
1009+ pglob->gl_pathc = 0;
1010+ pglob->gl_pathv = NULL;
1011+ }
1012+ firstc = pglob->gl_pathc;
1013+
1014+ p = begin + 1;
1015+ while (1)
1016+ {
1017+ int result;
1018+
1019+ /* Construct the new glob expression. */
1020+#ifdef HAVE_MEMPCPY
1021+ mempcpy (mempcpy (alt_start, p, next - p), rest, rest_len);
1022+#else
1023+ memcpy (alt_start, p, next - p);
1024+ memcpy (&alt_start[next - p], rest, rest_len);
1025+#endif
1026+
1027+ result = glob_limited (depth + 1U, onealt,
1028+ ((flags & ~(GLOB_NOCHECK|GLOB_NOMAGIC))
1029+ | GLOB_APPEND), errfunc, pglob);
1030+
1031+ /* If we got an error, return it. */
1032+ if (result && result != GLOB_NOMATCH)
1033+ {
1034+#ifndef __GNUC__
1035+ free (onealt);
1036+#endif
1037+ if (!(flags & GLOB_APPEND))
1038+ globfree (pglob);
1039+ return result;
1040+ }
1041+
1042+ if (*next == '}')
1043+ /* We saw the last entry. */
1044+ break;
1045+
1046+ p = next + 1;
1047+ next = next_brace_sub (p);
1048+ assert (next != NULL);
1049+ }
1050+
1051+#ifndef __GNUC__
1052+ free (onealt);
1053+#endif
1054+
1055+ if (pglob->gl_pathc != firstc)
1056+ /* We found some entries. */
1057+ return 0;
1058+ else if (!(flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
1059+ return GLOB_NOMATCH;
1060+ }
1061+ }
1062+
1063+ /* Find the filename. */
1064+ filename = strrchr (pattern, '/');
1065+#if defined __MSDOS__ || defined WINDOWS32
1066+ /* The case of "d:pattern". Since `:' is not allowed in
1067+ file names, we can safely assume that wherever it
1068+ happens in pattern, it signals the filename part. This
1069+ is so we could some day support patterns like "[a-z]:foo". */
1070+ if (filename == NULL)
1071+ filename = strchr (pattern, ':');
1072+#endif /* __MSDOS__ || WINDOWS32 */
1073+ if (filename == NULL)
1074+ {
1075+ /* This can mean two things: a simple name or "~name". The latter
1076+ case is nothing but a notation for a directory. */
1077+ if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && pattern[0] == '~')
1078+ {
1079+ dirname = pattern;
1080+ dirlen = strlen (pattern);
1081+
1082+ /* Set FILENAME to NULL as a special flag. This is ugly but
1083+ other solutions would require much more code. We test for
1084+ this special case below. */
1085+ filename = NULL;
1086+ }
1087+ else
1088+ {
1089+ filename = pattern;
1090+#ifdef _AMIGA
1091+ dirname = "";
1092+#else
1093+ dirname = ".";
1094+#endif
1095+ dirlen = 0;
1096+ }
1097+ }
1098+ else if (filename == pattern)
1099+ {
1100+ /* "/pattern". */
1101+ dirname = "/";
1102+ dirlen = 1;
1103+ ++filename;
1104+ }
1105+ else
1106+ {
1107+ char *newp;
1108+ dirlen = filename - pattern;
1109+#if defined __MSDOS__ || defined WINDOWS32
1110+ if (*filename == ':'
1111+ || (filename > pattern + 1 && filename[-1] == ':'))
1112+ {
1113+ char *drive_spec;
1114+
1115+ ++dirlen;
1116+ drive_spec = (char *) __alloca (dirlen + 1);
1117+#ifdef HAVE_MEMPCPY
1118+ *((char *) mempcpy (drive_spec, pattern, dirlen)) = '\0';
1119+#else
1120+ memcpy (drive_spec, pattern, dirlen);
1121+ drive_spec[dirlen] = '\0';
1122+#endif
1123+ /* For now, disallow wildcards in the drive spec, to
1124+ prevent infinite recursion in glob. */
1125+ if (__glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE)))
1126+ return GLOB_NOMATCH;
1127+ /* If this is "d:pattern", we need to copy `:' to DIRNAME
1128+ as well. If it's "d:/pattern", don't remove the slash
1129+ from "d:/", since "d:" and "d:/" are not the same.*/
1130+ }
1131+#endif
1132+ newp = (char *) __alloca (dirlen + 1);
1133+#ifdef HAVE_MEMPCPY
1134+ *((char *) mempcpy (newp, pattern, dirlen)) = '\0';
1135+#else
1136+ memcpy (newp, pattern, dirlen);
1137+ newp[dirlen] = '\0';
1138+#endif
1139+ dirname = newp;
1140+ ++filename;
1141+
1142+ if (filename[0] == '\0'
1143+#if defined __MSDOS__ || defined WINDOWS32
1144+ && dirname[dirlen - 1] != ':'
1145+ && (dirlen < 3 || dirname[dirlen - 2] != ':'
1146+ || dirname[dirlen - 1] != '/')
1147+#endif
1148+ && dirlen > 1)
1149+ /* "pattern/". Expand "pattern", appending slashes. */
1150+ {
1151+ int val = glob_limited (depth + 1U, dirname, flags | GLOB_MARK, errfunc, pglob);
1152+ if (val == 0)
1153+ pglob->gl_flags = ((pglob->gl_flags & ~GLOB_MARK)
1154+ | (flags & GLOB_MARK));
1155+ return val;
1156+ }
1157+ }
1158+
1159+ if (!(flags & GLOB_APPEND))
1160+ {
1161+ pglob->gl_pathc = 0;
1162+ if (!(flags & GLOB_DOOFFS))
1163+ pglob->gl_pathv = NULL;
1164+ else
1165+ {
1166+ size_t i;
1167+ pglob->gl_pathv = (char **) malloc ((pglob->gl_offs + 1)
1168+ * sizeof (char *));
1169+ if (pglob->gl_pathv == NULL)
1170+ return GLOB_NOSPACE;
1171+
1172+ for (i = 0; i <= pglob->gl_offs; ++i)
1173+ pglob->gl_pathv[i] = NULL;
1174+ }
1175+ }
1176+
1177+ oldcount = pglob->gl_pathc + pglob->gl_offs;
1178+
1179+#ifndef VMS
1180+ if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~')
1181+ {
1182+ if (dirname[1] == '\0' || dirname[1] == '/')
1183+ {
1184+ /* Look up home directory. */
1185+ const char *home_dir = getenv ("HOME");
1186+# ifdef _AMIGA
1187+ if (home_dir == NULL || home_dir[0] == '\0')
1188+ home_dir = "SYS:";
1189+# else
1190+# ifdef WINDOWS32
1191+ if (home_dir == NULL || home_dir[0] == '\0')
1192+ home_dir = "c:/users/default"; /* poor default */
1193+# else
1194+ if (home_dir == NULL || home_dir[0] == '\0')
1195+ {
1196+ int success;
1197+ char *name;
1198+# if defined HAVE_GETLOGIN_R || defined _LIBC
1199+ size_t buflen = sysconf (_SC_LOGIN_NAME_MAX) + 1;
1200+
1201+ if (buflen == 0)
1202+ /* `sysconf' does not support _SC_LOGIN_NAME_MAX. Try
1203+ a moderate value. */
1204+ buflen = 20;
1205+ name = (char *) __alloca (buflen);
1206+
1207+ success = getlogin_r (name, buflen) >= 0;
1208+# else
1209+ success = (name = getlogin ()) != NULL;
1210+# endif
1211+ if (success)
1212+ {
1213+ struct passwd *p;
1214+# if defined HAVE_GETPWNAM_R || defined _LIBC
1215+ long int pwbuflen = sysconf (_SC_GETPW_R_SIZE_MAX);
1216+ char *pwtmpbuf;
1217+ struct passwd pwbuf;
1218+ int save = errno;
1219+
1220+ if (pwbuflen == -1)
1221+ /* `sysconf' does not support _SC_GETPW_R_SIZE_MAX.
1222+ Try a moderate value. */
1223+ pwbuflen = 1024;
1224+ pwtmpbuf = (char *) __alloca (pwbuflen);
1225+
1226+ while (getpwnam_r (name, &pwbuf, pwtmpbuf, pwbuflen, &p)
1227+ != 0)
1228+ {
1229+ if (errno != ERANGE)
1230+ {
1231+ p = NULL;
1232+ break;
1233+ }
1234+ pwbuflen *= 2;
1235+ pwtmpbuf = (char *) __alloca (pwbuflen);
1236+ __set_errno (save);
1237+ }
1238+# else
1239+ p = getpwnam (name);
1240+# endif
1241+ if (p != NULL)
1242+ home_dir = p->pw_dir;
1243+ }
1244+ }
1245+ if (home_dir == NULL || home_dir[0] == '\0')
1246+ {
1247+ if (flags & GLOB_TILDE_CHECK)
1248+ return GLOB_NOMATCH;
1249+ else
1250+ home_dir = "~"; /* No luck. */
1251+ }
1252+# endif /* WINDOWS32 */
1253+# endif
1254+ /* Now construct the full directory. */
1255+ if (dirname[1] == '\0')
1256+ dirname = home_dir;
1257+ else
1258+ {
1259+ char *newp;
1260+ size_t home_len = strlen (home_dir);
1261+ newp = (char *) __alloca (home_len + dirlen);
1262+# ifdef HAVE_MEMPCPY
1263+ mempcpy (mempcpy (newp, home_dir, home_len),
1264+ &dirname[1], dirlen);
1265+# else
1266+ memcpy (newp, home_dir, home_len);
1267+ memcpy (&newp[home_len], &dirname[1], dirlen);
1268+# endif
1269+ dirname = newp;
1270+ }
1271+ }
1272+# if !defined _AMIGA && !defined WINDOWS32
1273+ else
1274+ {
1275+ char *end_name = strchr (dirname, '/');
1276+ const char *user_name;
1277+ const char *home_dir;
1278+
1279+ if (end_name == NULL)
1280+ user_name = dirname + 1;
1281+ else
1282+ {
1283+ char *newp;
1284+ newp = (char *) __alloca (end_name - dirname);
1285+# ifdef HAVE_MEMPCPY
1286+ *((char *) mempcpy (newp, dirname + 1, end_name - dirname))
1287+ = '\0';
1288+# else
1289+ memcpy (newp, dirname + 1, end_name - dirname);
1290+ newp[end_name - dirname - 1] = '\0';
1291+# endif
1292+ user_name = newp;
1293+ }
1294+
1295+ /* Look up specific user's home directory. */
1296+ {
1297+ struct passwd *p;
1298+# if defined HAVE_GETPWNAM_R || defined _LIBC
1299+ long int buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
1300+ char *pwtmpbuf;
1301+ struct passwd pwbuf;
1302+ int save = errno;
1303+
1304+ if (buflen == -1)
1305+ /* `sysconf' does not support _SC_GETPW_R_SIZE_MAX. Try a
1306+ moderate value. */
1307+ buflen = 1024;
1308+ pwtmpbuf = (char *) __alloca (buflen);
1309+
1310+ while (getpwnam_r (user_name, &pwbuf, pwtmpbuf, buflen, &p) != 0)
1311+ {
1312+ if (errno != ERANGE)
1313+ {
1314+ p = NULL;
1315+ break;
1316+ }
1317+ buflen *= 2;
1318+ pwtmpbuf = __alloca (buflen);
1319+ __set_errno (save);
1320+ }
1321+# else
1322+ p = getpwnam (user_name);
1323+# endif
1324+ if (p != NULL)
1325+ home_dir = p->pw_dir;
1326+ else
1327+ home_dir = NULL;
1328+ }
1329+ /* If we found a home directory use this. */
1330+ if (home_dir != NULL)
1331+ {
1332+ char *newp;
1333+ size_t home_len = strlen (home_dir);
1334+ size_t rest_len = end_name == NULL ? 0 : strlen (end_name);
1335+ newp = (char *) __alloca (home_len + rest_len + 1);
1336+# ifdef HAVE_MEMPCPY
1337+ *((char *) mempcpy (mempcpy (newp, home_dir, home_len),
1338+ end_name, rest_len)) = '\0';
1339+# else
1340+ memcpy (newp, home_dir, home_len);
1341+ memcpy (&newp[home_len], end_name, rest_len);
1342+ newp[home_len + rest_len] = '\0';
1343+# endif
1344+ dirname = newp;
1345+ }
1346+ else
1347+ if (flags & GLOB_TILDE_CHECK)
1348+ /* We have to regard it as an error if we cannot find the
1349+ home directory. */
1350+ return GLOB_NOMATCH;
1351+ }
1352+# endif /* Not Amiga && not WINDOWS32. */
1353+ }
1354+#endif /* Not VMS. */
1355+
1356+ /* Now test whether we looked for "~" or "~NAME". In this case we
1357+ can give the answer now. */
1358+ if (filename == NULL)
1359+ {
1360+ struct stat st;
1361+#ifdef HAVE_STAT64
1362+ struct stat64 st64;
1363+#endif
1364+
1365+ /* Return the directory if we don't check for error or if it exists. */
1366+ if ((flags & GLOB_NOCHECK)
1367+ || (((flags & GLOB_ALTDIRFUNC)
1368+ ? ((*pglob->gl_stat) (dirname, &st) == 0
1369+ && S_ISDIR (st.st_mode))
1370+ : (__stat64 (dirname, &st64) == 0 && S_ISDIR (st64.st_mode)))))
1371+ {
1372+ int newcount = pglob->gl_pathc + pglob->gl_offs;
1373+
1374+ pglob->gl_pathv
1375+ = (char **) realloc (pglob->gl_pathv,
1376+ (newcount + 1 + 1) * sizeof (char *));
1377+ if (pglob->gl_pathv == NULL)
1378+ return GLOB_NOSPACE;
1379+
1380+#if defined HAVE_STRDUP || defined _LIBC
1381+ pglob->gl_pathv[newcount] = strdup (dirname);
1382+#else
1383+ {
1384+ size_t len = strlen (dirname) + 1;
1385+ char *dircopy = malloc (len);
1386+ if (dircopy != NULL)
1387+ pglob->gl_pathv[newcount] = memcpy (dircopy, dirname, len);
1388+ }
1389+#endif
1390+ if (pglob->gl_pathv[newcount] == NULL)
1391+ {
1392+ free (pglob->gl_pathv);
1393+ return GLOB_NOSPACE;
1394+ }
1395+ pglob->gl_pathv[++newcount] = NULL;
1396+ ++pglob->gl_pathc;
1397+ pglob->gl_flags = flags;
1398+
1399+ return 0;
1400+ }
1401+
1402+ /* Not found. */
1403+ return GLOB_NOMATCH;
1404+ }
1405+
1406+ if (__glob_pattern_p (dirname, !(flags & GLOB_NOESCAPE)))
1407+ {
1408+ /* The directory name contains metacharacters, so we
1409+ have to glob for the directory, and then glob for
1410+ the pattern in each directory found. */
1411+ glob_t dirs;
1412+ size_t i;
1413+
1414+ if ((flags & GLOB_ALTDIRFUNC) != 0)
1415+ {
1416+ /* Use the alternative access functions also in the recursive
1417+ call. */
1418+ dirs.gl_opendir = pglob->gl_opendir;
1419+ dirs.gl_readdir = pglob->gl_readdir;
1420+ dirs.gl_closedir = pglob->gl_closedir;
1421+ dirs.gl_stat = pglob->gl_stat;
1422+ dirs.gl_lstat = pglob->gl_lstat;
1423+ }
1424+
1425+ status = glob_limited (depth + 1U, dirname,
1426+ ((flags & (GLOB_ERR | GLOB_NOCHECK | GLOB_NOESCAPE
1427+ | GLOB_ALTDIRFUNC))
1428+ | GLOB_NOSORT | GLOB_ONLYDIR),
1429+ errfunc, &dirs);
1430+ if (status != 0)
1431+ return status;
1432+
1433+ /* We have successfully globbed the preceding directory name.
1434+ For each name we found, call glob_in_dir on it and FILENAME,
1435+ appending the results to PGLOB. */
1436+ for (i = 0; i < dirs.gl_pathc; ++i)
1437+ {
1438+ int old_pathc;
1439+
1440+#ifdef SHELL
1441+ {
1442+ /* Make globbing interruptible in the bash shell. */
1443+ extern int interrupt_state;
1444+
1445+ if (interrupt_state)
1446+ {
1447+ globfree (&dirs);
1448+ return GLOB_ABORTED;
1449+ }
1450+ }
1451+#endif /* SHELL. */
1452+
1453+ old_pathc = pglob->gl_pathc;
1454+ status = glob_in_dir (filename, dirs.gl_pathv[i],
1455+ ((flags | GLOB_APPEND) & ~GLOB_NOCHECK),
1456+ errfunc, pglob);
1457+ if (status == GLOB_NOMATCH)
1458+ /* No matches in this directory. Try the next. */
1459+ continue;
1460+
1461+ if (status != 0)
1462+ {
1463+ globfree (&dirs);
1464+ globfree (pglob);
1465+ return status;
1466+ }
1467+
1468+ /* Stick the directory on the front of each name. */
1469+ if (prefix_array (dirs.gl_pathv[i],
1470+ &pglob->gl_pathv[old_pathc + pglob->gl_offs],
1471+ pglob->gl_pathc - old_pathc))
1472+ {
1473+ globfree (&dirs);
1474+ globfree (pglob);
1475+ return GLOB_NOSPACE;
1476+ }
1477+ }
1478+
1479+ flags |= GLOB_MAGCHAR;
1480+
1481+ /* We have ignored the GLOB_NOCHECK flag in the `glob_in_dir' calls.
1482+ But if we have not found any matching entry and the GLOB_NOCHECK
1483+ flag was set we must return the list consisting of the disrectory
1484+ names followed by the filename. */
1485+ if (pglob->gl_pathc + pglob->gl_offs == oldcount)
1486+ {
1487+ /* No matches. */
1488+ if (flags & GLOB_NOCHECK)
1489+ {
1490+ size_t filename_len = strlen (filename) + 1;
1491+ char **new_pathv;
1492+ int newcount = pglob->gl_pathc + pglob->gl_offs;
1493+ struct stat st;
1494+#ifdef HAVE_STAT64
1495+ struct stat64 st64;
1496+#endif
1497+
1498+ /* This is an pessimistic guess about the size. */
1499+ pglob->gl_pathv
1500+ = (char **) realloc (pglob->gl_pathv,
1501+ (newcount + dirs.gl_pathc + 1)
1502+ * sizeof (char *));
1503+ if (pglob->gl_pathv == NULL)
1504+ {
1505+ globfree (&dirs);
1506+ return GLOB_NOSPACE;
1507+ }
1508+
1509+ for (i = 0; i < dirs.gl_pathc; ++i)
1510+ {
1511+ const char *dir = dirs.gl_pathv[i];
1512+ size_t dir_len = strlen (dir);
1513+
1514+ /* First check whether this really is a directory. */
1515+ if (((flags & GLOB_ALTDIRFUNC)
1516+ ? ((*pglob->gl_stat) (dir, &st) != 0
1517+ || !S_ISDIR (st.st_mode))
1518+ : (__stat64 (dir, &st64) != 0
1519+ || !S_ISDIR (st64.st_mode))))
1520+ /* No directory, ignore this entry. */
1521+ continue;
1522+
1523+ pglob->gl_pathv[newcount] = malloc (dir_len + 1
1524+ + filename_len);
1525+ if (pglob->gl_pathv[newcount] == NULL)
1526+ {
1527+ globfree (&dirs);
1528+ globfree (pglob);
1529+ return GLOB_NOSPACE;
1530+ }
1531+
1532+#ifdef HAVE_MEMPCPY
1533+ mempcpy (mempcpy (mempcpy (pglob->gl_pathv[newcount],
1534+ dir, dir_len),
1535+ "/", 1),
1536+ filename, filename_len);
1537+#else
1538+ memcpy (pglob->gl_pathv[newcount], dir, dir_len);
1539+ pglob->gl_pathv[newcount][dir_len] = '/';
1540+ memcpy (&pglob->gl_pathv[newcount][dir_len + 1],
1541+ filename, filename_len);
1542+#endif
1543+ ++pglob->gl_pathc;
1544+ ++newcount;
1545+ }
1546+
1547+ pglob->gl_pathv[newcount] = NULL;
1548+ pglob->gl_flags = flags;
1549+
1550+ /* Now we know how large the gl_pathv vector must be. */
1551+ new_pathv = (char **) realloc (pglob->gl_pathv,
1552+ ((newcount + 1)
1553+ * sizeof (char *)));
1554+ if (new_pathv != NULL)
1555+ pglob->gl_pathv = new_pathv;
1556+ }
1557+ else
1558+ {
1559+ globfree (&dirs);
1560+ return GLOB_NOMATCH;
1561+ }
1562+ }
1563+
1564+ globfree (&dirs);
1565+ }
1566+ else
1567+ {
1568+ int old_pathc = pglob->gl_pathc;
1569+
1570+ status = glob_in_dir (filename, dirname, flags, errfunc, pglob);
1571+ if (status != 0)
1572+ return status;
1573+
1574+ if (dirlen > 0)
1575+ {
1576+ /* Stick the directory on the front of each name. */
1577+ if (prefix_array (dirname,
1578+ &pglob->gl_pathv[old_pathc + pglob->gl_offs],
1579+ pglob->gl_pathc - old_pathc))
1580+ {
1581+ globfree (pglob);
1582+ return GLOB_NOSPACE;
1583+ }
1584+ }
1585+ }
1586+
1587+ if (flags & GLOB_MARK)
1588+ {
1589+ /* Append slashes to directory names. */
1590+ size_t i;
1591+ struct stat st;
1592+#ifdef HAVE_STAT64
1593+ struct stat64 st64;
1594+#endif
1595+
1596+ for (i = oldcount; i < pglob->gl_pathc + pglob->gl_offs; ++i)
1597+ if (((flags & GLOB_ALTDIRFUNC)
1598+ ? ((*pglob->gl_stat) (pglob->gl_pathv[i], &st) == 0
1599+ && S_ISDIR (st.st_mode))
1600+ : (__stat64 (pglob->gl_pathv[i], &st64) == 0
1601+ && S_ISDIR (st64.st_mode))))
1602+ {
1603+ size_t len = strlen (pglob->gl_pathv[i]) + 2;
1604+ char *new = realloc (pglob->gl_pathv[i], len);
1605+ if (new == NULL)
1606+ {
1607+ globfree (pglob);
1608+ return GLOB_NOSPACE;
1609+ }
1610+ strcpy (&new[len - 2], "/");
1611+ pglob->gl_pathv[i] = new;
1612+ }
1613+ }
1614+
1615+ if (!(flags & GLOB_NOSORT))
1616+ {
1617+ /* Sort the vector. */
1618+ qsort ((__ptr_t) &pglob->gl_pathv[oldcount],
1619+ pglob->gl_pathc + pglob->gl_offs - oldcount,
1620+ sizeof (char *), collated_compare);
1621+ }
1622+
1623+ return 0;
1624+}
1625+
1626+int
1627+glob (pattern, flags, errfunc, pglob)
1628+
1629+ const char *pattern;
1630+ int flags;
1631+ int (*errfunc) __P ((const char *, int));
1632+ glob_t *pglob;
1633+{
1634+ nbresults = 0UL;
1635+ return glob_limited(0U, pattern, flags, errfunc, pglob);
1636+}
1637+
1638+#if !defined _LIBC || !defined GLOB_ONLY_P
1639+
1640+/* Free storage allocated in PGLOB by a previous `glob' call. */
1641+void
1642+globfree (pglob)
1643+ register glob_t *pglob;
1644+{
1645+ if (pglob->gl_pathv != NULL)
1646+ {
1647+ size_t i;
1648+ for (i = 0; i < pglob->gl_pathc; ++i)
1649+ if (pglob->gl_pathv[pglob->gl_offs + i] != NULL)
1650+ free ((__ptr_t) pglob->gl_pathv[pglob->gl_offs + i]);
1651+ free ((__ptr_t) pglob->gl_pathv);
1652+ }
1653+}
1654+
1655+
1656+/* Do a collated comparison of A and B. */
1657+static int
1658+collated_compare (a, b)
1659+ const __ptr_t a;
1660+ const __ptr_t b;
1661+{
1662+ const char *const s1 = *(const char *const * const) a;
1663+ const char *const s2 = *(const char *const * const) b;
1664+
1665+ if (s1 == s2)
1666+ return 0;
1667+ if (s1 == NULL)
1668+ return 1;
1669+ if (s2 == NULL)
1670+ return -1;
1671+ return strcoll (s1, s2);
1672+}
1673+
1674+
1675+/* Prepend DIRNAME to each of N members of ARRAY, replacing ARRAY's
1676+ elements in place. Return nonzero if out of memory, zero if successful.
1677+ A slash is inserted between DIRNAME and each elt of ARRAY,
1678+ unless DIRNAME is just "/". Each old element of ARRAY is freed. */
1679+static int
1680+prefix_array (dirname, array, n)
1681+ const char *dirname;
1682+ char **array;
1683+ size_t n;
1684+{
1685+ register size_t i;
1686+ size_t dirlen = strlen (dirname);
1687+#if defined __MSDOS__ || defined WINDOWS32
1688+ int sep_char = '/';
1689+# define DIRSEP_CHAR sep_char
1690+#else
1691+# define DIRSEP_CHAR '/'
1692+#endif
1693+
1694+ if (dirlen == 1 && dirname[0] == '/')
1695+ /* DIRNAME is just "/", so normal prepending would get us "//foo".
1696+ We want "/foo" instead, so don't prepend any chars from DIRNAME. */
1697+ dirlen = 0;
1698+#if defined __MSDOS__ || defined WINDOWS32
1699+ else if (dirlen > 1)
1700+ {
1701+ if (dirname[dirlen - 1] == '/' && dirname[dirlen - 2] == ':')
1702+ /* DIRNAME is "d:/". Don't prepend the slash from DIRNAME. */
1703+ --dirlen;
1704+ else if (dirname[dirlen - 1] == ':')
1705+ {
1706+ /* DIRNAME is "d:". Use `:' instead of `/'. */
1707+ --dirlen;
1708+ sep_char = ':';
1709+ }
1710+ }
1711+#endif
1712+
1713+ for (i = 0; i < n; ++i)
1714+ {
1715+ size_t eltlen = strlen (array[i]) + 1;
1716+ char *new = (char *) malloc (dirlen + 1 + eltlen);
1717+ if (new == NULL)
1718+ {
1719+ while (i > 0)
1720+ free ((__ptr_t) array[--i]);
1721+ return 1;
1722+ }
1723+
1724+#ifdef HAVE_MEMPCPY
1725+ {
1726+ char *endp = (char *) mempcpy (new, dirname, dirlen);
1727+ *endp++ = DIRSEP_CHAR;
1728+ mempcpy (endp, array[i], eltlen);
1729+ }
1730+#else
1731+ memcpy (new, dirname, dirlen);
1732+ new[dirlen] = DIRSEP_CHAR;
1733+ memcpy (&new[dirlen + 1], array[i], eltlen);
1734+#endif
1735+ free ((__ptr_t) array[i]);
1736+ array[i] = new;
1737+ }
1738+
1739+ return 0;
1740+}
1741+
1742+
1743+/* We must not compile this function twice. */
1744+#if !defined _LIBC || !defined NO_GLOB_PATTERN_P
1745+/* Return nonzero if PATTERN contains any metacharacters.
1746+ Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
1747+int
1748+__glob_pattern_p (pattern, quote)
1749+ const char *pattern;
1750+ int quote;
1751+{
1752+ register const char *p;
1753+ int open = 0;
1754+
1755+ for (p = pattern; *p != '\0'; ++p)
1756+ switch (*p)
1757+ {
1758+ case '?':
1759+ case '*':
1760+ return 1;
1761+
1762+ case '\\':
1763+ if (quote && p[1] != '\0')
1764+ ++p;
1765+ break;
1766+
1767+ case '[':
1768+ open = 1;
1769+ break;
1770+
1771+ case ']':
1772+ if (open)
1773+ return 1;
1774+ break;
1775+ }
1776+
1777+ return 0;
1778+}
1779+# ifdef _LIBC
1780+weak_alias (__glob_pattern_p, glob_pattern_p)
1781+# endif
1782+#endif
1783+
1784+#endif /* !GLOB_ONLY_P */
1785+
1786+
1787+/* Like `glob', but PATTERN is a final pathname component,
1788+ and matches are searched for in DIRECTORY.
1789+ The GLOB_NOSORT bit in FLAGS is ignored. No sorting is ever done.
1790+ The GLOB_APPEND flag is assumed to be set (always appends). */
1791+static int
1792+glob_in_dir (pattern, directory, flags, errfunc, pglob)
1793+ const char *pattern;
1794+ const char *directory;
1795+ int flags;
1796+ int (*errfunc) __P ((const char *, int));
1797+ glob_t *pglob;
1798+{
1799+ __ptr_t stream = NULL;
1800+ struct globlink
1801+ {
1802+ struct globlink *next;
1803+ char *name;
1804+ };
1805+ struct globlink *names = NULL;
1806+ size_t nfound;
1807+ int meta;
1808+ int save;
1809+
1810+ meta = __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE));
1811+ if (meta == 0 && (flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
1812+ {
1813+ /* We need not do any tests. The PATTERN contains no meta
1814+ characters and we must not return an error therefore the
1815+ result will always contain exactly one name. */
1816+ flags |= GLOB_NOCHECK;
1817+ nfound = 0;
1818+ }
1819+ else if (meta == 0 &&
1820+ ((flags & GLOB_NOESCAPE) || strchr(pattern, '\\') == NULL))
1821+ {
1822+ /* Since we use the normal file functions we can also use stat()
1823+ to verify the file is there. */
1824+ struct stat st;
1825+# ifdef HAVE_STAT64
1826+ struct stat64 st64;
1827+# endif
1828+ size_t patlen = strlen (pattern);
1829+ size_t dirlen = strlen (directory);
1830+ char *fullname = (char *) __alloca (dirlen + 1 + patlen + 1);
1831+
1832+# ifdef HAVE_MEMPCPY
1833+ mempcpy (mempcpy (mempcpy (fullname, directory, dirlen),
1834+ "/", 1),
1835+ pattern, patlen + 1);
1836+# else
1837+ memcpy (fullname, directory, dirlen);
1838+ fullname[dirlen] = '/';
1839+ memcpy (&fullname[dirlen + 1], pattern, patlen + 1);
1840+# endif
1841+ if (((flags & GLOB_ALTDIRFUNC)
1842+ ? (*pglob->gl_stat) (fullname, &st)
1843+ : __stat64 (fullname, &st64)) == 0)
1844+ /* We found this file to be existing. Now tell the rest
1845+ of the function to copy this name into the result. */
1846+ flags |= GLOB_NOCHECK;
1847+
1848+ nfound = 0;
1849+ }
1850+ else
1851+ {
1852+ if (pattern[0] == '\0')
1853+ {
1854+ /* This is a special case for matching directories like in
1855+ "*a/". */
1856+ names = (struct globlink *) __alloca (sizeof (struct globlink));
1857+ names->name = (char *) malloc (1);
1858+ if (names->name == NULL)
1859+ goto memory_error;
1860+ names->name[0] = '\0';
1861+ names->next = NULL;
1862+ nfound = 1;
1863+ meta = 0;
1864+ }
1865+ else
1866+ {
1867+ stream = ((flags & GLOB_ALTDIRFUNC)
1868+ ? (*pglob->gl_opendir) (directory)
1869+ : (__ptr_t) opendir (directory));
1870+ if (stream == NULL)
1871+ {
1872+ if (errno != ENOTDIR
1873+ && ((errfunc != NULL && (*errfunc) (directory, errno))
1874+ || (flags & GLOB_ERR)))
1875+ return GLOB_ABORTED;
1876+ nfound = 0;
1877+ meta = 0;
1878+ }
1879+ else
1880+ {
1881+ int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0)
1882+ | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)
1883+#if defined _AMIGA || defined VMS
1884+ | FNM_CASEFOLD
1885+#endif
1886+ );
1887+ nfound = 0;
1888+ flags |= GLOB_MAGCHAR;
1889+
1890+ while (1)
1891+ {
1892+ const char *name;
1893+ size_t len;
1894+#if defined HAVE_DIRENT64 && !defined COMPILE_GLOB64
1895+ struct dirent64 *d;
1896+ struct dirent64 d64;
1897+
1898+ if (flags & GLOB_ALTDIRFUNC)
1899+ {
1900+ struct dirent *d32 = (*pglob->gl_readdir) (stream);
1901+ if (d32 != NULL)
1902+ {
1903+ CONVERT_DIRENT_DIRENT64 (&d64, d32);
1904+ d = &d64;
1905+ }
1906+ else
1907+ d = NULL;
1908+ }
1909+ else
1910+ d = __readdir64 ((DIR *) stream);
1911+#else
1912+ struct dirent *d = ((flags & GLOB_ALTDIRFUNC)
1913+ ? ((struct dirent *)
1914+ (*pglob->gl_readdir) (stream))
1915+ : __readdir ((DIR *) stream));
1916+#endif
1917+ if (d == NULL)
1918+ break;
1919+ if (nbresults > MAX_RESULTS) {
1920+ break;
1921+ }
1922+ nbresults++;
1923+ if (! REAL_DIR_ENTRY (d))
1924+ continue;
1925+
1926+#ifdef HAVE_D_TYPE
1927+ /* If we shall match only directories use the information
1928+ provided by the dirent call if possible. */
1929+ if ((flags & GLOB_ONLYDIR)
1930+ && d->d_type != DT_UNKNOWN && d->d_type != DT_DIR)
1931+ continue;
1932+#endif
1933+
1934+ name = d->d_name;
1935+
1936+ if (fnmatch (pattern, name, fnm_flags) == 0)
1937+ {
1938+ struct globlink *new = (struct globlink *)
1939+ __alloca (sizeof (struct globlink));
1940+ len = NAMLEN (d);
1941+ new->name = (char *) malloc (len + 1);
1942+ if (new->name == NULL)
1943+ goto memory_error;
1944+#ifdef HAVE_MEMPCPY
1945+ *((char *) mempcpy ((__ptr_t) new->name, name, len))
1946+ = '\0';
1947+#else
1948+ memcpy ((__ptr_t) new->name, name, len);
1949+ new->name[len] = '\0';
1950+#endif
1951+ new->next = names;
1952+ names = new;
1953+ ++nfound;
1954+ }
1955+ }
1956+ }
1957+ }
1958+ }
1959+
1960+ if (nfound == 0 && (flags & GLOB_NOCHECK))
1961+ {
1962+ size_t len = strlen (pattern);
1963+ nfound = 1;
1964+ names = (struct globlink *) __alloca (sizeof (struct globlink));
1965+ names->next = NULL;
1966+ names->name = (char *) malloc (len + 1);
1967+ if (names->name == NULL)
1968+ goto memory_error;
1969+#ifdef HAVE_MEMPCPY
1970+ *((char *) mempcpy (names->name, pattern, len)) = '\0';
1971+#else
1972+ memcpy (names->name, pattern, len);
1973+ names->name[len] = '\0';
1974+#endif
1975+ }
1976+
1977+ if (nfound != 0)
1978+ {
1979+ pglob->gl_pathv
1980+ = (char **) realloc (pglob->gl_pathv,
1981+ (pglob->gl_pathc + pglob->gl_offs + nfound + 1)
1982+ * sizeof (char *));
1983+ if (pglob->gl_pathv == NULL)
1984+ goto memory_error;
1985+
1986+ for (; names != NULL; names = names->next)
1987+ pglob->gl_pathv[pglob->gl_offs + pglob->gl_pathc++] = names->name;
1988+ pglob->gl_pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
1989+
1990+ pglob->gl_flags = flags;
1991+ }
1992+
1993+ save = errno;
1994+ if (stream != NULL)
1995+ {
1996+ if (flags & GLOB_ALTDIRFUNC)
1997+ (*pglob->gl_closedir) (stream);
1998+ else
1999+ closedir ((DIR *) stream);
2000+ }
2001+ __set_errno (save);
2002+
2003+ return nfound == 0 ? GLOB_NOMATCH : 0;
2004+
2005+ memory_error:
2006+ {
2007+ int save = errno;
2008+ if (flags & GLOB_ALTDIRFUNC)
2009+ (*pglob->gl_closedir) (stream);
2010+ else
2011+ closedir ((DIR *) stream);
2012+ __set_errno (save);
2013+ }
2014+ while (names != NULL)
2015+ {
2016+ if (names->name != NULL)
2017+ free ((__ptr_t) names->name);
2018+ names = names->next;
2019+ }
2020+ return GLOB_NOSPACE;
2021+}
2022+
2023+#endif /* Not ELIDE_CODE. */
2024diff -urN proftpd-1.2.1/lib/glob.c proftpd-1.2/lib/glob.c
2025--- proftpd-1.2.1/lib/glob.c Wed Jul 26 10:16:33 2000
2026+++ proftpd-1.2/lib/glob.c Thu Jan 1 01:00:00 1970
2027@@ -1,1108 +0,0 @@
2028-/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
2029-
2030- This library is free software; you can redistribute it and/or
2031- modify it under the terms of the GNU Library General Public License as
2032- published by the Free Software Foundation; either version 2 of the
2033- License, or (at your option) any later version.
2034-
2035- This library is distributed in the hope that it will be useful,
2036- but WITHOUT ANY WARRANTY; without even the implied warranty of
2037- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2038- Library General Public License for more details.
2039-
2040- You should have received a copy of the GNU Library General Public
2041- License along with this library; see the file COPYING.LIB. If not,
2042- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
2043- Boston, MA 02111-1307, USA. */
2044-
2045-/* AIX requires this to be the first thing in the file. */
2046-#if defined _AIX && !defined __GNUC__
2047- #pragma alloca
2048-#endif
2049-
2050-/* Enable GNU extensions in glob.h. */
2051-#ifndef _GNU_SOURCE
2052-# define _GNU_SOURCE 1
2053-#endif
2054-
2055-/* Required to tell conf.h not to include the standard ProFTPD
2056- * header files
2057- */
2058-
2059-#define __PROFTPD_SUPPORT_LIBRARY
2060-
2061-#include <conf.h>
2062-
2063-#include <errno.h>
2064-#include <sys/types.h>
2065-#include <sys/stat.h>
2066-
2067-#include <assert.h>
2068-#include <stdio.h> /* Needed on stupid SunOS for assert. */
2069-
2070-#include <libsupp.h>
2071-
2072-#undef _LIBC
2073-#undef __GNU_LIBRARY__
2074-
2075-#ifndef HAVE_GLOB
2076-
2077-/* Comment out all this code if we are using the GNU C Library, and are not
2078- actually compiling the library itself. This code is part of the GNU C
2079- Library, but also included in many other GNU distributions. Compiling
2080- and linking in this code is a waste when using the GNU C library
2081- (especially if it is a shared library). Rather than having every GNU
2082- program understand `configure --with-gnu-libc' and omit the object files,
2083- it is simpler to just do this in the source for each such file. */
2084-
2085-#if defined(STDC_HEADERS) || defined(__GNU_LIBRARY__)
2086-# include <stddef.h>
2087-#endif
2088-
2089-#if defined(HAVE_UNISTD_H) || defined(_LIBC)
2090-# include <unistd.h>
2091-# ifndef POSIX
2092-# ifdef _POSIX_VERSION
2093-# define POSIX
2094-# endif
2095-# endif
2096-#endif
2097-
2098-#if !defined(_AMIGA) && !defined(VMS) && !defined(WINDOWS32)
2099-# include <pwd.h>
2100-#endif
2101-
2102-#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
2103-extern int errno;
2104-#endif
2105-#ifndef __set_errno
2106-# define __set_errno(val) errno = (val)
2107-#endif
2108-
2109-#ifndef NULL
2110-# define NULL 0
2111-#endif
2112-
2113-#if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__
2114-# include <dirent.h>
2115-# define NAMLEN(dirent) strlen((dirent)->d_name)
2116-#else
2117-# define dirent direct
2118-# define NAMLEN(dirent) (dirent)->d_namlen
2119-# ifdef HAVE_SYS_NDIR_H
2120-# include <sys/ndir.h>
2121-# endif
2122-# ifdef HAVE_SYS_DIR_H
2123-# include <sys/dir.h>
2124-# endif
2125-# ifdef HAVE_NDIR_H
2126-# include <ndir.h>
2127-# endif
2128-# ifdef HAVE_VMSDIR_H
2129-# include "vmsdir.h"
2130-# endif /* HAVE_VMSDIR_H */
2131-#endif
2132-
2133-/* In GNU systems, <dirent.h> defines this macro for us. */
2134-#ifdef _D_NAMLEN
2135-# undef NAMLEN
2136-# define NAMLEN(d) _D_NAMLEN(d)
2137-#endif
2138-
2139-#ifdef _DIRENT_HAVE_D_TYPE
2140-# define HAVE_D_TYPE 1
2141-#endif
2142-
2143-#if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__
2144-/* Posix does not require that the d_ino field be present, and some
2145- systems do not provide it. */
2146-# define REAL_DIR_ENTRY(dp) 1
2147-#else
2148-# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
2149-#endif /* POSIX */
2150-
2151-#if defined STDC_HEADERS || defined __GNU_LIBRARY__
2152-# include <stdlib.h>
2153-# include <string.h>
2154-# define ANSI_STRING
2155-#else /* No standard headers. */
2156-
2157-extern char *getenv ();
2158-
2159-# ifdef HAVE_STRING_H
2160-# include <string.h>
2161-# define ANSI_STRING
2162-# else
2163-# include <strings.h>
2164-# endif
2165-# ifdef HAVE_MEMORY_H
2166-# include <memory.h>
2167-# endif
2168-
2169-#ifndef __osf__
2170-extern char *malloc (), *realloc ();
2171-extern void free ();
2172-
2173-extern void qsort ();
2174-extern void abort (), exit ();
2175-#endif /* __osf__ */
2176-
2177-#endif /* Standard headers. */
2178-
2179-#ifndef ANSI_STRING
2180-
2181-# ifndef bzero
2182-extern void bzero ();
2183-# endif
2184-# ifndef bcopy
2185-extern void bcopy ();
2186-# endif
2187-
2188-# undef memcpy
2189-# define memcpy(d, s, n) bcopy ((s), (d), (n))
2190-# undef strrchr
2191-# define strrchr rindex
2192-/* memset is only used for zero here, but let's be paranoid. */
2193-# undef memset
2194-# define memset(s, better_be_zero, n) \
2195- ((void) ((better_be_zero) == 0 ? (bzero((s), (n)), 0) : (abort(), 0)))
2196-#endif /* Not ANSI_STRING. */
2197-
2198-#if !defined HAVE_STRCOLL && !defined _LIBC
2199-# define strcoll strcmp
2200-#endif
2201-
2202-#if !defined HAVE_MEMPCPY && __GLIBC__ - 0 == 2 && __GLIBC_MINOR__ >= 1
2203-# define HAVE_MEMPCPY 1
2204-# define mempcpy(Dest, Src, Len) __mempcpy (Dest, Src, Len)
2205-#endif
2206-
2207-#ifndef __GNU_LIBRARY__
2208-# ifdef __GNUC__
2209-__inline
2210-# endif
2211-# ifndef __SASC
2212-# ifdef WINDOWS32
2213-static void *
2214-# else
2215-static char *
2216-# endif
2217-my_realloc (p, n)
2218- char *p;
2219- unsigned int n;
2220-{
2221- /* These casts are the for sake of the broken Ultrix compiler,
2222- which warns of illegal pointer combinations otherwise. */
2223- if (p == NULL)
2224- return (char *) malloc (n);
2225- return (char *) realloc (p, n);
2226-}
2227-# define realloc my_realloc
2228-# endif /* __SASC */
2229-#endif /* __GNU_LIBRARY__ */
2230-
2231-
2232-#if !defined __alloca && !defined __GNU_LIBRARY__
2233-
2234-# ifdef __GNUC__
2235-# undef alloca
2236-# define alloca(n) __builtin_alloca (n)
2237-# else /* Not GCC. */
2238-# ifdef HAVE_ALLOCA_H
2239-# include <alloca.h>
2240-# else /* Not HAVE_ALLOCA_H. */
2241-# ifndef _AIX
2242-# ifdef WINDOWS32
2243-# include <malloc.h>
2244-# else
2245-extern char *alloca ();
2246-# endif /* WINDOWS32 */
2247-# endif /* Not _AIX. */
2248-# endif /* sparc or HAVE_ALLOCA_H. */
2249-# endif /* GCC. */
2250-
2251-# define __alloca alloca
2252-
2253-#endif
2254-
2255-#ifndef __GNU_LIBRARY__
2256-# define __stat stat
2257-# ifdef STAT_MACROS_BROKEN
2258-# undef S_ISDIR
2259-# endif
2260-# ifndef S_ISDIR
2261-# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
2262-# endif
2263-#endif
2264-
2265-#if !(defined STDC_HEADERS || defined __GNU_LIBRARY__)
2266-# undef size_t
2267-# define size_t unsigned int
2268-#endif
2269-
2270-/* Some system header files erroneously define these.
2271- We want our own definitions from <glob.h> to take precedence. */
2272-#undef GLOB_ERR
2273-#undef GLOB_MARK
2274-#undef GLOB_NOSORT
2275-#undef GLOB_DOOFFS
2276-#undef GLOB_NOCHECK
2277-#undef GLOB_APPEND
2278-#undef GLOB_NOESCAPE
2279-#undef GLOB_PERIOD
2280-#include "glob.h"
2281-
2282-static
2283-#if __GNUC__ - 0 >= 2
2284-inline
2285-#endif
2286-const char *next_brace_sub __P ((const char *begin));
2287-static int glob_in_dir __P ((const char *pattern, const char *directory,
2288- int flags,
2289- int (*errfunc) __P ((const char *, int)),
2290- glob_t *pglob));
2291-static int prefix_array __P ((const char *prefix, char **array, size_t n));
2292-static int collated_compare __P ((const __ptr_t, const __ptr_t));
2293-
2294-
2295-/* Find the end of the sub-pattern in a brace expression. We define
2296- this as an inline function if the compiler permits. */
2297-static
2298-#if __GNUC__ - 0 >= 2
2299-inline
2300-#endif
2301-const char *
2302-next_brace_sub (begin)
2303- const char *begin;
2304-{
2305- unsigned int depth = 0;
2306- const char *cp = begin;
2307-
2308- while (1)
2309- {
2310- if (depth == 0)
2311- {
2312- if (*cp != ',' && *cp != '}' && *cp != '\0')
2313- {
2314- if (*cp == '{')
2315- ++depth;
2316- ++cp;
2317- continue;
2318- }
2319- }
2320- else
2321- {
2322- while (*cp != '\0' && (*cp != '}' || depth > 0))
2323- {
2324- if (*cp == '}')
2325- --depth;
2326- ++cp;
2327- }
2328- if (*cp == '\0')
2329- /* An incorrectly terminated brace expression. */
2330- return NULL;
2331-
2332- continue;
2333- }
2334- break;
2335- }
2336-
2337- return cp;
2338-}
2339-
2340-/* Do glob searching for PATTERN, placing results in PGLOB.
2341- The bits defined above may be set in FLAGS.
2342- If a directory cannot be opened or read and ERRFUNC is not nil,
2343- it is called with the pathname that caused the error, and the
2344- `errno' value from the failing call; if it returns non-zero
2345- `glob' returns GLOB_ABORTED; if it returns zero, the error is ignored.
2346- If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
2347- Otherwise, `glob' returns zero. */
2348-int
2349-glob (pattern, flags, errfunc, pglob)
2350- const char *pattern;
2351- int flags;
2352- int (*errfunc) __P ((const char *, int));
2353- glob_t *pglob;
2354-{
2355- const char *filename;
2356- char *dirname;
2357- size_t dirlen;
2358- int status;
2359- int oldcount;
2360-
2361- if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0)
2362- {
2363- __set_errno (EINVAL);
2364- return -1;
2365- }
2366-
2367- if (flags & GLOB_BRACE)
2368- {
2369- const char *begin = strchr (pattern, '{');
2370- if (begin != NULL)
2371- {
2372- /* Allocate working buffer large enough for our work. Note that
2373- we have at least an opening and closing brace. */
2374- int firstc;
2375- char *alt_start;
2376- const char *p;
2377- const char *next;
2378- const char *rest;
2379- size_t rest_len;
2380-#ifdef __GNUC__
2381- char onealt[strlen (pattern) - 1];
2382-#else
2383- char *onealt = (char *) malloc (strlen (pattern) - 1);
2384- if (onealt == NULL)
2385- {
2386- if (!(flags & GLOB_APPEND))
2387- globfree (pglob);
2388- return GLOB_NOSPACE;
2389- }
2390-#endif
2391-
2392- /* We know the prefix for all sub-patterns. */
2393-#ifdef HAVE_MEMPCPY
2394- alt_start = mempcpy (onealt, pattern, begin - pattern);
2395-#else
2396- memcpy (onealt, pattern, begin - pattern);
2397- alt_start = &onealt[begin - pattern];
2398-#endif
2399-
2400- /* Find the first sub-pattern and at the same time find the
2401- rest after the closing brace. */
2402- next = next_brace_sub (begin + 1);
2403- if (next == NULL)
2404- {
2405- /* It is an illegal expression. */
2406-#ifndef __GNUC__
2407- free (onealt);
2408-#endif
2409- return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob);
2410- }
2411-
2412- /* Now find the end of the whole brace expression. */
2413- rest = next;
2414- while (*rest != '}')
2415- {
2416- rest = next_brace_sub (rest + 1);
2417- if (rest == NULL)
2418- {
2419- /* It is an illegal expression. */
2420-#ifndef __GNUC__
2421- free (onealt);
2422-#endif
2423- return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob);
2424- }
2425- }
2426- /* Please note that we now can be sure the brace expression
2427- is well-formed. */
2428- rest_len = strlen (++rest) + 1;
2429-
2430- /* We have a brace expression. BEGIN points to the opening {,
2431- NEXT points past the terminator of the first element, and END
2432- points past the final }. We will accumulate result names from
2433- recursive runs for each brace alternative in the buffer using
2434- GLOB_APPEND. */
2435-
2436- if (!(flags & GLOB_APPEND))
2437- {
2438- /* This call is to set a new vector, so clear out the
2439- vector so we can append to it. */
2440- pglob->gl_pathc = 0;
2441- pglob->gl_pathv = NULL;
2442- }
2443- firstc = pglob->gl_pathc;
2444-
2445- p = begin + 1;
2446- while (1)
2447- {
2448- int result;
2449-
2450- /* Construct the new glob expression. */
2451-#ifdef HAVE_MEMPCPY
2452- mempcpy (mempcpy (alt_start, p, next - p), rest, rest_len);
2453-#else
2454- memcpy (alt_start, p, next - p);
2455- memcpy (&alt_start[next - p], rest, rest_len);
2456-#endif
2457-
2458- result = glob (onealt,
2459- ((flags & ~(GLOB_NOCHECK|GLOB_NOMAGIC))
2460- | GLOB_APPEND), errfunc, pglob);
2461-
2462- /* If we got an error, return it. */
2463- if (result && result != GLOB_NOMATCH)
2464- {
2465-#ifndef __GNUC__
2466- free (onealt);
2467-#endif
2468- if (!(flags & GLOB_APPEND))
2469- globfree (pglob);
2470- return result;
2471- }
2472-
2473- if (*next == '}')
2474- /* We saw the last entry. */
2475- break;
2476-
2477- p = next + 1;
2478- next = next_brace_sub (p);
2479- assert (next != NULL);
2480- }
2481-
2482-#ifndef __GNUC__
2483- free (onealt);
2484-#endif
2485-
2486- if (pglob->gl_pathc != firstc)
2487- /* We found some entries. */
2488- return 0;
2489- else if (!(flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
2490- return GLOB_NOMATCH;
2491- }
2492- }
2493-
2494- /* Find the filename. */
2495- filename = strrchr (pattern, '/');
2496- if (filename == NULL)
2497- {
2498- filename = pattern;
2499-#ifdef _AMIGA
2500- dirname = (char *) "";
2501-#else
2502- dirname = (char *) ".";
2503-#endif
2504- dirlen = 0;
2505- }
2506- else if (filename == pattern)
2507- {
2508- /* "/pattern". */
2509- dirname = (char *) "/";
2510- dirlen = 1;
2511- ++filename;
2512- }
2513- else
2514- {
2515- dirlen = filename - pattern;
2516- dirname = (char *) __alloca (dirlen + 1);
2517-#ifdef HAVE_MEMPCPY
2518- *((char *) mempcpy (dirname, pattern, dirlen)) = '\0';
2519-#else
2520- memcpy (dirname, pattern, dirlen);
2521- dirname[dirlen] = '\0';
2522-#endif
2523- ++filename;
2524- }
2525-
2526- if (filename[0] == '\0' && dirlen > 1)
2527- /* "pattern/". Expand "pattern", appending slashes. */
2528- {
2529- int val = glob (dirname, flags | GLOB_MARK, errfunc, pglob);
2530- if (val == 0)
2531- pglob->gl_flags = (pglob->gl_flags & ~GLOB_MARK) | (flags & GLOB_MARK);
2532- return val;
2533- }
2534-
2535- if (!(flags & GLOB_APPEND))
2536- {
2537- pglob->gl_pathc = 0;
2538- pglob->gl_pathv = NULL;
2539- }
2540-
2541- oldcount = pglob->gl_pathc;
2542-
2543-#ifndef VMS
2544- if ((flags & GLOB_TILDE) && dirname[0] == '~')
2545- {
2546- if (dirname[1] == '\0' || dirname[1] == '/')
2547- {
2548- /* Look up home directory. */
2549- char *home_dir = getenv ("HOME");
2550-# ifdef _AMIGA
2551- if (home_dir == NULL || home_dir[0] == '\0')
2552- home_dir = "SYS:";
2553-# else
2554-# ifdef WINDOWS32
2555- if (home_dir == NULL || home_dir[0] == '\0')
2556- home_dir = "c:/users/default"; /* poor default */
2557-# else
2558- if (home_dir == NULL || home_dir[0] == '\0')
2559- {
2560- int success;
2561-# if defined HAVE_GETLOGIN_R || defined _LIBC
2562- extern int getlogin_r __P ((char *, size_t));
2563- size_t buflen = sysconf (_SC_LOGIN_NAME_MAX) + 1;
2564- char *name;
2565-
2566- if (buflen == 0)
2567- /* `sysconf' does not support _SC_LOGIN_NAME_MAX. Try
2568- a moderate value. */
2569- buflen = 16;
2570- name = (char *) __alloca (buflen);
2571-
2572- success = getlogin_r (name, buflen) >= 0;
2573-# else
2574- extern char *getlogin __P ((void));
2575- char *name;
2576-
2577- success = (name = getlogin ()) != NULL;
2578-# endif
2579- if (success)
2580- {
2581-# if defined HAVE_GETPWNAM_R || defined _LIBC
2582- size_t pwbuflen = sysconf (_SC_GETPW_R_SIZE_MAX);
2583- char *pwtmpbuf;
2584- struct passwd pwbuf, *p;
2585-
2586- pwtmpbuf = (char *) __alloca (pwbuflen);
2587-
2588- success = (__getpwnam_r (name, &pwbuf, pwtmpbuf,
2589- pwbuflen, &p) >= 0);
2590-# else
2591- struct passwd *p = getpwnam (name);
2592- success = p != NULL;
2593-# endif
2594- if (success)
2595- home_dir = p->pw_dir;
2596- }
2597- }
2598- if (home_dir == NULL || home_dir[0] == '\0')
2599- home_dir = (char *) "~"; /* No luck. */
2600-# endif /* WINDOWS32 */
2601-# endif
2602- /* Now construct the full directory. */
2603- if (dirname[1] == '\0')
2604- dirname = home_dir;
2605- else
2606- {
2607- char *newp;
2608- size_t home_len = strlen (home_dir);
2609- newp = (char *) __alloca (home_len + dirlen);
2610-# ifdef HAVE_MEMPCPY
2611- mempcpy (mempcpy (newp, home_dir, home_len),
2612- &dirname[1], dirlen);
2613-# else
2614- memcpy (newp, home_dir, home_len);
2615- memcpy (&newp[home_len], &dirname[1], dirlen);
2616-# endif
2617- dirname = newp;
2618- }
2619- }
2620-# if !defined _AMIGA && !defined WINDOWS32
2621- else
2622- {
2623- char *end_name = strchr (dirname, '/');
2624- char *user_name;
2625- char *home_dir;
2626-
2627- if (end_name == NULL)
2628- user_name = dirname + 1;
2629- else
2630- {
2631- user_name = (char *) __alloca (end_name - dirname);
2632-# ifdef HAVE_MEMPCPY
2633- *((char *) mempcpy (user_name, dirname + 1, end_name - dirname))
2634- = '\0';
2635-# else
2636- memcpy (user_name, dirname + 1, end_name - dirname);
2637- user_name[end_name - dirname - 1] = '\0';
2638-# endif
2639- }
2640-
2641- /* Look up specific user's home directory. */
2642- {
2643-# if defined HAVE_GETPWNAM_R || defined _LIBC
2644- size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
2645- char *pwtmpbuf = (char *) __alloca (buflen);
2646- struct passwd pwbuf, *p;
2647- if (__getpwnam_r (user_name, &pwbuf, pwtmpbuf, buflen, &p) >= 0)
2648- home_dir = p->pw_dir;
2649- else
2650- home_dir = NULL;
2651-# else
2652- struct passwd *p = getpwnam (user_name);
2653- if (p != NULL)
2654- home_dir = p->pw_dir;
2655- else
2656- home_dir = NULL;
2657-# endif
2658- }
2659- /* If we found a home directory use this. */
2660- if (home_dir != NULL)
2661- {
2662- char *newp;
2663- size_t home_len = strlen (home_dir);
2664- size_t rest_len = end_name == NULL ? 0 : strlen (end_name);
2665- newp = (char *) __alloca (home_len + rest_len + 1);
2666-# ifdef HAVE_MEMPCPY
2667- *((char *) mempcpy (mempcpy (newp, home_dir, home_len),
2668- end_name, rest_len)) = '\0';
2669-# else
2670- memcpy (newp, home_dir, home_len);
2671- memcpy (&newp[home_len], end_name, rest_len);
2672- newp[home_len + rest_len] = '\0';
2673-# endif
2674- dirname = newp;
2675- }
2676- }
2677-# endif /* Not Amiga && not WINDOWS32. */
2678- }
2679-#endif /* Not VMS. */
2680-
2681- if (__glob_pattern_p (dirname, !(flags & GLOB_NOESCAPE)))
2682- {
2683- /* The directory name contains metacharacters, so we
2684- have to glob for the directory, and then glob for
2685- the pattern in each directory found. */
2686- glob_t dirs;
2687- register int i;
2688-
2689- status = glob (dirname,
2690- ((flags & (GLOB_ERR | GLOB_NOCHECK | GLOB_NOESCAPE))
2691- | GLOB_NOSORT | GLOB_ONLYDIR),
2692- errfunc, &dirs);
2693- if (status != 0)
2694- return status;
2695-
2696- /* We have successfully globbed the preceding directory name.
2697- For each name we found, call glob_in_dir on it and FILENAME,
2698- appending the results to PGLOB. */
2699- for (i = 0; i < dirs.gl_pathc; ++i)
2700- {
2701- int oldcount;
2702-
2703-#ifdef SHELL
2704- {
2705- /* Make globbing interruptible in the bash shell. */
2706- extern int interrupt_state;
2707-
2708- if (interrupt_state)
2709- {
2710- globfree (&dirs);
2711- globfree (&files);
2712- return GLOB_ABORTED;
2713- }
2714- }
2715-#endif /* SHELL. */
2716-
2717- oldcount = pglob->gl_pathc;
2718- status = glob_in_dir (filename, dirs.gl_pathv[i],
2719- ((flags | GLOB_APPEND)
2720- & ~(GLOB_NOCHECK | GLOB_ERR)),
2721- errfunc, pglob);
2722- if (status == GLOB_NOMATCH)
2723- /* No matches in this directory. Try the next. */
2724- continue;
2725-
2726- if (status != 0)
2727- {
2728- globfree (&dirs);
2729- globfree (pglob);
2730- return status;
2731- }
2732-
2733- /* Stick the directory on the front of each name. */
2734- if (prefix_array (dirs.gl_pathv[i],
2735- &pglob->gl_pathv[oldcount],
2736- pglob->gl_pathc - oldcount))
2737- {
2738- globfree (&dirs);
2739- globfree (pglob);
2740- return GLOB_NOSPACE;
2741- }
2742- }
2743-
2744- flags |= GLOB_MAGCHAR;
2745-
2746- if (pglob->gl_pathc == oldcount)
2747- {
2748- /* No matches. */
2749- if (flags & GLOB_NOCHECK)
2750- {
2751- size_t len = strlen (pattern) + 1;
2752- char *patcopy = (char *) malloc (len);
2753- if (patcopy == NULL)
2754- return GLOB_NOSPACE;
2755- memcpy (patcopy, pattern, len);
2756-
2757- pglob->gl_pathv
2758- = (char **) realloc (pglob->gl_pathv,
2759- (pglob->gl_pathc +
2760- ((flags & GLOB_DOOFFS) ?
2761- pglob->gl_offs : 0) +
2762- 1 + 1) *
2763- sizeof (char *));
2764- if (pglob->gl_pathv == NULL)
2765- {
2766- free (patcopy);
2767- return GLOB_NOSPACE;
2768- }
2769-
2770- if (flags & GLOB_DOOFFS)
2771- while (pglob->gl_pathc < pglob->gl_offs)
2772- pglob->gl_pathv[pglob->gl_pathc++] = NULL;
2773-
2774- pglob->gl_pathv[pglob->gl_pathc++] = patcopy;
2775- pglob->gl_pathv[pglob->gl_pathc] = NULL;
2776- pglob->gl_flags = flags;
2777- }
2778- else {
2779- return GLOB_NOMATCH;
2780- }
2781- }
2782- }
2783- else
2784- {
2785- status = glob_in_dir (filename, dirname, flags, errfunc, pglob);
2786- if (status != 0)
2787- return status;
2788-
2789- if (dirlen > 0)
2790- {
2791- /* Stick the directory on the front of each name. */
2792- if (prefix_array (dirname,
2793- &pglob->gl_pathv[oldcount],
2794- pglob->gl_pathc - oldcount))
2795- {
2796- globfree (pglob);
2797- return GLOB_NOSPACE;
2798- }
2799- }
2800- }
2801-
2802- if (flags & GLOB_MARK)
2803- {
2804- /* Append slashes to directory names. */
2805- int i;
2806- struct stat st;
2807- for (i = oldcount; i < pglob->gl_pathc; ++i)
2808- if (((flags & GLOB_ALTDIRFUNC) ?
2809- (*pglob->gl_stat) (pglob->gl_pathv[i], &st) :
2810- __stat (pglob->gl_pathv[i], &st)) == 0 &&
2811- S_ISDIR (st.st_mode))
2812- {
2813- size_t len = strlen (pglob->gl_pathv[i]) + 2;
2814- char *new = realloc (pglob->gl_pathv[i], len);
2815- if (new == NULL)
2816- {
2817- globfree (pglob);
2818- return GLOB_NOSPACE;
2819- }
2820- strncpy (&new[len - 2], "/", 2);
2821- pglob->gl_pathv[i] = new;
2822- }
2823- }
2824-
2825- if (!(flags & GLOB_NOSORT))
2826- /* Sort the vector. */
2827- qsort ((__ptr_t) &pglob->gl_pathv[oldcount],
2828- pglob->gl_pathc - oldcount,
2829- sizeof (char *), collated_compare);
2830-
2831- return 0;
2832-}
2833-
2834-
2835-/* Free storage allocated in PGLOB by a previous `glob' call. */
2836-void
2837-globfree (pglob)
2838- register glob_t *pglob;
2839-{
2840- if (pglob->gl_pathv != NULL)
2841- {
2842- register int i;
2843- for (i = 0; i < pglob->gl_pathc; ++i)
2844- if (pglob->gl_pathv[i] != NULL)
2845- free ((__ptr_t) pglob->gl_pathv[i]);
2846- free ((__ptr_t) pglob->gl_pathv);
2847- }
2848-}
2849-
2850-
2851-/* Do a collated comparison of A and B. */
2852-static int
2853-collated_compare (a, b)
2854- const __ptr_t a;
2855- const __ptr_t b;
2856-{
2857- const char *const s1 = *(const char *const * const) a;
2858- const char *const s2 = *(const char *const * const) b;
2859-
2860- if (s1 == s2)
2861- return 0;
2862- if (s1 == NULL)
2863- return 1;
2864- if (s2 == NULL)
2865- return -1;
2866- return strcoll (s1, s2);
2867-}
2868-
2869-
2870-/* Prepend DIRNAME to each of N members of ARRAY, replacing ARRAY's
2871- elements in place. Return nonzero if out of memory, zero if successful.
2872- A slash is inserted between DIRNAME and each elt of ARRAY,
2873- unless DIRNAME is just "/". Each old element of ARRAY is freed. */
2874-static int
2875-prefix_array (dirname, array, n)
2876- const char *dirname;
2877- char **array;
2878- size_t n;
2879-{
2880- register size_t i;
2881- size_t dirlen = strlen (dirname);
2882-
2883- if (dirlen == 1 && dirname[0] == '/')
2884- /* DIRNAME is just "/", so normal prepending would get us "//foo".
2885- We want "/foo" instead, so don't prepend any chars from DIRNAME. */
2886- dirlen = 0;
2887-
2888- for (i = 0; i < n; ++i)
2889- {
2890- size_t eltlen = strlen (array[i]) + 1;
2891- char *new = (char *) malloc (dirlen + 1 + eltlen);
2892- if (new == NULL)
2893- {
2894- while (i > 0)
2895- free ((__ptr_t) array[--i]);
2896- return 1;
2897- }
2898-
2899-#ifdef HAVE_MEMPCPY
2900- {
2901- char *endp = (char *) mempcpy (new, dirname, dirlen);
2902- *endp++ = '/';
2903- mempcpy (endp, array[i], eltlen);
2904- }
2905-#else
2906- memcpy (new, dirname, dirlen);
2907- new[dirlen] = '/';
2908- memcpy (&new[dirlen + 1], array[i], eltlen);
2909-#endif
2910- free ((__ptr_t) array[i]);
2911- array[i] = new;
2912- }
2913-
2914- return 0;
2915-}
2916-
2917-
2918-/* Return nonzero if PATTERN contains any metacharacters.
2919- Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
2920-int
2921-__glob_pattern_p (pattern, quote)
2922- const char *pattern;
2923- int quote;
2924-{
2925- register const char *p;
2926- int open = 0;
2927-
2928- for (p = pattern; *p != '\0'; ++p)
2929- switch (*p)
2930- {
2931- case '?':
2932- case '*':
2933- return 1;
2934-
2935- case '\\':
2936- if (quote && p[1] != '\0')
2937- ++p;
2938- break;
2939-
2940- case '[':
2941- open = 1;
2942- break;
2943-
2944- case ']':
2945- if (open)
2946- return 1;
2947- break;
2948- }
2949-
2950- return 0;
2951-}
2952-#ifdef _LIBC
2953-weak_alias (__glob_pattern_p, glob_pattern_p)
2954-#endif
2955-
2956-
2957-/* Like `glob', but PATTERN is a final pathname component,
2958- and matches are searched for in DIRECTORY.
2959- The GLOB_NOSORT bit in FLAGS is ignored. No sorting is ever done.
2960- The GLOB_APPEND flag is assumed to be set (always appends). */
2961-static int
2962-glob_in_dir (pattern, directory, flags, errfunc, pglob)
2963- const char *pattern;
2964- const char *directory;
2965- int flags;
2966- int (*errfunc) __P ((const char *, int));
2967- glob_t *pglob;
2968-{
2969- __ptr_t stream;
2970-
2971- struct globlink
2972- {
2973- struct globlink *next;
2974- char *name;
2975- };
2976- struct globlink *names = NULL;
2977- size_t nfound;
2978- int meta;
2979- int save;
2980-
2981- stream = ((flags & GLOB_ALTDIRFUNC) ?
2982- (*pglob->gl_opendir) (directory) :
2983- (__ptr_t) opendir (directory));
2984- if (stream == NULL)
2985- {
2986- if ((errfunc != NULL && (*errfunc) (directory, errno)) ||
2987- (flags & GLOB_ERR))
2988- return GLOB_ABORTED;
2989- nfound = 0;
2990- meta = 0;
2991- }
2992- else if (pattern[0] == '\0')
2993- {
2994- /* This is a special case for matching directories like in
2995- "*a/". */
2996- names = (struct globlink *) __alloca (sizeof (struct globlink));
2997- names->name = (char *) malloc (1);
2998- if (names->name == NULL)
2999- goto memory_error;
3000- names->name[0] = '\0';
3001- names->next = NULL;
3002- nfound = 1;
3003- meta = 0;
3004- }
3005- else
3006- {
3007- nfound = 0;
3008- meta = __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE));
3009- if(meta)
3010- flags |= GLOB_MAGCHAR;
3011-
3012- while (1)
3013- {
3014- const char *name;
3015- size_t len;
3016- struct dirent *d = ((flags & GLOB_ALTDIRFUNC) ?
3017- (*pglob->gl_readdir) (stream) :
3018- readdir ((DIR *) stream));
3019- if (d == NULL)
3020- break;
3021- if (! REAL_DIR_ENTRY (d))
3022- continue;
3023-
3024-#ifdef HAVE_D_TYPE
3025- /* If we shall match only directories use the information
3026- provided by the dirent call if possible. */
3027- if ((flags & GLOB_ONLYDIR)
3028- && d->d_type != DT_UNKNOWN && d->d_type != DT_DIR)
3029- continue;
3030-#endif
3031-
3032- name = d->d_name;
3033-
3034- if ((!meta && strcmp (pattern, name) == 0)
3035- || pr_fnmatch (pattern, name,
3036- (!(flags & GLOB_PERIOD) ? PR_FNM_PERIOD : 0) |
3037- ((flags & GLOB_NOESCAPE) ? PR_FNM_NOESCAPE : 0)
3038-#ifdef _AMIGA
3039- | FNM_CASEFOLD
3040-#endif
3041- ) == 0)
3042- {
3043- struct globlink *new
3044- = (struct globlink *) __alloca (sizeof (struct globlink));
3045- len = NAMLEN (d);
3046- new->name = (char *) malloc (len + 1);
3047- if (new->name == NULL)
3048- goto memory_error;
3049-#ifdef HAVE_MEMPCPY
3050- *((char *) mempcpy ((__ptr_t) new->name, name, len)) = '\0';
3051-#else
3052- memcpy ((__ptr_t) new->name, name, len);
3053- new->name[len] = '\0';
3054-#endif
3055- new->next = names;
3056- names = new;
3057- ++nfound;
3058- if (!meta)
3059- break;
3060- }
3061- }
3062- }
3063-
3064- if (nfound == 0 && (flags & GLOB_NOMAGIC) && !meta)
3065- flags |= GLOB_NOCHECK;
3066-
3067- if (nfound == 0 && (flags & GLOB_NOCHECK))
3068- {
3069- size_t len = strlen (pattern);
3070- nfound = 1;
3071- names = (struct globlink *) __alloca (sizeof (struct globlink));
3072- names->next = NULL;
3073- names->name = (char *) malloc (len + 1);
3074- if (names->name == NULL)
3075- goto memory_error;
3076-#ifdef HAVE_MEMPCPY
3077- *((char *) mempcpy (names->name, pattern, len)) = '\0';
3078-#else
3079- memcpy (names->name, pattern, len);
3080- names->name[len] = '\0';
3081-#endif
3082- }
3083-
3084- if (nfound != 0)
3085- {
3086- pglob->gl_pathv
3087- = (char **) realloc (pglob->gl_pathv,
3088- (pglob->gl_pathc +
3089- ((flags & GLOB_DOOFFS) ? pglob->gl_offs : 0) +
3090- nfound + 1) *
3091- sizeof (char *));
3092- if (pglob->gl_pathv == NULL)
3093- goto memory_error;
3094-
3095- if (flags & GLOB_DOOFFS)
3096- while (pglob->gl_pathc < pglob->gl_offs)
3097- pglob->gl_pathv[pglob->gl_pathc++] = NULL;
3098-
3099- for (; names != NULL; names = names->next)
3100- pglob->gl_pathv[pglob->gl_pathc++] = names->name;
3101- pglob->gl_pathv[pglob->gl_pathc] = NULL;
3102-
3103- pglob->gl_flags = flags;
3104- }
3105-
3106- save = errno;
3107- if(stream) {
3108- if (flags & GLOB_ALTDIRFUNC)
3109- (*pglob->gl_closedir) (stream);
3110- else
3111- closedir ((DIR *) stream);
3112- }
3113- __set_errno (save);
3114-
3115- return nfound == 0 ? GLOB_NOMATCH : 0;
3116-
3117- memory_error:
3118- {
3119- int save = errno;
3120- if (flags & GLOB_ALTDIRFUNC)
3121- (*pglob->gl_closedir) (stream);
3122- else
3123- closedir ((DIR *) stream);
3124- __set_errno (save);
3125- }
3126- while (names != NULL)
3127- {
3128- if (names->name != NULL)
3129- free ((__ptr_t) names->name);
3130- names = names->next;
3131- }
3132- return GLOB_NOSPACE;
3133-}
3134-
3135-#endif /* HAVE_GLOB */
3136diff -urN proftpd-1.2.1/lib/glob.h proftpd-1.2/lib/glob.h
3137--- proftpd-1.2.1/lib/glob.h Sun Oct 18 04:24:41 1998
3138+++ proftpd-1.2/lib/glob.h Thu Jan 1 01:00:00 1970
3139@@ -1,133 +0,0 @@
3140-/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
3141-
3142- The GNU C Library is free software; you can redistribute it and/or
3143- modify it under the terms of the GNU Library General Public License as
3144- published by the Free Software Foundation; either version 2 of the
3145- License, or (at your option) any later version.
3146-
3147- The GNU C Library is distributed in the hope that it will be useful,
3148- but WITHOUT ANY WARRANTY; without even the implied warranty of
3149- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3150- Library General Public License for more details.
3151-
3152- You should have received a copy of the GNU Library General Public
3153- License along with the GNU C Library; see the file COPYING.LIB. If not,
3154- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3155- Boston, MA 02111-1307, USA. */
3156-
3157-#ifndef _GLOB_H
3158-#define _GLOB_H 1
3159-
3160-#ifdef __cplusplus
3161-extern "C"
3162-{
3163-#endif
3164-
3165-#undef __ptr_t
3166-#if (defined __cplusplus || (defined __STDC__ && __STDC__) \
3167- || defined WINDOWS32)
3168-# undef __P
3169-# define __P(protos) protos
3170-# define __ptr_t void *
3171-# if !defined __GNUC__ || __GNUC__ < 2
3172-# undef __const
3173-# define __const const
3174-# endif
3175-#else /* Not C++ or ANSI C. */
3176-# undef __P
3177-# define __P(protos) ()
3178-# undef __const
3179-# define __const
3180-# define __ptr_t char *
3181-#endif /* C++ or ANSI C. */
3182-
3183-/* Bits set in the FLAGS argument to `glob'. */
3184-#define GLOB_ERR (1 << 0)/* Return on read errors. */
3185-#define GLOB_MARK (1 << 1)/* Append a slash to each name. */
3186-#define GLOB_NOSORT (1 << 2)/* Don't sort the names. */
3187-#define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */
3188-#define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */
3189-#define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */
3190-#define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */
3191-#define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */
3192-
3193-#if (!defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _BSD_SOURCE \
3194- || defined _GNU_SOURCE)
3195-# define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */
3196-# define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */
3197-# define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */
3198-# define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */
3199-# define GLOB_TILDE (1 << 12)/* Expand ~user and ~ to home directories. */
3200-# define GLOB_ONLYDIR (1 << 13)/* Match only directories. */
3201-# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
3202- GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
3203- GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \
3204- GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR)
3205-#else
3206-# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
3207- GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
3208- GLOB_PERIOD)
3209-#endif
3210-
3211-/* Error returns from `glob'. */
3212-#define GLOB_NOSPACE 1 /* Ran out of memory. */
3213-#define GLOB_ABORTED 2 /* Read error. */
3214-#define GLOB_NOMATCH 3 /* No matches found. */
3215-
3216-#ifdef _GNU_SOURCE
3217-/* Previous versions of this file defined GLOB_ABEND instead of
3218- GLOB_ABORTED. Provide a compatibility definition here. */
3219-# define GLOB_ABEND GLOB_ABORTED
3220-#endif
3221-
3222-/* Structure describing a globbing run. */
3223-#if !defined _AMIGA && !defined VMS /* Buggy compiler. */
3224-struct stat;
3225-#endif
3226-typedef struct
3227- {
3228- int gl_pathc; /* Count of paths matched by the pattern. */
3229- char **gl_pathv; /* List of matched pathnames. */
3230- int gl_offs; /* Slots to reserve in `gl_pathv'. */
3231- int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
3232-
3233- /* If the GLOB_ALTDIRFUNC flag is set, the following functions
3234- are used instead of the normal file access functions. */
3235- void (*gl_closedir) __P ((void *));
3236- struct dirent *(*gl_readdir) __P ((void *));
3237- __ptr_t (*gl_opendir) __P ((__const char *));
3238- int (*gl_lstat) __P ((__const char *, struct stat *));
3239- int (*gl_stat) __P ((__const char *, struct stat *));
3240- } glob_t;
3241-
3242-/* Do glob searching for PATTERN, placing results in PGLOB.
3243- The bits defined above may be set in FLAGS.
3244- If a directory cannot be opened or read and ERRFUNC is not nil,
3245- it is called with the pathname that caused the error, and the
3246- `errno' value from the failing call; if it returns non-zero
3247- `glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
3248- If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
3249- Otherwise, `glob' returns zero. */
3250-extern int glob __P ((__const char *__pattern, int __flags,
3251- int (*__errfunc) __P ((__const char *, int)),
3252- glob_t *__pglob));
3253-
3254-/* Free storage allocated in PGLOB by a previous `glob' call. */
3255-extern void globfree __P ((glob_t *__pglob));
3256-
3257-
3258-#ifdef _GNU_SOURCE
3259-/* Return nonzero if PATTERN contains any metacharacters.
3260- Metacharacters can be quoted with backslashes if QUOTE is nonzero.
3261-
3262- This function is not part of the interface specified by POSIX.2
3263- but several programs want to use it. */
3264-extern int __glob_pattern_p __P ((__const char *__pattern, int __quote));
3265-extern int glob_pattern_p __P ((__const char *__pattern, int __quote));
3266-#endif
3267-
3268-#ifdef __cplusplus
3269-}
3270-#endif
3271-
3272-#endif /* glob.h */
3273diff -urN proftpd-1.2.1/src/fs.c proftpd-1.2/src/fs.c
3274--- proftpd-1.2.1/src/fs.c Sat Feb 3 00:09:26 2001
3275+++ proftpd-1.2/src/fs.c Mon Mar 19 23:11:36 2001
3276@@ -19,7 +19,7 @@
3277 */
3278
3279 /* ProFTPD virtual/modular file-system support
3280- * $Id$
3281+ * $Id$
3282 */
3283
3284 #include "conf.h"
3285@@ -1132,10 +1132,10 @@
3286 flags |= GLOB_ALTDIRFUNC;
3287
3288 pglob->gl_closedir = (void (*)(void*))fs_closedir;
3289- pglob->gl_readdir = fs_readdir;
3290+ pglob->gl_readdir = (void*(*)(void*))fs_readdir;
3291 pglob->gl_opendir = fs_opendir;
3292- pglob->gl_lstat = fs_lstat;
3293- pglob->gl_stat = fs_stat;
3294+ pglob->gl_lstat = (int (*)(const char *,void*))fs_lstat;
3295+ pglob->gl_stat = (int (*)(const char *,void*))fs_stat;
3296 }
3297
3298 return glob(pattern,flags,errfunc,pglob);
3299
This page took 0.471684 seconds and 4 git commands to generate.