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