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
60 /* Not char because of type promotion; NeXT gcc can't handle it. */
65 /* Pointer to function returning boolean. */
66 typedef boolean (*PFB
)();
68 /* The number of seconds in a day. */
71 /* Argument structures for predicates. */
90 enum predicate_precedence
102 enum comparison_type kind
;
108 enum comparison_type kind
;
115 short offset
; /* Offset in `vec' of this arg. */
116 short count
; /* Number of path replacements in this arg. */
117 char *origarg
; /* Arg with "{}" intact. */
122 struct path_arg
*paths
; /* Array of args with path replacements. */
123 char **vec
; /* Array of args to pass to program. */
126 /* The format string for a -printf or -fprintf is chopped into one or
127 more `struct segment', linked together into a list.
128 Each stretch of plain text is a segment, and
129 each \c and `%' conversion is a segment. */
131 /* Special values for the `kind' field of `struct segment'. */
132 #define KIND_PLAIN 0 /* Segment containing just plain text. */
133 #define KIND_STOP 1 /* \c -- stop printing and flush output. */
137 int kind
; /* Format chars or KIND_{PLAIN,STOP}. */
138 char *text
; /* Plain text or `%' format string. */
139 int text_len
; /* Length of `text'. */
140 struct segment
*next
; /* Next segment for this predicate. */
145 struct segment
*segment
; /* Linked list of segments. */
146 FILE *stream
; /* Output stream to print on. */
151 /* Pointer to the function that implements this predicate. */
154 /* Only used for debugging, but defined unconditionally so individual
155 modules can be compiled with -DDEBUG. */
158 /* The type of this node. There are two kinds. The first is real
159 predicates ("primaries") such as -perm, -print, or -exec. The
160 other kind is operators for combining predicates. */
161 enum predicate_type p_type
;
163 /* The precedence of this node. Only has meaning for operators. */
164 enum predicate_precedence p_prec
;
166 /* True if this predicate node produces side effects. */
167 boolean side_effects
;
169 /* True if this predicate node requires a stat system call to execute. */
172 /* Information needed by the predicate processor.
173 Next to each member are listed the predicates that use it. */
176 char *str
; /* fstype [i]lname [i]name [i]path */
177 struct re_pattern_buffer
*regex
; /* regex */
178 struct exec_val exec_vec
; /* exec ok */
179 struct long_val info
; /* atime ctime mtime inum links */
180 struct size_val size
; /* size */
181 uid_t uid
; /* user */
182 gid_t gid
; /* group */
183 time_t time
; /* newer */
184 unsigned long perm
; /* perm */
185 unsigned long type
; /* type */
186 FILE *stream
; /* fprint fprint0 */
187 struct format_val printf_vec
; /* printf fprintf */
190 /* The next predicate in the user input sequence,
191 which repesents the order in which the user supplied the
192 predicates on the command line. */
193 struct predicate
*pred_next
;
195 /* The right and left branches from this node in the expression
196 tree, which represents the order in which the nodes should be
198 struct predicate
*pred_left
;
199 struct predicate
*pred_right
;
202 /* find library function declarations. */
205 char *dirname
P_((char *path
));
208 void error
P_((int status
, int errnum
, char *message
, ...));
211 void list_file
P_((char *name
, char *relname
, struct stat
*statp
, FILE *stream
));
212 char *get_link_name
P_((char *name
, char *relname
));
215 char *savedir
P_((char *dir
, unsigned name_size
));
219 char *stpcpy
P_((char *dest
, const char *src
));
223 char *xgetcwd
P_((void));
232 VOID
*xmalloc
P_((size_t n
));
233 VOID
*xrealloc
P_((VOID
*p
, size_t n
));
236 char *xstrdup
P_((char *string
));
238 /* find global function declarations. */
241 char *filesystem_type
P_((char *path
, char *relpath
, struct stat
*statp
));
244 PFB find_parser
P_((char *search_name
));
245 boolean parse_close
P_((char *argv
[], int *arg_ptr
));
246 boolean parse_open
P_((char *argv
[], int *arg_ptr
));
247 boolean parse_print
P_((char *argv
[], int *arg_ptr
));
250 boolean pred_amin
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
251 boolean pred_and
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
252 boolean pred_anewer
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
253 boolean pred_atime
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
254 boolean pred_close
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
255 boolean pred_cmin
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
256 boolean pred_cnewer
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
257 boolean pred_comma
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
258 boolean pred_ctime
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
259 boolean pred_empty
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
260 boolean pred_exec
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
261 boolean pred_false
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
262 boolean pred_fls
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
263 boolean pred_fprint
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
264 boolean pred_fprint0
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
265 boolean pred_fprintf
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
266 boolean pred_fstype
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
267 boolean pred_gid
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
268 boolean pred_group
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
269 boolean pred_ilname
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
270 boolean pred_iname
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
271 boolean pred_inum
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
272 boolean pred_ipath
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
273 boolean pred_links
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
274 boolean pred_lname
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
275 boolean pred_ls
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
276 boolean pred_mmin
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
277 boolean pred_mtime
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
278 boolean pred_name
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
279 boolean pred_negate
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
280 boolean pred_newer
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
281 boolean pred_nogroup
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
282 boolean pred_nouser
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
283 boolean pred_ok
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
284 boolean pred_open
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
285 boolean pred_or
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
286 boolean pred_path
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
287 boolean pred_perm
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
288 boolean pred_print
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
289 boolean pred_print0
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
290 boolean pred_prune
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
291 boolean pred_regex
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
292 boolean pred_size
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
293 boolean pred_true
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
294 boolean pred_type
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
295 boolean pred_uid
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
296 boolean pred_used
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
297 boolean pred_user
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
298 boolean pred_xtype
P_((char *pathname
, struct stat
*stat_buf
, struct predicate
*pred_ptr
));
299 char *find_pred_name
P_((PFB pred_func
));
301 void print_tree
P_((struct predicate
*node
, int indent
));
302 void print_list
P_((struct predicate
*node
));
306 struct predicate
*get_expr
P_((struct predicate
**input
, int prev_prec
));
307 boolean opt_expr
P_((struct predicate
**eval_treep
));
308 boolean mark_stat
P_((struct predicate
*tree
));
311 #ifndef HAVE_BASENAME
312 const char *basename
P_((const char *fname
));
314 struct predicate
*get_new_pred
P_((void));
315 struct predicate
*get_new_pred_chk_op
P_((void));
316 struct predicate
*insert_primary
P_((boolean (*pred_func
)()));
317 void usage
P_((char *msg
));
319 extern char *program_name
;
320 extern struct predicate
*predicates
;
321 extern struct predicate
*last_pred
;
322 extern boolean do_dir_first
;
326 extern time_t cur_day_start
;
327 extern boolean full_days
;
328 extern boolean no_leaf_check
;
329 extern boolean stay_on_filesystem
;
330 extern boolean stop_at_current_level
;
331 extern boolean have_stat
;
332 extern char *rel_pathname
;
334 extern char *starting_dir
;
336 extern int starting_desc
;
338 extern int exit_status
;
339 extern int path_length
;
340 extern int (*xstat
) ();
341 extern boolean dereference
;