324 need serbian locale support
[illumos-gate.git] / usr / src / head / pwd.h
blob47dc2f136be650c95f6f8da6a6ccf4545d9c0b93
1 /*
2 * CDDL HEADER START
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
7 * with the License.
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]
20 * CDDL HEADER END
22 /* Copyright (c) 1988 AT&T */
23 /* All Rights Reserved */
27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
31 #ifndef _PWD_H
32 #define _PWD_H
34 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3.1.9 */
36 #include <sys/feature_tests.h>
38 #include <sys/types.h>
40 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
41 #include <stdio.h>
42 #endif
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
48 struct passwd {
49 char *pw_name;
50 char *pw_passwd;
51 uid_t pw_uid;
52 gid_t pw_gid;
53 char *pw_age;
54 char *pw_comment;
55 char *pw_gecos;
56 char *pw_dir;
57 char *pw_shell;
60 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
61 struct comment {
62 char *c_dept;
63 char *c_name;
64 char *c_acct;
65 char *c_bin;
67 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
69 #if defined(__STDC__)
71 extern struct passwd *getpwuid(uid_t); /* MT-unsafe */
72 extern struct passwd *getpwnam(const char *); /* MT-unsafe */
74 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
75 extern struct passwd *getpwent_r(struct passwd *, char *, int);
76 extern struct passwd *fgetpwent_r(FILE *, struct passwd *, char *, int);
77 extern struct passwd *fgetpwent(FILE *); /* MT-unsafe */
78 extern int putpwent(const struct passwd *, FILE *);
79 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
81 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
82 defined(__EXTENSIONS__)
83 extern void endpwent(void);
84 extern struct passwd *getpwent(void); /* MT-unsafe */
85 extern void setpwent(void);
86 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */
88 #else /* (__STDC__) */
90 extern struct passwd *getpwuid(); /* MT-unsafe */
91 extern struct passwd *getpwnam(); /* MT-unsafe */
93 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
94 extern struct passwd *getpwent_r();
95 extern struct passwd *fgetpwent_r();
97 extern struct passwd *fgetpwent(); /* MT-unsafe */
98 extern int putpwent();
99 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
101 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
102 defined(__EXTENSIONS__)
103 extern void endpwent();
104 extern struct passwd *getpwent(); /* MT-unsafe */
105 extern void setpwent();
106 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */
108 #endif /* (__STDC__) */
111 * getpwuid_r() & getpwnam_r() prototypes are defined here.
115 * Previous releases of Solaris, starting at 2.3, provided definitions of
116 * various functions as specified in POSIX.1c, Draft 6. For some of these
117 * functions, the final POSIX 1003.1c standard had a different number of
118 * arguments and return values.
120 * The following segment of this header provides support for the standard
121 * interfaces while supporting applications written under earlier
122 * releases. The application defines appropriate values of the feature
123 * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate
124 * whether it was written to expect the Draft 6 or standard versions of
125 * these interfaces, before including this header. This header then
126 * provides a mapping from the source version of the interface to an
127 * appropriate binary interface. Such mappings permit an application
128 * to be built from libraries and objects which have mixed expectations
129 * of the definitions of these functions.
131 * For applications using the Draft 6 definitions, the binary symbol is the
132 * same as the source symbol, and no explicit mapping is needed. For the
133 * standard interface, the function func() is mapped to the binary symbol
134 * _posix_func(). The preferred mechanism for the remapping is a compiler
135 * #pragma. If the compiler does not provide such a #pragma, the header file
136 * defines a static function func() which calls the _posix_func() version;
137 * this has to be done instead of #define since POSIX specifies that an
138 * application can #undef the symbol and still be bound to the correct
139 * implementation. Unfortunately, the statics confuse lint so we fallback to
140 * #define in that case.
142 * NOTE: Support for the Draft 6 definitions is provided for compatibility
143 * only. New applications/libraries should use the standard definitions.
146 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
147 defined(_POSIX_PTHREAD_SEMANTICS) || defined(__EXTENSIONS__)
149 #if defined(__STDC__)
151 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
153 #ifdef __PRAGMA_REDEFINE_EXTNAME
154 #pragma redefine_extname getpwuid_r __posix_getpwuid_r
155 #pragma redefine_extname getpwnam_r __posix_getpwnam_r
156 extern int getpwuid_r(uid_t, struct passwd *, char *, int, struct passwd **);
157 extern int getpwnam_r(const char *, struct passwd *, char *,
158 int, struct passwd **);
159 #else /* __PRAGMA_REDEFINE_EXTNAME */
161 extern int __posix_getpwuid_r(uid_t, struct passwd *, char *, size_t,
162 struct passwd **);
163 extern int __posix_getpwnam_r(const char *, struct passwd *, char *,
164 size_t, struct passwd **);
166 #ifdef __lint
168 #define getpwuid_r __posix_getpwuid_r
169 #define getpwnam_r __posix_getpwnam_r
171 #else /* !__lint */
173 static int
174 getpwuid_r(uid_t __uid, struct passwd *__pwd, char *__buf, int __len,
175 struct passwd **__res)
177 return (__posix_getpwuid_r(__uid, __pwd, __buf, __len, __res));
179 static int
180 getpwnam_r(const char *__cb, struct passwd *__pwd, char *__buf, int __len,
181 struct passwd **__res)
183 return (__posix_getpwnam_r(__cb, __pwd, __buf, __len, __res));
186 #endif /* !__lint */
187 #endif /* __PRAGMA_REDEFINE_EXTNAME */
189 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
191 extern struct passwd *getpwuid_r(uid_t, struct passwd *, char *, int);
192 extern struct passwd *getpwnam_r(const char *, struct passwd *, char *, int);
194 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
196 #else /* __STDC__ */
198 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
200 #ifdef __PRAGMA_REDEFINE_EXTNAME
201 #pragma redefine_extname getpwuid_r __posix_getpwuid_r
202 #pragma redefine_extname getpwnam_r __posix_getpwnam_r
203 extern int getpwuid_r();
204 extern int getpwnam_r();
205 #else /* __PRAGMA_REDEFINE_EXTNAME */
207 extern int __posix_getpwuid_r();
208 extern int __posix_getpwnam_r();
210 #ifdef __lint
212 #define getpwuid_r __posix_getpwuid_r
213 #define getpwnam_r __posix_getpwnam_r
215 #else /* !__lint */
217 static int
218 getpwuid_r(__uid, __pwd, __buf, __len, __res)
219 uid_t __uid;
220 struct passwd *__pwd;
221 char *__buf;
222 int __len;
223 struct passwd **__res;
225 return (__posix_getpwuid_r(__uid, __pwd, __buf, __len, __res));
227 static int
228 getpwnam_r(__cb, __pwd, __buf, __len, __res)
229 char *__cb;
230 struct passwd *__pwd;
231 char *__buf;
232 int __len;
233 struct passwd **__res;
235 return (__posix_getpwnam_r(__cb, __pwd, __buf, __len, __res));
238 #endif /* !__lint */
239 #endif /* __PRAGMA_REDEFINE_EXTNAME */
241 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
243 extern struct passwd *getpwuid_r();
244 extern struct passwd *getpwnam_r();
246 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
248 #endif /* __STDC__ */
250 #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L)... */
252 #ifdef __cplusplus
254 #endif
256 #endif /* _PWD_H */