V7/usr/man/man3/getgrent.3
.TH GETGRENT 3
.SH NAME
getgrent, getgrgid, getgrnam, setgrent, endgrent \- get group file entry
.SH SYNOPSIS
.B #include <grp.h>
.PP
.B struct group *getgrent();
.PP
.B struct group *getgrgid(gid) int gid;
.PP
.B struct group *getgrnam(name) char *name;
.PP
.B int setgrent();
.PP
.B int endgrent();
.SH DESCRIPTION
.I Getgrent,
.I getgrgid
and
.I getgrnam
each return pointers
to an object
with the following structure
containing the broken-out
fields of a line in the group file.
.RS
.PP
.nf
.so /usr/include/grp.h
.fi
.RE
.PP
The members of this structure are:
.TP
gr_name
The name of the group.
.br
.ns
.TP
gr_passwd
The encrypted password of the group.
.br
.ns
.TP
gr_gid
The numerical group-ID.
.br
.ns
.TP
gr_mem
Null-terminated vector
of pointers to the individual
member names.
.PP
.I Getgrent
simply reads the next
line while
.I getgrgid
and
.I getgrnam
search until a matching
.I gid
or
.I 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.
.PP
A call to
.I setgrent
has the effect of rewinding
the group file
to allow
repeated searches.
.I Endgrent
may be called to
close the group file
when processing is complete.
.SH FILES
/etc/group
.SH "SEE ALSO"
getlogin(3), getpwent(3), group(5)
.SH DIAGNOSTICS
A null pointer
(0) is returned on EOF or error.
.SH BUGS
All information
is contained in a static area
so it must be copied if it is
to be saved.