1: /*	@(#)getpw.c	2.1	SCCS id keyword	*/
   2: #include    <stdio.h>
   3: 
   4: getpw(uid, buf)
   5: int uid;
   6: char buf[];
   7: {
   8:     static FILE *pwf;
   9:     register n, c;
  10:     register char *bp;
  11: 
  12:     if(pwf == 0)
  13:         pwf = fopen("/etc/passwd", "r");
  14:     if(pwf == NULL)
  15:         return(1);
  16:     rewind(pwf);
  17: 
  18:     for (;;) {
  19:         bp = buf;
  20:         while((c=getc(pwf)) != '\n') {
  21:             if(c == EOF)
  22:                 return(1);
  23:             *bp++ = c;
  24:         }
  25:         *bp++ = '\0';
  26:         bp = buf;
  27:         n = 3;
  28:         while(--n)
  29:         while((c = *bp++) != ':')
  30:             if(c == '\n')
  31:                 return(1);
  32:         while((c = *bp++) != ':') {
  33:             if(c<'0' || c>'9')
  34:                 continue;
  35:             n = n*10+c-'0';
  36:         }
  37:         if(n == uid)
  38:             return(0);
  39:     }
  40: }

Defined functions

getpw defined in line 4; used 3 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 658
Valid CSS Valid XHTML 1.0 Strict