]> git.ipfire.org Git - thirdparty/glibc.git/blob - pwd/pwd.h
Update.
[thirdparty/glibc.git] / pwd / pwd.h
1 /* Copyright (C) 1991, 92, 95, 96, 97, 98 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
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.
8
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.
13
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. */
18
19 /*
20 * POSIX Standard: 9.2.2 User Database Access <pwd.h>
21 */
22
23 #ifndef _PWD_H
24 #define _PWD_H 1
25
26 #include <features.h>
27
28 __BEGIN_DECLS
29
30 #include <bits/types.h>
31
32 #define __need_size_t
33 #include <stddef.h>
34
35 #ifdef __USE_XOPEN
36 /* The Single Unix specification says that some more types are
37 available here. */
38 # ifndef gid_t
39 typedef __gid_t gid_t;
40 # define gid_t gid_t
41 # endif
42
43 # ifndef uid_t
44 typedef __uid_t uid_t;
45 # define uid_t uid_t
46 # endif
47 #endif
48
49 /* The passwd structure. */
50 struct passwd
51 {
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. */
59 };
60
61
62 #if defined __USE_SVID || defined __USE_GNU
63 # define __need_FILE
64 # include <stdio.h>
65 #endif
66
67 #ifdef __USE_GNU
68 /* Return a new stream open on the password file. */
69 extern FILE *__pwdopen __P ((void));
70
71 /* Read a password entry from STREAM, filling in P.
72 Return the `struct passwd' of P if successful, NULL on failure. */
73 extern struct passwd *__pwdread __P ((FILE *__stream, __ptr_t __p));
74
75 /* Return a chunk of memory containing pre-initialized data for __pwdread. */
76 extern __ptr_t __pwdalloc __P ((void));
77
78 /* Scan the password file, filling in P, until SELECTOR returns nonzero for
79 an entry. Return the `struct passwd' of P if successful, NULL on
80 failure. */
81 extern struct passwd *__pwdscan __P ((__ptr_t *__p,
82 int (*__selector) (struct passwd *)));
83 #endif
84
85
86 #if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN_EXTENDED
87 /* Rewind the password-file stream. */
88 extern void setpwent __P ((void));
89
90 /* Close the password-file stream. */
91 extern void endpwent __P ((void));
92
93 /* Read an entry from the password-file stream, opening it if necessary. */
94 extern struct passwd *getpwent __P ((void));
95 #endif
96
97 #ifdef __USE_SVID
98 /* Read an entry from STREAM. */
99 extern struct passwd *fgetpwent __P ((FILE *__stream));
100
101 /* Write the given entry onto the given stream. */
102 extern int putpwent __P ((__const struct passwd *__p, FILE *__f));
103 #endif
104
105 /* Search for an entry with a matching user ID. */
106 extern struct passwd *getpwuid __P ((__uid_t __uid));
107
108 /* Search for an entry with a matching username. */
109 extern struct passwd *getpwnam __P ((__const char *__name));
110
111 #if defined __USE_POSIX || defined __USE_MISC
112
113 # ifdef __USE_MISC
114 /* Reasonable value for the buffer sized used in the reentrant
115 functions below. But better use `sysconf'. */
116 # define NSS_BUFLEN_PASSWD 1024
117 # endif
118
119 /* Reentrant versions of some of the functions above.
120
121 PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.
122 The interface may change in later versions of this library. But
123 the interface is designed following the principals used for the
124 other reentrant functions so the chances are good this is what the
125 POSIX people would choose. */
126
127 # if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN_EXTENDED
128 extern int __getpwent_r __P ((struct passwd *__resultbuf, char *__buffer,
129 size_t __buflen, struct passwd **__result));
130 extern int getpwent_r __P ((struct passwd *__resultbuf, char *__buffer,
131 size_t __buflen, struct passwd **__result));
132 # endif
133
134 extern int __getpwuid_r __P ((__uid_t __uid, struct passwd *__resultbuf,
135 char *__buffer, size_t __buflen,
136 struct passwd **__result));
137 extern int getpwuid_r __P ((__uid_t __uid, struct passwd *__resultbuf,
138 char *__buffer, size_t __buflen,
139 struct passwd **__result));
140
141 extern int __getpwnam_r __P ((__const char *__name, struct passwd *__resultbuf,
142 char *__buffer, size_t __buflen,
143 struct passwd **__result));
144 extern int getpwnam_r __P ((__const char *__name, struct passwd *__resultbuf,
145 char *__buffer, size_t __buflen,
146 struct passwd **__result));
147
148
149 # ifdef __USE_SVID
150 /* Read an entry from STREAM. This function is not standardized and
151 probably never will. */
152 extern int __fgetpwent_r __P ((FILE * __stream, struct passwd *__resultbuf,
153 char *__buffer, size_t __buflen,
154 struct passwd **__result));
155 extern int fgetpwent_r __P ((FILE * __stream, struct passwd *__resultbuf,
156 char *__buffer, size_t __buflen,
157 struct passwd **__result));
158 # endif
159
160 #endif /* POSIX or reentrant */
161
162
163 __END_DECLS
164
165 #endif /* pwd.h */