1 /* Copyright (C) 1991,1992,1995-2001,2003,2004 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * POSIX Standard: 9.2.2 User Database Access <pwd.h>
30 #include <bits/types.h>
35 #if defined __USE_XOPEN || defined __USE_XOPEN2K
36 /* The Single Unix specification says that some more types are
38 # ifndef __gid_t_defined
39 typedef __gid_t gid_t
;
40 # define __gid_t_defined
43 # ifndef __uid_t_defined
44 typedef __uid_t uid_t
;
45 # define __uid_t_defined
49 /* The passwd structure. */
52 char *pw_name
; /* Username. */
53 char *pw_passwd
; /* Password. */
54 __uid_t pw_uid
; /* User ID. */
55 __gid_t pw_gid
; /* Group ID. */
56 char *pw_gecos
; /* Real name. */
57 char *pw_dir
; /* Home directory. */
58 char *pw_shell
; /* Shell program. */
62 #if defined __USE_SVID || defined __USE_GNU
68 #if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN_EXTENDED
69 /* Rewind the password-file stream.
71 This function is a possible cancellation point and therefore not
72 marked with __THROW. */
73 extern void setpwent (void);
75 /* Close the password-file stream.
77 This function is a possible cancellation point and therefore not
78 marked with __THROW. */
79 extern void endpwent (void);
81 /* Read an entry from the password-file stream, opening it if necessary.
83 This function is a possible cancellation point and therefore not
84 marked with __THROW. */
85 extern struct passwd
*getpwent (void);
89 /* Read an entry from STREAM.
91 This function is not part of POSIX and therefore no official
92 cancellation point. But due to similarity with an POSIX interface
93 or due to the implementation it is a cancellation point and
94 therefore not marked with __THROW. */
95 extern struct passwd
*fgetpwent (FILE *__stream
);
97 /* Write the given entry onto the given stream.
99 This function is not part of POSIX and therefore no official
100 cancellation point. But due to similarity with an POSIX interface
101 or due to the implementation it is a cancellation point and
102 therefore not marked with __THROW. */
103 extern int putpwent (__const
struct passwd
*__restrict __p
,
104 FILE *__restrict __f
);
107 /* Search for an entry with a matching user ID.
109 This function is a possible cancellation point and therefore not
110 marked with __THROW. */
111 extern struct passwd
*getpwuid (__uid_t __uid
);
113 /* Search for an entry with a matching username.
115 This function is a possible cancellation point and therefore not
116 marked with __THROW. */
117 extern struct passwd
*getpwnam (__const
char *__name
);
119 #if defined __USE_POSIX || defined __USE_MISC
122 /* Reasonable value for the buffer sized used in the reentrant
123 functions below. But better use `sysconf'. */
124 # define NSS_BUFLEN_PASSWD 1024
127 /* Reentrant versions of some of the functions above.
129 PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.
130 The interface may change in later versions of this library. But
131 the interface is designed following the principals used for the
132 other reentrant functions so the chances are good this is what the
133 POSIX people would choose. */
135 # if defined __USE_SVID || defined __USE_MISC
136 /* This function is not part of POSIX and therefore no official
137 cancellation point. But due to similarity with an POSIX interface
138 or due to the implementation it is a cancellation point and
139 therefore not marked with __THROW. */
140 extern int getpwent_r (struct passwd
*__restrict __resultbuf
,
141 char *__restrict __buffer
, size_t __buflen
,
142 struct passwd
**__restrict __result
);
143 libc_hidden_proto(getpwent_r
)
146 extern int getpwuid_r (__uid_t __uid
,
147 struct passwd
*__restrict __resultbuf
,
148 char *__restrict __buffer
, size_t __buflen
,
149 struct passwd
**__restrict __result
);
150 libc_hidden_proto(getpwuid_r
)
152 extern int getpwnam_r (__const
char *__restrict __name
,
153 struct passwd
*__restrict __resultbuf
,
154 char *__restrict __buffer
, size_t __buflen
,
155 struct passwd
**__restrict __result
);
156 libc_hidden_proto(getpwnam_r
)
160 /* Read an entry from STREAM. This function is not standardized and
163 This function is not part of POSIX and therefore no official
164 cancellation point. But due to similarity with an POSIX interface
165 or due to the implementation it is a cancellation point and
166 therefore not marked with __THROW. */
167 extern int fgetpwent_r (FILE *__restrict __stream
,
168 struct passwd
*__restrict __resultbuf
,
169 char *__restrict __buffer
, size_t __buflen
,
170 struct passwd
**__restrict __result
);
171 libc_hidden_proto(fgetpwent_r
)
174 #endif /* POSIX or reentrant */
177 /* Re-construct the password-file line for the given uid
178 in the given buffer. This knows the format that the caller
179 will expect, but this need not be the format of the password file.
181 This function is not part of POSIX and therefore no official
182 cancellation point. But due to similarity with an POSIX interface
183 or due to the implementation it is a cancellation point and
184 therefore not marked with __THROW. */
185 extern int getpw (__uid_t __uid
, char *__buffer
);