add setgrfile; bug report 4.3BSD/lib/96
[unix-history] / usr / src / lib / libc / gen / getgrent.3
CommitLineData
792b7b2c 1.\" @(#)getgrent.3 6.2 (Berkeley) %G%
6c9d675c 2.\"
6548329e 3.TH GETGRENT 3 ""
6c9d675c
KM
4.AT 3
5.SH NAME
6getgrent, getgrgid, getgrnam, setgrent, endgrent \- get group file entry
7.SH SYNOPSIS
8.nf
9.B #include <grp.h>
10.PP
11.B struct group *getgrent()
12.PP
13.B struct group *getgrgid(gid)
14.B int gid;
15.PP
16.B struct group *getgrnam(name)
17.B char *name;
18.PP
19.B setgrent()
20.PP
21.B endgrent()
22.fi
23.SH DESCRIPTION
24.I Getgrent,
25.I getgrgid
26and
27.I getgrnam
28each return pointers
29to an object
30with the following structure
31containing the broken-out
32fields of a line in the group file.
33.RS
34.PP
35.nf
36.so /usr/include/grp.h
37.fi
38.RE
39.PP
40The members of this structure are:
41.TP \w'gr_passwd'u+2n
42gr_name
43The name of the group.
44.br
45.ns
46.TP \w'gr_passwd'u+2n
47gr_passwd
48The encrypted password of the group.
49.br
50.ns
51.TP \w'gr_passwd'u+2n
52gr_gid
53The numerical group-ID.
54.br
55.ns
56.TP \w'gr_passwd'u+2n
57gr_mem
58Null-terminated vector
59of pointers to the individual
60member names.
61.PP
62.I Getgrent
63simply reads the next
64line while
65.I getgrgid
66and
67.I getgrnam
68search until a matching
69.I gid
70or
71.I name
72is found
73(or until EOF is encountered).
74Each routine picks up
75where the others leave off
76so successive calls may be used
77to search the entire file.
78.PP
79A call to
80.I setgrent
81has the effect of rewinding
82the group file
83to allow
84repeated searches.
85.I Endgrent
86may be called to
87close the group file
88when processing is complete.
89.SH FILES
90/etc/group
91.SH "SEE ALSO"
92getlogin(3), getpwent(3), group(5)
93.SH DIAGNOSTICS
94A null pointer
95(0) is returned on EOF or error.
96.SH BUGS
97All information
98is contained in a static area
99so it must be copied if it is
100to be saved.