]> git.ipfire.org Git - thirdparty/glibc.git/blame - grp/grp.h
Replace FSF snail mail address with URLs.
[thirdparty/glibc.git] / grp / grp.h
CommitLineData
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 15 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
28f540f4
RM
18
19/*
20 * POSIX Standard: 9.2.1 Group Database Access <grp.h>
21 */
22
23#ifndef _GRP_H
28f540f4 24#define _GRP_H 1
5107cf1d 25
28f540f4
RM
26#include <features.h>
27
28__BEGIN_DECLS
29
5107cf1d 30#include <bits/types.h>
28f540f4 31
0f110f41
TBB
32#define __need_size_t
33#include <stddef.h>
34
28f540f4 35
9756dfe1 36/* For the Single Unix specification we must define this type here. */
7a80496f 37#if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined
9756dfe1 38typedef __gid_t gid_t;
7df789e0 39# define __gid_t_defined
9756dfe1
UD
40#endif
41
28f540f4
RM
42/* The group structure. */
43struct group
44 {
45 char *gr_name; /* Group name. */
46 char *gr_passwd; /* Password. */
47 __gid_t gr_gid; /* Group ID. */
48 char **gr_mem; /* Member list. */
49 };
50
51
dfd2257a
UD
52#if defined __USE_SVID || defined __USE_GNU
53# define __need_FILE
54# include <stdio.h>
28f540f4
RM
55#endif
56
28f540f4 57
dfd2257a 58#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
2c008571 59/* Rewind the group-file stream.
28f540f4 60
2c008571
UD
61 This function is a possible cancellation point and therefore not
62 marked with __THROW. */
63extern void setgrent (void);
dfe11a13 64#endif
28f540f4 65
dfe11a13
UD
66#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED \
67 || defined __USE_XOPEN2K8
2c008571
UD
68/* Close the group-file stream.
69
70 This function is a possible cancellation point and therefore not
71 marked with __THROW. */
72extern void endgrent (void);
73
74/* Read an entry from the group-file stream, opening it if necessary.
75
76 This function is a possible cancellation point and therefore not
77 marked with __THROW. */
78extern struct group *getgrent (void);
28f540f4
RM
79#endif
80
81#ifdef __USE_SVID
2c008571
UD
82/* Read a group entry from STREAM.
83
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. */
88extern struct group *fgetgrent (FILE *__stream);
28f540f4
RM
89#endif
90
7ce241a0 91#ifdef __USE_GNU
2c008571
UD
92/* Write the given entry onto the given stream.
93
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. */
a784e502 98extern int putgrent (const struct group *__restrict __p,
2c008571 99 FILE *__restrict __f);
7ce241a0
UD
100#endif
101
2c008571
UD
102/* Search for an entry with a matching group ID.
103
104 This function is a possible cancellation point and therefore not
105 marked with __THROW. */
106extern struct group *getgrgid (__gid_t __gid);
107
108/* Search for an entry with a matching group name.
28f540f4 109
2c008571
UD
110 This function is a possible cancellation point and therefore not
111 marked with __THROW. */
a784e502 112extern struct group *getgrnam (const char *__name);
28f540f4 113
19361cb7
UD
114#if defined __USE_POSIX || defined __USE_MISC
115
dfd2257a 116# ifdef __USE_MISC
23396375
UD
117/* Reasonable value for the buffer sized used in the reentrant
118 functions below. But better use `sysconf'. */
dfd2257a
UD
119# define NSS_BUFLEN_GROUP 1024
120# endif
23396375
UD
121
122/* Reentrant versions of some of the functions above.
123
84384f5b
UD
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
2c008571
UD
128 POSIX people would choose.
129
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. */
23396375 134
0ed99ce4 135# ifdef __USE_GNU
c1422e5b
UD
136extern int getgrent_r (struct group *__restrict __resultbuf,
137 char *__restrict __buffer, size_t __buflen,
2c008571 138 struct group **__restrict __result);
dfd2257a 139# endif
23396375 140
2c008571
UD
141/* Search for an entry with a matching group ID.
142
143 This function is a possible cancellation point and therefore not
144 marked with __THROW. */
c1422e5b
UD
145extern int getgrgid_r (__gid_t __gid, struct group *__restrict __resultbuf,
146 char *__restrict __buffer, size_t __buflen,
2c008571
UD
147 struct group **__restrict __result);
148
149/* Search for an entry with a matching group name.
23396375 150
2c008571
UD
151 This function is a possible cancellation point and therefore not
152 marked with __THROW. */
a784e502 153extern int getgrnam_r (const char *__restrict __name,
c1422e5b
UD
154 struct group *__restrict __resultbuf,
155 char *__restrict __buffer, size_t __buflen,
2c008571 156 struct group **__restrict __result);
23396375 157
dfd2257a 158# ifdef __USE_SVID
84384f5b 159/* Read a group entry from STREAM. This function is not standardized
2c008571
UD
160 an probably never will.
161
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. */
c1422e5b
UD
166extern int fgetgrent_r (FILE *__restrict __stream,
167 struct group *__restrict __resultbuf,
168 char *__restrict __buffer, size_t __buflen,
2c008571 169 struct group **__restrict __result);
dfd2257a 170# endif
a8922de8 171
9d187dd4 172#endif /* POSIX or reentrant */
23396375 173
28f540f4
RM
174
175#ifdef __USE_BSD
176
dfd2257a
UD
177# define __need_size_t
178# include <stddef.h>
28f540f4
RM
179
180/* Set the group set for the current user to GROUPS (N of them). */
a784e502 181extern int setgroups (size_t __n, const __gid_t *__groups) __THROW;
28f540f4 182
8fee1bb0
UD
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
2c008571
UD
185 returned in *NGROUPS. Return -1 if the if *NGROUPS is too small.
186
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. */
a784e502 191extern int getgrouplist (const char *__user, __gid_t __group,
2c008571 192 __gid_t *__groups, int *__ngroups);
8fee1bb0 193
28f540f4
RM
194/* Initialize the group set for the current user
195 by reading the group database and using all groups
2c008571
UD
196 of which USER is a member. Also include GROUP.
197
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. */
a784e502 202extern int initgroups (const char *__user, __gid_t __group);
28f540f4
RM
203
204#endif /* Use BSD. */
205
206__END_DECLS
207
208#endif /* grp.h */