OSDN Git Service

(split) LDP man-pages の original/ を v3.29 に更新。
[linuxjm/LDP_man-pages.git] / original / man3 / getgrent.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\"     386BSD man pages
27 .\" Modified Sat Jul 24 19:29:54 1993 by Rik Faith (faith@cs.unc.edu)
28 .TH GETGRENT 3  2010-09-20 "" "Linux Programmer's Manual"
29 .SH NAME
30 getgrent, setgrent, endgrent \- get group file entry
31 .SH SYNOPSIS
32 .nf
33 .B #include <sys/types.h>
34 .B #include <grp.h>
35 .sp
36 .B struct group *getgrent(void);
37 .sp
38 .B void setgrent(void);
39 .sp
40 .B void endgrent(void);
41 .fi
42 .sp
43 .in -4n
44 Feature Test Macro Requirements for glibc (see
45 .BR feature_test_macros (7)):
46 .in
47 .sp
48 .PD 0
49 .ad l
50 .BR setgrent ():
51 .RS 4
52 _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
53 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED ||
54 .br
55 /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L
56 .RE
57 .sp
58 .BR getgrent (),
59 .BR endgrent ():
60 .RS 4
61 _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
62 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
63 .RE
64 .PD
65 .ad b
66 .SH DESCRIPTION
67 The
68 .BR getgrent ()
69 function returns a pointer to a structure containing
70 the broken-out fields of a record in the group database
71 (e.g., the local group file
72 .IR /etc/group ,
73 NIS, and LDAP).
74 The first time
75 .BR getgrent ()
76 is called,
77 it returns the first entry; thereafter, it returns successive entries.
78 .PP
79 The
80 .BR setgrent ()
81 function rewinds to the beginning
82 of the group database, to allow repeated scans.
83 .PP
84 The
85 .BR endgrent ()
86 function is used to close the group database
87 after all processing has been performed.
88 .PP
89 The \fIgroup\fP structure is defined in \fI<grp.h>\fP as follows:
90 .sp
91 .in +4n
92 .nf
93 struct group {
94     char   *gr_name;       /* group name */
95     char   *gr_passwd;     /* group password */
96     gid_t   gr_gid;        /* group ID */
97     char  **gr_mem;        /* group members */
98 };
99 .fi
100 .in
101 .SH "RETURN VALUE"
102 The
103 .BR getgrent ()
104 function returns a pointer to a
105 .I group
106 structure,
107 or NULL if there are no more entries or an error occurs.
108 .LP
109 Upon error,
110 .I errno
111 may be set.
112 If one wants to check
113 .I errno
114 after the call, it should be set to zero before the call.
115
116 The return value may point to a static area, and may be overwritten
117 by subsequent calls to
118 .BR getgrent (),
119 .BR getgrgid (3),
120 or
121 .BR getgrnam (3).
122 (Do not pass the returned pointer to
123 .BR free (3).)
124 .SH ERRORS
125 .TP
126 .B EINTR
127 A signal was caught.
128 .TP
129 .B EIO
130 I/O error.
131 .TP
132 .B EMFILE
133 The calling process already has too many open files.
134 .TP
135 .B ENFILE
136 Too many open files in the system.
137 .TP
138 .B ENOMEM
139 .\" not in POSIX
140 Insufficient memory to allocate
141 .I group
142 structure.
143 .TP
144 .B ERANGE
145 Insufficient buffer space supplied.
146 .SH FILES
147 .TP
148 .I /etc/group
149 local group database file
150 .SH "CONFORMING TO"
151 SVr4, 4.3BSD, POSIX.1-2001.
152 .SH "SEE ALSO"
153 .BR fgetgrent (3),
154 .BR getgrent_r (3),
155 .BR getgrgid (3),
156 .BR getgrnam (3),
157 .BR getgrouplist (3),
158 .BR putgrent (3)