update from main archive 961105
[glibc/history.git] / pwd / pwd.h
blob3d6d2a1977ef8081d4b24859783ca2274540533b
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 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>
23 #ifndef _PWD_H
25 #define _PWD_H 1
26 #include <features.h>
28 __BEGIN_DECLS
30 #include <gnu/types.h>
32 #define __need_size_t
33 #include <stddef.h>
35 /* The passwd structure. */
36 struct passwd
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)
49 #define __need_FILE
50 #include <stdio.h>
51 #endif
53 #ifdef __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
66 failure. */
67 extern struct passwd *__pwdscan __P ((__ptr_t *__p,
68 int (*__selector) (struct passwd *)));
69 #endif
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));
81 #endif
83 #ifdef __USE_SVID
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));
89 #endif
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 #ifdef __USE_REENTRANT
98 /* Reasonable value for the buffer sized used in the reentrant
99 functions below. But better use `sysconf'. */
100 #define NSS_BUFLEN_PASSWD 1024
102 /* Reentrant versions of some of the functions above.
104 PLEASE NOTE: these functions are not yet standardized. The interface
105 may change in later versions of this library. */
107 #if defined(__USE_SVID) || defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
108 extern int __getpwent_r __P ((struct passwd *__resultbuf, char *__buffer,
109 size_t __buflen, struct passwd **__result));
110 extern int getpwent_r __P ((struct passwd *__resultbuf, char *__buffer,
111 size_t __buflen, struct passwd **__result));
112 #endif
114 extern int __getpwuid_r __P ((__uid_t __uid, struct passwd *__resultbuf,
115 char *__buffer, size_t __buflen,
116 struct passwd **__result));
117 extern int getpwuid_r __P ((__uid_t __uid, struct passwd *__resultbuf,
118 char *__buffer, size_t __buflen,
119 struct passwd **__result));
121 extern int __getpwnam_r __P ((__const char *__name, struct passwd *__resultbuf,
122 char *__buffer, size_t __buflen,
123 struct passwd **__result));
124 extern int getpwnam_r __P ((__const char *__name, struct passwd *__resultbuf,
125 char *__buffer, size_t __buflen,
126 struct passwd **__result));
129 #ifdef __USE_SVID
130 /* Read an entry from STREAM. */
131 extern int __fgetpwent_r __P ((FILE * __stream, struct passwd *__resultbuf,
132 char *__buffer, size_t __buflen,
133 struct passwd **__result));
134 extern int fgetpwent_r __P ((FILE * __stream, struct passwd *__resultbuf,
135 char *__buffer, size_t __buflen,
136 struct passwd **__result));
137 #endif
139 #endif /* reentrant */
142 __END_DECLS
144 #endif /* pwd.h */