Tape Blocking via stat, vfile output and linebuffering output
[unix-history] / usr / src / old / whereis / whereis.c
index e055400..a88fb8b 100644 (file)
@@ -1,9 +1,23 @@
-static char *sccsid = "@(#)whereis.c   4.5 (Berkeley) %G%";
+/*
+ * 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/types.h>
+#include <sys/param.h>
+#include <sys/dir.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <ctype.h>
-#include <sys/dir.h>
 
 static char *bindirs[] = {
        "/etc",
 
 static char *bindirs[] = {
        "/etc",
@@ -16,6 +30,8 @@ static char *bindirs[] = {
        "/usr/local",
        "/usr/new",
        "/usr/old",
        "/usr/local",
        "/usr/new",
        "/usr/old",
+       "/usr/hosts",
+       "/usr/include",
        0
 };
 static char *mandirs[] = {
        0
 };
 static char *mandirs[] = {
@@ -27,17 +43,31 @@ static char *mandirs[] = {
        "/usr/man/man6",
        "/usr/man/man7",
        "/usr/man/man8",
        "/usr/man/man6",
        "/usr/man/man7",
        "/usr/man/man8",
+       "/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",
-       "/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",
        0
 };
        "/usr/src/undoc",
        0
 };
@@ -242,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);