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 * 4. Neither the name of the University nor the names of its contributors 171590Srgrimes * may be used to endorse or promote products derived from this software 181590Srgrimes * without specific prior written permission. 191590Srgrimes * 201590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 211590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231590Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 241590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271590Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 301590Srgrimes * SUCH DAMAGE. 311590Srgrimes * 321590Srgrimes * @(#)find.h 8.1 (Berkeley) 6/6/93 3354828Sroberto * $FreeBSD$ 341590Srgrimes */ 351590Srgrimes 3672945Sknu#include <regex.h> 3772945Sknu 3876250Sphk/* forward declarations */ 3976250Sphkstruct _plandata; 4076250Sphkstruct _option; 411590Srgrimes 4276250Sphk/* execute function */ 4392786Smarkmtypedef int exec_f(struct _plandata *, FTSENT *); 4476250Sphk/* create function */ 4576250Sphktypedef struct _plandata *creat_f(struct _option *, char ***); 4676250Sphk 4776250Sphk/* function modifiers */ 4876250Sphk#define F_NEEDOK 0x00000001 /* -ok vs. -exec */ 4976250Sphk#define F_EXECDIR 0x00000002 /* -execdir vs. -exec */ 5076250Sphk#define F_TIME_A 0x00000004 /* one of -atime, -anewer, -newera* */ 5176250Sphk#define F_TIME_C 0x00000008 /* one of -ctime, -cnewer, -newerc* */ 5276250Sphk#define F_TIME2_A 0x00000010 /* one of -newer?a */ 5376250Sphk#define F_TIME2_C 0x00000020 /* one of -newer?c */ 5476250Sphk#define F_TIME2_T 0x00000040 /* one of -newer?t */ 5576250Sphk#define F_MAXDEPTH F_TIME_A /* maxdepth vs. mindepth */ 56129812Seik#define F_DEPTH F_TIME_A /* -depth n vs. -d */ 5776250Sphk/* command line function modifiers */ 5876250Sphk#define F_EQUAL 0x00000000 /* [acm]min [acm]time inum links size */ 5976250Sphk#define F_LESSTHAN 0x00000100 6076250Sphk#define F_GREATER 0x00000200 6176250Sphk#define F_ELG_MASK 0x00000300 6276250Sphk#define F_ATLEAST 0x00000400 /* flags perm */ 6376250Sphk#define F_ANY 0x00000800 /* perm */ 6476250Sphk#define F_MTMASK 0x00003000 6576250Sphk#define F_MTFLAG 0x00000000 /* fstype */ 6676250Sphk#define F_MTTYPE 0x00001000 6776250Sphk#define F_MTUNKNOWN 0x00002000 6876250Sphk#define F_IGNCASE 0x00010000 /* iname ipath iregex */ 6983450Sru#define F_EXACTTIME F_IGNCASE /* -[acm]time units syntax */ 7097736Stjr#define F_EXECPLUS 0x00020000 /* -exec ... {} + */ 71157440Sceri#define F_TIME_B 0x00040000 /* one of -Btime, -Bnewer, -newerB* */ 72157440Sceri#define F_TIME2_B 0x00080000 /* one of -newer?B */ 73176478Simp#define F_LINK 0x00100000 /* lname or ilname */ 7476250Sphk 751590Srgrimes/* node definition */ 761590Srgrimestypedef struct _plandata { 7776250Sphk struct _plandata *next; /* next node */ 7876250Sphk exec_f *execute; /* node evaluation function */ 7976250Sphk int flags; /* private flags */ 801590Srgrimes union { 8176250Sphk gid_t _g_data; /* gid */ 8276250Sphk ino_t _i_data; /* inode */ 8376250Sphk mode_t _m_data; /* mode mask */ 8454828Sroberto struct { 8554828Sroberto u_long _f_flags; 8682972Sru u_long _f_notflags; 8754828Sroberto } fl; 881590Srgrimes nlink_t _l_data; /* link count */ 89129812Seik short _d_data; /* level depth (-1 to N) */ 901590Srgrimes off_t _o_data; /* file size */ 91248446Sjilles struct timespec _t_data; /* time value */ 921590Srgrimes uid_t _u_data; /* uid */ 931590Srgrimes short _mt_data; /* mount flags */ 941590Srgrimes struct _plandata *_p_data[2]; /* PLAN trees */ 951590Srgrimes struct _ex { 961590Srgrimes char **_e_argv; /* argv array */ 971590Srgrimes char **_e_orig; /* original strings */ 981590Srgrimes int *_e_len; /* allocated length */ 9997736Stjr int _e_pbnum; /* base num. of args. used */ 10097736Stjr int _e_ppos; /* number of arguments used */ 10197736Stjr int _e_pnummax; /* max. number of arguments */ 10297736Stjr int _e_psize; /* number of bytes of args. */ 10397736Stjr int _e_pbsize; /* base num. of bytes of args */ 10497736Stjr int _e_psizemax; /* max num. of bytes of args */ 105158572Skrion struct _plandata *_e_next;/* next F_EXECPLUS in tree */ 1061590Srgrimes } ex; 1071590Srgrimes char *_a_data[2]; /* array of char pointers */ 1081590Srgrimes char *_c_data; /* char pointer */ 10972945Sknu regex_t *_re_data; /* regex */ 1101590Srgrimes } p_un; 1111590Srgrimes} PLAN; 1121590Srgrimes#define a_data p_un._a_data 1131590Srgrimes#define c_data p_un._c_data 114129812Seik#define d_data p_un._d_data 11554828Sroberto#define fl_flags p_un.fl._f_flags 11682972Sru#define fl_notflags p_un.fl._f_notflags 11754828Sroberto#define g_data p_un._g_data 1181590Srgrimes#define i_data p_un._i_data 1191590Srgrimes#define l_data p_un._l_data 1201590Srgrimes#define m_data p_un._m_data 1211590Srgrimes#define mt_data p_un._mt_data 1221590Srgrimes#define o_data p_un._o_data 1231590Srgrimes#define p_data p_un._p_data 1241590Srgrimes#define t_data p_un._t_data 1251590Srgrimes#define u_data p_un._u_data 12672945Sknu#define re_data p_un._re_data 1271590Srgrimes#define e_argv p_un.ex._e_argv 1281590Srgrimes#define e_orig p_un.ex._e_orig 1291590Srgrimes#define e_len p_un.ex._e_len 13097736Stjr#define e_pbnum p_un.ex._e_pbnum 13197736Stjr#define e_ppos p_un.ex._e_ppos 13297736Stjr#define e_pnummax p_un.ex._e_pnummax 13397736Stjr#define e_psize p_un.ex._e_psize 13497736Stjr#define e_pbsize p_un.ex._e_pbsize 13597736Stjr#define e_psizemax p_un.ex._e_psizemax 136158572Skrion#define e_next p_un.ex._e_next 1371590Srgrimes 1381590Srgrimestypedef struct _option { 13991400Sdwmalone const char *name; /* option name */ 14076250Sphk creat_f *create; /* create function */ 14176250Sphk exec_f *execute; /* execute function */ 1421590Srgrimes int flags; 1431590Srgrimes} OPTION; 1441590Srgrimes 1451590Srgrimes#include "extern.h" 146