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 rewritten 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.
The way to scan all the entries in the group database is with setgrent
, getgrent
, and endgrent
.
getgrent
.
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 rewritten on subsequent calls to getgrent
. You must copy the contents of the structure if you wish to save the information.
getgrent
.