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