1 /* Copyright (C) 1991, 1992, 1995, 1996, 1997 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 Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 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 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
20 * POSIX Standard: 9.2.2 User Database Access <pwd.h>
30 #include <gnu/types.h>
35 /* The passwd structure. */
38 char *pw_name
; /* Username. */
39 char *pw_passwd
; /* Password. */
40 __uid_t pw_uid
; /* User ID. */
41 __gid_t pw_gid
; /* Group ID. */
42 char *pw_gecos
; /* Real name. */
43 char *pw_dir
; /* Home directory. */
44 char *pw_shell
; /* Shell program. */
48 #if defined(__USE_SVID) || defined(__USE_GNU)
54 /* Return a new stream open on the password file. */
55 extern FILE *__pwdopen
__P ((void));
57 /* Read a password entry from STREAM, filling in P.
58 Return the `struct passwd' of P if successful, NULL on failure. */
59 extern struct passwd
*__pwdread
__P ((FILE *__stream
, __ptr_t __p
));
61 /* Return a chunk of memory containing pre-initialized data for __pwdread. */
62 extern __ptr_t __pwdalloc
__P ((void));
64 /* Scan the password file, filling in P, until SELECTOR returns nonzero for
65 an entry. Return the `struct passwd' of P if successful, NULL on
67 extern struct passwd
*__pwdscan
__P ((__ptr_t
*__p
,
68 int (*__selector
) (struct passwd
*)));
72 #if defined(__USE_SVID) || defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
73 /* Rewind the password-file stream. */
74 extern void setpwent
__P ((void));
76 /* Close the password-file stream. */
77 extern void endpwent
__P ((void));
79 /* Read an entry from the password-file stream, opening it if necessary. */
80 extern struct passwd
*getpwent
__P ((void));
84 /* Read an entry from STREAM. */
85 extern struct passwd
*fgetpwent
__P ((FILE *__stream
));
87 /* Write the given entry onto the given stream. */
88 extern int putpwent
__P ((__const
struct passwd
*__p
, FILE *__f
));
91 /* Search for an entry with a matching user ID. */
92 extern struct passwd
*getpwuid
__P ((__uid_t __uid
));
94 /* Search for an entry with a matching username. */
95 extern struct passwd
*getpwnam
__P ((__const
char *__name
));
97 #if defined __USE_POSIX || defined __USE_MISC
100 /* Reasonable value for the buffer sized used in the reentrant
101 functions below. But better use `sysconf'. */
102 #define NSS_BUFLEN_PASSWD 1024
105 /* Reentrant versions of some of the functions above.
107 PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.
108 The interface may change in later versions of this library. But
109 the interface is designed following the principals used for the
110 other reentrant functions so the chances are good this is what the
111 POSIX people would choose. */
113 #if defined(__USE_SVID) || defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
114 extern int __getpwent_r
__P ((struct passwd
*__resultbuf
, char *__buffer
,
115 size_t __buflen
, struct passwd
**__result
));
116 extern int getpwent_r
__P ((struct passwd
*__resultbuf
, char *__buffer
,
117 size_t __buflen
, struct passwd
**__result
));
120 extern int __getpwuid_r
__P ((__uid_t __uid
, struct passwd
*__resultbuf
,
121 char *__buffer
, size_t __buflen
,
122 struct passwd
**__result
));
123 extern int getpwuid_r
__P ((__uid_t __uid
, struct passwd
*__resultbuf
,
124 char *__buffer
, size_t __buflen
,
125 struct passwd
**__result
));
127 extern int __getpwnam_r
__P ((__const
char *__name
, struct passwd
*__resultbuf
,
128 char *__buffer
, size_t __buflen
,
129 struct passwd
**__result
));
130 extern int getpwnam_r
__P ((__const
char *__name
, struct passwd
*__resultbuf
,
131 char *__buffer
, size_t __buflen
,
132 struct passwd
**__result
));
136 /* Read an entry from STREAM. This function is not standardized and
137 probably never will. */
138 extern int __fgetpwent_r
__P ((FILE * __stream
, struct passwd
*__resultbuf
,
139 char *__buffer
, size_t __buflen
,
140 struct passwd
**__result
));
141 extern int fgetpwent_r
__P ((FILE * __stream
, struct passwd
*__resultbuf
,
142 char *__buffer
, size_t __buflen
,
143 struct passwd
**__result
));
146 #endif /* POSIX or reentrant */