1 /* defs.h -- data types and declarations.
2 Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
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)
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
18 #if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
26 #define strrchr rindex
52 # if defined PROTOTYPES || (defined __STDC__ && __STDC__)
53 # define PARAMS(Args) Args
55 # define PARAMS(Args) ()
59 int lstat
PARAMS((const char *__path
, struct stat
*__statbuf
));
60 int stat
PARAMS((const char *__path
, struct stat
*__statbuf
));
62 /* Not char because of type promotion; NeXT gcc can't handle it. */
67 /* Pointer to function returning boolean. */
68 typedef boolean (*PFB
)();
70 /* The number of seconds in a day. */
73 /* Argument structures for predicates. */
92 enum predicate_precedence
104 enum comparison_type kind
;
110 enum comparison_type kind
;
117 short offset
; /* Offset in `vec' of this arg. */
118 short count
; /* Number of path replacements in this arg. */
119 char *origarg
; /* Arg with "{}" intact. */
124 struct path_arg
*paths
; /* Array of args with path replacements. */
125 char **vec
; /* Array of args to pass to program. */
128 /* The format string for a -printf or -fprintf is chopped into one or
129 more `struct segment', linked together into a list.
130 Each stretch of plain text is a segment, and
131 each \c and `%' conversion is a segment. */
133 /* Special values for the `kind' field of `struct segment'. */
134 #define KIND_PLAIN 0 /* Segment containing just plain text. */
135 #define KIND_STOP 1 /* \c -- stop printing and flush output. */
139 int kind
; /* Format chars or KIND_{PLAIN,STOP}. */
140 char *text
; /* Plain text or `%' format string. */
141 int text_len
; /* Length of `text'. */
142 struct segment
*next
; /* Next segment for this predicate. */
147 struct segment
*segment
; /* Linked list of segments. */
148 FILE *stream
; /* Output stream to print on. */
153 /* Pointer to the function that implements this predicate. */
156 /* Only used for debugging, but defined unconditionally so individual
157 modules can be compiled with -DDEBUG. */
160 /* The type of this node. There are two kinds. The first is real
161 predicates ("primaries") such as -perm, -print, or -exec. The
162 other kind is operators for combining predicates. */
163 enum predicate_type p_type
;
165 /* The precedence of this node. Only has meaning for operators. */
166 enum predicate_precedence p_prec
;
168 /* True if this predicate node produces side effects. */
169 boolean side_effects
;
171 /* True if this predicate node requires a stat system call to execute. */
174 /* Information needed by the predicate processor.
175 Next to each member are listed the predicates that use it. */
178 char *str
; /* fstype [i]lname [i]name [i]path */
179 struct re_pattern_buffer
*regex
; /* regex */
180 struct exec_val exec_vec
; /* exec ok */
181 struct long_val info
; /* atime ctime mtime inum links */
182 struct size_val size
; /* size */
183 uid_t uid
; /* user */
184 gid_t gid
; /* group */
185 time_t time
; /* newer */
186 unsigned long perm
; /* perm */
187 unsigned long type
; /* type */
188 FILE *stream
; /* fprint fprint0 */
189 struct format_val printf_vec
; /* printf fprintf */
192 /* The next predicate in the user input sequence,
193 which repesents the order in which the user supplied the
194 predicates on the command line. */
195 struct predicate
*pred_next
;
197 /* The right and left branches from this node in the expression
198 tree, which represents the order in which the nodes should be
200 struct predicate
*pred_left
;
201 struct predicate
*pred_right
;
204 /* find library function declarations. */
207 char *dirname
PARAMS((char *path
));
210 void error
PARAMS((int status
, int errnum
, char *message
, ...));
213 void list_file
PARAMS((char *name
, char *relname
, struct stat
*statp
, FILE *stream
));
214 char *get_link_name
PARAMS((char *name
, char *relname
));
217 char *savedir
PARAMS((char *dir
, unsigned name_size
));
221 char *stpcpy
PARAMS((char *dest
, const char *src
));
225 char *xgetcwd
PARAMS((void));
234 VOID
*xmalloc
PARAMS((size_t n
));
235 VOID
*xrealloc
PARAMS((VOID
*p
, size_t n
));
238 char *xstrdup
PARAMS((char *string
));
240 /* find global function declarations. */
243 char *filesystem_type
PARAMS((char *path
, char *relpath
, struct stat
*statp
));
246 PFB find_parser
PARAMS((char *search_name
));
247 boolean parse_close
PARAMS((char *argv
[], int *arg_ptr
));
248 boolean parse_open
PARAMS((char *argv
[], int *arg_ptr
));
249 boolean parse_print
PARAMS((char *argv
[], int *arg_ptr
));
252 boolean pred_amin
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
253 boolean pred_and
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
254 boolean pred_anewer
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
255 boolean pred_atime
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
256 boolean pred_close
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
257 boolean pred_cmin
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
258 boolean pred_cnewer
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
259 boolean pred_comma
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
260 boolean pred_ctime
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
261 boolean pred_empty
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
262 boolean pred_exec
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
263 boolean pred_false
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
264 boolean pred_fls
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
265 boolean pred_fprint
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
266 boolean pred_fprint0
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
267 boolean pred_fprintf
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
268 boolean pred_fstype
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
269 boolean pred_gid
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
270 boolean pred_group
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
271 boolean pred_ilname
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
272 boolean pred_iname
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
273 boolean pred_inum
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
274 boolean pred_ipath
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
275 boolean pred_links
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
276 boolean pred_lname
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
277 boolean pred_ls
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
278 boolean pred_mmin
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
279 boolean pred_mtime
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
280 boolean pred_name
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
281 boolean pred_negate
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
282 boolean pred_newer
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
283 boolean pred_nogroup
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
284 boolean pred_nouser
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
285 boolean pred_ok
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
286 boolean pred_open
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
287 boolean pred_or
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
288 boolean pred_path
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
289 boolean pred_perm
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
290 boolean pred_print
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
291 boolean pred_print0
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
292 boolean pred_prune
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
293 boolean pred_regex
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
294 boolean pred_size
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
295 boolean pred_true
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
296 boolean pred_type
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
297 boolean pred_uid
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
298 boolean pred_used
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
299 boolean pred_user
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
300 boolean pred_xtype
PARAMS((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
301 char *find_pred_name
PARAMS((PFB pred_func
));
303 void print_tree
PARAMS((struct predicate
*node
, int indent
));
304 void print_list
PARAMS((struct predicate
*node
));
309 get_expr (struct predicate
**input
, short int prev_prec
);
310 boolean opt_expr
PARAMS((struct predicate
**eval_treep
));
311 boolean mark_stat
PARAMS((struct predicate
*tree
));
314 char *base_name
PARAMS((const char *fname
));
315 struct predicate
*get_new_pred
PARAMS((void));
316 struct predicate
*get_new_pred_chk_op
PARAMS((void));
317 struct predicate
*insert_primary
PARAMS((boolean (*pred_func
)()));
318 void usage
PARAMS((char *msg
));
320 extern char *program_name
;
321 extern struct predicate
*predicates
;
322 extern struct predicate
*last_pred
;
323 extern boolean do_dir_first
;
327 extern time_t cur_day_start
;
328 extern boolean full_days
;
329 extern boolean no_leaf_check
;
330 extern boolean stay_on_filesystem
;
331 extern boolean stop_at_current_level
;
332 extern boolean have_stat
;
333 extern char *rel_pathname
;
335 extern char *starting_dir
;
337 extern int starting_desc
;
339 extern int exit_status
;
340 extern int path_length
;
341 extern int (*xstat
) ();
342 extern boolean dereference
;