xref: /original-bsd/usr.bin/find/find.h (revision c3e32dec)
1 /*-
2  * Copyright (c) 1990, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Cimarron D. Taylor of the University of California, Berkeley.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)find.h	8.1 (Berkeley) 06/06/93
11  */
12 
13 /* node type */
14 enum ntype {
15 	N_AND = 1, 				/* must start > 0 */
16 	N_ATIME, N_CLOSEPAREN, N_CTIME, N_DEPTH, N_EXEC, N_EXPR, N_FOLLOW,
17 	N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MTIME, N_NAME, N_NEWER,
18 	N_NOGROUP, N_NOT, N_NOUSER, N_OK, N_OPENPAREN, N_OR, N_PATH,
19 	N_PERM, N_PRINT, N_PRUNE, N_SIZE, N_TYPE, N_USER, N_XDEV,
20 };
21 
22 /* node definition */
23 typedef struct _plandata {
24 	struct _plandata *next;			/* next node */
25 	int (*eval)				/* node evaluation function */
26 	    __P((struct _plandata *, FTSENT *));
27 #define	F_EQUAL		1			/* [acm]time inum links size */
28 #define	F_LESSTHAN	2
29 #define	F_GREATER	3
30 #define	F_NEEDOK	1			/* exec ok */
31 #define	F_MTFLAG	1			/* fstype */
32 #define	F_MTTYPE	2
33 #define	F_ATLEAST	1			/* perm */
34 	int flags;				/* private flags */
35 	enum ntype type;			/* plan node type */
36 	union {
37 		gid_t _g_data;			/* gid */
38 		ino_t _i_data;			/* inode */
39 		mode_t _m_data;			/* mode mask */
40 		nlink_t _l_data;		/* link count */
41 		off_t _o_data;			/* file size */
42 		time_t _t_data;			/* time value */
43 		uid_t _u_data;			/* uid */
44 		short _mt_data;			/* mount flags */
45 		struct _plandata *_p_data[2];	/* PLAN trees */
46 		struct _ex {
47 			char **_e_argv;		/* argv array */
48 			char **_e_orig;		/* original strings */
49 			int *_e_len;		/* allocated length */
50 		} ex;
51 		char *_a_data[2];		/* array of char pointers */
52 		char *_c_data;			/* char pointer */
53 	} p_un;
54 } PLAN;
55 #define	a_data	p_un._a_data
56 #define	c_data	p_un._c_data
57 #define	i_data	p_un._i_data
58 #define	g_data	p_un._g_data
59 #define	l_data	p_un._l_data
60 #define	m_data	p_un._m_data
61 #define	mt_data	p_un._mt_data
62 #define	o_data	p_un._o_data
63 #define	p_data	p_un._p_data
64 #define	t_data	p_un._t_data
65 #define	u_data	p_un._u_data
66 #define	e_argv	p_un.ex._e_argv
67 #define	e_orig	p_un.ex._e_orig
68 #define	e_len	p_un.ex._e_len
69 
70 typedef struct _option {
71 	char *name;			/* option name */
72 	enum ntype token;		/* token type */
73 	PLAN *(*create)();		/* create function: DON'T PROTOTYPE! */
74 #define	O_NONE		0x01		/* no call required */
75 #define	O_ZERO		0x02		/* pass: nothing */
76 #define	O_ARGV		0x04		/* pass: argv, increment argv */
77 #define	O_ARGVP		0x08		/* pass: *argv, N_OK || N_EXEC */
78 	int flags;
79 } OPTION;
80 
81 #include "extern.h"
82