converted man page
[unix-history] / usr / src / old / whereis / whereis.c
index 1619816..0b1cab4 100644 (file)
@@ -1,38 +1,48 @@
-static char *sccsid = "@(#)whereis.c   4.3 (Berkeley) %G%";
-#include <sys/types.h>
+/*
+ * Copyright (c) 1980, 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1980, 1990 The Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)whereis.c  5.3 (Berkeley) %G%";
+#endif /* not lint */
+
+#include <sys/param.h>
+#include <sys/dir.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <ctype.h>
-#include <sys/dir.h>
-#include <whoami.h>
 
 static char *bindirs[] = {
        "/etc",
        "/bin",
        "/usr/bin",
        "/usr/games",
 
 static char *bindirs[] = {
        "/etc",
        "/bin",
        "/usr/bin",
        "/usr/games",
-#ifdef CSVAX
        "/lib",
        "/usr/ucb",
        "/usr/lib",
        "/usr/local",
        "/usr/new",
        "/usr/old",
        "/lib",
        "/usr/ucb",
        "/usr/lib",
        "/usr/local",
        "/usr/new",
        "/usr/old",
-#endif
-#ifdef CORY
-       "/usr/bin/eecs",
-       "/usr/bin/new",
-       "/usr/bin/v7",
-       "/usr/bin/old",
-       "/usr/bin/UNSUPPORTED",
-#endif
-#ifdef ARPAVAX
-       "/lib",
-       "/usr/ucb",
-       "/usr/lib",
-       "/usr/local",
-       "/usr/new",
-       "/usr/old",
-#endif
+       "/usr/hosts",
+       "/usr/include",
        0
 };
 static char *mandirs[] = {
        0
 };
 static char *mandirs[] = {
@@ -44,40 +54,32 @@ static char *mandirs[] = {
        "/usr/man/man6",
        "/usr/man/man7",
        "/usr/man/man8",
        "/usr/man/man6",
        "/usr/man/man7",
        "/usr/man/man8",
-#ifdef CORY
-       "/usr/man/manu",
-       "/usr/man/manc",
-       "/usr/man/manv7",
-       "/usr/bin/eecs/mane",
-#endif
+       "/usr/man/manl",
+       "/usr/man/mann",
+       "/usr/man/mano",
        0
 };
 static char *srcdirs[]  = {
        0
 };
 static char *srcdirs[]  = {
-       "/usr/src/cmd",
+       "/usr/src/bin",
+       "/usr/src/usr.bin",
+       "/usr/src/etc",
+       "/usr/src/ucb",
        "/usr/src/games",
        "/usr/src/games",
-       "/usr/src/libc/gen",
-       "/usr/src/libc/stdio",
-#ifdef CSVAX
-       "/usr/src/libc/sys",
+       "/usr/src/usr.lib",
+       "/usr/src/lib",
+       "/usr/src/local",
        "/usr/src/new",
        "/usr/src/old",
        "/usr/src/new",
        "/usr/src/old",
-       "/usr/src/local",
+       "/usr/src/include",
+       "/usr/src/lib/libc/gen",
+       "/usr/src/lib/libc/stdio",
+       "/usr/src/lib/libc/sys",
+       "/usr/src/lib/libc/net/common",
+       "/usr/src/lib/libc/net/inet",
+       "/usr/src/lib/libc/net/misc",
+       "/usr/src/ucb/pascal",
+       "/usr/src/ucb/pascal/utilities",
        "/usr/src/undoc",
        "/usr/src/undoc",
-#endif
-#ifdef CORY
-       "/usr/bin/eecs/src",
-       "/usr/src/cmd/v7",
-       "/usr/src/cmd/new",
-       "/usr/src/cmd/old",
-       "/usr/src/cmd/UNSUPPORTED",
-#endif
-#ifdef ARPAVAX
-       "/ra/src/cmd",
-       "/ra/src/new",
-       "/ra/src/old",
-       "/ra/src/libc/gen",
-       "/ra/src/libc/stdio",
-#endif
        0
 };
 
        0
 };
 
@@ -100,12 +102,6 @@ main(argc, argv)
        char *argv[];
 {
 
        char *argv[];
 {
 
-#ifdef CORY
-       if (getuid() == 0)
-               nice(-20);
-       if (((getuid() >> 8) & 0377) > 10)
-               setuid(getuid());
-#endif
        argc--, argv++;
        if (argc == 0) {
 usage:
        argc--, argv++;
        if (argc == 0) {
 usage:
@@ -158,6 +154,7 @@ usage:
                } else
                        lookup(*argv++);
        while (--argc > 0);
                } else
                        lookup(*argv++);
        while (--argc > 0);
+       exit(0);
 }
 
 getlist(argcp, argvp, flagp, cntp)
 }
 
 getlist(argcp, argvp, flagp, cntp)
@@ -287,28 +284,26 @@ find(dirs, cp)
 findin(dir, cp)
        char *dir, *cp;
 {
 findin(dir, cp)
        char *dir, *cp;
 {
-       register FILE *d;
-       struct direct direct;
+       DIR *dirp;
+       struct direct *dp;
 
 
-       d = fopen(dir, "r");
-       if (d == NULL)
+       dirp = opendir(dir);
+       if (dirp == NULL)
                return;
                return;
-       while (fread(&direct, sizeof direct, 1, d) == 1) {
-               if (direct.d_ino == 0)
-                       continue;
-               if (itsit(cp, direct.d_name)) {
+       while ((dp = readdir(dirp)) != NULL) {
+               if (itsit(cp, dp->d_name)) {
                        count++;
                        if (print)
                        count++;
                        if (print)
-                               printf(" %s/%.14s", dir, direct.d_name);
+                               printf(" %s/%s", dir, dp->d_name);
                }
        }
                }
        }
-       fclose(d);
+       closedir(dirp);
 }
 
 itsit(cp, dp)
        register char *cp, *dp;
 {
 }
 
 itsit(cp, dp)
        register char *cp, *dp;
 {
-       register int i = 14;
+       register int i = strlen(dp);
 
        if (dp[0] == 's' && dp[1] == '.' && itsit(cp, dp+2))
                return (1);
 
        if (dp[0] == 's' && dp[1] == '.' && itsit(cp, dp+2))
                return (1);