xref: /onnv-gate/usr/src/head/grp.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
23*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*0Sstevel@tonic-gate 
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate /*
27*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28*0Sstevel@tonic-gate  * Use is subject to license terms.
29*0Sstevel@tonic-gate  */
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate #ifndef _GRP_H
32*0Sstevel@tonic-gate #define	_GRP_H
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.3.3.1 */
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #include <sys/feature_tests.h>
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate #include <sys/types.h>
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
41*0Sstevel@tonic-gate #include <stdio.h>
42*0Sstevel@tonic-gate #endif
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate #ifdef	__cplusplus
45*0Sstevel@tonic-gate extern "C" {
46*0Sstevel@tonic-gate #endif
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate struct	group {	/* see getgrent(3C) */
49*0Sstevel@tonic-gate 	char	*gr_name;
50*0Sstevel@tonic-gate 	char	*gr_passwd;
51*0Sstevel@tonic-gate 	gid_t	gr_gid;
52*0Sstevel@tonic-gate 	char	**gr_mem;
53*0Sstevel@tonic-gate };
54*0Sstevel@tonic-gate 
55*0Sstevel@tonic-gate #if defined(__STDC__)
56*0Sstevel@tonic-gate 
57*0Sstevel@tonic-gate extern struct group *getgrgid(gid_t);		/* MT-unsafe */
58*0Sstevel@tonic-gate extern struct group *getgrnam(const char *);	/* MT-unsafe */
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
61*0Sstevel@tonic-gate extern struct group *getgrent_r(struct group *, char *, int);
62*0Sstevel@tonic-gate extern struct group *fgetgrent_r(FILE *, struct group *, char *, int);
63*0Sstevel@tonic-gate 
64*0Sstevel@tonic-gate 
65*0Sstevel@tonic-gate extern struct group *fgetgrent(FILE *);		/* MT-unsafe */
66*0Sstevel@tonic-gate extern int initgroups(const char *, gid_t);
67*0Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */
68*0Sstevel@tonic-gate 
69*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)
70*0Sstevel@tonic-gate extern void endgrent(void);
71*0Sstevel@tonic-gate extern void setgrent(void);
72*0Sstevel@tonic-gate extern struct group *getgrent(void);		/* MT-unsafe */
73*0Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)... */
74*0Sstevel@tonic-gate 
75*0Sstevel@tonic-gate #else
76*0Sstevel@tonic-gate 
77*0Sstevel@tonic-gate extern struct group *getgrgid();		/* MT-unsafe */
78*0Sstevel@tonic-gate extern struct group *getgrnam();		/* MT-unsafe */
79*0Sstevel@tonic-gate 
80*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
81*0Sstevel@tonic-gate extern struct group *getgrent_r();
82*0Sstevel@tonic-gate extern struct group *fgetgrent_r();
83*0Sstevel@tonic-gate 
84*0Sstevel@tonic-gate extern struct group *fgetgrent();		/* MT-unsafe */
85*0Sstevel@tonic-gate extern int initgroups();
86*0Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */
87*0Sstevel@tonic-gate 
88*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)
89*0Sstevel@tonic-gate extern void endgrent();
90*0Sstevel@tonic-gate extern void setgrent();
91*0Sstevel@tonic-gate extern struct group *getgrent();		/* MT-unsafe */
92*0Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)... */
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate #endif	/* __STDC__ */
95*0Sstevel@tonic-gate 
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate /*
98*0Sstevel@tonic-gate  * getgrgid_r() & getgrnam_r() prototypes are defined here.
99*0Sstevel@tonic-gate  */
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate /*
102*0Sstevel@tonic-gate  * Previous releases of Solaris, starting at 2.3, provided definitions of
103*0Sstevel@tonic-gate  * various functions as specified in POSIX.1c, Draft 6.  For some of these
104*0Sstevel@tonic-gate  * functions, the final POSIX 1003.1c standard had a different number of
105*0Sstevel@tonic-gate  * arguments and return values.
106*0Sstevel@tonic-gate  *
107*0Sstevel@tonic-gate  * The following segment of this header provides support for the standard
108*0Sstevel@tonic-gate  * interfaces while supporting applications written under earlier
109*0Sstevel@tonic-gate  * releases.  The application defines appropriate values of the feature
110*0Sstevel@tonic-gate  * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate
111*0Sstevel@tonic-gate  * whether it was written to expect the Draft 6 or standard versions of
112*0Sstevel@tonic-gate  * these interfaces, before including this header.  This header then
113*0Sstevel@tonic-gate  * provides a mapping from the source version of the interface to an
114*0Sstevel@tonic-gate  * appropriate binary interface.  Such mappings permit an application
115*0Sstevel@tonic-gate  * to be built from libraries and objects which have mixed expectations
116*0Sstevel@tonic-gate  * of the definitions of these functions.
117*0Sstevel@tonic-gate  *
118*0Sstevel@tonic-gate  * For applications using the Draft 6 definitions, the binary symbol is the
119*0Sstevel@tonic-gate  * same as the source symbol, and no explicit mapping is needed.  For the
120*0Sstevel@tonic-gate  * standard interface, the function func() is mapped to the binary symbol
121*0Sstevel@tonic-gate  * _posix_func().  The preferred mechanism for the remapping is a compiler
122*0Sstevel@tonic-gate  * #pragma.  If the compiler does not provide such a #pragma, the header file
123*0Sstevel@tonic-gate  * defines a static function func() which calls the _posix_func() version;
124*0Sstevel@tonic-gate  * this has to be done instead of #define since POSIX specifies that an
125*0Sstevel@tonic-gate  * application can #undef the symbol and still be bound to the correct
126*0Sstevel@tonic-gate  * implementation.  Unfortunately, the statics confuse lint so we fallback to
127*0Sstevel@tonic-gate  * #define in that case.
128*0Sstevel@tonic-gate  *
129*0Sstevel@tonic-gate  * NOTE: Support for the Draft 6 definitions is provided for compatibility
130*0Sstevel@tonic-gate  * only.  New applications/libraries should use the standard definitions.
131*0Sstevel@tonic-gate  */
132*0Sstevel@tonic-gate 
133*0Sstevel@tonic-gate #if	defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
134*0Sstevel@tonic-gate 	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
135*0Sstevel@tonic-gate 
136*0Sstevel@tonic-gate #if	defined(__STDC__)
137*0Sstevel@tonic-gate 
138*0Sstevel@tonic-gate #if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
139*0Sstevel@tonic-gate 
140*0Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME
141*0Sstevel@tonic-gate #pragma redefine_extname getgrgid_r __posix_getgrgid_r
142*0Sstevel@tonic-gate #pragma redefine_extname getgrnam_r __posix_getgrnam_r
143*0Sstevel@tonic-gate extern int getgrgid_r(gid_t, struct group *, char *, int, struct group **);
144*0Sstevel@tonic-gate extern int getgrnam_r(const char *, struct group *, char *, int,
145*0Sstevel@tonic-gate 							struct group **);
146*0Sstevel@tonic-gate #else  /* __PRAGMA_REDEFINE_EXTNAME */
147*0Sstevel@tonic-gate 
148*0Sstevel@tonic-gate extern int __posix_getgrgid_r(gid_t, struct group *, char *, size_t,
149*0Sstevel@tonic-gate     struct group **);
150*0Sstevel@tonic-gate extern int __posix_getgrnam_r(const char *, struct group *, char *, size_t,
151*0Sstevel@tonic-gate     struct group **);
152*0Sstevel@tonic-gate 
153*0Sstevel@tonic-gate #ifdef __lint
154*0Sstevel@tonic-gate 
155*0Sstevel@tonic-gate #define	getgrgid_r __posix_getgrgid_r
156*0Sstevel@tonic-gate #define	getgrnam_r __posix_getgrnam_r
157*0Sstevel@tonic-gate 
158*0Sstevel@tonic-gate #else	/* !__lint */
159*0Sstevel@tonic-gate 
160*0Sstevel@tonic-gate static int
getgrgid_r(gid_t __gid,struct group * __grp,char * __buf,int __len,struct group ** __res)161*0Sstevel@tonic-gate getgrgid_r(gid_t __gid, struct group *__grp, char *__buf, int __len,
162*0Sstevel@tonic-gate     struct group **__res)
163*0Sstevel@tonic-gate {
164*0Sstevel@tonic-gate 	return (__posix_getgrgid_r(__gid, __grp, __buf, __len, __res));
165*0Sstevel@tonic-gate }
166*0Sstevel@tonic-gate static int
getgrnam_r(const char * __cb,struct group * __grp,char * __buf,int __len,struct group ** __res)167*0Sstevel@tonic-gate getgrnam_r(const char *__cb, struct group *__grp, char *__buf, int __len,
168*0Sstevel@tonic-gate     struct group **__res)
169*0Sstevel@tonic-gate {
170*0Sstevel@tonic-gate 	return (__posix_getgrnam_r(__cb, __grp, __buf, __len, __res));
171*0Sstevel@tonic-gate }
172*0Sstevel@tonic-gate 
173*0Sstevel@tonic-gate #endif /* !__lint */
174*0Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */
175*0Sstevel@tonic-gate 
176*0Sstevel@tonic-gate #else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
177*0Sstevel@tonic-gate 
178*0Sstevel@tonic-gate extern struct group *getgrgid_r(gid_t, struct group *, char *, int);
179*0Sstevel@tonic-gate extern struct group *getgrnam_r(const char *, struct group *, char *, int);
180*0Sstevel@tonic-gate 
181*0Sstevel@tonic-gate #endif  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
182*0Sstevel@tonic-gate 
183*0Sstevel@tonic-gate #else  /* __STDC__ */
184*0Sstevel@tonic-gate 
185*0Sstevel@tonic-gate #if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
186*0Sstevel@tonic-gate 
187*0Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME
188*0Sstevel@tonic-gate #pragma redefine_extname getgrgid_r __posix_getgrgid_r
189*0Sstevel@tonic-gate #pragma redefine_extname getgrnam_r __posix_getgrnam_r
190*0Sstevel@tonic-gate extern int getgrgid_r();
191*0Sstevel@tonic-gate extern int getgrnam_r();
192*0Sstevel@tonic-gate #else  /* __PRAGMA_REDEFINE_EXTNAME */
193*0Sstevel@tonic-gate 
194*0Sstevel@tonic-gate extern int __posix_getgrgid_r();
195*0Sstevel@tonic-gate extern int __posix_getgrnam_r();
196*0Sstevel@tonic-gate 
197*0Sstevel@tonic-gate #ifdef	__lint
198*0Sstevel@tonic-gate 
199*0Sstevel@tonic-gate #define	getgrgid_r __posix_getgrgid_r
200*0Sstevel@tonic-gate #define	getgrnam_r __posix_getgrnam_r
201*0Sstevel@tonic-gate 
202*0Sstevel@tonic-gate #else	/* !__lint */
203*0Sstevel@tonic-gate 
204*0Sstevel@tonic-gate static int
getgrgid_r(__gid,__grp,__buf,__len,__res)205*0Sstevel@tonic-gate getgrgid_r(__gid, __grp, __buf, __len, __res)
206*0Sstevel@tonic-gate 	gid_t __gid;
207*0Sstevel@tonic-gate 	struct group *__grp;
208*0Sstevel@tonic-gate 	char *__buf;
209*0Sstevel@tonic-gate 	int __len;
210*0Sstevel@tonic-gate 	struct group **__res;
211*0Sstevel@tonic-gate {
212*0Sstevel@tonic-gate 	return (__posix_getgrgid_r(__gid, __grp, __buf, __len, __res));
213*0Sstevel@tonic-gate }
214*0Sstevel@tonic-gate static int
getgrnam_r(__cb,__grp,__buf,__len,__res)215*0Sstevel@tonic-gate getgrnam_r(__cb, __grp, __buf, __len, __res)
216*0Sstevel@tonic-gate 	char *__cb;
217*0Sstevel@tonic-gate 	struct group *__grp;
218*0Sstevel@tonic-gate 	char *__buf;
219*0Sstevel@tonic-gate 	int __len;
220*0Sstevel@tonic-gate 	struct group **__res;
221*0Sstevel@tonic-gate {
222*0Sstevel@tonic-gate 	return (__posix_getgrnam_r(__cb, __grp, __buf, __len, __res));
223*0Sstevel@tonic-gate }
224*0Sstevel@tonic-gate 
225*0Sstevel@tonic-gate #endif /* !__lint */
226*0Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */
227*0Sstevel@tonic-gate 
228*0Sstevel@tonic-gate #else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
229*0Sstevel@tonic-gate 
230*0Sstevel@tonic-gate extern struct group *getgrgid_r();
231*0Sstevel@tonic-gate extern struct group *getgrnam_r();
232*0Sstevel@tonic-gate 
233*0Sstevel@tonic-gate #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
234*0Sstevel@tonic-gate 
235*0Sstevel@tonic-gate #endif /* __STDC__ */
236*0Sstevel@tonic-gate 
237*0Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)... */
238*0Sstevel@tonic-gate 
239*0Sstevel@tonic-gate #ifdef	__cplusplus
240*0Sstevel@tonic-gate }
241*0Sstevel@tonic-gate #endif
242*0Sstevel@tonic-gate 
243*0Sstevel@tonic-gate #endif	/* _GRP_H */
244