[BACK]Return to finger.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / finger

Diff for /src/usr.bin/finger/finger.c between version 1.6 and 1.7

version 1.6, 1997/01/17 07:12:31 version 1.7, 1997/05/30 23:35:51
Line 37 
Line 37 
  */   */
   
 /*  /*
  * Mail status reporting added 931007 by Luke Mewburn, <zak@rmit.edu.au>.   * Luke Mewburn <lukem@netbsd.org> 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  #ifndef lint
Line 59 
Line 65 
  *   *
  * There are currently two output formats; the short format is one line   * 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,   * per user and displays login name, tty, login time, real name, idle time,
  * and office location/phone number.  The long format gives the same   * and either remote host information (default) or office location/phone
  * information (in a more legible format) as well as home directory, shell,   * number, depending on if -h or -o is used respectively.
  * mail info, and .plan/.project files.   * 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 <sys/param.h>  #include <sys/param.h>
 #include <sys/file.h>  #include <sys/file.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
   #include <string.h>
   #include <time.h>
 #include "finger.h"  #include "finger.h"
   #include "extern.h"
   
 time_t now;  time_t now;
 int lflag, sflag, mflag, pplan, Mflag;  int entries, lflag, sflag, mflag, oflag, pplan, Mflag;
 char tbuf[1024];  char tbuf[1024];
   
 int     loginlist __P((void));  
 void    userlist __P((int, char **));  
   
 int  int
 main(argc, argv)  main(argc, argv)
         int argc;          int argc;
Line 85 
Line 92 
         extern int optind;          extern int optind;
         int ch;          int ch;
         char domain[256];          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) {                  switch(ch) {
                 case 'l':                  case 'l':
                         lflag = 1;              /* long format */                          lflag = 1;              /* long format */
Line 104 
Line 112 
                 case 's':                  case 's':
                         sflag = 1;              /* short format */                          sflag = 1;              /* short format */
                         break;                          break;
                   case 'h':
                           oflag = 0;              /* remote host info */
                           break;
                   case 'o':
                           oflag = 1;              /* office info */
                           break;
                 case '?':                  case '?':
                 default:                  default:
                         (void)fprintf(stderr,                          (void)fprintf(stderr,
                             "usage: finger [-lmMps] [login ...]\n");                              "usage: finger [-lmMpsho] [login ...]\n");
                         exit(1);                          exit(1);
                 }                  }
         argc -= optind;          argc -= optind;
Line 149 
Line 163 
         exit(0);          exit(0);
 }  }
   
 int  void
 loginlist()  loginlist()
 {  {
         register PERSON *pn;          PERSON *pn;
         struct passwd *pw;          struct passwd *pw;
         struct utmp user;          struct utmp user;
         char name[UT_NAMESIZE + 1];          char name[UT_NAMESIZE + 1];
Line 161 
Line 175 
                 (void)fprintf(stderr, "finger: can't read %s.\n", _PATH_UTMP);                  (void)fprintf(stderr, "finger: can't read %s.\n", _PATH_UTMP);
                 exit(2);                  exit(2);
         }          }
         name[UT_NAMESIZE] = NULL;          name[UT_NAMESIZE] = '\0';
         while (fread((char *)&user, sizeof(user), 1, stdin) == 1) {          while (fread((char *)&user, sizeof(user), 1, stdin) == 1) {
                 if (!user.ut_name[0])                  if (!user.ut_name[0])
                         continue;                          continue;
Line 179 
Line 193 
   
 void  void
 userlist(argc, argv)  userlist(argc, argv)
         register argc;          int argc;
         register char **argv;          char **argv;
 {  {
         register i;          register int i;
         register PERSON *pn;          register PERSON *pn;
         PERSON *nethead, **nettail;          PERSON *nethead, **nettail;
         struct utmp user;          struct utmp user;
Line 221 
Line 235 
                                 enter_person(pw);                                  enter_person(pw);
                                 used[i] = 1;                                  used[i] = 1;
                         }                          }
         } else while (pw = getpwent())          } else while ((pw = getpwent()) != NULL)
                 for (i = 0; i < argc; i++)                  for (i = 0; i < argc; i++)
                         if (used[i] >= 0 &&                          if (used[i] >= 0 &&
                             (!strcasecmp(pw->pw_name, argv[i]) ||                              (!strcasecmp(pw->pw_name, argv[i]) ||

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7