GETGRENT(3) — SUBROUTINES
NAME
getgrent, getgrgid, getgrnam, setgrent, endgrent − get group file entry
SYNOPSIS
#include <grp.h>
struct group ∗getgrent()
struct group ∗getgrgid(gid)
int gid;
struct group ∗getgrnam(name)
char ∗name;
setgrent()
endgrent()
DESCRIPTION
Getgrent, getgrgid and getgrnam each return pointers to an object with the following structure containing the broken-out fields of a line in the group file:
structgroup {
char∗gr_name;
char∗gr_passwd;
intgr_gid;
char∗∗gr_mem;
};
The members of this structure are:
gr_name The name of the group.
gr_passwd The encrypted password of the group.
gr_gid The numerical group-ID.
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.
FILES
/etc/group
/etc/yp/domainname/group.byname
/etc/yp/domainname/group.bygid
SEE ALSO
getlogin(3), getpwent(3), group(5), ypserv(8)
DIAGNOSTICS
A null pointer (0) is returned on EOF or error.
BUGS
The return value points to static information which is overwritten on each call.
Sun Release 2.0 — Last change: 23 August 1983