=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/finger/finger.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- src/usr.bin/finger/finger.c 1997/01/17 07:12:31 1.6 +++ src/usr.bin/finger/finger.c 1997/05/30 23:35:51 1.7 @@ -1,4 +1,4 @@ -/* $OpenBSD: finger.c,v 1.6 1997/01/17 07:12:31 millert Exp $ */ +/* $OpenBSD: finger.c,v 1.7 1997/05/30 23:35:51 kstailey Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -37,7 +37,13 @@ */ /* - * Mail status reporting added 931007 by Luke Mewburn, . + * Luke Mewburn added the following on 961121: + * - mail status ("No Mail", "Mail read:...", or "New Mail ..., + * Unread since ...".) + * - 4 digit phone extensions (3210 is printed as x3210.) + * - host/office toggling in short format with -h & -o. + * - short day names (`Tue' printed instead of `Jun 21' if the + * login time is < 6 days. */ #ifndef lint @@ -48,7 +54,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)finger.c 5.22 (Berkeley) 6/29/90";*/ -static char rcsid[] = "$OpenBSD: finger.c,v 1.6 1997/01/17 07:12:31 millert Exp $"; +static char rcsid[] = "$OpenBSD: finger.c,v 1.7 1997/05/30 23:35:51 kstailey Exp $"; #endif /* not lint */ /* @@ -59,24 +65,25 @@ * * There are currently two output formats; the short format is one line * per user and displays login name, tty, login time, real name, idle time, - * and office location/phone number. The long format gives the same - * information (in a more legible format) as well as home directory, shell, - * mail info, and .plan/.project files. + * and either remote host information (default) or office location/phone + * number, depending on if -h or -o is used respectively. + * The long format gives the same information (in a more legible format) as + * well as home directory, shell, mail info, and .plan/.project files. */ #include #include #include #include +#include +#include #include "finger.h" +#include "extern.h" time_t now; -int lflag, sflag, mflag, pplan, Mflag; +int entries, lflag, sflag, mflag, oflag, pplan, Mflag; char tbuf[1024]; -int loginlist __P((void)); -void userlist __P((int, char **)); - int main(argc, argv) int argc; @@ -85,9 +92,10 @@ extern int optind; int ch; char domain[256]; - time_t time(); - while ((ch = getopt(argc, argv, "lmMps")) != -1) + oflag = 1; /* default to old "office" behavior */ + + while ((ch = getopt(argc, argv, "lmMpsho")) != -1) switch(ch) { case 'l': lflag = 1; /* long format */ @@ -104,10 +112,16 @@ case 's': sflag = 1; /* short format */ break; + case 'h': + oflag = 0; /* remote host info */ + break; + case 'o': + oflag = 1; /* office info */ + break; case '?': default: (void)fprintf(stderr, - "usage: finger [-lmMps] [login ...]\n"); + "usage: finger [-lmMpsho] [login ...]\n"); exit(1); } argc -= optind; @@ -149,10 +163,10 @@ exit(0); } -int +void loginlist() { - register PERSON *pn; + PERSON *pn; struct passwd *pw; struct utmp user; char name[UT_NAMESIZE + 1]; @@ -161,7 +175,7 @@ (void)fprintf(stderr, "finger: can't read %s.\n", _PATH_UTMP); exit(2); } - name[UT_NAMESIZE] = NULL; + name[UT_NAMESIZE] = '\0'; while (fread((char *)&user, sizeof(user), 1, stdin) == 1) { if (!user.ut_name[0]) continue; @@ -179,10 +193,10 @@ void userlist(argc, argv) - register argc; - register char **argv; + int argc; + char **argv; { - register i; + register int i; register PERSON *pn; PERSON *nethead, **nettail; struct utmp user; @@ -221,7 +235,7 @@ enter_person(pw); used[i] = 1; } - } else while (pw = getpwent()) + } else while ((pw = getpwent()) != NULL) for (i = 0; i < argc; i++) if (used[i] >= 0 && (!strcasecmp(pw->pw_name, argv[i]) ||