find.h revision 72945
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 72945 2001-02-23 16:20:55Z knu $
381590Srgrimes */
391590Srgrimes
4072945Sknu#include <regex.h>
4172945Sknu
421590Srgrimes/* node type */
431590Srgrimesenum ntype {
441590Srgrimes	N_AND = 1, 				/* must start > 0 */
4530395Swosch	N_AMIN, N_ATIME, N_CLOSEPAREN, N_CMIN, N_CTIME, N_DEPTH,
4671422Speter	N_EMPTY, N_EXEC, N_EXECDIR, N_EXPR, N_FLAGS,
4730395Swosch	N_FOLLOW, N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MMIN,
4872945Sknu	N_MTIME, N_NAME, N_INAME, N_PATH, N_IPATH, N_REGEX, N_IREGEX,
4972945Sknu	N_NEWER, N_NOGROUP, N_NOT, N_NOUSER, N_OK, N_OPENPAREN, N_OR,
501590Srgrimes	N_PERM, N_PRINT, N_PRUNE, N_SIZE, N_TYPE, N_USER, N_XDEV,
5161575Sroberto	N_PRINT0, N_DELETE, N_MAXDEPTH, N_MINDEPTH
521590Srgrimes};
531590Srgrimes
541590Srgrimes/* node definition */
551590Srgrimestypedef struct _plandata {
561590Srgrimes	struct _plandata *next;			/* next node */
571590Srgrimes	int (*eval)				/* node evaluation function */
581590Srgrimes	    __P((struct _plandata *, FTSENT *));
591590Srgrimes#define	F_EQUAL		1			/* [acm]time inum links size */
601590Srgrimes#define	F_LESSTHAN	2
611590Srgrimes#define	F_GREATER	3
621590Srgrimes#define	F_NEEDOK	1			/* exec ok */
631590Srgrimes#define	F_MTFLAG	1			/* fstype */
641590Srgrimes#define	F_MTTYPE	2
651590Srgrimes#define	F_ATLEAST	1			/* perm */
6661573Sroberto#define	F_ANY		2			/* perm */
671590Srgrimes	int flags;				/* private flags */
681590Srgrimes	enum ntype type;			/* plan node type */
691590Srgrimes	union {
701590Srgrimes		gid_t _g_data;			/* gid */
711590Srgrimes		ino_t _i_data;			/* inode */
721590Srgrimes		mode_t _m_data;			/* mode mask */
7354828Sroberto		struct {
7454828Sroberto			u_long _f_flags;
7554828Sroberto			u_long _f_mask;
7654828Sroberto		} fl;
771590Srgrimes		nlink_t _l_data;		/* link count */
781590Srgrimes		off_t _o_data;			/* file size */
791590Srgrimes		time_t _t_data;			/* time value */
801590Srgrimes		uid_t _u_data;			/* uid */
811590Srgrimes		short _mt_data;			/* mount flags */
821590Srgrimes		struct _plandata *_p_data[2];	/* PLAN trees */
831590Srgrimes		struct _ex {
841590Srgrimes			char **_e_argv;		/* argv array */
851590Srgrimes			char **_e_orig;		/* original strings */
861590Srgrimes			int *_e_len;		/* allocated length */
871590Srgrimes		} ex;
881590Srgrimes		char *_a_data[2];		/* array of char pointers */
891590Srgrimes		char *_c_data;			/* char pointer */
9072945Sknu		regex_t *_re_data;		/* regex */
911590Srgrimes	} p_un;
921590Srgrimes} PLAN;
931590Srgrimes#define	a_data	p_un._a_data
941590Srgrimes#define	c_data	p_un._c_data
9554828Sroberto#define fl_flags	p_un.fl._f_flags
9654828Sroberto#define fl_mask		p_un.fl._f_mask
9754828Sroberto#define	g_data	p_un._g_data
981590Srgrimes#define	i_data	p_un._i_data
991590Srgrimes#define	l_data	p_un._l_data
1001590Srgrimes#define	m_data	p_un._m_data
1011590Srgrimes#define	mt_data	p_un._mt_data
1021590Srgrimes#define	o_data	p_un._o_data
1031590Srgrimes#define	p_data	p_un._p_data
1041590Srgrimes#define	t_data	p_un._t_data
1051590Srgrimes#define	u_data	p_un._u_data
10672945Sknu#define	re_data	p_un._re_data
1071590Srgrimes#define	e_argv	p_un.ex._e_argv
1081590Srgrimes#define	e_orig	p_un.ex._e_orig
1091590Srgrimes#define	e_len	p_un.ex._e_len
1101590Srgrimes
1111590Srgrimestypedef struct _option {
1121590Srgrimes	char *name;			/* option name */
1131590Srgrimes	enum ntype token;		/* token type */
1141590Srgrimes	PLAN *(*create)();		/* create function: DON'T PROTOTYPE! */
1151590Srgrimes#define	O_NONE		0x01		/* no call required */
1161590Srgrimes#define	O_ZERO		0x02		/* pass: nothing */
1171590Srgrimes#define	O_ARGV		0x04		/* pass: argv, increment argv */
11828914Simp#define	O_ARGVP		0x08		/* pass: *argv, N_OK || N_EXEC || N_EXECDIR */
1191590Srgrimes	int flags;
1201590Srgrimes} OPTION;
1211590Srgrimes
1221590Srgrimes#include "extern.h"
123