home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1350 / getpwnam.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  491 b   |  32 lines

  1. /*
  2.  *      getpwnam.c: Get password file entry by name
  3.  *
  4.  *      Stephen C. Trier
  5.  *      March 26, 1990
  6.  *
  7.  *      This program is in the public domain
  8.  *
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <pwd.h>
  14.  
  15. extern FILE *_pw_file;
  16.  
  17. struct passwd *getpwnam(char *name)
  18. {
  19.     struct passwd *temp;
  20.  
  21.     if (setpwent())
  22.     return NULL;
  23.     while (temp = getpwent())
  24.     if (strcmp(temp->pw_name, name) == 0)  {
  25.         setpwent();
  26.         return temp;
  27.         }
  28.     setpwent();
  29.     return NULL;
  30. }
  31.  
  32.