xref: /titanic_44/usr/src/head/grp.h (revision 591ef764641217c678e78cf03e535ae8016a4595)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
237c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
27ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
28ba3594baSGarrett D'Amore  *
297c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
307c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifndef _GRP_H
347c478bd9Sstevel@tonic-gate #define	_GRP_H
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #include <sys/types.h>
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
417c478bd9Sstevel@tonic-gate #include <stdio.h>
427c478bd9Sstevel@tonic-gate #endif
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
457c478bd9Sstevel@tonic-gate extern "C" {
467c478bd9Sstevel@tonic-gate #endif
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate struct	group {	/* see getgrent(3C) */
497c478bd9Sstevel@tonic-gate 	char	*gr_name;
507c478bd9Sstevel@tonic-gate 	char	*gr_passwd;
517c478bd9Sstevel@tonic-gate 	gid_t	gr_gid;
527c478bd9Sstevel@tonic-gate 	char	**gr_mem;
537c478bd9Sstevel@tonic-gate };
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate extern struct group *getgrgid(gid_t);		/* MT-unsafe */
567c478bd9Sstevel@tonic-gate extern struct group *getgrnam(const char *);	/* MT-unsafe */
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
597c478bd9Sstevel@tonic-gate extern struct group *getgrent_r(struct group *, char *, int);
607c478bd9Sstevel@tonic-gate extern struct group *fgetgrent_r(FILE *, struct group *, char *, int);
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate extern struct group *fgetgrent(FILE *);		/* MT-unsafe */
647c478bd9Sstevel@tonic-gate extern int initgroups(const char *, gid_t);
657c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)
687c478bd9Sstevel@tonic-gate extern void endgrent(void);
697c478bd9Sstevel@tonic-gate extern void setgrent(void);
707c478bd9Sstevel@tonic-gate extern struct group *getgrent(void);		/* MT-unsafe */
717c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)... */
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate /*
747c478bd9Sstevel@tonic-gate  * getgrgid_r() & getgrnam_r() prototypes are defined here.
757c478bd9Sstevel@tonic-gate  */
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate /*
787c478bd9Sstevel@tonic-gate  * Previous releases of Solaris, starting at 2.3, provided definitions of
797c478bd9Sstevel@tonic-gate  * various functions as specified in POSIX.1c, Draft 6.  For some of these
807c478bd9Sstevel@tonic-gate  * functions, the final POSIX 1003.1c standard had a different number of
817c478bd9Sstevel@tonic-gate  * arguments and return values.
827c478bd9Sstevel@tonic-gate  *
837c478bd9Sstevel@tonic-gate  * The following segment of this header provides support for the standard
847c478bd9Sstevel@tonic-gate  * interfaces while supporting applications written under earlier
857c478bd9Sstevel@tonic-gate  * releases.  The application defines appropriate values of the feature
867c478bd9Sstevel@tonic-gate  * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate
877c478bd9Sstevel@tonic-gate  * whether it was written to expect the Draft 6 or standard versions of
887c478bd9Sstevel@tonic-gate  * these interfaces, before including this header.  This header then
897c478bd9Sstevel@tonic-gate  * provides a mapping from the source version of the interface to an
907c478bd9Sstevel@tonic-gate  * appropriate binary interface.  Such mappings permit an application
917c478bd9Sstevel@tonic-gate  * to be built from libraries and objects which have mixed expectations
927c478bd9Sstevel@tonic-gate  * of the definitions of these functions.
937c478bd9Sstevel@tonic-gate  *
947c478bd9Sstevel@tonic-gate  * For applications using the Draft 6 definitions, the binary symbol is the
957c478bd9Sstevel@tonic-gate  * same as the source symbol, and no explicit mapping is needed.  For the
967c478bd9Sstevel@tonic-gate  * standard interface, the function func() is mapped to the binary symbol
977c478bd9Sstevel@tonic-gate  * _posix_func().  The preferred mechanism for the remapping is a compiler
987c478bd9Sstevel@tonic-gate  * #pragma.  If the compiler does not provide such a #pragma, the header file
997c478bd9Sstevel@tonic-gate  * defines a static function func() which calls the _posix_func() version;
1007c478bd9Sstevel@tonic-gate  * this has to be done instead of #define since POSIX specifies that an
1017c478bd9Sstevel@tonic-gate  * application can #undef the symbol and still be bound to the correct
1027c478bd9Sstevel@tonic-gate  * implementation.  Unfortunately, the statics confuse lint so we fallback to
1037c478bd9Sstevel@tonic-gate  * #define in that case.
1047c478bd9Sstevel@tonic-gate  *
1057c478bd9Sstevel@tonic-gate  * NOTE: Support for the Draft 6 definitions is provided for compatibility
1067c478bd9Sstevel@tonic-gate  * only.  New applications/libraries should use the standard definitions.
1077c478bd9Sstevel@tonic-gate  */
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate #if	defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
1107c478bd9Sstevel@tonic-gate 	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate #if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME
1157c478bd9Sstevel@tonic-gate #pragma redefine_extname getgrgid_r __posix_getgrgid_r
1167c478bd9Sstevel@tonic-gate #pragma redefine_extname getgrnam_r __posix_getgrnam_r
117*591ef764SKeith M Wesolowski extern int getgrgid_r(gid_t, struct group *, char *,
118*591ef764SKeith M Wesolowski     size_t, struct group **);
119*591ef764SKeith M Wesolowski extern int getgrnam_r(const char *, struct group *, char *,
120*591ef764SKeith M Wesolowski     size_t, struct group **);
1217c478bd9Sstevel@tonic-gate #else  /* __PRAGMA_REDEFINE_EXTNAME */
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate extern int __posix_getgrgid_r(gid_t, struct group *, char *, size_t,
1247c478bd9Sstevel@tonic-gate     struct group **);
1257c478bd9Sstevel@tonic-gate extern int __posix_getgrnam_r(const char *, struct group *, char *, size_t,
1267c478bd9Sstevel@tonic-gate     struct group **);
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate #ifdef __lint
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate #define	getgrgid_r __posix_getgrgid_r
1317c478bd9Sstevel@tonic-gate #define	getgrnam_r __posix_getgrnam_r
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate #else	/* !__lint */
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate static int
getgrgid_r(gid_t __gid,struct group * __grp,char * __buf,size_t __len,struct group ** __res)136*591ef764SKeith M Wesolowski getgrgid_r(gid_t __gid, struct group *__grp, char *__buf, size_t __len,
1377c478bd9Sstevel@tonic-gate     struct group **__res)
1387c478bd9Sstevel@tonic-gate {
1397c478bd9Sstevel@tonic-gate 	return (__posix_getgrgid_r(__gid, __grp, __buf, __len, __res));
1407c478bd9Sstevel@tonic-gate }
1417c478bd9Sstevel@tonic-gate static int
getgrnam_r(const char * __cb,struct group * __grp,char * __buf,size_t __len,struct group ** __res)142*591ef764SKeith M Wesolowski getgrnam_r(const char *__cb, struct group *__grp, char *__buf, size_t __len,
1437c478bd9Sstevel@tonic-gate     struct group **__res)
1447c478bd9Sstevel@tonic-gate {
1457c478bd9Sstevel@tonic-gate 	return (__posix_getgrnam_r(__cb, __grp, __buf, __len, __res));
1467c478bd9Sstevel@tonic-gate }
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate #endif /* !__lint */
1497c478bd9Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate #else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate extern struct group *getgrgid_r(gid_t, struct group *, char *, int);
1547c478bd9Sstevel@tonic-gate extern struct group *getgrnam_r(const char *, struct group *, char *, int);
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate #endif  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)... */
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1617c478bd9Sstevel@tonic-gate }
1627c478bd9Sstevel@tonic-gate #endif
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate #endif	/* _GRP_H */
165