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

  1. /*
  2.  *      getpwuid.c: Get password file entry by user id
  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 <pwd.h>
  13.  
  14. extern FILE *_pw_file;
  15.  
  16. struct passwd *getpwuid(int id)
  17. {
  18.     struct passwd *temp;
  19.  
  20.     if (setpwent())
  21.     return NULL;
  22.     while (temp = getpwent())
  23.     if (temp->pw_uid == id)  {
  24.         setpwent();
  25.         return temp;
  26.         }
  27.     setpwent();
  28.     return NULL;
  29. }
  30.  
  31.  
  32.