xref: /freebsd/lib/libc/gen/fts-compat15.h (revision 4bd01d6ae01632501b63438b8d9a401db9744a78)
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 1989, 1993
5  *      The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31 
32 #ifndef _FTS_COMPAT15_H_
33 #define _FTS_COMPAT15_H_
34 
35 typedef struct {
36 	struct _ftsent15 *fts_cur;	/* current node */
37 	struct _ftsent15 *fts_child;	/* linked list of children */
38 	struct _ftsent15 **fts_array;	/* sort array */
39 	dev_t		 fts_dev;	/* starting device # */
40 	char		*fts_path;	/* path for this descent */
41 	int		 fts_rfd;	/* fd for root */
42 	__size_t	 fts_pathlen;	/* sizeof(path) */
43 	__size_t	 fts_nitems;	/* elements in the sort array */
44 	union {
45 		int	(*fts_compar)	/* compare function */
46 		    (const struct _ftsent15 * const *,
47 		    const struct _ftsent15 * const *);
48 #ifdef __BLOCKS__
49 		int	(^fts_compar_b)
50 		    (const struct _ftsent15 * const *,
51 		    const struct _ftsent15 * const *);
52 #else
53 		void	*fts_compar_b;
54 #endif
55 	};
56 	int		 fts_options;	/* fts_open options, global flags */
57 	void		*fts_clientptr;	/* thunk for sort function */
58 } FTS15;
59 
60 typedef struct _ftsent15 {
61 	struct _ftsent15 *fts_cycle;	/* cycle node */
62 	struct _ftsent15 *fts_parent;	/* parent directory */
63 	struct _ftsent15 *fts_link;	/* next file in directory */
64 	long long	 fts_number;	/* local numeric value */
65 	void		*fts_pointer;	/* local address value */
66 	char		*fts_accpath;	/* access path */
67 	char		*fts_path;	/* root path */
68 	int		 fts_errno;	/* errno for this node */
69 	int		 fts_symfd;	/* fd for symlink */
70 	__size_t	 fts_pathlen;	/* strlen(fts_path) */
71 	__size_t	 fts_namelen;	/* strlen(fts_name) */
72 	__ino_t		 fts_ino;	/* inode */
73 	__dev_t		 fts_dev;	/* device */
74 	__nlink_t	 fts_nlink;	/* link count */
75 	long		 fts_level;	/* depth (-1 to N) */
76 	int		 fts_info;	/* user status for FTSENT structure */
77 	unsigned	 fts_flags;	/* private flags for FTSENT structure */
78 	int		 fts_instr;	/* fts_set() instructions */
79 	struct stat	*fts_statp;	/* stat(2) information */
80 	char		*fts_name;	/* file name */
81 	FTS15		*fts_fts;	/* back pointer to main FTS */
82 } FTSENT15;
83 
84 FTSENT15	*freebsd15_fts_children(FTS15 *, int);
85 int		 freebsd15_fts_close(FTS15 *);
86 void		*freebsd15_fts_get_clientptr(FTS15 *);
87 #define		 freebsd15_fts_get_clientptr(fts) ((fts)->fts_clientptr)
88 FTS15		*freebsd15_fts_get_stream(FTSENT15 *);
89 #define		 freebsd15_fts_get_stream(ftsent) ((ftsent)->fts_fts)
90 FTS15		*freebsd15_fts_open(char * const *, int,
91 		    int (*)(const FTSENT15 * const *,
92 		    const FTSENT15 * const *));
93 FTSENT15	*freebsd15_fts_read(FTS15 *);
94 int		 freebsd15_fts_set(FTS15 *, FTSENT15 *, int);
95 void		 freebsd15_fts_set_clientptr(FTS15 *, void *);
96 
97 #endif /* !_FTS_COMPAT15_H_ */
98