OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / 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  2009-03-30 "" "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 .ad l
49 .BR getgrent (),
50 .BR setgrent (),
51 .BR endgrent ():
52 _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
53 .ad b
54 .SH DESCRIPTION
55 The
56 .BR getgrent ()
57 function returns a pointer to a structure containing
58 the broken-out fields of a record in the group database
59 (e.g., the local group file
60 .IR /etc/group ,
61 NIS, and LDAP).
62 The first time it is called
63 it returns the first entry; thereafter, it returns successive entries.
64 .PP
65 The
66 .BR setgrent ()
67 function rewinds to the beginning
68 of the group database, to allow repeated scans.
69 .PP
70 The
71 .BR endgrent ()
72 function is used to close the group database
73 after all processing has been performed.
74 .PP
75 The \fIgroup\fP structure is defined in \fI<grp.h>\fP as follows:
76 .sp
77 .in +4n
78 .nf
79 struct group {
80     char   *gr_name;       /* group name */
81     char   *gr_passwd;     /* group password */
82     gid_t   gr_gid;        /* group ID */
83     char  **gr_mem;        /* group members */
84 };
85 .fi
86 .in
87 .SH "RETURN VALUE"
88 The
89 .BR getgrent ()
90 function returns a pointer to a
91 .I group
92 structure,
93 or NULL if there are no more entries or an error occurs.
94 .LP
95 Upon error,
96 .I errno
97 may be set.
98 If one wants to check
99 .I errno
100 after the call, it should be set to zero before the call.
101
102 The return value may point to a static area, and may be overwritten
103 by subsequent calls to
104 .BR getgrent (),
105 .BR getgrgid (3),
106 or
107 .BR getgrnam (3).
108 (Do not pass the returned pointer to
109 .BR free (3).)
110 .SH ERRORS
111 .TP
112 .B EINTR
113 A signal was caught.
114 .TP
115 .B EIO
116 I/O error.
117 .TP
118 .B EMFILE
119 The calling process already has too many open files.
120 .TP
121 .B ENFILE
122 Too many open files in the system.
123 .TP
124 .B ENOMEM
125 .\" not in POSIX
126 Insufficient memory to allocate
127 .I group
128 structure.
129 .TP
130 .B ERANGE
131 Insufficient buffer space supplied.
132 .SH FILES
133 .TP
134 .I /etc/group
135 local group database file
136 .SH "CONFORMING TO"
137 SVr4, 4.3BSD, POSIX.1-2001.
138 .SH "SEE ALSO"
139 .BR fgetgrent (3),
140 .BR getgrent_r (3),
141 .BR getgrgid (3),
142 .BR getgrnam (3),
143 .BR getgrouplist (3),
144 .BR putgrent (3)