* glob.c: Remove.

* glob.cc: New file.  Latest glob version from FreeBSD plus Cygwin
	specific changes (__stat64/__stat32, ignore_case_with_glob,
	drop collate functions).
	(glob3): Return GLOB_ABORTED in case directory is unreadable and
	GLOB_ERR is set, as demanded by SUSv3.
	* glob.h: Import latest version from FreeBSD.
This commit is contained in:
Corinna Vinschen
2006-10-17 17:34:56 +00:00
parent c4e12ec359
commit 733c9ed374
3 changed files with 328 additions and 273 deletions

View File

@ -1,5 +1,3 @@
/* $NetBSD: glob.h,v 1.6.2.2 1997/11/04 23:38:33 thorpej Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@ -36,6 +34,7 @@
* SUCH DAMAGE.
*
* @(#)glob.h 8.1 (Berkeley) 6/2/93
* $FreeBSD: /repoman/r/ncvs/src/include/glob.h,v 1.10 2006/05/22 05:57:39 ache Exp $
*/
#ifndef _GLOB_H_
@ -46,9 +45,9 @@
#include <sys/stat.h>
typedef struct {
int gl_pathc; /* Count of total paths so far. */
int gl_matchc; /* Count of paths matching pattern. */
int gl_offs; /* Reserved at beginning of gl_pathv. */
size_t gl_pathc; /* Count of total paths so far. */
size_t gl_matchc; /* Count of paths matching pattern. */
size_t gl_offs; /* Reserved at beginning of gl_pathv. */
int gl_flags; /* Copy of flags parameter to glob. */
char **gl_pathv; /* List of paths matching pattern. */
/* Copy of errfunc parameter to glob. */
@ -59,29 +58,33 @@ typedef struct {
* versions of closedir(3), readdir(3), opendir(3), stat(2)
* and lstat(2).
*/
void (*gl_closedir) __P((void *));
struct dirent *(*gl_readdir) __P((void *));
void *(*gl_opendir) __P((const char *));
#ifdef __LIBC12_SOURCE__
int (*gl_lstat) __P((const char *, struct stat12 *));
int (*gl_stat) __P((const char *, struct stat12 *));
#else
void (*gl_closedir)(void *);
struct dirent *(*gl_readdir)(void *);
void *(*gl_opendir)(const char *);
#if defined (__INSIDE_CYGWIN__)
int (*gl_lstat) ();
int (*gl_stat) ();
int (*gl_lstat) __P((const char *, struct __stat64 *));
int (*gl_stat) __P((const char *, struct __stat64 *));
#else
int (*gl_lstat) __P((const char *, struct stat *));
int (*gl_stat) __P((const char *, struct stat *));
#endif
#endif
} glob_t;
/* Believed to have been introduced in 1003.2-1992 */
#define GLOB_APPEND 0x0001 /* Append to output from previous call. */
#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */
#define GLOB_ERR 0x0004 /* Return on error. */
#define GLOB_MARK 0x0008 /* Append / to matching directories. */
#define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */
#define GLOB_NOSORT 0x0020 /* Don't sort. */
#define GLOB_NOESCAPE 0x2000 /* Disable backslash escaping. */
/* Error values returned by glob(3) */
#define GLOB_NOSPACE (-1) /* Malloc call failed. */
#define GLOB_ABORTED (-2) /* Unignored error. */
#define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK was not set. */
#define GLOB_NOSYS (-4) /* Obsolete: source comptability only. */
#ifndef _POSIX_SOURCE
#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */
@ -90,11 +93,12 @@ typedef struct {
#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */
#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */
#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */
#define GLOB_LIMIT 0x1000 /* Limit memory used by matches to ARG_MAX */
#endif
#define GLOB_LIMIT 0x1000 /* limit number of returned paths */
#define GLOB_NOSPACE (-1) /* Malloc call failed. */
#define GLOB_ABEND (-2) /* Unignored error. */
/* source compatibility, these are the old names */
#define GLOB_MAXPATH GLOB_LIMIT
#define GLOB_ABEND GLOB_ABORTED
#endif /* __BSD_VISIBLE */
__BEGIN_DECLS
@ -104,10 +108,9 @@ __BEGIN_DECLS
#else
# define DLLEXPORT __declspec(dllimport)
#endif
int DLLEXPORT glob(const char *, int, int (*)(const char *, int), glob_t *);
void DLLEXPORT globfree(glob_t *);
#undef DLLEXPORT
int DLLEXPORT glob(const char *, int, int (*)(const char *, int), glob_t *);
void DLLEXPORT globfree(glob_t *);
__END_DECLS
#endif /* !_GLOB_H_ */