find.h revision 61575
11590Srgrimes/*-
21590Srgrimes * Copyright (c) 1990, 1993
31590Srgrimes *	The Regents of the University of California.  All rights reserved.
41590Srgrimes *
51590Srgrimes * This code is derived from software contributed to Berkeley by
61590Srgrimes * Cimarron D. Taylor of the University of California, Berkeley.
71590Srgrimes *
81590Srgrimes * Redistribution and use in source and binary forms, with or without
91590Srgrimes * modification, are permitted provided that the following conditions
101590Srgrimes * are met:
111590Srgrimes * 1. Redistributions of source code must retain the above copyright
121590Srgrimes *    notice, this list of conditions and the following disclaimer.
131590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
141590Srgrimes *    notice, this list of conditions and the following disclaimer in the
151590Srgrimes *    documentation and/or other materials provided with the distribution.
161590Srgrimes * 3. All advertising materials mentioning features or use of this software
171590Srgrimes *    must display the following acknowledgement:
181590Srgrimes *	This product includes software developed by the University of
191590Srgrimes *	California, Berkeley and its contributors.
201590Srgrimes * 4. Neither the name of the University nor the names of its contributors
211590Srgrimes *    may be used to endorse or promote products derived from this software
221590Srgrimes *    without specific prior written permission.
231590Srgrimes *
241590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271590Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
291590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311590Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341590Srgrimes * SUCH DAMAGE.
351590Srgrimes *
361590Srgrimes *	@(#)find.h	8.1 (Berkeley) 6/6/93
3754828Sroberto *	$FreeBSD: head/usr.bin/find/find.h 61575 2000-06-12 11:12:41Z roberto $
381590Srgrimes */
391590Srgrimes
401590Srgrimes/* node type */
411590Srgrimesenum ntype {
421590Srgrimes	N_AND = 1, 				/* must start > 0 */
4330395Swosch	N_AMIN, N_ATIME, N_CLOSEPAREN, N_CMIN, N_CTIME, N_DEPTH,
4454828Sroberto	N_EXEC, N_EXECDIR, N_EXPR, N_FLAGS,
4530395Swosch	N_FOLLOW, N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MMIN,
4630395Swosch        N_MTIME, N_NAME,
4728914Simp	N_NEWER, N_NOGROUP, N_NOT, N_NOUSER, N_OK, N_OPENPAREN, N_OR, N_PATH,
481590Srgrimes	N_PERM, N_PRINT, N_PRUNE, N_SIZE, N_TYPE, N_USER, N_XDEV,
4961575Sroberto	N_PRINT0, N_DELETE, N_MAXDEPTH, N_MINDEPTH
501590Srgrimes};
511590Srgrimes
521590Srgrimes/* node definition */
531590Srgrimestypedef struct _plandata {
541590Srgrimes	struct _plandata *next;			/* next node */
551590Srgrimes	int (*eval)				/* node evaluation function */
561590Srgrimes	    __P((struct _plandata *, FTSENT *));
571590Srgrimes#define	F_EQUAL		1			/* [acm]time inum links size */
581590Srgrimes#define	F_LESSTHAN	2
591590Srgrimes#define	F_GREATER	3
601590Srgrimes#define	F_NEEDOK	1			/* exec ok */
611590Srgrimes#define	F_MTFLAG	1			/* fstype */
621590Srgrimes#define	F_MTTYPE	2
631590Srgrimes#define	F_ATLEAST	1			/* perm */
6461573Sroberto#define	F_ANY		2			/* perm */
651590Srgrimes	int flags;				/* private flags */
661590Srgrimes	enum ntype type;			/* plan node type */
671590Srgrimes	union {
681590Srgrimes		gid_t _g_data;			/* gid */
691590Srgrimes		ino_t _i_data;			/* inode */
701590Srgrimes		mode_t _m_data;			/* mode mask */
7154828Sroberto		struct {
7254828Sroberto			u_long _f_flags;
7354828Sroberto			u_long _f_mask;
7454828Sroberto		} fl;
751590Srgrimes		nlink_t _l_data;		/* link count */
761590Srgrimes		off_t _o_data;			/* file size */
771590Srgrimes		time_t _t_data;			/* time value */
781590Srgrimes		uid_t _u_data;			/* uid */
791590Srgrimes		short _mt_data;			/* mount flags */
801590Srgrimes		struct _plandata *_p_data[2];	/* PLAN trees */
811590Srgrimes		struct _ex {
821590Srgrimes			char **_e_argv;		/* argv array */
831590Srgrimes			char **_e_orig;		/* original strings */
841590Srgrimes			int *_e_len;		/* allocated length */
851590Srgrimes		} ex;
861590Srgrimes		char *_a_data[2];		/* array of char pointers */
871590Srgrimes		char *_c_data;			/* char pointer */
881590Srgrimes	} p_un;
891590Srgrimes} PLAN;
901590Srgrimes#define	a_data	p_un._a_data
911590Srgrimes#define	c_data	p_un._c_data
9254828Sroberto#define fl_flags	p_un.fl._f_flags
9354828Sroberto#define fl_mask		p_un.fl._f_mask
9454828Sroberto#define	g_data	p_un._g_data
951590Srgrimes#define	i_data	p_un._i_data
961590Srgrimes#define	l_data	p_un._l_data
971590Srgrimes#define	m_data	p_un._m_data
981590Srgrimes#define	mt_data	p_un._mt_data
991590Srgrimes#define	o_data	p_un._o_data
1001590Srgrimes#define	p_data	p_un._p_data
1011590Srgrimes#define	t_data	p_un._t_data
1021590Srgrimes#define	u_data	p_un._u_data
1031590Srgrimes#define	e_argv	p_un.ex._e_argv
1041590Srgrimes#define	e_orig	p_un.ex._e_orig
1051590Srgrimes#define	e_len	p_un.ex._e_len
1061590Srgrimes
1071590Srgrimestypedef struct _option {
1081590Srgrimes	char *name;			/* option name */
1091590Srgrimes	enum ntype token;		/* token type */
1101590Srgrimes	PLAN *(*create)();		/* create function: DON'T PROTOTYPE! */
1111590Srgrimes#define	O_NONE		0x01		/* no call required */
1121590Srgrimes#define	O_ZERO		0x02		/* pass: nothing */
1131590Srgrimes#define	O_ARGV		0x04		/* pass: argv, increment argv */
11428914Simp#define	O_ARGVP		0x08		/* pass: *argv, N_OK || N_EXEC || N_EXECDIR */
1151590Srgrimes	int flags;
1161590Srgrimes} OPTION;
1171590Srgrimes
1181590Srgrimes#include "extern.h"
119