instrs -> instrs.adb
[unix-history] / usr / src / lib / libc / gen / getgrent.3
CommitLineData
62ab31a2
KB
1.\" Copyright (c) 1988 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)getgrent.3 6.3 (Berkeley) %G%
6c9d675c 6.\"
6548329e 7.TH GETGRENT 3 ""
6c9d675c
KM
8.AT 3
9.SH NAME
f39b3af6 10getgrent, getgrgid, getgrnam, setgrent, endgrent setgrfile \- get group file entry
6c9d675c
KM
11.SH SYNOPSIS
12.nf
62ab31a2 13.B #include <sys/types.h>
6c9d675c
KM
14.B #include <grp.h>
15.PP
16.B struct group *getgrent()
17.PP
18.B struct group *getgrgid(gid)
62ab31a2 19.B gid_t gid;
6c9d675c
KM
20.PP
21.B struct group *getgrnam(name)
22.B char *name;
23.PP
24.B setgrent()
25.PP
62ab31a2 26.B void endgrent()
f39b3af6 27.PP
62ab31a2 28.B void setgrfile(name)
f39b3af6 29.B char *name;
6c9d675c
KM
30.fi
31.SH DESCRIPTION
32.I Getgrent,
33.I getgrgid
34and
35.I getgrnam
62ab31a2
KB
36each return pointers to an object with the following structure
37containing the broken-out fields of a line in the group file,
38as described in
39.IR < grp.h > .
6c9d675c
KM
40.RS
41.PP
42.nf
62ab31a2
KB
43struct group {
44 char *gr_name;
45 char *gr_passwd;
46 gid_t gr_gid;
47 char **gr_mem;
48};
49.ft R
50.ad
6c9d675c
KM
51.fi
52.RE
53.PP
62ab31a2
KB
54The fields have meanings described in
55.IR grp (5).
6c9d675c 56.PP
62ab31a2
KB
57.I Setgrfile
58changes the default group file to
59.IR name ,
60thus allowing usage of alternate group files.
61.PP
62.I Setgrent
63opens the file (closing any previously opened file) or rewinds it
64if it it already open.
65.PP
66.I Endgrent
67closes any open files.
68.PP
69.I Getgrgid
6c9d675c
KM
70and
71.I getgrnam
62ab31a2 72search the entire file (opening it if necessary) for a matching
6c9d675c
KM
73.I gid
74or
62ab31a2 75.IR name .
6c9d675c 76.PP
62ab31a2
KB
77For programs wishing to read the entire database,
78.I getgrent
79reads the next entry (opening the file if necessary).
6c9d675c
KM
80.SH FILES
81/etc/group
82.SH "SEE ALSO"
83getlogin(3), getpwent(3), group(5)
84.SH DIAGNOSTICS
62ab31a2
KB
85The routines
86.IR getgrent ,
87.IR getgruid ,
88and
89.IR getgrnam ,
90return a null pointer (0) on EOF or error.
91.I Setgrent
92returns 0 on failure, 1 on success.
93.I Endgrent
94and
95.I setgrfile
96have no return value.
6c9d675c 97.SH BUGS
62ab31a2
KB
98All information is contained in a static area so it must be
99copied if it is to be saved.