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

Diff for /src/usr.bin/finger/util.c between version 1.19 and 1.20

version 1.19, 2003/07/02 21:04:10 version 1.20, 2004/03/15 02:50:29
Line 35 
Line 35 
   
 #ifndef lint  #ifndef lint
 /*static char sccsid[] = "from: @(#)util.c      5.14 (Berkeley) 1/17/91";*/  /*static char sccsid[] = "from: @(#)util.c      5.14 (Berkeley) 1/17/91";*/
 static char rcsid[] = "$OpenBSD$";  static const char rcsid[] = "$OpenBSD$";
 #endif /* not lint */  #endif /* not lint */
   
 #include <sys/types.h>  #include <sys/types.h>
Line 140 
Line 140 
   
         /* ampersands get replaced by the login name */          /* ampersands get replaced by the login name */
         if (!(p = strtok(p, ",")))          if (!(p = strtok(p, ",")))
                 return(0);                  return (0);
         expandusername(p, pw->pw_name, name, sizeof(name));          expandusername(p, pw->pw_name, name, sizeof(name));
         for (t = name; (p = strtok(t, "\t ")) != NULL; t = NULL)          for (t = name; (p = strtok(t, "\t ")) != NULL; t = NULL)
                 if (!strcasecmp(p, user))                  if (!strcasecmp(p, user))
                         return(1);                          return (1);
         return(0);          return (0);
 }  }
   
 /* inspired by usr.sbin/sendmail/util.c::buildfname */  /* inspired by usr.sbin/sendmail/util.c::buildfname */
Line 248 
Line 248 
         PERSON *pn, **pp;          PERSON *pn, **pp;
   
         for (pp = htab + hash(pw->pw_name);          for (pp = htab + hash(pw->pw_name);
              *pp != NULL && strcmp((*pp)->name, pw->pw_name) != 0;              *pp != NULL && strcmp((*pp)->name, pw->pw_name) != 0;
              pp = &(*pp)->hlink)              pp = &(*pp)->hlink)
                 ;                  ;
         if ((pn = *pp) == NULL) {          if ((pn = *pp) == NULL) {
                 pn = palloc();                  pn = palloc();
Line 266 
Line 266 
                 userinfo(pn, pw);                  userinfo(pn, pw);
                 pn->whead = NULL;                  pn->whead = NULL;
         }          }
         return(pn);          return (pn);
 }  }
   
 PERSON *  PERSON *
Line 276 
Line 276 
   
         /* name may be only UT_NAMESIZE long and not terminated */          /* name may be only UT_NAMESIZE long and not terminated */
         for (pn = htab[hash(name)];          for (pn = htab[hash(name)];
              pn != NULL && strncmp(pn->name, name, UT_NAMESIZE) != 0;              pn != NULL && strncmp(pn->name, name, UT_NAMESIZE) != 0;
              pn = pn->hlink)              pn = pn->hlink)
                 ;                  ;
         return(pn);          return (pn);
 }  }
   
 int  int
Line 291 
Line 291 
         /* name may be only UT_NAMESIZE long and not terminated */          /* name may be only UT_NAMESIZE long and not terminated */
         for (i = UT_NAMESIZE; --i >= 0 && *name;)          for (i = UT_NAMESIZE; --i >= 0 && *name;)
                 h = ((h << 2 | h >> (HBITS - 2)) ^ *name++) & HMASK;                  h = ((h << 2 | h >> (HBITS - 2)) ^ *name++) & HMASK;
         return(h);          return (h);
 }  }
   
 PERSON *  PERSON *
Line 301 
Line 301 
   
         if ((p = (PERSON *)malloc((u_int) sizeof(PERSON))) == NULL)          if ((p = (PERSON *)malloc((u_int) sizeof(PERSON))) == NULL)
                 err(1, "malloc");                  err(1, "malloc");
         return(p);          return (p);
 }  }
   
 WHERE *  WHERE *
Line 318 
Line 318 
                 pn->wtail = w;                  pn->wtail = w;
         }          }
         w->next = NULL;          w->next = NULL;
         return(w);          return (w);
 }  }
   
 char *  char *
Line 331 
Line 331 
         /* don't touch anything if the user has their own formatting */          /* don't touch anything if the user has their own formatting */
         for (p = num; *p; ++p)          for (p = num; *p; ++p)
                 if (!isdigit(*p))                  if (!isdigit(*p))
                         return(num);                          return (num);
         len = p - num;          len = p - num;
         p = pbuf;          p = pbuf;
         switch(len) {          switch (len) {
         case 11:                        /* +0-123-456-7890 */          case 11:                        /* +0-123-456-7890 */
                 *p++ = '+';                  *p++ = '+';
                 *p++ = *num++;                  *p++ = *num++;
Line 357 
Line 357 
                 *p++ = *num++;                  *p++ = *num++;
                 break;                  break;
         default:          default:
                 return(num);                  return (num);
         }          }
         if (len != 4) {          if (len != 4) {
                 *p++ = '-';                  *p++ = '-';
Line 367 
Line 367 
         *p++ = *num++;          *p++ = *num++;
         *p++ = *num++;          *p++ = *num++;
         *p = '\0';          *p = '\0';
         return(pbuf);          return (pbuf);
 }  }
   
 /* Like strvis(), but use malloc() to get the space and return a pointer  /* Like strvis(), but use malloc() to get the space and return a pointer
Line 384 
Line 384 
                 err(1, "malloc failed");                  err(1, "malloc failed");
   
         strvis(dst, src, VIS_SAFE|VIS_NOSLASH);          strvis(dst, src, VIS_SAFE|VIS_NOSLASH);
         return(dst);          return (dst);
 }  }

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20