1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char *sccsid = "@(#)getname.c	5.2 (Berkeley) 6/21/85";
   9: #endif not lint
  10: 
  11: #include <pwd.h>
  12: 
  13: /*
  14:  * Getname / getuserid for those with
  15:  * hashed passwd data base).
  16:  *
  17:  */
  18: 
  19: #include "rcv.h"
  20: 
  21: /*
  22:  * Search the passwd file for a uid.  Return name through ref parameter
  23:  * if found, indicating success with 0 return.  Return -1 on error.
  24:  * If -1 is passed as the user id, close the passwd file.
  25:  */
  26: 
  27: getname(uid, namebuf)
  28:     char namebuf[];
  29: {
  30:     struct passwd *pw;
  31: 
  32:     if (uid == -1) {
  33:         return(0);
  34:     }
  35:     if ((pw = getpwuid(uid)) == NULL)
  36:         return(-1);
  37:     strcpy(namebuf, pw->pw_name);
  38:     return 0;
  39: }
  40: 
  41: /*
  42:  * Convert the passed name to a user id and return it.  Return -1
  43:  * on error.  Iff the name passed is -1 (yech) close the pwfile.
  44:  */
  45: 
  46: getuserid(name)
  47:     char name[];
  48: {
  49:     struct passwd *pw;
  50: 
  51:     if (name == (char *) -1) {
  52:         return(0);
  53:     }
  54:     if ((pw = getpwnam(name)) == NULL)
  55:         return 0;
  56:     return pw->pw_uid;
  57: }

Defined functions

getname defined in line 27; used 1 times
getuserid defined in line 46; used 3 times

Defined variables

sccsid defined in line 8; never used
Last modified: 1985-06-22
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 883
Valid CSS Valid XHTML 1.0 Strict