home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / SMAILSRC.ZIP / PASSWD.ZIP / GETPWENT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-03  |  810 b   |  37 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.  *      Unlike the passwd file on UNIX systems, this password file is
  10.  *      semicolon-delimited.  This is because the colon is used in the
  11.  *      MS-DOS path syntax to designate a drive.
  12.  */
  13.  
  14. #include <stdio.h>
  15. #include <pwd.h>
  16.  
  17. extern FILE *_pw_file;
  18.  
  19. struct passwd *getpwent(void)
  20. {
  21.     static struct passwd temp;
  22.  
  23.     if ((_pw_file == NULL) && (!pw_openfile(NULL)))
  24.     return NULL;
  25.     if (fscanf(_pw_file, "%[^;];%[^;];%d;%d;%[^;];%[^;];%[^;\n] ", temp.pw_name,
  26.         temp.pw_passwd, &(temp.pw_uid), &(temp.pw_gid), temp.pw_gecos,
  27.         temp.pw_dir, temp.pw_shell) == 7)
  28.     return &temp;
  29.     else
  30.     return NULL;
  31. }
  32.  
  33.  
  34.  
  35.  
  36.  
  37.