update from main archive 960910
[glibc.git] / pwd / pwd.h
blob9bd380a6dbe43e77b39a605f3dbc55eccd47ccbc
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>
23 #ifndef _PWD_H
25 #define _PWD_H 1
26 #include <features.h>
28 __BEGIN_DECLS
30 #include <gnu/types.h>
33 /* The passwd structure. */
34 struct passwd
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)
47 #define __need_FILE
48 #include <stdio.h>
49 #endif
51 #ifdef __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
64 failure. */
65 extern struct passwd *__pwdscan __P ((__ptr_t *__p,
66 int (*__selector) (struct passwd *)));
67 #endif
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));
79 #endif
81 #ifdef __USE_SVID
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));
87 #endif
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 struct passwd *__getpwent_r __P ((struct passwd *__resultbuf,
107 char *__buffer, int __buflen));
108 extern struct passwd *getpwent_r __P ((struct passwd *__resultbuf,
109 char *__buffer, int __buflen));
110 #endif
112 extern struct passwd *__getpwuid_r __P ((__uid_t __uid,
113 struct passwd *__resultbuf,
114 char *__buffer, int __buflen));
115 extern struct passwd *getpwuid_r __P ((__uid_t __uid,
116 struct passwd *__resultbuf,
117 char *__buffer, int __buflen));
119 extern struct passwd *__getpwnam_r __P ((__const char *__name,
120 struct passwd *__resultbuf,
121 char *__buffer, int __buflen));
122 extern struct passwd *getpwnam_r __P ((__const char *__name,
123 struct passwd *__resultbuf,
124 char *__buffer, int __buflen));
127 #ifdef __USE_SVID
128 /* Read an entry from STREAM. */
129 extern struct passwd *__fgetpwent_r __P ((FILE * __stream,
130 struct passwd *__resultbuf,
131 char *__buffer, int __buflen));
132 extern struct passwd *fgetpwent_r __P ((FILE * __stream,
133 struct passwd *__resultbuf,
134 char *__buffer, int __buflen));
135 #endif
137 #endif /* reentrant */
140 __END_DECLS
142 #endif /* pwd.h */