1GETGRENT(3) Linux Programmer's Manual GETGRENT(3)
2
3
4
6 getgrent, setgrent, endgrent - get group file entry
7
9 #include <sys/types.h>
10 #include <grp.h>
11
12 struct group *getgrent(void);
13
14 void setgrent(void);
15
16 void endgrent(void);
17
18 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20 getgrent(), setgrent(), endgrent(): _SVID_SOURCE || _BSD_SOURCE ||
21 _XOPEN_SOURCE >= 500
22
24 The getgrent() function returns a pointer to a structure containing the
25 broken-out fields of a record in the group database (e.g., the local
26 group file /etc/group, NIS, and LDAP). The first time it is called it
27 returns the first entry; thereafter, it returns successive entries.
28
29 The setgrent() function rewinds to the beginning of the group database,
30 to allow repeated scans.
31
32 The endgrent() function is used to close the group database after all
33 processing has been performed.
34
35 The group structure is defined in <grp.h> as follows:
36
37 struct group {
38 char *gr_name; /* group name */
39 char *gr_passwd; /* group password */
40 gid_t gr_gid; /* group ID */
41 char **gr_mem; /* group members */
42 };
43
45 The getgrent() function returns a pointer to a group structure, or NULL
46 if there are no more entries or an error occurs.
47
48 Upon error, errno may be set. If one wants to check errno after the
49 call, it should be set to zero before the call.
50
51 The return value may point to a static area, and may be overwritten by
52 subsequent calls to getgrent(), getgrgid(3), or getgrnam(3). (Do not
53 pass the returned pointer to free(3).)
54
56 EINTR A signal was caught.
57
58 EIO I/O error.
59
60 EMFILE The calling process already has too many open files.
61
62 ENFILE Too many open files in the system.
63
64 ENOMEM Insufficient memory to allocate group structure.
65
66 ERANGE Insufficient buffer space supplied.
67
69 /etc/group
70 local group database file
71
73 SVr4, 4.3BSD, POSIX.1-2001.
74
76 fgetgrent(3), getgrent_r(3), getgrgid(3), getgrnam(3), getgrouplist(3),
77 putgrent(3)
78
80 This page is part of release 3.22 of the Linux man-pages project. A
81 description of the project, and information about reporting bugs, can
82 be found at http://www.kernel.org/doc/man-pages/.
83
84
85
86 2009-03-30 GETGRENT(3)