]>
Commit | Line | Data |
---|---|---|
a784e502 | 1 | /* Copyright (C) 1991,1992,1995-2001,2003,2004,2010,2012 |
dfe11a13 | 2 | Free Software Foundation, Inc. |
2c6fe0bd | 3 | This file is part of the GNU C Library. |
28f540f4 | 4 | |
2c6fe0bd | 5 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
28f540f4 | 9 | |
2c6fe0bd UD |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
28f540f4 | 14 | |
41bdb6e2 AJ |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, write to the Free | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. */ | |
28f540f4 RM |
19 | |
20 | /* | |
21 | * POSIX Standard: 9.2.1 Group Database Access <grp.h> | |
22 | */ | |
23 | ||
24 | #ifndef _GRP_H | |
28f540f4 | 25 | #define _GRP_H 1 |
5107cf1d | 26 | |
28f540f4 RM |
27 | #include <features.h> |
28 | ||
29 | __BEGIN_DECLS | |
30 | ||
5107cf1d | 31 | #include <bits/types.h> |
28f540f4 | 32 | |
0f110f41 TBB |
33 | #define __need_size_t |
34 | #include <stddef.h> | |
35 | ||
28f540f4 | 36 | |
9756dfe1 | 37 | /* For the Single Unix specification we must define this type here. */ |
7a80496f | 38 | #if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined |
9756dfe1 | 39 | typedef __gid_t gid_t; |
7df789e0 | 40 | # define __gid_t_defined |
9756dfe1 UD |
41 | #endif |
42 | ||
28f540f4 RM |
43 | /* The group structure. */ |
44 | struct group | |
45 | { | |
46 | char *gr_name; /* Group name. */ | |
47 | char *gr_passwd; /* Password. */ | |
48 | __gid_t gr_gid; /* Group ID. */ | |
49 | char **gr_mem; /* Member list. */ | |
50 | }; | |
51 | ||
52 | ||
dfd2257a UD |
53 | #if defined __USE_SVID || defined __USE_GNU |
54 | # define __need_FILE | |
55 | # include <stdio.h> | |
28f540f4 RM |
56 | #endif |
57 | ||
28f540f4 | 58 | |
dfd2257a | 59 | #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED |
2c008571 | 60 | /* Rewind the group-file stream. |
28f540f4 | 61 | |
2c008571 UD |
62 | This function is a possible cancellation point and therefore not |
63 | marked with __THROW. */ | |
64 | extern void setgrent (void); | |
dfe11a13 | 65 | #endif |
28f540f4 | 66 | |
dfe11a13 UD |
67 | #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED \ |
68 | || defined __USE_XOPEN2K8 | |
2c008571 UD |
69 | /* Close the group-file stream. |
70 | ||
71 | This function is a possible cancellation point and therefore not | |
72 | marked with __THROW. */ | |
73 | extern void endgrent (void); | |
74 | ||
75 | /* Read an entry from the group-file stream, opening it if necessary. | |
76 | ||
77 | This function is a possible cancellation point and therefore not | |
78 | marked with __THROW. */ | |
79 | extern struct group *getgrent (void); | |
28f540f4 RM |
80 | #endif |
81 | ||
82 | #ifdef __USE_SVID | |
2c008571 UD |
83 | /* Read a group entry from STREAM. |
84 | ||
85 | This function is not part of POSIX and therefore no official | |
86 | cancellation point. But due to similarity with an POSIX interface | |
87 | or due to the implementation it is a cancellation point and | |
88 | therefore not marked with __THROW. */ | |
89 | extern struct group *fgetgrent (FILE *__stream); | |
28f540f4 RM |
90 | #endif |
91 | ||
7ce241a0 | 92 | #ifdef __USE_GNU |
2c008571 UD |
93 | /* Write the given entry onto the given stream. |
94 | ||
95 | This function is not part of POSIX and therefore no official | |
96 | cancellation point. But due to similarity with an POSIX interface | |
97 | or due to the implementation it is a cancellation point and | |
98 | therefore not marked with __THROW. */ | |
a784e502 | 99 | extern int putgrent (const struct group *__restrict __p, |
2c008571 | 100 | FILE *__restrict __f); |
7ce241a0 UD |
101 | #endif |
102 | ||
2c008571 UD |
103 | /* Search for an entry with a matching group ID. |
104 | ||
105 | This function is a possible cancellation point and therefore not | |
106 | marked with __THROW. */ | |
107 | extern struct group *getgrgid (__gid_t __gid); | |
108 | ||
109 | /* Search for an entry with a matching group name. | |
28f540f4 | 110 | |
2c008571 UD |
111 | This function is a possible cancellation point and therefore not |
112 | marked with __THROW. */ | |
a784e502 | 113 | extern struct group *getgrnam (const char *__name); |
28f540f4 | 114 | |
19361cb7 UD |
115 | #if defined __USE_POSIX || defined __USE_MISC |
116 | ||
dfd2257a | 117 | # ifdef __USE_MISC |
23396375 UD |
118 | /* Reasonable value for the buffer sized used in the reentrant |
119 | functions below. But better use `sysconf'. */ | |
dfd2257a UD |
120 | # define NSS_BUFLEN_GROUP 1024 |
121 | # endif | |
23396375 UD |
122 | |
123 | /* Reentrant versions of some of the functions above. | |
124 | ||
84384f5b UD |
125 | PLEASE NOTE: the `getgrent_r' function is not (yet) standardized. |
126 | The interface may change in later versions of this library. But | |
127 | the interface is designed following the principals used for the | |
128 | other reentrant functions so the chances are good this is what the | |
2c008571 UD |
129 | POSIX people would choose. |
130 | ||
131 | This function is not part of POSIX and therefore no official | |
132 | cancellation point. But due to similarity with an POSIX interface | |
133 | or due to the implementation it is a cancellation point and | |
134 | therefore not marked with __THROW. */ | |
23396375 | 135 | |
0ed99ce4 | 136 | # ifdef __USE_GNU |
c1422e5b UD |
137 | extern int getgrent_r (struct group *__restrict __resultbuf, |
138 | char *__restrict __buffer, size_t __buflen, | |
2c008571 | 139 | struct group **__restrict __result); |
dfd2257a | 140 | # endif |
23396375 | 141 | |
2c008571 UD |
142 | /* Search for an entry with a matching group ID. |
143 | ||
144 | This function is a possible cancellation point and therefore not | |
145 | marked with __THROW. */ | |
c1422e5b UD |
146 | extern int getgrgid_r (__gid_t __gid, struct group *__restrict __resultbuf, |
147 | char *__restrict __buffer, size_t __buflen, | |
2c008571 UD |
148 | struct group **__restrict __result); |
149 | ||
150 | /* Search for an entry with a matching group name. | |
23396375 | 151 | |
2c008571 UD |
152 | This function is a possible cancellation point and therefore not |
153 | marked with __THROW. */ | |
a784e502 | 154 | extern int getgrnam_r (const char *__restrict __name, |
c1422e5b UD |
155 | struct group *__restrict __resultbuf, |
156 | char *__restrict __buffer, size_t __buflen, | |
2c008571 | 157 | struct group **__restrict __result); |
23396375 | 158 | |
dfd2257a | 159 | # ifdef __USE_SVID |
84384f5b | 160 | /* Read a group entry from STREAM. This function is not standardized |
2c008571 UD |
161 | an probably never will. |
162 | ||
163 | This function is not part of POSIX and therefore no official | |
164 | cancellation point. But due to similarity with an POSIX interface | |
165 | or due to the implementation it is a cancellation point and | |
166 | therefore not marked with __THROW. */ | |
c1422e5b UD |
167 | extern int fgetgrent_r (FILE *__restrict __stream, |
168 | struct group *__restrict __resultbuf, | |
169 | char *__restrict __buffer, size_t __buflen, | |
2c008571 | 170 | struct group **__restrict __result); |
dfd2257a | 171 | # endif |
a8922de8 | 172 | |
9d187dd4 | 173 | #endif /* POSIX or reentrant */ |
23396375 | 174 | |
28f540f4 RM |
175 | |
176 | #ifdef __USE_BSD | |
177 | ||
dfd2257a UD |
178 | # define __need_size_t |
179 | # include <stddef.h> | |
28f540f4 RM |
180 | |
181 | /* Set the group set for the current user to GROUPS (N of them). */ | |
a784e502 | 182 | extern int setgroups (size_t __n, const __gid_t *__groups) __THROW; |
28f540f4 | 183 | |
8fee1bb0 UD |
184 | /* Store at most *NGROUPS members of the group set for USER into |
185 | *GROUPS. Also include GROUP. The actual number of groups found is | |
2c008571 UD |
186 | returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. |
187 | ||
188 | This function is not part of POSIX and therefore no official | |
189 | cancellation point. But due to similarity with an POSIX interface | |
190 | or due to the implementation it is a cancellation point and | |
191 | therefore not marked with __THROW. */ | |
a784e502 | 192 | extern int getgrouplist (const char *__user, __gid_t __group, |
2c008571 | 193 | __gid_t *__groups, int *__ngroups); |
8fee1bb0 | 194 | |
28f540f4 RM |
195 | /* Initialize the group set for the current user |
196 | by reading the group database and using all groups | |
2c008571 UD |
197 | of which USER is a member. Also include GROUP. |
198 | ||
199 | This function is not part of POSIX and therefore no official | |
200 | cancellation point. But due to similarity with an POSIX interface | |
201 | or due to the implementation it is a cancellation point and | |
202 | therefore not marked with __THROW. */ | |
a784e502 | 203 | extern int initgroups (const char *__user, __gid_t __group); |
28f540f4 RM |
204 | |
205 | #endif /* Use BSD. */ | |
206 | ||
207 | __END_DECLS | |
208 | ||
209 | #endif /* grp.h */ |