-#ifndef lint
+#include <gen.h>
+/*#include <grp.h> gen.h*/
+/*#include <pwd.h> gen.h*/
+#include <stdio.h>
+/*#include <strings.h> gen.h*/
+/*#include <sys/dir.h> gen.h*/
+/*#include <sys/errno.h> gen.h*/
+/*#include <sys/exec.h> gen.h*/
+#include <sys/file.h>
+/*#include <sys/param.h> gen.h*/
+/*#include <sys/proc.h> gen.h*/
+/*#include <sys/signal.h> gen.h*/
+#include <sys/stat.h>
+/*#include <sys/time.h> gen.h*/
+/*#include <sys/types.h> gen.h*/
+#include <sys/wait.h>
+/*#include <time.h> gen.h*/
+/*#include <utmp.h> gen.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid = "@(#)find.c 4.17 (Berkeley) 1/31/86";
#endif
-#include <stdio.h>
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <sys/stat.h>
+/*#include <stdio.h>*/
+/*#include <sys/param.h>*/
+/*#include <sys/dir.h>*/
+/*#include <sys/stat.h>*/
#define A_DAY 86400L /* a day full of seconds */
#define EQ(x, y) (strcmp(x, y)==0)
*e2(),
*e3(),
*mk();
-char *nxtarg();
+/*char *nxtarg();*/
char Home[MAXPATHLEN + 1];
long Blocks;
-char *rindex();
-char *sbrk();
+/*char *rindex();*/
+/*char *sbrk();*/
/*
* SEE ALSO: updatedb, bigram.c, code.c
*/
#define AMES 1
-main(argc, argv)
- int argc;
- char *argv[];
-{
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+int main __P((int argc, char *argv[]));
+struct anode *exp __P((void));
+struct anode *e1 __P((void));
+struct anode *e2 __P((void));
+struct anode *e3 __P((void));
+struct anode *mk __P((int (*f)(void), struct anode *l, struct anode *r));
+char *nxtarg __P((void));
+int and __P((register struct anode *p));
+int or __P((register struct anode *p));
+int not __P((register struct anode *p));
+int glob __P((register struct anode *p));
+int print __P((struct anode *p));
+int mtime __P((register struct anode *p));
+int atime __P((register struct anode *p));
+int user __P((register struct anode *p));
+int nouser __P((struct anode *p));
+int ino __P((register struct anode *p));
+int group __P((register struct anode *p));
+int nogroup __P((struct anode *p));
+int links __P((register struct anode *p));
+int size __P((register struct anode *p));
+int perm __P((register struct anode *p));
+int type __P((register struct anode *p));
+int exeq __P((register struct anode *p));
+int ok __P((struct anode *p));
+long mklong __P((short v[]));
+int cpio __P((void));
+int newer __P((struct anode *p));
+int ls __P((struct anode *p));
+int dummy __P((struct anode *p));
+int scomp __P((register a, register b, int s));
+int doex __P((int com));
+int getunum __P((char *f, char *s));
+int descend __P((char *name, char *fname, struct anode *exlist));
+int gmatch __P((register char *s, register char *p));
+int amatch __P((register char *s, register char *p));
+int umatch __P((register char *s, register char *p));
+int bwrite __P((register short *rp, register c));
+int chgreel __P((int x, int fl));
+int fastfind __P((char pathpart[]));
+char *patprep __P((char *name));
+char *getname __P((int uid));
+char *getgroup __P((int gid));
+int _getuid __P((char *username));
+int _getgid __P((char *groupname));
+int list __P((char *file, register struct stat *stp));
+
+int main(argc, argv) int argc; char *argv[]; {
struct anode *exlist;
int paths;
register char *cp, *sp = 0;
else if(EQ(a, "-atime"))
return(mk(atime, (struct anode *)atoi(b), (struct anode *)s));
else if(EQ(a, "-user")) {
- if((i=getuid(b)) == -1) {
+ if((i=_getuid(b)) == -1) {
if(gmatch(b, "[0-9]*"))
return mk(user, (struct anode *)atoi(b), (struct anode *)s);
fprintf(stderr, "find: cannot find -user name\n");
else if(EQ(a, "-inum"))
return(mk(ino, (struct anode *)atoi(b), (struct anode *)s));
else if(EQ(a, "-group")) {
- if((i=getgid(b)) == -1) {
+ if((i=_getgid(b)) == -1) {
if(gmatch(b, "[0-9]*"))
return mk(group, (struct anode *)atoi(b), (struct anode *)s);
fprintf(stderr, "find: cannot find -group name\n");
err: fprintf(stderr, "find: bad option < %s >\n", a);
exit(1);
}
-struct anode *mk(f, l, r)
-int (*f)();
-struct anode *l, *r;
-{
+struct anode *mk(f, l, r) int (*f)(); struct anode *l; struct anode *r; {
if (Nn >= MAXNODES) {
fprintf(stderr, "find: Too many options\n");
exit(1);
}
/* execution time functions */
-and(p)
-register struct anode *p;
-{
+int and(p) register struct anode *p; {
return(((*p->L->F)(p->L)) && ((*p->R->F)(p->R))?1:0);
}
-or(p)
-register struct anode *p;
-{
+int or(p) register struct anode *p; {
return(((*p->L->F)(p->L)) || ((*p->R->F)(p->R))?1:0);
}
-not(p)
-register struct anode *p;
-{
+int not(p) register struct anode *p; {
return( !((*p->L->F)(p->L)));
}
-glob(p)
-register struct anode *p;
-{
+int glob(p) register struct anode *p; {
return(gmatch(Fname, (char *)p->L));
}
-print(p)
-struct anode *p;
-{
+int print(p) struct anode *p; {
puts(Pathname);
return(1);
}
-mtime(p)
-register struct anode *p;
-{
+int mtime(p) register struct anode *p; {
/* p->L is formerly int t */
/* p->R is formerly int s */
return(scomp((int)((Now - Statb.st_mtime) / A_DAY), (int)p->L, (int)p->R));
}
-atime(p)
-register struct anode *p;
-{
+int atime(p) register struct anode *p; {
/* p->L is formerly int t */
/* p->R is formerly int s */
return(scomp((int)((Now - Statb.st_atime) / A_DAY), (int)p->L, (int)p->R));
}
-user(p)
-register struct anode *p;
-{
+int user(p) register struct anode *p; {
/* p->L is formerly int u */
/* p->R is formerly int s */
return(scomp(Statb.st_uid, (int)p->L, (int)p->R));
}
-nouser(p)
-struct anode *p;
-{
+int nouser(p) struct anode *p; {
char *getname();
return (getname(Statb.st_uid) == NULL);
}
-ino(p)
-register struct anode *p;
-{
+int ino(p) register struct anode *p; {
/* p->L is formerly int u */
/* p->R is formerly int s */
return(scomp((int)Statb.st_ino, (int)p->L, (int)p->R));
}
-group(p)
-register struct anode *p;
-{
+int group(p) register struct anode *p; {
/* p->L is formerly int u */
return((int)p->L == Statb.st_gid);
}
-nogroup(p)
-struct anode *p;
-{
+int nogroup(p) struct anode *p; {
char *getgroup();
return (getgroup(Statb.st_gid) == NULL);
}
-links(p)
-register struct anode *p;
-{
+int links(p) register struct anode *p; {
/* p->L is formerly int link */
/* p->R is formerly int s */
return(scomp(Statb.st_nlink, (int)p->L, (int)p->R));
}
-size(p)
-register struct anode *p;
-{
+int size(p) register struct anode *p; {
/* p->L is formerly int sz */
/* p->R is formerly int s */
return(scomp((int)((Statb.st_size+511)>>9), (int)p->L, (int)p->R));
}
-perm(p)
-register struct anode *p;
-{
+int perm(p) register struct anode *p; {
/* p->L is formerly int per */
/* p->R is formerly int s */
register i;
i = ((int)p->R=='-') ? (int)p->L : 07777; /* '-' means only arg bits */
return((Statb.st_mode & i & 07777) == (int)p->L);
}
-type(p)
-register struct anode *p;
-{
+int type(p) register struct anode *p; {
/* p->L is formerly int per */
return((Statb.st_mode&S_IFMT)==(int)p->L);
}
-exeq(p)
-register struct anode *p;
-{
+int exeq(p) register struct anode *p; {
/* p->L is formerly int com */
fflush(stdout); /* to flush possible `-print' */
return(doex((int)p->L));
}
-ok(p)
-struct anode *p;
-{
+int ok(p) struct anode *p; {
/* p->L is formerly int com */
char c; int yes;
yes = 0;
#define MKSHORT(v, lv) {U.l=1L;if(U.c[0]) U.l=lv, v[0]=U.s[1], v[1]=U.s[0]; else U.l=lv, v[0]=U.s[0], v[1]=U.s[1];}
union { long l; short s[2]; char c[4]; } U;
-long mklong(v)
-short v[];
-{
+long mklong(v) short v[]; {
U.l = 1;
if(U.c[0] /* VAX */)
U.s[0] = v[1], U.s[1] = v[0];
U.s[0] = v[0], U.s[1] = v[1];
return U.l;
}
-cpio()
-{
+int cpio() {
#define MAGIC 070707
struct header {
short h_magic,
close(ifile);
return;
}
-newer(p)
-struct anode *p;
-{
+int newer(p) struct anode *p; {
return Statb.st_mtime > Newer;
}
-ls(p)
-struct anode *p;
-{
+int ls(p) struct anode *p; {
list(Pathname, &Statb);
return (1);
}
-dummy(p)
-struct anode *p;
-{
+int dummy(p) struct anode *p; {
/* dummy */
return (1);
}
/* support functions */
-scomp(a, b, s) /* funny signed compare */
-register a, b;
-register char s;
-{
+int scomp(a, b, s) /* funny signed compare */ register a; register b; int s; {
if(s == '+')
return(a > b);
if(s == '-')
return(a == b);
}
-doex(com)
-{
+int doex(com) int com; {
register np;
register char *na;
static char *nargv[50];
}
}
-getunum(f, s) char *f, *s; { /* find user/group name and return number */
+int getunum(f, s) char *f; char *s; { /* find user/group name and return number */
register i;
register char *sp;
register c;
return(i);
}
-descend(name, fname, exlist)
- struct anode *exlist;
- char *name, *fname;
-{
+int descend(name, fname, exlist) char *name; char *fname; struct anode *exlist; {
DIR *dir = NULL;
register struct direct *dp;
register char *c1;
return(rv);
}
-gmatch(s, p) /* string match as in glob */
-register char *s, *p;
-{
+int gmatch(s, p) /* string match as in glob */ register char *s; register char *p; {
if (*s=='.' && *p!='.') return(0);
return amatch(s, p);
}
-amatch(s, p)
-register char *s, *p;
-{
+int amatch(s, p) register char *s; register char *p; {
register cc;
int scc, k;
int c, lc;
return(0);
}
-umatch(s, p)
-register char *s, *p;
-{
+int umatch(s, p) register char *s; register char *p; {
if(*p==0) return(1);
while(*s)
if (amatch(s++, p)) return(1);
return(0);
}
-bwrite(rp, c)
-register short *rp;
-register c;
-{
+int bwrite(rp, c) register short *rp; register c; {
register short *wp = Wp;
c = (c+1) >> 1;
}
Wp = wp;
}
-chgreel(x, fl)
-{
+int chgreel(x, fl) int x; int fl; {
register f;
char str[22];
FILE *devtty;
#define OFFSET 14
#define ESCCODE 30
-fastfind ( pathpart )
- char pathpart[];
-{
+int fastfind(pathpart) char pathpart[]; {
register char *p, *s;
register int c;
char *q, *index(), *patprep();
*/
static char globfree[100];
-char *
-patprep ( name )
- char *name;
-{
+char *patprep(name) char *name; {
register char *p, *endmark;
register char *subp = globfree;
/* rest should be done with nameserver or database */
-#include <pwd.h>
-#include <grp.h>
-#include <utmp.h>
+/*#include <pwd.h>*/
+/*#include <grp.h>*/
+/*#include <utmp.h>*/
struct utmp utmp;
#define NMAX (sizeof (utmp.ut_name))
* (or some such) to allow fast access based on a name key.
* If this isn't true, duplicate the code for getgroup().
*/
-char *
-getname(uid)
-{
+char *getname(uid) int uid; {
register struct passwd *pw;
struct passwd *getpwent();
register int cp;
return (nc[cp].name);
}
-char *
-getgroup(gid)
-{
+char *getgroup(gid) int gid; {
register struct group *gr;
static init;
struct group *getgrent();
goto rescan;
}
-int
-getuid(username)
- char *username;
-{
+int _getuid(username) char *username; {
register struct passwd *pw;
struct passwd *getpwnam();
#ifndef NO_PW_STAYOPEN
return (-1);
}
-int
-getgid(groupname)
- char *groupname;
-{
+int _getgid(groupname) char *groupname; {
register struct group *gr;
struct group *getgrnam();
#define permission(who, type) ((type) >> permoffset(who))
#define kbytes(bytes) (((bytes) + 1023) / 1024)
-list(file, stp)
- char *file;
- register struct stat *stp;
-{
+int list(file, stp) char *file; register struct stat *stp; {
char pmode[32], uname[32], gname[32], fsize[32], ftime[32];
char *getname(), *getgroup(), *ctime();
static long special[] = { S_ISUID, 's', S_ISGID, 's', S_ISVTX, 't' };