]> git.ipfire.org Git - thirdparty/glibc.git/blob - pwd/pwd.h
Remove pre-ISO C support
[thirdparty/glibc.git] / pwd / pwd.h
1 /* Copyright (C) 1991,1992,1995-2001,2003,2004,2012
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20 /*
21 * POSIX Standard: 9.2.2 User Database Access <pwd.h>
22 */
23
24 #ifndef _PWD_H
25 #define _PWD_H 1
26
27 #include <features.h>
28
29 __BEGIN_DECLS
30
31 #include <bits/types.h>
32
33 #define __need_size_t
34 #include <stddef.h>
35
36 #if defined __USE_XOPEN || defined __USE_XOPEN2K
37 /* The Single Unix specification says that some more types are
38 available here. */
39 # ifndef __gid_t_defined
40 typedef __gid_t gid_t;
41 # define __gid_t_defined
42 # endif
43
44 # ifndef __uid_t_defined
45 typedef __uid_t uid_t;
46 # define __uid_t_defined
47 # endif
48 #endif
49
50 /* The passwd structure. */
51 struct passwd
52 {
53 char *pw_name; /* Username. */
54 char *pw_passwd; /* Password. */
55 __uid_t pw_uid; /* User ID. */
56 __gid_t pw_gid; /* Group ID. */
57 char *pw_gecos; /* Real name. */
58 char *pw_dir; /* Home directory. */
59 char *pw_shell; /* Shell program. */
60 };
61
62
63 #if defined __USE_SVID || defined __USE_GNU
64 # define __need_FILE
65 # include <stdio.h>
66 #endif
67
68
69 #if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN_EXTENDED
70 /* Rewind the password-file stream.
71
72 This function is a possible cancellation point and therefore not
73 marked with __THROW. */
74 extern void setpwent (void);
75
76 /* Close the password-file stream.
77
78 This function is a possible cancellation point and therefore not
79 marked with __THROW. */
80 extern void endpwent (void);
81
82 /* Read an entry from the password-file stream, opening it if necessary.
83
84 This function is a possible cancellation point and therefore not
85 marked with __THROW. */
86 extern struct passwd *getpwent (void);
87 #endif
88
89 #ifdef __USE_SVID
90 /* Read an entry from STREAM.
91
92 This function is not part of POSIX and therefore no official
93 cancellation point. But due to similarity with an POSIX interface
94 or due to the implementation it is a cancellation point and
95 therefore not marked with __THROW. */
96 extern struct passwd *fgetpwent (FILE *__stream);
97
98 /* Write the given entry onto the given stream.
99
100 This function is not part of POSIX and therefore no official
101 cancellation point. But due to similarity with an POSIX interface
102 or due to the implementation it is a cancellation point and
103 therefore not marked with __THROW. */
104 extern int putpwent (const struct passwd *__restrict __p,
105 FILE *__restrict __f);
106 #endif
107
108 /* Search for an entry with a matching user ID.
109
110 This function is a possible cancellation point and therefore not
111 marked with __THROW. */
112 extern struct passwd *getpwuid (__uid_t __uid);
113
114 /* Search for an entry with a matching username.
115
116 This function is a possible cancellation point and therefore not
117 marked with __THROW. */
118 extern struct passwd *getpwnam (const char *__name);
119
120 #if defined __USE_POSIX || defined __USE_MISC
121
122 # ifdef __USE_MISC
123 /* Reasonable value for the buffer sized used in the reentrant
124 functions below. But better use `sysconf'. */
125 # define NSS_BUFLEN_PASSWD 1024
126 # endif
127
128 /* Reentrant versions of some of the functions above.
129
130 PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.
131 The interface may change in later versions of this library. But
132 the interface is designed following the principals used for the
133 other reentrant functions so the chances are good this is what the
134 POSIX people would choose. */
135
136 # if defined __USE_SVID || defined __USE_MISC
137 /* This function is not part of POSIX and therefore no official
138 cancellation point. But due to similarity with an POSIX interface
139 or due to the implementation it is a cancellation point and
140 therefore not marked with __THROW. */
141 extern int getpwent_r (struct passwd *__restrict __resultbuf,
142 char *__restrict __buffer, size_t __buflen,
143 struct passwd **__restrict __result);
144 # endif
145
146 extern int getpwuid_r (__uid_t __uid,
147 struct passwd *__restrict __resultbuf,
148 char *__restrict __buffer, size_t __buflen,
149 struct passwd **__restrict __result);
150
151 extern int getpwnam_r (const char *__restrict __name,
152 struct passwd *__restrict __resultbuf,
153 char *__restrict __buffer, size_t __buflen,
154 struct passwd **__restrict __result);
155
156
157 # ifdef __USE_SVID
158 /* Read an entry from STREAM. This function is not standardized and
159 probably never will.
160
161 This function is not part of POSIX and therefore no official
162 cancellation point. But due to similarity with an POSIX interface
163 or due to the implementation it is a cancellation point and
164 therefore not marked with __THROW. */
165 extern int fgetpwent_r (FILE *__restrict __stream,
166 struct passwd *__restrict __resultbuf,
167 char *__restrict __buffer, size_t __buflen,
168 struct passwd **__restrict __result);
169 # endif
170
171 #endif /* POSIX or reentrant */
172
173 #ifdef __USE_GNU
174 /* Re-construct the password-file line for the given uid
175 in the given buffer. This knows the format that the caller
176 will expect, but this need not be the format of the password file.
177
178 This function is not part of POSIX and therefore no official
179 cancellation point. But due to similarity with an POSIX interface
180 or due to the implementation it is a cancellation point and
181 therefore not marked with __THROW. */
182 extern int getpw (__uid_t __uid, char *__buffer);
183 #endif
184
185 __END_DECLS
186
187 #endif /* pwd.h */