aboutsummaryrefslogtreecommitdiffstats
path: root/include/fts.h
diff options
context:
space:
mode:
authorGarrett Wollman <wollman@FreeBSD.org>2002-09-21 01:28:41 +0000
committerGarrett Wollman <wollman@FreeBSD.org>2002-09-21 01:28:41 +0000
commit0d3bcc2e8068cb87817b732860cbde589ea25347 (patch)
treec2d8e348e30a733b07a594d611c3ba17a5b0e689 /include/fts.h
parent0c7fb5347cd38d724f34bacd8f4992a1ea9cc30d (diff)
downloadsrc-0d3bcc2e8068cb87817b732860cbde589ea25347.tar.gz
src-0d3bcc2e8068cb87817b732860cbde589ea25347.zip
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
Notes
Notes: svn path=/head/; revision=103726
Diffstat (limited to 'include/fts.h')
-rw-r--r--include/fts.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/include/fts.h b/include/fts.h
index 8dd2c4160c10..09c4600a1072 100644
--- a/include/fts.h
+++ b/include/fts.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_ */