function.c (389017e544d3ed443f988cf5670b98b65273ed81) | function.c (567664c4a7534c7e998249b59cba10d5395c9086) |
---|---|
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 * Redistribution and use in source and binary forms, with or without --- 22 unchanged lines hidden (view full) --- 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37#ifndef lint 38static char sccsid[] = "@(#)function.c 8.10 (Berkeley) 5/4/95"; | 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 * Redistribution and use in source and binary forms, with or without --- 22 unchanged lines hidden (view full) --- 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37#ifndef lint 38static char sccsid[] = "@(#)function.c 8.10 (Berkeley) 5/4/95"; |
39static char rcsid[] = "$FreeBSD$"; |
|
39#endif /* not lint */ 40 41#include <sys/param.h> 42#include <sys/ucred.h> 43#include <sys/stat.h> 44#include <sys/wait.h> 45#include <sys/mount.h> 46 --- 5 unchanged lines hidden (view full) --- 52#include <pwd.h> 53#include <stdio.h> 54#include <stdlib.h> 55#include <string.h> 56#include <unistd.h> 57 58#include "find.h" 59 | 40#endif /* not lint */ 41 42#include <sys/param.h> 43#include <sys/ucred.h> 44#include <sys/stat.h> 45#include <sys/wait.h> 46#include <sys/mount.h> 47 --- 5 unchanged lines hidden (view full) --- 53#include <pwd.h> 54#include <stdio.h> 55#include <stdlib.h> 56#include <string.h> 57#include <unistd.h> 58 59#include "find.h" 60 |
61int string_to_flags __P((char **, u_long *, u_long *)); 62 |
|
60#define COMPARE(a, b) { \ 61 switch (plan->flags) { \ 62 case F_EQUAL: \ 63 return (a == b); \ 64 case F_LESSTHAN: \ 65 return (a < b); \ 66 case F_GREATER: \ 67 return (a > b); \ --- 872 unchanged lines hidden (view full) --- 940 new = palloc(N_PERM, f_perm); 941 942 if (*perm == '-') { 943 new->flags = F_ATLEAST; 944 ++perm; 945 } 946 947 if ((set = setmode(perm)) == NULL) | 63#define COMPARE(a, b) { \ 64 switch (plan->flags) { \ 65 case F_EQUAL: \ 66 return (a == b); \ 67 case F_LESSTHAN: \ 68 return (a < b); \ 69 case F_GREATER: \ 70 return (a > b); \ --- 872 unchanged lines hidden (view full) --- 943 new = palloc(N_PERM, f_perm); 944 945 if (*perm == '-') { 946 new->flags = F_ATLEAST; 947 ++perm; 948 } 949 950 if ((set = setmode(perm)) == NULL) |
948 err(1, "-perm: %s: illegal mode string", perm); | 951 errx(1, "-perm: %s: illegal mode string", perm); |
949 950 new->m_data = getmode(set, 0); 951 free(set); 952 return (new); 953} 954 955/* | 952 953 new->m_data = getmode(set, 0); 954 free(set); 955 return (new); 956} 957 958/* |
959 * -flags functions -- 960 * 961 * The flags argument is used to represent file flags bits. 962 */ 963int 964f_flags(plan, entry) 965 PLAN *plan; 966 FTSENT *entry; 967{ 968 u_long flags; 969 970 flags = entry->fts_statp->st_flags & 971 (UF_NODUMP | UF_IMMUTABLE | UF_APPEND | UF_OPAQUE | 972 SF_ARCHIVED | SF_IMMUTABLE | SF_APPEND); 973 if (plan->flags == F_ATLEAST) 974 /* note that plan->fl_flags always is a subset of 975 plan->fl_mask */ 976 return (flags & plan->fl_mask) == plan->fl_flags; 977 else 978 return flags == plan->fl_flags; 979 /* NOTREACHED */ 980} 981 982PLAN * 983c_flags(flags_str) 984 char *flags_str; 985{ 986 PLAN *new; 987 u_long flags, notflags; 988 989 ftsoptions &= ~FTS_NOSTAT; 990 991 new = palloc(N_FLAGS, f_flags); 992 993 if (*flags_str == '-') { 994 new->flags = F_ATLEAST; 995 flags_str++; 996 } 997 if (string_to_flags(&flags_str, &flags, ¬flags) == 1) 998 errx(1, "-flags: %s: illegal flags string", flags_str); 999 1000 new->fl_flags = flags; 1001 new->fl_mask = flags | notflags; 1002#if 0 1003 printf("flags = %08x, mask = %08x (%08x, %08x)\n", 1004 new->fl_flags, new->fl_mask, flags, notflags); 1005#endif 1006 return new; 1007} 1008 1009 /* 1010 1011 1012/* |
|
956 * -print functions -- 957 * 958 * Always true, causes the current pathame to be written to 959 * standard output. 960 */ 961int 962f_print(plan, entry) 963 PLAN *plan; --- 381 unchanged lines hidden --- | 1013 * -print functions -- 1014 * 1015 * Always true, causes the current pathame to be written to 1016 * standard output. 1017 */ 1018int 1019f_print(plan, entry) 1020 PLAN *plan; --- 381 unchanged lines hidden --- |