home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- *
- * $Source: /unixb/home/unixlib/source/unixlib37/src/pwd/c/RCS/getpwent,v $
- * $Date: 1996/10/30 22:04:51 $
- * $Revision: 1.1 $
- * $State: Rel $
- * $Author: unixlib $
- *
- * $Log: getpwent,v $
- * Revision 1.1 1996/10/30 22:04:51 unixlib
- * Initial revision
- *
- ***************************************************************************/
-
- static const char rcs_id[] = "$Id: getpwent,v 1.1 1996/10/30 22:04:51 unixlib Rel $";
-
- /* pwd.c.getpwent. Password-file operations.
-
- Written by Nick Burrett, 13 October 1996. */
-
- #include <stddef.h>
- #include <stdio.h>
- #include <pwd.h>
-
- static FILE *stream = NULL;
-
- /* Rewind the stream. */
- void setpwent (void)
- {
- if (stream != NULL)
- rewind (stream);
- }
-
- /* Close the stream. */
- void endpwent (void)
- {
- if (stream != NULL)
- {
- fclose(stream);
- stream = NULL;
- }
- }
-
- /* Return one entry from the password file. */
- struct passwd *getpwent (void)
- {
- static struct passwd pwd;
-
- /* Open the password file if not already open. */
- if (stream == NULL)
- stream = fopen ("/etc/passwd", "r");
-
- if (stream == NULL)
- return NULL;
-
- return __pwdread (stream, &pwd);
- }
-