BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / finger / finger.c
index 8a3be81..7c08c04 100644 (file)
@@ -2,17 +2,22 @@
  * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1989 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.
+ * This code is derived from software contributed to Berkeley by
+ * Tony Nardo of the Johns Hopkins University/Applied Physics Lab.
+ *
+ * Redistribution and use in source and binary forms are permitted provided
+ * that: (1) source distributions retain this entire copyright notice and
+ * comment, and (2) distributions including binaries display the following
+ * acknowledgement:  ``This product includes software developed by the
+ * University of California, Berkeley and its contributors'' in the
+ * documentation or other materials provided with the distribution and in
+ * all advertising materials mentioning features or use of this software.
+ * Neither the name of the University nor the names of its contributors may
+ * 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
  */
 
 #ifndef lint
@@ -22,7 +27,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)finger.c   5.17 (Berkeley) %G%";
+static char sccsid[] = "@(#)finger.c   5.21 (Berkeley) 6/24/90";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -42,7 +47,6 @@ static char sccsid[] = "@(#)finger.c  5.17 (Berkeley) %G%";
 #include <sys/file.h>
 #include <stdio.h>
 #include "finger.h"
 #include <sys/file.h>
 #include <stdio.h>
 #include "finger.h"
-#include "pathnames.h"
 
 time_t now;
 int lflag, sflag, mflag, pplan;
 
 time_t now;
 int lflag, sflag, mflag, pplan;
@@ -114,17 +118,16 @@ main(argc, argv)
 loginlist()
 {
        register PERSON *pn;
 loginlist()
 {
        register PERSON *pn;
-       FILE *fp;
        struct passwd *pw;
        struct utmp user;
        char name[UT_NAMESIZE + 1];
 
        struct passwd *pw;
        struct utmp user;
        char name[UT_NAMESIZE + 1];
 
-       if ((fp = fopen(_PATH_UTMP, "r")) == NULL) {
+       if (!freopen(_PATH_UTMP, "r", stdin)) {
                (void)fprintf(stderr, "finger: can't read %s.\n", _PATH_UTMP);
                exit(2);
        }
        name[UT_NAMESIZE] = NULL;
                (void)fprintf(stderr, "finger: can't read %s.\n", _PATH_UTMP);
                exit(2);
        }
        name[UT_NAMESIZE] = NULL;
-       while (fread((char *)&user, sizeof(user), 1, fp) == 1) {
+       while (fread((char *)&user, sizeof(user), 1, stdin) == 1) {
                if (!user.ut_name[0])
                        continue;
                if ((pn = find_person(user.ut_name)) == NULL) {
                if (!user.ut_name[0])
                        continue;
                if ((pn = find_person(user.ut_name)) == NULL) {
@@ -135,7 +138,6 @@ loginlist()
                }
                enter_where(&user, pn);
        }
                }
                enter_where(&user, pn);
        }
-       (void)fclose(fp);
        for (pn = phead; lflag && pn != NULL; pn = pn->next)
                enter_lastlog(pn);
 }
        for (pn = phead; lflag && pn != NULL; pn = pn->next)
                enter_lastlog(pn);
 }
@@ -150,7 +152,6 @@ userlist(argc, argv)
        struct utmp user;
        struct passwd *pw;
        int dolocal, *used;
        struct utmp user;
        struct passwd *pw;
        int dolocal, *used;
-       FILE *fp;
        char *index();
 
        if (!(used = (int *)calloc((u_int)argc, (u_int)sizeof(int)))) {
        char *index();
 
        if (!(used = (int *)calloc((u_int)argc, (u_int)sizeof(int)))) {
@@ -213,18 +214,17 @@ net:      for (pn = nethead; pn; pn = pn->next) {
         * Scan thru the list of users currently logged in, saving
         * appropriate data whenever a match occurs.
         */
         * Scan thru the list of users currently logged in, saving
         * appropriate data whenever a match occurs.
         */
-       if ((fp = fopen(_PATH_UTMP, "r")) == NULL) {
+       if (!freopen(_PATH_UTMP, "r", stdin)) {
                (void)fprintf( stderr, "finger: can't read %s.\n", _PATH_UTMP);
                exit(1);
        }
                (void)fprintf( stderr, "finger: can't read %s.\n", _PATH_UTMP);
                exit(1);
        }
-       while (fread((char *)&user, sizeof(user), 1, fp) == 1) {
+       while (fread((char *)&user, sizeof(user), 1, stdin) == 1) {
                if (!user.ut_name[0])
                        continue;
                if ((pn = find_person(user.ut_name)) == NULL)
                        continue;
                enter_where(&user, pn);
        }
                if (!user.ut_name[0])
                        continue;
                if ((pn = find_person(user.ut_name)) == NULL)
                        continue;
                enter_where(&user, pn);
        }
-       (void)fclose(fp);
        for (pn = phead; pn != NULL; pn = pn->next)
                enter_lastlog(pn);
 }
        for (pn = phead; pn != NULL; pn = pn->next)
                enter_lastlog(pn);
 }