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

Diff for /src/usr.bin/who/who.c between version 1.5 and 1.6

version 1.5, 1997/07/28 17:38:53 version 1.6, 1997/08/20 05:37:21
Line 72 
Line 72 
 int show_term;                  /* show term state */  int show_term;                  /* show term state */
 int show_idle;                  /* show idle time */  int show_idle;                  /* show idle time */
 int show_labels;                /* show column labels */  int show_labels;                /* show column labels */
   int show_quick;                 /* quick, names only */
   
 int  int
 main(argc, argv)  main(argc, argv)
Line 85 
Line 86 
         setlocale(LC_ALL, "");          setlocale(LC_ALL, "");
   
         only_current_term = show_term = show_idle = show_labels = 0;          only_current_term = show_term = show_idle = show_labels = 0;
         while ((c = getopt(argc, argv, "HmTu")) != -1) {          show_quick = 0;
           while ((c = getopt(argc, argv, "HmqTu")) != -1) {
                 switch (c) {                  switch (c) {
                   case 'H':
                           show_labels = 1;
                           break;
                 case 'm':                  case 'm':
                         only_current_term = 1;                          only_current_term = 1;
                         break;                          break;
                   case 'q':
                           show_quick = 1;
                           break;
                 case 'T':                  case 'T':
                         show_term = 1;                          show_term = 1;
                         break;                          break;
                 case 'u':                  case 'u':
                         show_idle = 1;                          show_idle = 1;
                         break;                          break;
                 case 'H':  
                         show_labels = 1;  
                         break;  
                 default:                  default:
                         usage();                          usage();
                         /* NOTREACHED */                          /* NOTREACHED */
Line 107 
Line 112 
         argc -= optind;          argc -= optind;
         argv += optind;          argv += optind;
   
           if (show_quick) {
                   only_current_term = show_term = show_idle = show_labels = 0;
           }
   
         if (chdir("/dev")) {          if (chdir("/dev")) {
                 err(1, "cannot change directory to /dev");                  err(1, "cannot change directory to /dev");
                 /* NOTREACHED */                  /* NOTREACHED */
Line 121 
Line 130 
   
                 if (only_current_term) {                  if (only_current_term) {
                         who_am_i(ufp);                          who_am_i(ufp);
                   } else if (show_quick) {
                           int count = 0;
   
                           while (fread((char *)&usr, sizeof(usr), 1, ufp) == 1) {
                                   if (*usr.ut_name && *usr.ut_line) {
                                           (void)printf("%-*.*s ", UT_NAMESIZE,
                                                   UT_NAMESIZE, usr.ut_name);
                                           if ((++count % 8) == 0)
                                                   (void) printf("\n");
                                   }
                           }
                           if (count % 8)
                                   (void) printf("\n");
                           (void) printf ("# users=%d\n", count);
                 } else {                  } else {
                         /* only entries with both name and line fields */                          /* only entries with both name and line fields */
                         while (fread((char *)&usr, sizeof(usr), 1, ufp) == 1)                          while (fread((char *)&usr, sizeof(usr), 1, ufp) == 1)
Line 133 
Line 156 
   
                 if (only_current_term) {                  if (only_current_term) {
                         who_am_i(ufp);                          who_am_i(ufp);
                   } else if (show_quick) {
                           int count = 0;
   
                           while (fread((char *)&usr, sizeof(usr), 1, ufp) == 1) {
                                   if (*usr.ut_name && *usr.ut_line) {
                                           (void)printf("%-*.*s ", UT_NAMESIZE,
                                                   UT_NAMESIZE, usr.ut_name);
                                           if ((++count % 8) == 0)
                                                   (void) printf("\n");
                                   }
                           }
                           if (count % 8)
                                   (void) printf("\n");
                           (void) printf ("# users=%d\n", count);
                 } else {                  } else {
                         /* all entries */                          /* all entries */
                         while (fread((char *)&usr, sizeof(usr), 1, ufp) == 1)                          while (fread((char *)&usr, sizeof(usr), 1, ufp) == 1)
Line 268 
Line 305 
 void  void
 usage()  usage()
 {  {
         (void)fprintf(stderr, "usage: who [-mTuH] [ file ]\n       who am i\n");          (void)fprintf(stderr, "usage: who [-mqTuH] [ file ]\n       who am i\n");
         exit(1);          exit(1);
 }  }

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