Tape Blocking via stat, vfile output and linebuffering output
[unix-history] / usr / src / old / whereis / whereis.c
index d17e49e..a88fb8b 100644 (file)
@@ -1,29 +1,37 @@
-static char *sccsid = "@(#)whereis.c   4.2 (Berkeley) %G%";
-#include <sys/types.h>
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1980 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif not lint
+
+#ifndef lint
+static char sccsid[] = "@(#)whereis.c  5.1 (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 CORY
-       "/usr/bin/eecs",
-       "/usr/bin/new",
-       "/usr/bin/v7",
-       "/usr/bin/old",
-       "/usr/bin/UNSUPPORTED",
-#else
        "/lib",
        "/usr/ucb",
        "/usr/lib",
        "/usr/local",
        "/usr/new",
        "/usr/old",
        "/lib",
        "/usr/ucb",
        "/usr/lib",
        "/usr/local",
        "/usr/new",
        "/usr/old",
-#endif
+       "/usr/hosts",
+       "/usr/include",
        0
 };
 static char *mandirs[] = {
        0
 };
 static char *mandirs[] = {
@@ -35,35 +43,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",
-#else
        "/usr/man/manl",
        "/usr/man/manl",
-#endif
-       "/usr/doc",
+       "/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 CORY
-       "/usr/bin/eecs/src",
-       "/usr/src/cmd/v7",
-       "/usr/src/cmd/new",
-       "/usr/src/cmd/old",
-       "/usr/src/cmd/UNSUPPORTED",
-#else
-       "/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/local/src",
+       "/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
        0
 };
 
        0
 };
 
@@ -86,12 +91,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:
@@ -273,28 +272,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);