#include <grp.h>struct group *getgrent()
struct group *getgrgid(gid) int gid;
struct group *getgrnam(name) char *name;
setgrent()
endgrent()
The members of this structure are:
\w'gr_passwd'u+2n gr_name The name of the group.
.ns
\w'gr_passwd'u+2n gr_passwd The encrypted password of the group.
.ns
\w'gr_passwd'u+2n gr_gid The numerical group-ID.
.ns
\w'gr_passwd'u+2n gr_mem Null-terminated vector of pointers to the individual member names.
Getgrent simply reads the next line while getgrgid and getgrnam search until a matching gid or name is found (or until EOF is encountered). Each routine picks up where the others leave off so successive calls may be used to search the entire file.
A call to setgrent has the effect of rewinding the group file to allow repeated searches. Endgrent may be called to close the group file when processing is complete.