powerpc: Various P7-optimized string functions
[glibc.git] / grp / grp.h
blobc06ef03ae6dff4be96589f35dc7d18d49aa1b4c3
1 /* Copyright (C) 1991,1992,1995-2001,2003,2004,2010
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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
21 * POSIX Standard: 9.2.1 Group Database Access <grp.h>
24 #ifndef _GRP_H
25 #define _GRP_H 1
27 #include <features.h>
29 __BEGIN_DECLS
31 #include <bits/types.h>
33 #define __need_size_t
34 #include <stddef.h>
37 /* For the Single Unix specification we must define this type here. */
38 #if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined
39 typedef __gid_t gid_t;
40 # define __gid_t_defined
41 #endif
43 /* The group structure. */
44 struct group
46 char *gr_name; /* Group name. */
47 char *gr_passwd; /* Password. */
48 __gid_t gr_gid; /* Group ID. */
49 char **gr_mem; /* Member list. */
53 #if defined __USE_SVID || defined __USE_GNU
54 # define __need_FILE
55 # include <stdio.h>
56 #endif
59 #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
60 /* Rewind the group-file stream.
62 This function is a possible cancellation point and therefore not
63 marked with __THROW. */
64 extern void setgrent (void);
65 #endif
67 #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED \
68 || defined __USE_XOPEN2K8
69 /* Close the group-file stream.
71 This function is a possible cancellation point and therefore not
72 marked with __THROW. */
73 extern void endgrent (void);
75 /* Read an entry from the group-file stream, opening it if necessary.
77 This function is a possible cancellation point and therefore not
78 marked with __THROW. */
79 extern struct group *getgrent (void);
80 #endif
82 #ifdef __USE_SVID
83 /* Read a group entry from STREAM.
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);
90 #endif
92 #ifdef __USE_GNU
93 /* Write the given entry onto the given stream.
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. */
99 extern int putgrent (__const struct group *__restrict __p,
100 FILE *__restrict __f);
101 #endif
103 /* Search for an entry with a matching group ID.
105 This function is a possible cancellation point and therefore not
106 marked with __THROW. */
107 extern struct group *getgrgid (__gid_t __gid);
109 /* Search for an entry with a matching group name.
111 This function is a possible cancellation point and therefore not
112 marked with __THROW. */
113 extern struct group *getgrnam (__const char *__name);
115 #if defined __USE_POSIX || defined __USE_MISC
117 # ifdef __USE_MISC
118 /* Reasonable value for the buffer sized used in the reentrant
119 functions below. But better use `sysconf'. */
120 # define NSS_BUFLEN_GROUP 1024
121 # endif
123 /* Reentrant versions of some of the functions above.
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
129 POSIX people would choose.
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. */
136 # ifdef __USE_GNU
137 extern int getgrent_r (struct group *__restrict __resultbuf,
138 char *__restrict __buffer, size_t __buflen,
139 struct group **__restrict __result);
140 # endif
142 /* Search for an entry with a matching group ID.
144 This function is a possible cancellation point and therefore not
145 marked with __THROW. */
146 extern int getgrgid_r (__gid_t __gid, struct group *__restrict __resultbuf,
147 char *__restrict __buffer, size_t __buflen,
148 struct group **__restrict __result);
150 /* Search for an entry with a matching group name.
152 This function is a possible cancellation point and therefore not
153 marked with __THROW. */
154 extern int getgrnam_r (__const char *__restrict __name,
155 struct group *__restrict __resultbuf,
156 char *__restrict __buffer, size_t __buflen,
157 struct group **__restrict __result);
159 # ifdef __USE_SVID
160 /* Read a group entry from STREAM. This function is not standardized
161 an probably never will.
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. */
167 extern int fgetgrent_r (FILE *__restrict __stream,
168 struct group *__restrict __resultbuf,
169 char *__restrict __buffer, size_t __buflen,
170 struct group **__restrict __result);
171 # endif
173 #endif /* POSIX or reentrant */
176 #ifdef __USE_BSD
178 # define __need_size_t
179 # include <stddef.h>
181 /* Set the group set for the current user to GROUPS (N of them). */
182 extern int setgroups (size_t __n, __const __gid_t *__groups) __THROW;
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
186 returned in *NGROUPS. Return -1 if the if *NGROUPS is too small.
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. */
192 extern int getgrouplist (__const char *__user, __gid_t __group,
193 __gid_t *__groups, int *__ngroups);
195 /* Initialize the group set for the current user
196 by reading the group database and using all groups
197 of which USER is a member. Also include GROUP.
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. */
203 extern int initgroups (__const char *__user, __gid_t __group);
205 #endif /* Use BSD. */
207 __END_DECLS
209 #endif /* grp.h */