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