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