1 | /* defs.h -- data types and declarations.
|
---|
2 | Copyright (C) 1990, 91, 92, 93, 94, 2000, 2004, 2005, 2006 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2, or (at your option)
|
---|
7 | any later version.
|
---|
8 |
|
---|
9 | This program is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
---|
17 | USA.
|
---|
18 | */
|
---|
19 | #ifndef INC_DEFS_H
|
---|
20 | #define INC_DEFS_H 1
|
---|
21 |
|
---|
22 | #include <config.h>
|
---|
23 | #include <sys/types.h>
|
---|
24 | #include <sys/stat.h>
|
---|
25 | #include <stdio.h>
|
---|
26 |
|
---|
27 | #if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
|
---|
28 | #include <string.h>
|
---|
29 | #else
|
---|
30 | #include <strings.h>
|
---|
31 | #ifndef strchr
|
---|
32 | #define strchr index
|
---|
33 | #endif
|
---|
34 | #ifndef strrchr
|
---|
35 | #define strrchr rindex
|
---|
36 | #endif
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | #include <errno.h>
|
---|
40 | #ifndef errno
|
---|
41 | extern int errno;
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | #ifdef STDC_HEADERS
|
---|
45 | #include <stdlib.h>
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | /* The presence of unistd.h is assumed by gnulib these days, so we
|
---|
49 | * might as well assume it too.
|
---|
50 | */
|
---|
51 | #include <unistd.h>
|
---|
52 |
|
---|
53 | #include <time.h>
|
---|
54 |
|
---|
55 | #if HAVE_LIMITS_H
|
---|
56 | # include <limits.h>
|
---|
57 | #endif
|
---|
58 | #ifndef CHAR_BIT
|
---|
59 | # define CHAR_BIT 8
|
---|
60 | #endif
|
---|
61 |
|
---|
62 | #if HAVE_INTTYPES_H
|
---|
63 | # include <inttypes.h>
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | #include "regex.h"
|
---|
67 |
|
---|
68 | #ifndef S_IFLNK
|
---|
69 | #define lstat stat
|
---|
70 | #endif
|
---|
71 |
|
---|
72 | # ifndef PARAMS
|
---|
73 | # if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
---|
74 | # define PARAMS(Args) Args
|
---|
75 | # else
|
---|
76 | # define PARAMS(Args) ()
|
---|
77 | # endif
|
---|
78 | # endif
|
---|
79 |
|
---|
80 | int lstat PARAMS((const char *__path, struct stat *__statbuf));
|
---|
81 | int stat PARAMS((const char *__path, struct stat *__statbuf));
|
---|
82 |
|
---|
83 | int optionl_stat PARAMS((const char *name, struct stat *p));
|
---|
84 | int optionp_stat PARAMS((const char *name, struct stat *p));
|
---|
85 | int optionh_stat PARAMS((const char *name, struct stat *p));
|
---|
86 | int debug_stat PARAMS((const char *file, struct stat *bufp));
|
---|
87 |
|
---|
88 | int get_statinfo PARAMS((const char *pathname, const char *name, struct stat *p));
|
---|
89 |
|
---|
90 | #if ! defined HAVE_FCHDIR && ! defined fchdir
|
---|
91 | # define fchdir(fd) (-1)
|
---|
92 | #endif
|
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|
96 | #ifndef S_ISUID
|
---|
97 | # define S_ISUID 0004000
|
---|
98 | #endif
|
---|
99 | #ifndef S_ISGID
|
---|
100 | # define S_ISGID 0002000
|
---|
101 | #endif
|
---|
102 | #ifndef S_ISVTX
|
---|
103 | # define S_ISVTX 0001000
|
---|
104 | #endif
|
---|
105 | #ifndef S_IRUSR
|
---|
106 | # define S_IRUSR 0000400
|
---|
107 | #endif
|
---|
108 | #ifndef S_IWUSR
|
---|
109 | # define S_IWUSR 0000200
|
---|
110 | #endif
|
---|
111 | #ifndef S_IXUSR
|
---|
112 | # define S_IXUSR 0000100
|
---|
113 | #endif
|
---|
114 | #ifndef S_IRGRP
|
---|
115 | # define S_IRGRP 0000040
|
---|
116 | #endif
|
---|
117 | #ifndef S_IWGRP
|
---|
118 | # define S_IWGRP 0000020
|
---|
119 | #endif
|
---|
120 | #ifndef S_IXGRP
|
---|
121 | # define S_IXGRP 0000010
|
---|
122 | #endif
|
---|
123 | #ifndef S_IROTH
|
---|
124 | # define S_IROTH 0000004
|
---|
125 | #endif
|
---|
126 | #ifndef S_IWOTH
|
---|
127 | # define S_IWOTH 0000002
|
---|
128 | #endif
|
---|
129 | #ifndef S_IXOTH
|
---|
130 | # define S_IXOTH 0000001
|
---|
131 | #endif
|
---|
132 |
|
---|
133 | #define MODE_WXUSR (S_IWUSR | S_IXUSR)
|
---|
134 | #define MODE_R (S_IRUSR | S_IRGRP | S_IROTH)
|
---|
135 | #define MODE_RW (S_IWUSR | S_IWGRP | S_IWOTH | MODE_R)
|
---|
136 | #define MODE_RWX (S_IXUSR | S_IXGRP | S_IXOTH | MODE_RW)
|
---|
137 | #define MODE_ALL (S_ISUID | S_ISGID | S_ISVTX | MODE_RWX)
|
---|
138 |
|
---|
139 | #if 1
|
---|
140 | #include <stdbool.h>
|
---|
141 | typedef bool boolean;
|
---|
142 | #else
|
---|
143 | /* Not char because of type promotion; NeXT gcc can't handle it. */
|
---|
144 | typedef int boolean;
|
---|
145 | #define true 1
|
---|
146 | #define false 0
|
---|
147 | #endif
|
---|
148 |
|
---|
149 | struct predicate;
|
---|
150 | struct options;
|
---|
151 |
|
---|
152 | /* Pointer to a predicate function. */
|
---|
153 | typedef boolean (*PRED_FUNC)(char *pathname, struct stat *stat_buf, struct predicate *pred_ptr);
|
---|
154 |
|
---|
155 | /* The number of seconds in a day. */
|
---|
156 | #define DAYSECS 86400
|
---|
157 |
|
---|
158 | /* Argument structures for predicates. */
|
---|
159 |
|
---|
160 | enum comparison_type
|
---|
161 | {
|
---|
162 | COMP_GT,
|
---|
163 | COMP_LT,
|
---|
164 | COMP_EQ
|
---|
165 | };
|
---|
166 |
|
---|
167 | enum permissions_type
|
---|
168 | {
|
---|
169 | PERM_AT_LEAST,
|
---|
170 | PERM_ANY,
|
---|
171 | PERM_EXACT
|
---|
172 | };
|
---|
173 |
|
---|
174 | enum predicate_type
|
---|
175 | {
|
---|
176 | NO_TYPE,
|
---|
177 | PRIMARY_TYPE,
|
---|
178 | UNI_OP,
|
---|
179 | BI_OP,
|
---|
180 | OPEN_PAREN,
|
---|
181 | CLOSE_PAREN
|
---|
182 | };
|
---|
183 |
|
---|
184 | enum predicate_precedence
|
---|
185 | {
|
---|
186 | NO_PREC,
|
---|
187 | COMMA_PREC,
|
---|
188 | OR_PREC,
|
---|
189 | AND_PREC,
|
---|
190 | NEGATE_PREC,
|
---|
191 | MAX_PREC
|
---|
192 | };
|
---|
193 |
|
---|
194 | struct long_val
|
---|
195 | {
|
---|
196 | enum comparison_type kind;
|
---|
197 | boolean negative; /* Defined only when representing time_t. */
|
---|
198 | uintmax_t l_val;
|
---|
199 | };
|
---|
200 |
|
---|
201 | struct perm_val
|
---|
202 | {
|
---|
203 | enum permissions_type kind;
|
---|
204 | mode_t val[2];
|
---|
205 | };
|
---|
206 |
|
---|
207 | /* dir_id is used to support loop detection in find.c and
|
---|
208 | * also to support the -samefile test.
|
---|
209 | */
|
---|
210 | struct dir_id
|
---|
211 | {
|
---|
212 | ino_t ino;
|
---|
213 | dev_t dev;
|
---|
214 | };
|
---|
215 |
|
---|
216 | struct size_val
|
---|
217 | {
|
---|
218 | enum comparison_type kind;
|
---|
219 | int blocksize;
|
---|
220 | uintmax_t size;
|
---|
221 | };
|
---|
222 |
|
---|
223 | #define NEW_EXEC 1
|
---|
224 | /*
|
---|
225 | #undef NEW_EXEC
|
---|
226 | */
|
---|
227 |
|
---|
228 | #if !defined(NEW_EXEC)
|
---|
229 | struct path_arg
|
---|
230 | {
|
---|
231 | short offset; /* Offset in `vec' of this arg. */
|
---|
232 | short count; /* Number of path replacements in this arg. */
|
---|
233 | char *origarg; /* Arg with "{}" intact. */
|
---|
234 | };
|
---|
235 | #endif
|
---|
236 |
|
---|
237 | #include "buildcmd.h"
|
---|
238 |
|
---|
239 | struct exec_val
|
---|
240 | {
|
---|
241 | #if defined(NEW_EXEC)
|
---|
242 | /* new-style */
|
---|
243 | boolean multiple; /* -exec {} \+ denotes multiple argument. */
|
---|
244 | struct buildcmd_control ctl;
|
---|
245 | struct buildcmd_state state;
|
---|
246 | char **replace_vec; /* Command arguments (for ";" style) */
|
---|
247 | int num_args;
|
---|
248 | boolean use_current_dir; /* If nonzero, don't chdir to start dir */
|
---|
249 | boolean close_stdin; /* If true, close stdin in the child. */
|
---|
250 | #else
|
---|
251 | struct path_arg *paths; /* Array of args with path replacements. */
|
---|
252 | char **vec; /* Array of args to pass to program. */
|
---|
253 | #endif
|
---|
254 | };
|
---|
255 |
|
---|
256 | /* The format string for a -printf or -fprintf is chopped into one or
|
---|
257 | more `struct segment', linked together into a list.
|
---|
258 | Each stretch of plain text is a segment, and
|
---|
259 | each \c and `%' conversion is a segment. */
|
---|
260 |
|
---|
261 | /* Special values for the `kind' field of `struct segment'. */
|
---|
262 | #define KIND_PLAIN 0 /* Segment containing just plain text. */
|
---|
263 | #define KIND_STOP 1 /* \c -- stop printing and flush output. */
|
---|
264 |
|
---|
265 | struct segment
|
---|
266 | {
|
---|
267 | int kind; /* Format chars or KIND_{PLAIN,STOP}. */
|
---|
268 | char *text; /* Plain text or `%' format string. */
|
---|
269 | int text_len; /* Length of `text'. */
|
---|
270 | struct segment *next; /* Next segment for this predicate. */
|
---|
271 | };
|
---|
272 |
|
---|
273 | struct format_val
|
---|
274 | {
|
---|
275 | struct segment *segment; /* Linked list of segments. */
|
---|
276 | FILE *stream; /* Output stream to print on. */
|
---|
277 | boolean dest_is_tty; /* True if the destination is a terminal. */
|
---|
278 | struct quoting_options *quote_opts;
|
---|
279 | };
|
---|
280 |
|
---|
281 | /* evaluation cost of a predicate */
|
---|
282 | enum EvaluationCost
|
---|
283 | {
|
---|
284 | NeedsNothing,
|
---|
285 | NeedsType,
|
---|
286 | NeedsStatInfo,
|
---|
287 | NeedsLinkName,
|
---|
288 | NeedsAccessInfo,
|
---|
289 | NeedsSyncDiskHit,
|
---|
290 | NeedsEventualExec,
|
---|
291 | NeedsImmediateExec,
|
---|
292 | NeedsUserInteraction,
|
---|
293 | NeedsUnknown,
|
---|
294 | NumEvaluationCosts
|
---|
295 | };
|
---|
296 |
|
---|
297 | struct predicate
|
---|
298 | {
|
---|
299 | /* Pointer to the function that implements this predicate. */
|
---|
300 | PRED_FUNC pred_func;
|
---|
301 |
|
---|
302 | /* Only used for debugging, but defined unconditionally so individual
|
---|
303 | modules can be compiled with -DDEBUG. */
|
---|
304 | char *p_name;
|
---|
305 |
|
---|
306 | /* The type of this node. There are two kinds. The first is real
|
---|
307 | predicates ("primaries") such as -perm, -print, or -exec. The
|
---|
308 | other kind is operators for combining predicates. */
|
---|
309 | enum predicate_type p_type;
|
---|
310 |
|
---|
311 | /* The precedence of this node. Only has meaning for operators. */
|
---|
312 | enum predicate_precedence p_prec;
|
---|
313 |
|
---|
314 | /* True if this predicate node produces side effects.
|
---|
315 | If side_effects are produced
|
---|
316 | then optimization will not be performed */
|
---|
317 | boolean side_effects;
|
---|
318 |
|
---|
319 | /* True if this predicate node requires default print be turned off. */
|
---|
320 | boolean no_default_print;
|
---|
321 |
|
---|
322 | /* True if this predicate node requires a stat system call to execute. */
|
---|
323 | boolean need_stat;
|
---|
324 |
|
---|
325 | /* True if this predicate node requires knowledge of the file type. */
|
---|
326 | boolean need_type;
|
---|
327 |
|
---|
328 | enum EvaluationCost p_cost;
|
---|
329 |
|
---|
330 | /* est_success_rate is a number between 0.0 and 1.0 */
|
---|
331 | float est_success_rate;
|
---|
332 |
|
---|
333 | /* True if this predicate should display control characters literally */
|
---|
334 | boolean literal_control_chars;
|
---|
335 |
|
---|
336 | /* True if this predicate didn't originate from the user. */
|
---|
337 | boolean artificial;
|
---|
338 |
|
---|
339 | /* The raw text of the argument of this predicate. */
|
---|
340 | char *arg_text;
|
---|
341 |
|
---|
342 | /* Information needed by the predicate processor.
|
---|
343 | Next to each member are listed the predicates that use it. */
|
---|
344 | union
|
---|
345 | {
|
---|
346 | char *str; /* fstype [i]lname [i]name [i]path */
|
---|
347 | struct re_pattern_buffer *regex; /* regex */
|
---|
348 | struct exec_val exec_vec; /* exec ok */
|
---|
349 | struct long_val info; /* atime ctime gid inum links mtime
|
---|
350 | size uid */
|
---|
351 | struct size_val size; /* size */
|
---|
352 | uid_t uid; /* user */
|
---|
353 | gid_t gid; /* group */
|
---|
354 | time_t time; /* newer */
|
---|
355 | struct perm_val perm; /* perm */
|
---|
356 | struct dir_id fileid; /* samefile */
|
---|
357 | mode_t type; /* type */
|
---|
358 | FILE *stream; /* ls fls fprint0 */
|
---|
359 | struct format_val printf_vec; /* printf fprintf fprint */
|
---|
360 | } args;
|
---|
361 |
|
---|
362 | /* The next predicate in the user input sequence,
|
---|
363 | which represents the order in which the user supplied the
|
---|
364 | predicates on the command line. */
|
---|
365 | struct predicate *pred_next;
|
---|
366 |
|
---|
367 | /* The right and left branches from this node in the expression
|
---|
368 | tree, which represents the order in which the nodes should be
|
---|
369 | processed. */
|
---|
370 | struct predicate *pred_left;
|
---|
371 | struct predicate *pred_right;
|
---|
372 |
|
---|
373 | const struct parser_table* parser_entry;
|
---|
374 | };
|
---|
375 |
|
---|
376 | /* find.c, ftsfind.c */
|
---|
377 | boolean is_fts_enabled();
|
---|
378 |
|
---|
379 |
|
---|
380 |
|
---|
381 | /* find library function declarations. */
|
---|
382 |
|
---|
383 | /* dirname.c */
|
---|
384 | char *dirname PARAMS((char *path));
|
---|
385 |
|
---|
386 | /* error.c */
|
---|
387 | void error PARAMS((int status, int errnum, char *message, ...));
|
---|
388 |
|
---|
389 | /* listfile.c */
|
---|
390 | char *get_link_name PARAMS((char *name, char *relname));
|
---|
391 |
|
---|
392 | /* stpcpy.c */
|
---|
393 | #if !HAVE_STPCPY
|
---|
394 | char *stpcpy PARAMS((char *dest, const char *src));
|
---|
395 | #endif
|
---|
396 |
|
---|
397 | /* xgetcwd.c */
|
---|
398 | char *xgetcwd PARAMS((void));
|
---|
399 |
|
---|
400 | /* xmalloc.c */
|
---|
401 | #if __STDC__
|
---|
402 | #define VOID void
|
---|
403 | #else
|
---|
404 | #define VOID char
|
---|
405 | #endif
|
---|
406 |
|
---|
407 | /* find global function declarations. */
|
---|
408 |
|
---|
409 | /* find.c */
|
---|
410 | /* SymlinkOption represents the choice of
|
---|
411 | * -P, -L or -P (default) on the command line.
|
---|
412 | */
|
---|
413 | enum SymlinkOption
|
---|
414 | {
|
---|
415 | SYMLINK_NEVER_DEREF, /* Option -P */
|
---|
416 | SYMLINK_ALWAYS_DEREF, /* Option -L */
|
---|
417 | SYMLINK_DEREF_ARGSONLY /* Option -H */
|
---|
418 | };
|
---|
419 | extern enum SymlinkOption symlink_handling; /* defined in find.c. */
|
---|
420 |
|
---|
421 | void set_follow_state PARAMS((enum SymlinkOption opt));
|
---|
422 | void cleanup(void);
|
---|
423 |
|
---|
424 | /* fstype.c */
|
---|
425 | char *filesystem_type PARAMS((const struct stat *statp, const char *path));
|
---|
426 | char * get_mounted_filesystems (void);
|
---|
427 | dev_t * get_mounted_devices PARAMS((size_t *));
|
---|
428 |
|
---|
429 |
|
---|
430 |
|
---|
431 | enum arg_type
|
---|
432 | {
|
---|
433 | ARG_OPTION, /* regular options like -maxdepth */
|
---|
434 | ARG_NOOP, /* does nothing, returns true, internal use only */
|
---|
435 | ARG_POSITIONAL_OPTION, /* options whose position is important (-follow) */
|
---|
436 | ARG_TEST, /* a like -name */
|
---|
437 | ARG_PUNCTUATION, /* like -o or ( */
|
---|
438 | ARG_ACTION /* like -print */
|
---|
439 | };
|
---|
440 |
|
---|
441 |
|
---|
442 | struct parser_table;
|
---|
443 | /* Pointer to a parser function. */
|
---|
444 | typedef boolean (*PARSE_FUNC)(const struct parser_table *p,
|
---|
445 | char *argv[], int *arg_ptr);
|
---|
446 | struct parser_table
|
---|
447 | {
|
---|
448 | enum arg_type type;
|
---|
449 | char *parser_name;
|
---|
450 | PARSE_FUNC parser_func;
|
---|
451 | PRED_FUNC pred_func;
|
---|
452 | };
|
---|
453 |
|
---|
454 | /* parser.c */
|
---|
455 | const struct parser_table* find_parser PARAMS((char *search_name));
|
---|
456 | boolean parse_open PARAMS((const struct parser_table* entry, char *argv[], int *arg_ptr));
|
---|
457 | boolean parse_close PARAMS((const struct parser_table* entry, char *argv[], int *arg_ptr));
|
---|
458 | boolean parse_print PARAMS((const struct parser_table*, char *argv[], int *arg_ptr));
|
---|
459 | void pred_sanity_check PARAMS((const struct predicate *predicates));
|
---|
460 | void parse_begin_user_args PARAMS((char **args, int argno, const struct predicate *last, const struct predicate *predicates));
|
---|
461 | void parse_end_user_args PARAMS((char **args, int argno, const struct predicate *last, const struct predicate *predicates));
|
---|
462 | boolean parse_openparen PARAMS((const struct parser_table* entry, char *argv[], int *arg_ptr));
|
---|
463 | boolean parse_closeparen PARAMS((const struct parser_table* entry, char *argv[], int *arg_ptr));
|
---|
464 |
|
---|
465 | /* pred.c */
|
---|
466 | boolean pred_amin PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
467 | boolean pred_and PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
468 | boolean pred_anewer PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
469 | boolean pred_atime PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
470 | boolean pred_close PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
471 | boolean pred_cmin PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
472 | boolean pred_cnewer PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
473 | boolean pred_comma PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
474 | boolean pred_ctime PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
475 | boolean pred_delete PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
476 | boolean pred_empty PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
477 | boolean pred_exec PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
478 | boolean pred_execdir PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
479 | boolean pred_executable PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
480 | boolean pred_false PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
481 | boolean pred_fls PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
482 | boolean pred_fprint PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
483 | boolean pred_fprint0 PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
484 | boolean pred_fprintf PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
485 | boolean pred_fstype PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
486 | boolean pred_gid PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
487 | boolean pred_group PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
488 | boolean pred_ilname PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
489 | boolean pred_iname PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
490 | boolean pred_inum PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
491 | boolean pred_ipath PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
492 | boolean pred_links PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
493 | boolean pred_lname PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
494 | boolean pred_ls PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
495 | boolean pred_mmin PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
496 | boolean pred_mtime PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
497 | boolean pred_name PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
498 | boolean pred_negate PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
499 | boolean pred_newer PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
500 | boolean pred_nogroup PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
501 | boolean pred_nouser PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
502 | boolean pred_ok PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
503 | boolean pred_okdir PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
504 | boolean pred_open PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
505 | boolean pred_or PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
506 | boolean pred_path PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
507 | boolean pred_perm PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
508 | boolean pred_print PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
509 | boolean pred_print0 PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
510 | boolean pred_prune PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
511 | boolean pred_quit PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
512 | boolean pred_readable PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
513 | boolean pred_regex PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
514 | boolean pred_samefile PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
515 | boolean pred_size PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
516 | boolean pred_true PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
517 | boolean pred_type PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
518 | boolean pred_uid PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
519 | boolean pred_used PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
520 | boolean pred_user PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
521 | boolean pred_writable PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
522 | boolean pred_xtype PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
|
---|
523 |
|
---|
524 |
|
---|
525 |
|
---|
526 | int launch PARAMS((const struct buildcmd_control *ctl,
|
---|
527 | struct buildcmd_state *buildstate));
|
---|
528 |
|
---|
529 |
|
---|
530 | char *find_pred_name PARAMS((PRED_FUNC pred_func));
|
---|
531 |
|
---|
532 |
|
---|
533 |
|
---|
534 | void print_predicate PARAMS((FILE *fp, const struct predicate *p));
|
---|
535 | void print_tree PARAMS((FILE*, struct predicate *node, int indent));
|
---|
536 | void print_list PARAMS((FILE*, struct predicate *node));
|
---|
537 | void print_optlist PARAMS((FILE *fp, const struct predicate *node));
|
---|
538 |
|
---|
539 |
|
---|
540 | /* tree.c */
|
---|
541 | struct predicate * build_expression_tree PARAMS((int argc, char *argv[], int end_of_leading_options));
|
---|
542 | struct predicate * get_eval_tree PARAMS((void));
|
---|
543 | struct predicate *get_new_pred PARAMS((const struct parser_table *entry));
|
---|
544 | struct predicate *get_new_pred_chk_op PARAMS((const struct parser_table *entry));
|
---|
545 | float calculate_derived_rates PARAMS((struct predicate *p));
|
---|
546 |
|
---|
547 | /* util.c */
|
---|
548 | struct predicate *insert_primary PARAMS((const struct parser_table *entry));
|
---|
549 | struct predicate *insert_primary_withpred PARAMS((const struct parser_table *entry, PRED_FUNC fptr));
|
---|
550 | void usage PARAMS((FILE *fp, int status, char *msg));
|
---|
551 | extern boolean check_nofollow(void);
|
---|
552 | void complete_pending_execs(struct predicate *p);
|
---|
553 | void complete_pending_execdirs(struct predicate *p);
|
---|
554 | int process_leading_options PARAMS((int argc, char *argv[]));
|
---|
555 | void set_option_defaults PARAMS((struct options *p));
|
---|
556 |
|
---|
557 |
|
---|
558 | /* find.c. */
|
---|
559 | int get_info PARAMS((const char *pathname, const char *name, struct stat *p, struct predicate *pred_ptr));
|
---|
560 | int following_links PARAMS((void));
|
---|
561 | int digest_mode PARAMS((mode_t mode, const char *pathname, const char *name, struct stat *pstat, boolean leaf));
|
---|
562 | boolean default_prints PARAMS((struct predicate *pred));
|
---|
563 | boolean looks_like_expression PARAMS((const char *arg, boolean leading));
|
---|
564 |
|
---|
565 |
|
---|
566 | enum DebugOption
|
---|
567 | {
|
---|
568 | DebugNone = 0,
|
---|
569 | DebugExpressionTree = 1,
|
---|
570 | DebugStat = 2,
|
---|
571 | DebugSearch = 4,
|
---|
572 | DebugTreeOpt = 8,
|
---|
573 | DebugHelp = 16
|
---|
574 | };
|
---|
575 |
|
---|
576 | struct options
|
---|
577 | {
|
---|
578 | /* If true, process directory before contents. True unless -depth given. */
|
---|
579 | boolean do_dir_first;
|
---|
580 |
|
---|
581 | /* If >=0, don't descend more than this many levels of subdirectories. */
|
---|
582 | int maxdepth;
|
---|
583 |
|
---|
584 | /* If >=0, don't process files above this level. */
|
---|
585 | int mindepth;
|
---|
586 |
|
---|
587 | /* If true, do not assume that files in directories with nlink == 2
|
---|
588 | are non-directories. */
|
---|
589 | boolean no_leaf_check;
|
---|
590 |
|
---|
591 | /* If true, don't cross filesystem boundaries. */
|
---|
592 | boolean stay_on_filesystem;
|
---|
593 |
|
---|
594 | /* If true, we ignore the problem where we find that a directory entry
|
---|
595 | * no longer exists by the time we get around to processing it.
|
---|
596 | */
|
---|
597 | boolean ignore_readdir_race;
|
---|
598 |
|
---|
599 | /* If true, pass control characters through. If false, escape them
|
---|
600 | * or turn them into harmless things.
|
---|
601 | */
|
---|
602 | boolean literal_control_chars;
|
---|
603 |
|
---|
604 | /* If true, we issue warning messages
|
---|
605 | */
|
---|
606 | boolean warnings;
|
---|
607 |
|
---|
608 | time_t start_time; /* Time at start of execution. */
|
---|
609 |
|
---|
610 | /* Seconds between 00:00 1/1/70 and either one day before now
|
---|
611 | (the default), or the start of today (if -daystart is given). */
|
---|
612 | time_t cur_day_start;
|
---|
613 |
|
---|
614 | /* If true, cur_day_start has been adjusted to the start of the day. */
|
---|
615 | boolean full_days;
|
---|
616 |
|
---|
617 | int output_block_size; /* Output block size. */
|
---|
618 |
|
---|
619 | /* bitmask for debug options */
|
---|
620 | unsigned long debug_options;
|
---|
621 |
|
---|
622 | enum SymlinkOption symlink_handling;
|
---|
623 |
|
---|
624 |
|
---|
625 | /* Pointer to the function used to stat files. */
|
---|
626 | int (*xstat) (const char *name, struct stat *statbuf);
|
---|
627 |
|
---|
628 |
|
---|
629 | /* Indicate if we can implement safely_chdir() using the O_NOFOLLOW
|
---|
630 | * flag to open(2).
|
---|
631 | */
|
---|
632 | boolean open_nofollow_available;
|
---|
633 |
|
---|
634 | /* The variety of regular expression that we support.
|
---|
635 | * The default is POSIX Basic Regular Expressions, but this
|
---|
636 | * can be changed with the positional option, -regextype.
|
---|
637 | */
|
---|
638 | int regex_options;
|
---|
639 |
|
---|
640 | /* Optimisation level. One is the default.
|
---|
641 | */
|
---|
642 | unsigned short optimisation_level;
|
---|
643 | };
|
---|
644 | extern struct options options;
|
---|
645 |
|
---|
646 |
|
---|
647 | struct state
|
---|
648 | {
|
---|
649 | /* Current depth; 0 means current path is a command line arg. */
|
---|
650 | int curdepth;
|
---|
651 |
|
---|
652 | /* If true, we have called stat on the current path. */
|
---|
653 | boolean have_stat;
|
---|
654 |
|
---|
655 | /* If true, we know the type of the current path. */
|
---|
656 | boolean have_type;
|
---|
657 | mode_t type; /* this is the actual type */
|
---|
658 |
|
---|
659 | /* The file being operated on, relative to the current directory.
|
---|
660 | Used for stat, readlink, remove, and opendir. */
|
---|
661 | char *rel_pathname;
|
---|
662 |
|
---|
663 | /* Length of starting path. */
|
---|
664 | int starting_path_length;
|
---|
665 |
|
---|
666 | /* If true, don't descend past current directory.
|
---|
667 | Can be set by -prune, -maxdepth, and -xdev/-mount. */
|
---|
668 | boolean stop_at_current_level;
|
---|
669 |
|
---|
670 | /* Status value to return to system. */
|
---|
671 | int exit_status;
|
---|
672 | };
|
---|
673 |
|
---|
674 | /* finddata.c */
|
---|
675 | extern struct state state;
|
---|
676 | extern char const *starting_dir;
|
---|
677 | extern int starting_desc;
|
---|
678 | extern char *program_name;
|
---|
679 |
|
---|
680 |
|
---|
681 |
|
---|
682 | #endif
|
---|