1 /* Copyright (C) 1991, 1992, 1995, 1996 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
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
20 * POSIX Standard: 9.2.2 User Database Access <pwd.h>
30 #include <gnu/types.h>
33 /* The passwd structure. */
36 char *pw_name; /* Username. */
37 char *pw_passwd; /* Password. */
38 __uid_t pw_uid; /* User ID. */
39 __gid_t pw_gid; /* Group ID. */
40 char *pw_gecos; /* Real name. */
41 char *pw_dir; /* Home directory. */
42 char *pw_shell; /* Shell program. */
46 #if defined(__USE_SVID) || defined(__USE_GNU)
52 /* Return a new stream open on the password file. */
53 extern FILE *__pwdopen __P ((void));
55 /* Read a password entry from STREAM, filling in P.
56 Return the `struct passwd' of P if successful, NULL on failure. */
57 extern struct passwd *__pwdread __P ((FILE *__stream, __ptr_t __p));
59 /* Return a chunk of memory containing pre-initialized data for __pwdread. */
60 extern __ptr_t __pwdalloc __P ((void));
62 /* Scan the password file, filling in P, until SELECTOR returns nonzero for
63 an entry. Return the `struct passwd' of P if successful, NULL on
65 extern struct passwd *__pwdscan __P ((__ptr_t *__p,
66 int (*__selector) (struct passwd *)));
70 #if defined(__USE_SVID) || defined(__USE_MISC)
71 /* Rewind the password-file stream. */
72 extern void setpwent __P ((void));
74 /* Close the password-file stream. */
75 extern void endpwent __P ((void));
77 /* Read an entry from the password-file stream, opening it if necessary. */
78 extern struct passwd *getpwent __P ((void));
82 /* Read an entry from STREAM. */
83 extern struct passwd *fgetpwent __P ((FILE *__stream));
85 /* Write the given entry onto the given stream. */
86 extern int putpwent __P ((__const struct passwd *__p, FILE *__f));
89 /* Search for an entry with a matching user ID. */
90 extern struct passwd *getpwuid __P ((__uid_t __uid));
92 /* Search for an entry with a matching username. */
93 extern struct passwd *getpwnam __P ((__const char *__name));
95 #ifdef __USE_REENTRANT
96 /* Reasonable value for the buffer sized used in the reentrant
97 functions below. But better use `sysconf'. */
98 #define NSS_BUFLEN_PASSWD 1024
100 /* Reentrant versions of some of the functions above.
102 PLEASE NOTE: these functions are not yet standardized. The interface
103 may change in later versions of this library. */
105 #if defined(__USE_SVID) || defined(__USE_MISC)
106 extern int __getpwent_r __P ((struct passwd *__resultbuf, char *__buffer,
107 size_t __buflen, struct passwd **__result));
108 extern int getpwent_r __P ((struct passwd *__resultbuf, char *__buffer,
109 size_t __buflen, struct passwd **__result));
112 extern int __getpwuid_r __P ((__uid_t __uid, struct passwd *__resultbuf,
113 char *__buffer, size_t __buflen,
114 struct passwd **__result));
115 extern int getpwuid_r __P ((__uid_t __uid, struct passwd *__resultbuf,
116 char *__buffer, size_t __buflen,
117 struct passwd **__result));
119 extern int __getpwnam_r __P ((__const char *__name, struct passwd *__resultbuf,
120 char *__buffer, size_t __buflen,
121 struct passwd **__result));
122 extern int getpwnam_r __P ((__const char *__name, struct passwd *__resultbuf,
123 char *__buffer, size_t __buflen,
124 struct passwd **__result));
128 /* Read an entry from STREAM. */
129 extern int __fgetpwent_r __P ((FILE * __stream, struct passwd *__resultbuf,
130 char *__buffer, size_t __buflen,
131 struct passwd **__result));
132 extern int fgetpwent_r __P ((FILE * __stream, struct passwd *__resultbuf,
133 char *__buffer, size_t __buflen,
134 struct passwd **__result));
137 #endif /* reentrant */