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

  1. /*
  2.  *      getpwent.c: Get next password file entry
  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 *getpwent(void)
  17. {
  18.     static struct passwd temp;
  19.  
  20.     if ((_pw_file == NULL) && (!pw_openfile(NULL)))
  21.     return NULL;
  22.     if (fscanf(_pw_file, "%[^:]:%[^:]:%d:%d:%[^:]:%[^:]:%[^:\n] ", temp.pw_name,
  23.         temp.pw_passwd, &(temp.pw_uid), &(temp.pw_gid), temp.pw_gecos,
  24.         temp.pw_dir, temp.pw_shell) == 7)
  25.     return &temp;
  26.     else
  27.     return NULL;
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34.