1 | /* $Id: fts-nt.h 2989 2016-11-01 21:27:14Z bird $ */
|
---|
2 | /** @file
|
---|
3 | * Header for the NT port of BSD fts.h.
|
---|
4 | *
|
---|
5 | * @copyright Copyright (c) 1989, 1993 The Regents of the University of California. All rights reserved.
|
---|
6 | * @copyright NT modifications Copyright (C) 2016 knut st. osmundsen <[email protected]>
|
---|
7 | * @licenses BSD3
|
---|
8 | */
|
---|
9 |
|
---|
10 | /*
|
---|
11 | * Copyright (c) 1989, 1993
|
---|
12 | * The Regents of the University of California. All rights reserved.
|
---|
13 | *
|
---|
14 | * Redistribution and use in source and binary forms, with or without
|
---|
15 | * modification, are permitted provided that the following conditions
|
---|
16 | * are met:
|
---|
17 | * 1. Redistributions of source code must retain the above copyright
|
---|
18 | * notice, this list of conditions and the following disclaimer.
|
---|
19 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
20 | * notice, this list of conditions and the following disclaimer in the
|
---|
21 | * documentation and/or other materials provided with the distribution.
|
---|
22 | * 3. Neither the name of the University nor the names of its contributors
|
---|
23 | * may be used to endorse or promote products derived from this software
|
---|
24 | * without specific prior written permission.
|
---|
25 | *
|
---|
26 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
---|
27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
---|
30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
36 | * SUCH DAMAGE.
|
---|
37 | *
|
---|
38 | * @(#)fts.h 8.3 (Berkeley) 8/14/94
|
---|
39 | * $FreeBSD$
|
---|
40 | *
|
---|
41 | */
|
---|
42 |
|
---|
43 | #ifndef INCLUDED_FTS_NT_H
|
---|
44 | #define INCLUDED_FTS_NT_H
|
---|
45 |
|
---|
46 | #include <sys/types.h>
|
---|
47 | #include <stdint.h>
|
---|
48 | #include "ntstat.h" /* ensure correct stat structure */
|
---|
49 |
|
---|
50 | typedef uint64_t fts_dev_t;
|
---|
51 | typedef uint64_t fts_ino_t;
|
---|
52 | typedef uint32_t fts_nlink_t;
|
---|
53 | #ifdef _WINNT_
|
---|
54 | typedef HANDLE fts_fd_t;
|
---|
55 | #else
|
---|
56 | typedef void * fts_fd_t;
|
---|
57 | #endif
|
---|
58 | #define FTSCALL __cdecl
|
---|
59 |
|
---|
60 | typedef struct {
|
---|
61 | struct _ftsent *fts_cur; /* current node */
|
---|
62 | struct _ftsent *fts_child; /* linked list of children */
|
---|
63 | struct _ftsent **fts_array; /* sort array */
|
---|
64 | fts_dev_t fts_dev; /* starting device # */
|
---|
65 | char *fts_path; /* path for this descent */
|
---|
66 | size_t fts_pathlen; /* sizeof(path) */
|
---|
67 | size_t fts_nitems; /* elements in the sort array */
|
---|
68 | int (FTSCALL *fts_compar) /* compare function */
|
---|
69 | (const struct _ftsent * const *, const struct _ftsent * const *);
|
---|
70 |
|
---|
71 | #define FTS_COMFOLLOW 0x001 /* follow command line symlinks */
|
---|
72 | #define FTS_LOGICAL 0x002 /* logical walk */
|
---|
73 | #define FTS_NOCHDIR 0x004 /* don't change directories */
|
---|
74 | #define FTS_NOSTAT 0x008 /* don't get stat info */
|
---|
75 | #define FTS_PHYSICAL 0x010 /* physical walk */
|
---|
76 | #define FTS_SEEDOT 0x020 /* return dot and dot-dot */
|
---|
77 | #define FTS_XDEV 0x040 /* don't cross devices */
|
---|
78 | #if 0 /* No whiteout on NT. */
|
---|
79 | #define FTS_WHITEOUT 0x080 /* return whiteout information */
|
---|
80 | #endif
|
---|
81 | #define FTS_OPTIONMASK 0x0ff /* valid user option mask */
|
---|
82 |
|
---|
83 | #define FTS_NAMEONLY 0x100 /* (private) child names only */
|
---|
84 | #define FTS_STOP 0x200 /* (private) unrecoverable error */
|
---|
85 | int fts_options; /* fts_open options, global flags */
|
---|
86 | void *fts_clientptr; /* thunk for sort function */
|
---|
87 | } FTS;
|
---|
88 |
|
---|
89 | typedef struct _ftsent {
|
---|
90 | struct _ftsent *fts_cycle; /* cycle node */
|
---|
91 | struct _ftsent *fts_parent; /* parent directory */
|
---|
92 | struct _ftsent *fts_link; /* next file in directory */
|
---|
93 | int64_t fts_number; /* local numeric value */
|
---|
94 | #define fts_bignum fts_number /* XXX non-std, should go away */
|
---|
95 | void *fts_pointer; /* local address value */
|
---|
96 | char *fts_accpath; /* access path */
|
---|
97 | char *fts_path; /* root path */
|
---|
98 | int fts_errno; /* errno for this node */
|
---|
99 | fts_fd_t fts_symfd; /* NT: Normally -1; -2 we followed this symlinked dir */
|
---|
100 | fts_fd_t fts_dirfd; /* NT: Handle to the directory */
|
---|
101 | size_t fts_pathlen; /* strlen(fts_path) */
|
---|
102 | size_t fts_namelen; /* strlen(fts_name) */
|
---|
103 |
|
---|
104 | fts_ino_t fts_ino; /* inode */
|
---|
105 | fts_dev_t fts_dev; /* device */
|
---|
106 | fts_nlink_t fts_nlink; /* link count */
|
---|
107 |
|
---|
108 | #define FTS_ROOTPARENTLEVEL -1
|
---|
109 | #define FTS_ROOTLEVEL 0
|
---|
110 | long fts_level; /* depth (-1 to N) */
|
---|
111 |
|
---|
112 | #define FTS_D 1 /* preorder directory */
|
---|
113 | #define FTS_DC 2 /* directory that causes cycles */
|
---|
114 | #define FTS_DEFAULT 3 /* none of the above */
|
---|
115 | #define FTS_DNR 4 /* unreadable directory */
|
---|
116 | #define FTS_DOT 5 /* dot or dot-dot */
|
---|
117 | #define FTS_DP 6 /* postorder directory */
|
---|
118 | #define FTS_ERR 7 /* error; errno is set */
|
---|
119 | #define FTS_F 8 /* regular file */
|
---|
120 | #define FTS_INIT 9 /* initialized only */
|
---|
121 | #define FTS_NS 10 /* stat(2) failed */
|
---|
122 | #define FTS_NSOK 11 /* no stat(2) requested */
|
---|
123 | #define FTS_SL 12 /* symbolic link */
|
---|
124 | #define FTS_SLNONE 13 /* symbolic link without target */
|
---|
125 | //#define FTS_W 14 /* whiteout object */
|
---|
126 | int fts_info; /* user status for FTSENT structure */
|
---|
127 |
|
---|
128 | #define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */
|
---|
129 | #define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */
|
---|
130 | #define FTS_ISW 0x04 /* this is a whiteout object */
|
---|
131 | unsigned fts_flags; /* private flags for FTSENT structure */
|
---|
132 |
|
---|
133 | #define FTS_AGAIN 1 /* read node again */
|
---|
134 | #define FTS_FOLLOW 2 /* follow symbolic link */
|
---|
135 | #define FTS_NOINSTR 3 /* no instructions */
|
---|
136 | #define FTS_SKIP 4 /* discard node */
|
---|
137 | int fts_instr; /* fts_set() instructions */
|
---|
138 |
|
---|
139 | struct stat *fts_statp; /* stat(2) information */
|
---|
140 | char *fts_name; /* file name */
|
---|
141 | FTS *fts_fts; /* back pointer to main FTS */
|
---|
142 | BirdStat_T fts_stat; /* NT: We always got stat info. */
|
---|
143 | } FTSENT;
|
---|
144 |
|
---|
145 |
|
---|
146 | #ifdef __cplusplus
|
---|
147 | extern "C" {
|
---|
148 | #endif
|
---|
149 | FTSENT *FTSCALL fts_children(FTS *, int);
|
---|
150 | int FTSCALL fts_close(FTS *);
|
---|
151 | void *FTSCALL fts_get_clientptr(FTS *);
|
---|
152 | #define fts_get_clientptr(fts) ((fts)->fts_clientptr)
|
---|
153 | FTS *FTSCALL fts_get_stream(FTSENT *);
|
---|
154 | #define fts_get_stream(ftsent) ((ftsent)->fts_fts)
|
---|
155 | FTS *FTSCALL fts_open(char * const *, int,
|
---|
156 | int (FTSCALL*)(const FTSENT * const *, const FTSENT * const *));
|
---|
157 | FTSENT *FTSCALL fts_read(FTS *);
|
---|
158 | int FTSCALL fts_set(FTS *, FTSENT *, int);
|
---|
159 | void FTSCALL fts_set_clientptr(FTS *, void *);
|
---|
160 | #ifdef __cplusplus
|
---|
161 | }
|
---|
162 | #endif
|
---|
163 |
|
---|
164 | #endif /* !INCLUDED_FTS_NT_H */
|
---|
165 |
|
---|