endpwent()

NAME

endpwent(), getpwent(), setpwent() - access user database

SYNOPSIS

#include <pwd.h>

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

DESCRIPTION

The getpwent(2) function returns a pointer to a struct passwd containing information from the user database for a user. Each entry in the user database contains a passwd structure. The first call to getpwent(2) returns a structure containing information from the first entry in the database. Each subsequent call proceeds through the database, returning a pointer to a structure containing information from the next line. In this way, getpwent(2) can be used to search the entire user database. When getpwent(2) reaches the end of the database or on error, it returns a null pointer.

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

The endpwent(2) function closes the user database when processing is complete.

RETURN VALUE

The getpwent(2) function returns a pointer to a structure on success; on end-of-file or on error, it returns a null pointer.

ERRORS

The getpwent(2), setpwent(2), and endpwent(2) functions may fail for these reasons:

[EIO]
An I/O error occurred.

The getpwent(2) and setpwent(2) functions may also fail for these reasons:

[EMFILE]
The process already has {OPEN_MAX} file descriptors open.
[ENFILE]
The system has the maximum allowable number of files open already.