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

Defined functions

getpw defined in line 3; used 2 times
Last modified: 1979-01-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 401
Valid CSS Valid XHTML 1.0 Strict