Simplify perturb_byte logic.
[glibc.git] / grp / grp.h
blob3cbfc262e6f91c53e7e685ffc8d0243d3b53073b
1 /* Copyright (C) 1991-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
19 * POSIX Standard: 9.2.1 Group Database Access <grp.h>
22 #ifndef _GRP_H
23 #define _GRP_H 1
25 #include <features.h>
27 __BEGIN_DECLS
29 #include <bits/types.h>
31 #define __need_size_t
32 #include <stddef.h>
35 /* For the Single Unix specification we must define this type here. */
36 #if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined
37 typedef __gid_t gid_t;
38 # define __gid_t_defined
39 #endif
41 /* The group structure. */
42 struct group
44 char *gr_name; /* Group name. */
45 char *gr_passwd; /* Password. */
46 __gid_t gr_gid; /* Group ID. */
47 char **gr_mem; /* Member list. */
51 #if defined __USE_SVID || defined __USE_GNU
52 # define __need_FILE
53 # include <stdio.h>
54 #endif
57 #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
58 /* Rewind the group-file stream.
60 This function is a possible cancellation point and therefore not
61 marked with __THROW. */
62 extern void setgrent (void);
63 #endif
65 #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED \
66 || defined __USE_XOPEN2K8
67 /* Close the group-file stream.
69 This function is a possible cancellation point and therefore not
70 marked with __THROW. */
71 extern void endgrent (void);
73 /* Read an entry from the group-file stream, opening it if necessary.
75 This function is a possible cancellation point and therefore not
76 marked with __THROW. */
77 extern struct group *getgrent (void);
78 #endif
80 #ifdef __USE_SVID
81 /* Read a group entry from STREAM.
83 This function is not part of POSIX and therefore no official
84 cancellation point. But due to similarity with an POSIX interface
85 or due to the implementation it is a cancellation point and
86 therefore not marked with __THROW. */
87 extern struct group *fgetgrent (FILE *__stream);
88 #endif
90 #ifdef __USE_GNU
91 /* Write the given entry onto the given stream.
93 This function is not part of POSIX and therefore no official
94 cancellation point. But due to similarity with an POSIX interface
95 or due to the implementation it is a cancellation point and
96 therefore not marked with __THROW. */
97 extern int putgrent (const struct group *__restrict __p,
98 FILE *__restrict __f);
99 #endif
101 /* Search for an entry with a matching group ID.
103 This function is a possible cancellation point and therefore not
104 marked with __THROW. */
105 extern struct group *getgrgid (__gid_t __gid);
107 /* Search for an entry with a matching group name.
109 This function is a possible cancellation point and therefore not
110 marked with __THROW. */
111 extern struct group *getgrnam (const char *__name);
113 #if defined __USE_POSIX || defined __USE_MISC
115 # ifdef __USE_MISC
116 /* Reasonable value for the buffer sized used in the reentrant
117 functions below. But better use `sysconf'. */
118 # define NSS_BUFLEN_GROUP 1024
119 # endif
121 /* Reentrant versions of some of the functions above.
123 PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.
124 The interface may change in later versions of this library. But
125 the interface is designed following the principals used for the
126 other reentrant functions so the chances are good this is what the
127 POSIX people would choose.
129 This function is not part of POSIX and therefore no official
130 cancellation point. But due to similarity with an POSIX interface
131 or due to the implementation it is a cancellation point and
132 therefore not marked with __THROW. */
134 # ifdef __USE_GNU
135 extern int getgrent_r (struct group *__restrict __resultbuf,
136 char *__restrict __buffer, size_t __buflen,
137 struct group **__restrict __result);
138 # endif
140 /* Search for an entry with a matching group ID.
142 This function is a possible cancellation point and therefore not
143 marked with __THROW. */
144 extern int getgrgid_r (__gid_t __gid, struct group *__restrict __resultbuf,
145 char *__restrict __buffer, size_t __buflen,
146 struct group **__restrict __result);
148 /* Search for an entry with a matching group name.
150 This function is a possible cancellation point and therefore not
151 marked with __THROW. */
152 extern int getgrnam_r (const char *__restrict __name,
153 struct group *__restrict __resultbuf,
154 char *__restrict __buffer, size_t __buflen,
155 struct group **__restrict __result);
157 # ifdef __USE_SVID
158 /* Read a group entry from STREAM. This function is not standardized
159 an probably never will.
161 This function is not part of POSIX and therefore no official
162 cancellation point. But due to similarity with an POSIX interface
163 or due to the implementation it is a cancellation point and
164 therefore not marked with __THROW. */
165 extern int fgetgrent_r (FILE *__restrict __stream,
166 struct group *__restrict __resultbuf,
167 char *__restrict __buffer, size_t __buflen,
168 struct group **__restrict __result);
169 # endif
171 #endif /* POSIX or reentrant */
174 #ifdef __USE_BSD
176 # define __need_size_t
177 # include <stddef.h>
179 /* Set the group set for the current user to GROUPS (N of them). */
180 extern int setgroups (size_t __n, const __gid_t *__groups) __THROW;
182 /* Store at most *NGROUPS members of the group set for USER into
183 *GROUPS. Also include GROUP. The actual number of groups found is
184 returned in *NGROUPS. Return -1 if the if *NGROUPS is too small.
186 This function is not part of POSIX and therefore no official
187 cancellation point. But due to similarity with an POSIX interface
188 or due to the implementation it is a cancellation point and
189 therefore not marked with __THROW. */
190 extern int getgrouplist (const char *__user, __gid_t __group,
191 __gid_t *__groups, int *__ngroups);
193 /* Initialize the group set for the current user
194 by reading the group database and using all groups
195 of which USER is a member. Also include GROUP.
197 This function is not part of POSIX and therefore no official
198 cancellation point. But due to similarity with an POSIX interface
199 or due to the implementation it is a cancellation point and
200 therefore not marked with __THROW. */
201 extern int initgroups (const char *__user, __gid_t __group);
203 #endif /* Use BSD. */
205 __END_DECLS
207 #endif /* grp.h */