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