4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1988 AT&T */
23 /* All Rights Reserved */
27 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
29 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
30 * Use is subject to license terms.
36 #include <sys/feature_tests.h>
38 #include <sys/types.h>
40 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
60 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
67 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
69 extern struct passwd
*getpwuid(uid_t
); /* MT-unsafe */
70 extern struct passwd
*getpwnam(const char *); /* MT-unsafe */
72 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
73 extern struct passwd
*getpwent_r(struct passwd
*, char *, int);
74 extern struct passwd
*fgetpwent_r(FILE *, struct passwd
*, char *, int);
75 extern struct passwd
*fgetpwent(FILE *); /* MT-unsafe */
76 extern int putpwent(const struct passwd
*, FILE *);
77 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
79 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
80 defined(__EXTENSIONS__)
81 extern void endpwent(void);
82 extern struct passwd
*getpwent(void); /* MT-unsafe */
83 extern void setpwent(void);
84 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */
87 * getpwuid_r() & getpwnam_r() prototypes are defined here.
91 * Previous releases of Solaris, starting at 2.3, provided definitions of
92 * various functions as specified in POSIX.1c, Draft 6. For some of these
93 * functions, the final POSIX 1003.1c standard had a different number of
94 * arguments and return values.
96 * The following segment of this header provides support for the standard
97 * interfaces while supporting applications written under earlier
98 * releases. The application defines appropriate values of the feature
99 * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate
100 * whether it was written to expect the Draft 6 or standard versions of
101 * these interfaces, before including this header. This header then
102 * provides a mapping from the source version of the interface to an
103 * appropriate binary interface. Such mappings permit an application
104 * to be built from libraries and objects which have mixed expectations
105 * of the definitions of these functions.
107 * For applications using the Draft 6 definitions, the binary symbol is the
108 * same as the source symbol, and no explicit mapping is needed. For the
109 * standard interface, the function func() is mapped to the binary symbol
110 * _posix_func(). The preferred mechanism for the remapping is a compiler
111 * #pragma. If the compiler does not provide such a #pragma, the header file
112 * defines a static function func() which calls the _posix_func() version;
113 * this has to be done instead of #define since POSIX specifies that an
114 * application can #undef the symbol and still be bound to the correct
115 * implementation. Unfortunately, the statics confuse lint so we fallback to
116 * #define in that case.
118 * NOTE: Support for the Draft 6 definitions is provided for compatibility
119 * only. New applications/libraries should use the standard definitions.
122 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
123 defined(_POSIX_PTHREAD_SEMANTICS) || defined(__EXTENSIONS__)
125 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
127 #ifdef __PRAGMA_REDEFINE_EXTNAME
128 #pragma redefine_extname getpwuid_r __posix_getpwuid_r
129 #pragma redefine_extname getpwnam_r __posix_getpwnam_r
130 extern int getpwuid_r(uid_t
, struct passwd
*, char *,
131 size_t, struct passwd
**);
132 extern int getpwnam_r(const char *, struct passwd
*, char *,
133 size_t, struct passwd
**);
134 #else /* __PRAGMA_REDEFINE_EXTNAME */
136 extern int __posix_getpwuid_r(uid_t
, struct passwd
*, char *, size_t,
138 extern int __posix_getpwnam_r(const char *, struct passwd
*, char *,
139 size_t, struct passwd
**);
143 #define getpwuid_r __posix_getpwuid_r
144 #define getpwnam_r __posix_getpwnam_r
149 getpwuid_r(uid_t __uid
, struct passwd
*__pwd
, char *__buf
, size_t __len
,
150 struct passwd
**__res
)
152 return (__posix_getpwuid_r(__uid
, __pwd
, __buf
, __len
, __res
));
155 getpwnam_r(const char *__cb
, struct passwd
*__pwd
, char *__buf
, size_t __len
,
156 struct passwd
**__res
)
158 return (__posix_getpwnam_r(__cb
, __pwd
, __buf
, __len
, __res
));
162 #endif /* __PRAGMA_REDEFINE_EXTNAME */
164 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
166 extern struct passwd
*getpwuid_r(uid_t
, struct passwd
*, char *, int);
167 extern struct passwd
*getpwnam_r(const char *, struct passwd
*, char *, int);
169 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
171 #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L)... */