diff options
author | wollman <wollman@FreeBSD.org> | 2002-09-21 01:28:41 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 2002-09-21 01:28:41 +0000 |
commit | aa09d8b564991123518bbfec303c1ceb346fc27a (patch) | |
tree | c2d8e348e30a733b07a594d611c3ba17a5b0e689 /lib/libc/gen/fts-compat.h | |
parent | fb1a9a69958da45404a3596741ae5c78ba503d78 (diff) | |
download | FreeBSD-src-aa09d8b564991123518bbfec303c1ceb346fc27a.zip FreeBSD-src-aa09d8b564991123518bbfec303c1ceb346fc27a.tar.gz |
Make the threatened fts(3) ABI fix. FTSENT now avoids the use of the struct
hack, thereby allowing future extensions to the structure (e.g., for extended
attributes) without rebreaking the ABI. FTSENT now contains a pointer to the
parent stream, which fts_compar() can then take advantage of, avoiding the
undefined behavior previously warned about. As a consequence of this change,
the prototype of the comparison function passed to fts_open() has changed
to reflect the required amount of constness for its use. All callers in the
tree are updated to use the correct prototype.
Comparison functions can now make use of the new parent pointer to access
the new stream-specific private data pointer, which is intended to assist
creation of reentrant library routines which use fts(3) internally.
Not objected to in spirit by: -arch
Diffstat (limited to 'lib/libc/gen/fts-compat.h')
-rw-r--r-- | lib/libc/gen/fts-compat.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/libc/gen/fts-compat.h b/lib/libc/gen/fts-compat.h index 8dd2c41..09c4600 100644 --- a/lib/libc/gen/fts-compat.h +++ b/lib/libc/gen/fts-compat.h @@ -47,7 +47,7 @@ typedef struct { int fts_pathlen; /* sizeof(path) */ int fts_nitems; /* elements in the sort array */ int (*fts_compar) /* compare function */ - (const struct _ftsent **, const struct _ftsent **); + (const struct _ftsent * const *, const struct _ftsent * const *); #define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ #define FTS_LOGICAL 0x002 /* logical walk */ @@ -62,6 +62,7 @@ typedef struct { #define FTS_NAMEONLY 0x100 /* (private) child names only */ #define FTS_STOP 0x200 /* (private) unrecoverable error */ int fts_options; /* fts_open options, global flags */ + void *fts_clientptr; /* thunk for sort function */ } FTS; typedef struct _ftsent { @@ -113,7 +114,8 @@ typedef struct _ftsent { u_short fts_instr; /* fts_set() instructions */ struct stat *fts_statp; /* stat(2) information */ - char fts_name[1]; /* file name */ + char *fts_name; /* file name */ + FTS *fts_fts; /* back pointer to main FTS */ } FTSENT; #include <sys/cdefs.h> @@ -121,10 +123,15 @@ typedef struct _ftsent { __BEGIN_DECLS FTSENT *fts_children(FTS *, int); int fts_close(FTS *); +void *fts_get_clientptr(FTS *); +#define fts_get_clientptr(fts) ((fts)->fts_clientptr) +FTS *fts_get_stream(FTSENT *); +#define fts_get_stream(ftsent) ((ftsent)->fts_fts) FTS *fts_open(char * const *, int, - int (*)(const FTSENT **, const FTSENT **)); + int (*)(const FTSENT * const *, const FTSENT * const *)); FTSENT *fts_read(FTS *); int fts_set(FTS *, FTSENT *, int); +void fts_set_clientptr(FTS *, void *); __END_DECLS #endif /* !_FTS_H_ */ |