1: # include   <stdio.h>
   2: 
   3: # include   "../ingres.h"
   4: # include   "../aux.h"
   5: 
   6: /*
   7: **  GETNUSER -- get line from user file based on name
   8: **
   9: **	Given a user name as a string, this routine returns the
  10: **	corresponding line from .../files/users into a buffer.
  11: **
  12: **	Parameters:
  13: **		name -- the name of the user
  14: **		buf -- a buf to dump the line in (declare as
  15: **			char buf[MAXLINE + 1]
  16: **
  17: **	Returns:
  18: **		zero -- success
  19: **		one -- failure (user not present)
  20: **
  21: **	Side effects:
  22: **		none
  23: **
  24: **	Requires:
  25: **		a free file descriptor
  26: **		fopen
  27: **		fclose
  28: **		getc
  29: **		syserr
  30: **
  31: **	Defines:
  32: **		getnuser
  33: **
  34: **	Files:
  35: **		.../files/users (readable)
  36: **
  37: **	History:
  38: **		1/9/78 -- adapted from getuser by eric
  39: */
  40: 
  41: getnuser(name, buf)
  42: char    *name;
  43: char    buf[];
  44: {
  45:     FILE        *userf;
  46:     register char   c;
  47:     register char   *bp;
  48: 
  49:     userf = fopen(ztack(Pathname, "/files/users"), "r");
  50:     if (userf == NULL)
  51:         syserr("getuser: open err");
  52: 
  53:     for (;;)
  54:     {
  55:         bp = buf;
  56:         while ((c = getc(userf)) != '\n')
  57:         {
  58:             if (c == EOF)
  59:             {
  60:                 fclose(userf);
  61:                 return (1);
  62:             }
  63:             *bp++ = c;
  64:         }
  65:         *bp++ = '\0';
  66:         bp = buf;
  67:         while ((c = *bp++) != ':')
  68:         {
  69:             if (c == '\0')
  70:             {
  71:                 fclose(userf);
  72:                 return (1);
  73:             }
  74:         }
  75:         *--bp = 0;
  76:         if (sequal(buf, name))
  77:         {
  78:             fclose(userf);
  79:             *bp = ':';
  80:             return (0);
  81:         }
  82:     }
  83: }

Defined functions

getnuser defined in line 41; used 1 times
Last modified: 1995-02-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2079
Valid CSS Valid XHTML 1.0 Strict