xref: /netbsd/external/bsd/mdocml/dist/compat_fts.h (revision b2070ba5)
10511d63cSchristos /*	$OpenBSD: fts.h,v 1.14 2012/12/05 23:19:57 deraadt Exp $	*/
247a17e0dSchristos /*	NetBSD: fts.h,v 1.7 2012/03/01 16:18:51 hans Exp 	*/
30511d63cSchristos 
40511d63cSchristos /*
50511d63cSchristos  * Copyright (c) 1989, 1993
60511d63cSchristos  *	The Regents of the University of California.  All rights reserved.
70511d63cSchristos  *
80511d63cSchristos  * Redistribution and use in source and binary forms, with or without
90511d63cSchristos  * modification, are permitted provided that the following conditions
100511d63cSchristos  * are met:
110511d63cSchristos  * 1. Redistributions of source code must retain the above copyright
120511d63cSchristos  *    notice, this list of conditions and the following disclaimer.
130511d63cSchristos  * 2. Redistributions in binary form must reproduce the above copyright
140511d63cSchristos  *    notice, this list of conditions and the following disclaimer in the
150511d63cSchristos  *    documentation and/or other materials provided with the distribution.
160511d63cSchristos  * 3. Neither the name of the University nor the names of its contributors
170511d63cSchristos  *    may be used to endorse or promote products derived from this software
180511d63cSchristos  *    without specific prior written permission.
190511d63cSchristos  *
200511d63cSchristos  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
210511d63cSchristos  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
220511d63cSchristos  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
230511d63cSchristos  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
240511d63cSchristos  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
250511d63cSchristos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
260511d63cSchristos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
270511d63cSchristos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
280511d63cSchristos  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
290511d63cSchristos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
300511d63cSchristos  * SUCH DAMAGE.
310511d63cSchristos  *
320511d63cSchristos  *	@(#)fts.h	8.3 (Berkeley) 8/14/94
330511d63cSchristos  */
340511d63cSchristos 
350511d63cSchristos #ifndef	_FTS_H_
360511d63cSchristos #define	_FTS_H_
370511d63cSchristos 
380511d63cSchristos typedef struct {
390511d63cSchristos 	struct _ftsent *fts_cur;	/* current node */
400511d63cSchristos 	struct _ftsent *fts_child;	/* linked list of children */
41*b2070ba5Schristos 	struct _ftsent **fts_array;	/* sort array */
420511d63cSchristos 	dev_t fts_dev;			/* starting device # */
430511d63cSchristos 	char *fts_path;			/* path for this descent */
440511d63cSchristos 	size_t fts_pathlen;		/* sizeof(path) */
45*b2070ba5Schristos 	int fts_nitems;			/* elements in the sort array */
46*b2070ba5Schristos 	int (*fts_compar)();		/* compare function */
470511d63cSchristos 
480511d63cSchristos #define	FTS_NOCHDIR	0x0004		/* don't change directories */
490511d63cSchristos #define	FTS_PHYSICAL	0x0010		/* physical walk */
500511d63cSchristos #define	FTS_XDEV	0x0040		/* don't cross devices */
5147a17e0dSchristos #define	FTS_OPTIONMASK	0x0054		/* valid user option mask */
520511d63cSchristos 
530511d63cSchristos #define	FTS_STOP	0x2000		/* (private) unrecoverable error */
540511d63cSchristos 	int fts_options;		/* fts_open options, global flags */
550511d63cSchristos } FTS;
560511d63cSchristos 
570511d63cSchristos typedef struct _ftsent {
580511d63cSchristos 	struct _ftsent *fts_cycle;	/* cycle node */
590511d63cSchristos 	struct _ftsent *fts_parent;	/* parent directory */
600511d63cSchristos 	struct _ftsent *fts_link;	/* next file in directory */
610511d63cSchristos 	char *fts_accpath;		/* access path */
620511d63cSchristos 	char *fts_path;			/* root path */
630511d63cSchristos 	int fts_errno;			/* errno for this node */
640511d63cSchristos 	size_t fts_pathlen;		/* strlen(fts_path) */
650511d63cSchristos 	size_t fts_namelen;		/* strlen(fts_name) */
660511d63cSchristos 
670511d63cSchristos 	ino_t fts_ino;			/* inode */
680511d63cSchristos 	dev_t fts_dev;			/* device */
690511d63cSchristos 	nlink_t fts_nlink;		/* link count */
700511d63cSchristos 
710511d63cSchristos #define	FTS_ROOTPARENTLEVEL	-1
720511d63cSchristos #define	FTS_ROOTLEVEL		 0
730511d63cSchristos #define	FTS_MAXLEVEL		 0x7fffffff
740511d63cSchristos 	int fts_level;		/* depth (-1 to N) */
750511d63cSchristos 
760511d63cSchristos #define	FTS_D		 1		/* preorder directory */
770511d63cSchristos #define	FTS_DC		 2		/* directory that causes cycles */
780511d63cSchristos #define	FTS_DEFAULT	 3		/* none of the above */
790511d63cSchristos #define	FTS_DNR		 4		/* unreadable directory */
800511d63cSchristos #define	FTS_DOT		 5		/* dot or dot-dot */
810511d63cSchristos #define	FTS_DP		 6		/* postorder directory */
820511d63cSchristos #define	FTS_ERR		 7		/* error; errno is set */
830511d63cSchristos #define	FTS_F		 8		/* regular file */
840511d63cSchristos #define	FTS_INIT	 9		/* initialized only */
850511d63cSchristos #define	FTS_NS		10		/* stat(2) failed */
860511d63cSchristos #define	FTS_NSOK	11		/* no stat(2) requested */
870511d63cSchristos #define	FTS_SL		12		/* symbolic link */
880511d63cSchristos 	unsigned short fts_info;	/* user flags for FTSENT structure */
890511d63cSchristos 
900511d63cSchristos #define	FTS_NOINSTR	 3		/* no instructions */
910511d63cSchristos #define	FTS_SKIP	 4		/* discard node */
920511d63cSchristos 	unsigned short fts_instr;	/* fts_set() instructions */
930511d63cSchristos 
940511d63cSchristos 	struct stat *fts_statp;		/* stat(2) information */
950511d63cSchristos 	char fts_name[1];		/* file name */
960511d63cSchristos } FTSENT;
970511d63cSchristos 
9847a17e0dSchristos 
990511d63cSchristos int	 fts_close(FTS *);
100*b2070ba5Schristos FTS	*fts_open(char * const *, int,
101*b2070ba5Schristos 	    int (*)(const FTSENT **, const FTSENT **));
1020511d63cSchristos FTSENT	*fts_read(FTS *);
1030511d63cSchristos int	 fts_set(FTS *, FTSENT *, int);
1040511d63cSchristos 
1050511d63cSchristos #endif /* !_FTS_H_ */
106