1: # include   <stdio.h>
   2: 
   3: # include   "../ingres.h"
   4: # include   "../aux.h"
   5: 
   6: /*
   7: **  GET LINE FROM USER FILE
   8: **
   9: **	Given a user code (a two byte string), this routine returns
  10: **	the line from .../files/users into `buf'.  The users
  11: **	file is automatically opened, and it is closed if getperm
  12: **	is called with `code' == 0.
  13: **
  14: **	If `code' == -1 then getuser will reinitialize itself.
  15: **	This will guarantee that getuser will reopen the file
  16: **	if (for example) an interrupt occured during the previous
  17: **	call.
  18: */
  19: 
  20: getuser(code, buf)
  21: char    *code;
  22: char    buf[];
  23: {
  24:     static FILE *userf;
  25:     register char   c;
  26:     register char   *bp;
  27: 
  28:     if (code == 0)
  29:     {
  30:         if (userf != NULL)
  31:             fclose(userf);
  32:         userf = NULL;
  33:         return (0);
  34:     }
  35:     if (code == -1)
  36:     {
  37:         userf = NULL;
  38:         return (0);
  39:     }
  40:     if (userf == NULL)
  41:     {
  42:         userf = fopen(ztack(Pathname, "/files/users"), "r");
  43:         if (userf == NULL)
  44:             syserr("getuser: open err");
  45:     }
  46:     else
  47:     {
  48:         rewind(userf);
  49:     }
  50: 
  51:     for (;;)
  52:     {
  53:         bp = buf;
  54:         if (fgetline(bp, MAXLINE, userf) == NULL)
  55:         {
  56:             return (1);
  57:         }
  58:         while ((c = *bp++) != ':')
  59:             if (c == '\0')
  60:             {
  61:                 return (1);
  62:             }
  63:         if (bequal(bp, code, 2))
  64:         {
  65:             return (0);
  66:         }
  67:     }
  68: }
Last modified: 1995-02-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2250
Valid CSS Valid XHTML 1.0 Strict