]> git.ipfire.org Git - thirdparty/glibc.git/blob - pwd/pwd.h
update from main archive 970122
[thirdparty/glibc.git] / pwd / pwd.h
1 /* Copyright (C) 1991, 1992, 1995, 1996, 1997 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
25 #define _PWD_H 1
26 #include <features.h>
27
28 __BEGIN_DECLS
29
30 #include <gnu/types.h>
31
32 #define __need_size_t
33 #include <stddef.h>
34
35 /* The passwd structure. */
36 struct passwd
37 {
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. */
45 };
46
47
48 #if defined(__USE_SVID) || defined(__USE_GNU)
49 #define __need_FILE
50 #include <stdio.h>
51 #endif
52
53 #ifdef __USE_GNU
54 /* Return a new stream open on the password file. */
55 extern FILE *__pwdopen __P ((void));
56
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));
60
61 /* Return a chunk of memory containing pre-initialized data for __pwdread. */
62 extern __ptr_t __pwdalloc __P ((void));
63
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
70
71
72 #if defined(__USE_SVID) || defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
73 /* Rewind the password-file stream. */
74 extern void setpwent __P ((void));
75
76 /* Close the password-file stream. */
77 extern void endpwent __P ((void));
78
79 /* Read an entry from the password-file stream, opening it if necessary. */
80 extern struct passwd *getpwent __P ((void));
81 #endif
82
83 #ifdef __USE_SVID
84 /* Read an entry from STREAM. */
85 extern struct passwd *fgetpwent __P ((FILE *__stream));
86
87 /* Write the given entry onto the given stream. */
88 extern int putpwent __P ((__const struct passwd *__p, FILE *__f));
89 #endif
90
91 /* Search for an entry with a matching user ID. */
92 extern struct passwd *getpwuid __P ((__uid_t __uid));
93
94 /* Search for an entry with a matching username. */
95 extern struct passwd *getpwnam __P ((__const char *__name));
96
97 #if defined __USE_POSIX || defined __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
101
102 /* Reentrant versions of some of the functions above.
103
104 PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.
105 The interface may change in later versions of this library. But
106 the interface is designed following the principals used for the
107 other reentrant functions so the chances are good this is what the
108 POSIX people would choose. */
109
110 #if defined(__USE_SVID) || defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
111 extern int __getpwent_r __P ((struct passwd *__resultbuf, char *__buffer,
112 size_t __buflen, struct passwd **__result));
113 extern int getpwent_r __P ((struct passwd *__resultbuf, char *__buffer,
114 size_t __buflen, struct passwd **__result));
115 #endif
116
117 extern int __getpwuid_r __P ((__uid_t __uid, struct passwd *__resultbuf,
118 char *__buffer, size_t __buflen,
119 struct passwd **__result));
120 extern int getpwuid_r __P ((__uid_t __uid, struct passwd *__resultbuf,
121 char *__buffer, size_t __buflen,
122 struct passwd **__result));
123
124 extern int __getpwnam_r __P ((__const char *__name, struct passwd *__resultbuf,
125 char *__buffer, size_t __buflen,
126 struct passwd **__result));
127 extern int getpwnam_r __P ((__const char *__name, struct passwd *__resultbuf,
128 char *__buffer, size_t __buflen,
129 struct passwd **__result));
130
131
132 #ifdef __USE_SVID
133 /* Read an entry from STREAM. This function is not standardized and
134 probably never will. */
135 extern int __fgetpwent_r __P ((FILE * __stream, struct passwd *__resultbuf,
136 char *__buffer, size_t __buflen,
137 struct passwd **__result));
138 extern int fgetpwent_r __P ((FILE * __stream, struct passwd *__resultbuf,
139 char *__buffer, size_t __buflen,
140 struct passwd **__result));
141 #endif
142
143 #endif /* POSIX or reentrant */
144
145
146 __END_DECLS
147
148 #endif /* pwd.h */