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

Diff for /src/usr.bin/finger/lprint.c between version 1.3 and 1.4

version 1.3, 1996/08/27 22:38:23 version 1.4, 1997/05/30 23:35:52
Line 48 
Line 48 
 #include <tzfile.h>  #include <tzfile.h>
 #include <stdio.h>  #include <stdio.h>
 #include <string.h>  #include <string.h>
   #include <time.h>
 #include <ctype.h>  #include <ctype.h>
 #include <paths.h>  #include <paths.h>
 #include <vis.h>  #include <vis.h>
 #include "finger.h"  #include "finger.h"
   #include "extern.h"
   
 #define LINE_LEN        80  #define LINE_LEN        80
 #define TAB_LEN         8               /* 8 spaces between tabs */  #define TAB_LEN         8               /* 8 spaces between tabs */
 #define _PATH_PLAN      ".plan"  #define _PATH_PLAN      ".plan"
 #define _PATH_PROJECT   ".project"  #define _PATH_PROJECT   ".project"
   
   void
 lflag_print()  lflag_print()
 {  {
         extern int pplan;          PERSON *pn;
         register PERSON *pn;  
   
         for (pn = phead;;) {          for (pn = phead;;) {
                 lprint(pn);                  lprint(pn);
Line 76 
Line 78 
         }          }
 }  }
   
   void
 lprint(pn)  lprint(pn)
         register PERSON *pn;          PERSON *pn;
 {  {
         extern time_t now;          struct tm *delta;
         register struct tm *delta;          WHERE *w;
         register WHERE *w;          int cpr, len, maxlen;
         register int cpr, len, maxlen;  
         struct tm *tp;          struct tm *tp;
         int oddfield;          int oddfield;
         time_t time();          char *t, *tzn;
         char *t, *tzn, *prphone();  
   
           cpr = 0;
         /*          /*
          * long format --           * long format --
          *      login name           *      login name
Line 95 
Line 97 
          *      home directory           *      home directory
          *      shell           *      shell
          *      office, office phone, home phone if available           *      office, office phone, home phone if available
            *      mail status
          */           */
         (void)printf("Login: %-15s\t\t\tName: %s\nDirectory: %-25s",          (void)printf("Login: %-15s\t\t\tName: %s\nDirectory: %-25s",
             pn->name, pn->realname, pn->dir);              pn->name, pn->realname, pn->dir);
Line 110 
Line 113 
         if (pn->office && pn->officephone &&          if (pn->office && pn->officephone &&
             strlen(pn->office) + strlen(pn->officephone) +              strlen(pn->office) + strlen(pn->officephone) +
             sizeof(OFFICE_TAG) + 2 <= 5 * TAB_LEN) {              sizeof(OFFICE_TAG) + 2 <= 5 * TAB_LEN) {
                 (void)sprintf(tbuf, "%s: %s, %s", OFFICE_TAG, pn->office,                  (void)snprintf(tbuf, sizeof(tbuf),
                       "%s: %s, %s", OFFICE_TAG, pn->office,
                     prphone(pn->officephone));                      prphone(pn->officephone));
                 oddfield = demi_print(tbuf, oddfield);                  oddfield = demi_print(tbuf, oddfield);
         } else {          } else {
                 if (pn->office) {                  if (pn->office) {
                         (void)sprintf(tbuf, "%s: %s", OFFICE_TAG, pn->office);                          (void)snprintf(tbuf, sizeof(tbuf),
                               "%s: %s", OFFICE_TAG, pn->office);
                         oddfield = demi_print(tbuf, oddfield);                          oddfield = demi_print(tbuf, oddfield);
                 }                  }
                 if (pn->officephone) {                  if (pn->officephone) {
                         (void)sprintf(tbuf, "%s: %s", OFFICE_PHONE_TAG,                          (void)snprintf(tbuf, sizeof(tbuf),
                               "%s: %s", OFFICE_PHONE_TAG,
                             prphone(pn->officephone));                              prphone(pn->officephone));
                         oddfield = demi_print(tbuf, oddfield);                          oddfield = demi_print(tbuf, oddfield);
                 }                  }
         }          }
         if (pn->homephone) {          if (pn->homephone) {
                 (void)sprintf(tbuf, "%s: %s", "Home Phone",                  (void)snprintf(tbuf, sizeof(tbuf), "%s: %s", "Home Phone",
                     prphone(pn->homephone));                      prphone(pn->homephone));
                 oddfield = demi_print(tbuf, oddfield);                  oddfield = demi_print(tbuf, oddfield);
         }          }
Line 133 
Line 139 
                 putchar('\n');                  putchar('\n');
   
         /*          /*
          * long format con't: * if logged in           * long format con't:
            * if logged in
          *      terminal           *      terminal
          *      idle time           *      idle time
          *      if messages allowed           *      if messages allowed
Line 221 
Line 228 
         }          }
 }  }
   
   int
 demi_print(str, oddfield)  demi_print(str, oddfield)
         char *str;          char *str;
         int oddfield;          int oddfield;
Line 260 
Line 268 
         return(oddfield);          return(oddfield);
 }  }
   
   int
 show_text(directory, file_name, header)  show_text(directory, file_name, header)
         char *directory, *file_name, *header;          char *directory, *file_name, *header;
 {  {
         register int ch, lastc;          int ch, lastc;
         register FILE *fp;          FILE *fp;
   
         (void)sprintf(tbuf, "%s/%s", directory, file_name);          lastc = 0;
           (void)snprintf(tbuf, sizeof(tbuf), "%s/%s", directory, file_name);
         if ((fp = fopen(tbuf, "r")) == NULL)          if ((fp = fopen(tbuf, "r")) == NULL)
                 return(0);                  return(0);
         (void)printf("%s\n", header);          (void)printf("%s\n", header);
Line 278 
Line 288 
         return(1);          return(1);
 }  }
   
   void
 vputc(ch)  vputc(ch)
         register int ch;          int ch;
 {  {
         char visout[4], *s2;          char visout[5], *s2;
   
         ch = toascii(ch);          ch = toascii(ch);
         vis(visout, ch, VIS_SAFE|VIS_NOSLASH, 0);          vis(visout, ch, VIS_SAFE|VIS_NOSLASH, 0);

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4