Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

getgrent_r(3) OSS Library Calls Reference Manual
Include the grp.h header file
To use the Standard POSIX Threads library, you must:
Include the spthread.h header file
Link your application to the Standard POSIX Threads Library:
/G/system/sysnn/zsptsrl (G-series)
or
/G/system/zdllnnn/zsptdll (H-series or J-series)
Compile your application using the #define _SPT_MODEL_ macro or an equivalent
compiler command option
For more information about threaded and 64-bit applications in the OSS environment, see the
Open System Services Programmers Guide.
The functions setgrent( ), getgrent( ), and endgrent( ) are used to enumerate group entries from
the database. The setgrent( ) function sets (or resets) the enumeration to the beginning of the set
of group entries. The setgrent( ) function should be called before the first call to the getgrent( )
function. Successive calls to getgrent( ) return either successive entries or NULL (which indi-
cates the end of the enumeration). Interleaving calls to re-entrant functions and their correspond-
ing non re-entrant counterparts leave the enumeration in an undetermined state.
RETURN VALUES
H06.21 and later H-series RVUs and J06.10 and later J-series RVUs
Upon successful completion, the getgrent_r( ) function returns 0 (zero). Otherwise, the
getgrent_r( ) function sets errno to indicate the specific error.
Standard POSIX Threads Library version of getgrent_r( )
The getgrent_r( ) function returns a pointer to a struct group if it successfully enumerates an
entry; otherwise, it returns a null pointer and sets errno to indicate the specific error. When the
pointer returned by the function is nonnull, it is always equal to the grp pointer that was supplied
by the caller.
ERRORS
If any of these conditions occur, the getgrent_r( ) function sets errno to the corresponding
value:
[EAGAIN] The system was unable to allocate sufficient user heap space to complete the
requested operation. Any list of usernames returned by the call might be trun-
cated. Reissue the call to obtain correct data.
[EIO] A disk process or file system input/output error occurred. Data might have been
lost during the transfer.
[EMFILE] The system limit for open file descriptors per process has already reached the
maximum permitted.
[ENOENT] No more group records exist to be returned.
[ENOMEM] The system was unable to allocate sufficient memory for a control block.
[ERANGE] Insufficient storage was supplied via buffer and buflen to contain the data to be
referenced by the resulting group structure.
338 Hewlett-Packard Company 527187-017