The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

endpwent, getpwent, setpwent - user database functions

 SYNOPSIS



#include <pwd.h>

void endpwent(void);
struct passwd *getpwent(void);
void setpwent(void);

 DESCRIPTION

The getpwent() function returns a pointer to a structure containing the broken-out fields of an entry in the user database. Each entry in the user database contains a passwd structure. When first called, getpwent() returns a pointer to a passwd structure containing the first entry in the user database. Thereafter, it returns a pointer to a passwd structure containing the next entry in the user database. Successive calls can be used to search the entire user database.

If an end-of-file or an error is encountered on reading, getpwent() returns a null pointer.

The setpwent() function effectively rewinds the user database to allow repeated searches.

The endpwent() function may be called to close the user database when processing is complete.

These interfaces need not be reentrant.

 RETURN VALUE

The getpwent() function returns a null pointer on end-of-file or error.

 ERRORS

The getpwent(), setpwent() and endpwent() functions may fail if:
[EIO]
An I/O error has occurred.

In addition, getpwent() and setpwent() may fail if:

[EMFILE]
{OPEN_MAX} file descriptors are currently open in the calling process.
[ENFILE]
The maximum allowable number of files is currently open in the system.

The return value may point to a static area which is overwritten by a subsequent call to getpwuid(), getpwnam() or getpwent().

 EXAMPLES

None.

 APPLICATION USAGE

These functions are provided due to their historical usage. Applications should avoid dependencies on fields in the password database, whether the database is a single file, or where in the filesystem namespace the database resides. Applications should use getpwuid() whenever possible both because it avoids these dependencies and for greater portability with systems that conform to earlier versions of this specification.

 FUTURE DIRECTIONS

None.

 SEE ALSO

endgrent(), getlogin(), getpwnam(), getpwuid(), <pwd.h>.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]