Add x32 C++ type data
[glibc.git] / grp / grp.h
blobe2f2ec1cf7c5df906512abae03bfd83201f5dd68
1 /* Copyright (C) 1991,1992,1995-2001,2003,2004,2010,2012
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
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.
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
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
20 * POSIX Standard: 9.2.1 Group Database Access <grp.h>
23 #ifndef _GRP_H
24 #define _GRP_H 1
26 #include <features.h>
28 __BEGIN_DECLS
30 #include <bits/types.h>
32 #define __need_size_t
33 #include <stddef.h>
36 /* For the Single Unix specification we must define this type here. */
37 #if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined
38 typedef __gid_t gid_t;
39 # define __gid_t_defined
40 #endif
42 /* The group structure. */
43 struct group
45 char *gr_name; /* Group name. */
46 char *gr_passwd; /* Password. */
47 __gid_t gr_gid; /* Group ID. */
48 char **gr_mem; /* Member list. */
52 #if defined __USE_SVID || defined __USE_GNU
53 # define __need_FILE
54 # include <stdio.h>
55 #endif
58 #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
59 /* Rewind the group-file stream.
61 This function is a possible cancellation point and therefore not
62 marked with __THROW. */
63 extern void setgrent (void);
64 #endif
66 #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED \
67 || defined __USE_XOPEN2K8
68 /* Close the group-file stream.
70 This function is a possible cancellation point and therefore not
71 marked with __THROW. */
72 extern void endgrent (void);
74 /* Read an entry from the group-file stream, opening it if necessary.
76 This function is a possible cancellation point and therefore not
77 marked with __THROW. */
78 extern struct group *getgrent (void);
79 #endif
81 #ifdef __USE_SVID
82 /* Read a group entry from STREAM.
84 This function is not part of POSIX and therefore no official
85 cancellation point. But due to similarity with an POSIX interface
86 or due to the implementation it is a cancellation point and
87 therefore not marked with __THROW. */
88 extern struct group *fgetgrent (FILE *__stream);
89 #endif
91 #ifdef __USE_GNU
92 /* Write the given entry onto the given stream.
94 This function is not part of POSIX and therefore no official
95 cancellation point. But due to similarity with an POSIX interface
96 or due to the implementation it is a cancellation point and
97 therefore not marked with __THROW. */
98 extern int putgrent (const struct group *__restrict __p,
99 FILE *__restrict __f);
100 #endif
102 /* Search for an entry with a matching group ID.
104 This function is a possible cancellation point and therefore not
105 marked with __THROW. */
106 extern struct group *getgrgid (__gid_t __gid);
108 /* Search for an entry with a matching group name.
110 This function is a possible cancellation point and therefore not
111 marked with __THROW. */
112 extern struct group *getgrnam (const char *__name);
114 #if defined __USE_POSIX || defined __USE_MISC
116 # ifdef __USE_MISC
117 /* Reasonable value for the buffer sized used in the reentrant
118 functions below. But better use `sysconf'. */
119 # define NSS_BUFLEN_GROUP 1024
120 # endif
122 /* Reentrant versions of some of the functions above.
124 PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.
125 The interface may change in later versions of this library. But
126 the interface is designed following the principals used for the
127 other reentrant functions so the chances are good this is what the
128 POSIX people would choose.
130 This function is not part of POSIX and therefore no official
131 cancellation point. But due to similarity with an POSIX interface
132 or due to the implementation it is a cancellation point and
133 therefore not marked with __THROW. */
135 # ifdef __USE_GNU
136 extern int getgrent_r (struct group *__restrict __resultbuf,
137 char *__restrict __buffer, size_t __buflen,
138 struct group **__restrict __result);
139 # endif
141 /* Search for an entry with a matching group ID.
143 This function is a possible cancellation point and therefore not
144 marked with __THROW. */
145 extern int getgrgid_r (__gid_t __gid, struct group *__restrict __resultbuf,
146 char *__restrict __buffer, size_t __buflen,
147 struct group **__restrict __result);
149 /* Search for an entry with a matching group name.
151 This function is a possible cancellation point and therefore not
152 marked with __THROW. */
153 extern int getgrnam_r (const char *__restrict __name,
154 struct group *__restrict __resultbuf,
155 char *__restrict __buffer, size_t __buflen,
156 struct group **__restrict __result);
158 # ifdef __USE_SVID
159 /* Read a group entry from STREAM. This function is not standardized
160 an probably never will.
162 This function is not part of POSIX and therefore no official
163 cancellation point. But due to similarity with an POSIX interface
164 or due to the implementation it is a cancellation point and
165 therefore not marked with __THROW. */
166 extern int fgetgrent_r (FILE *__restrict __stream,
167 struct group *__restrict __resultbuf,
168 char *__restrict __buffer, size_t __buflen,
169 struct group **__restrict __result);
170 # endif
172 #endif /* POSIX or reentrant */
175 #ifdef __USE_BSD
177 # define __need_size_t
178 # include <stddef.h>
180 /* Set the group set for the current user to GROUPS (N of them). */
181 extern int setgroups (size_t __n, const __gid_t *__groups) __THROW;
183 /* Store at most *NGROUPS members of the group set for USER into
184 *GROUPS. Also include GROUP. The actual number of groups found is
185 returned in *NGROUPS. Return -1 if the if *NGROUPS is too small.
187 This function is not part of POSIX and therefore no official
188 cancellation point. But due to similarity with an POSIX interface
189 or due to the implementation it is a cancellation point and
190 therefore not marked with __THROW. */
191 extern int getgrouplist (const char *__user, __gid_t __group,
192 __gid_t *__groups, int *__ngroups);
194 /* Initialize the group set for the current user
195 by reading the group database and using all groups
196 of which USER is a member. Also include GROUP.
198 This function is not part of POSIX and therefore no official
199 cancellation point. But due to similarity with an POSIX interface
200 or due to the implementation it is a cancellation point and
201 therefore not marked with __THROW. */
202 extern int initgroups (const char *__user, __gid_t __group);
204 #endif /* Use BSD. */
206 __END_DECLS
208 #endif /* grp.h */