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

Defined functions

getnuser defined in line 6; used 1 times
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 517
Valid CSS Valid XHTML 1.0 Strict