getpwent_r()

Get the next entry from the password database

Synopsis:

#include <sys/types.h>
#include <pwd.h>

int getpwent_r( struct passwd *pwd,
                char *buffer,
                size_t bufsize,
                struct passwd **result);

Arguments:

pwd
A pointer to a passwd structure where the function can store the entry.
buffer
A block of memory that the function can use to allocate storage referenced by the passwd structure. You can determine the maximum size needed for this buffer by calling sysconf() with an argument of _SC_GETPW_R_SIZE_MAX.
bufsize
The size of the block that buffer points to, in characters.
result
The address of a pointer to a passwd structure. If getpwent_r() finds the next entry, it stores a pointer to pwd in the location indicated by result; otherwise the function stores a NULL pointer there.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The getpwent_r() function returns the next entry from the password database. It's similar to getpwent(), but getpwent_r() is reentrant.

Returns:

0 on success or if the entry couldn't be found, or nonzero if an error occurred (errno is set).

Errors:

The getpwent_r() function uses the following functions, and as a result, errno can be set to an error for any of these calls:

Classification:

POSIX 1003.1 TSF

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

See also:

endpwent(), errno, getgrent(), getlogin(), getpwnam(), getpwuid(), setpwent()