This section explains how a program can read the list of all groups in the system, one group at a time. The functions described here are declared in `grp.h'.
You can use the fgetgrent
function to read group entries from a
particular file.
fgetgrent
function reads the next entry from stream.
It returns a pointer to the entry. The structure is statically
allocated and is overwritten on subsequent calls to fgetgrent
. You
must copy the contents of the structure if you wish to save the
information.
The stream must correspond to a file in the same format as the standard group database file.
fgetgrent
in that it reads the next
user entry from stream. But the result is returned in the
structure pointed to by result_buf. The first buflen bytes
of the additional buffer pointed to by buffer are used to contain
additional information, normally strings which are pointed to by the
elements of the result structure.
This stream must correspond to a file in the same format as the standard group database file.
If the function returns zero result points to the structure with the wanted data (normally this is in result_buf). If errors occurred the return value is non-zero and result contains a null pointer.
The way to scan all the entries in the group database is with
setgrent
, getgrent
, and endgrent
.
getgrent
or getgrent_r
.
getgrent
function reads the next entry from the stream
initialized by setgrent
. It returns a pointer to the entry. The
structure is statically allocated and is overwritten on subsequent calls
to getgrent
. You must copy the contents of the structure if you
wish to save the information.
getgrent
in that it returns the next
entry from the stream initialized by setgrent
. Like
fgetgrent_r
, it places the result in user-supplied buffers
pointed to result_buf and buffer.
If the function returns zero result contains a pointer to the data (normally equal to result_buf). If errors occurred the return value is non-zero and result contains a null pointer.
getgrent
or
getgrent_r
.
Go to the first, previous, next, last section, table of contents.