Update.
[glibc.git] / pwd / pwd.h
blobedccfedbca8e0351e93742294c8978428de53d8e
1 /* Copyright (C) 1991, 92, 95, 96, 97, 98 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
24 #define _PWD_H 1
26 #include <features.h>
28 __BEGIN_DECLS
30 #include <bits/types.h>
32 #define __need_size_t
33 #include <stddef.h>
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
43 # ifndef uid_t
44 typedef __uid_t uid_t;
45 # define uid_t uid_t
46 # endif
47 #endif
49 /* The passwd structure. */
50 struct passwd
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. */
62 #if defined __USE_SVID || defined __USE_GNU
63 # define __need_FILE
64 # include <stdio.h>
65 #endif
68 #if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN_EXTENDED
69 /* Rewind the password-file stream. */
70 extern void setpwent __P ((void));
72 /* Close the password-file stream. */
73 extern void endpwent __P ((void));
75 /* Read an entry from the password-file stream, opening it if necessary. */
76 extern struct passwd *getpwent __P ((void));
77 #endif
79 #ifdef __USE_SVID
80 /* Read an entry from STREAM. */
81 extern struct passwd *fgetpwent __P ((FILE *__stream));
83 /* Write the given entry onto the given stream. */
84 extern int putpwent __P ((__const struct passwd *__p, FILE *__f));
85 #endif
87 /* Search for an entry with a matching user ID. */
88 extern struct passwd *getpwuid __P ((__uid_t __uid));
90 /* Search for an entry with a matching username. */
91 extern struct passwd *getpwnam __P ((__const char *__name));
93 #if defined __USE_POSIX || defined __USE_MISC
95 # ifdef __USE_MISC
96 /* Reasonable value for the buffer sized used in the reentrant
97 functions below. But better use `sysconf'. */
98 # define NSS_BUFLEN_PASSWD 1024
99 # endif
101 /* Reentrant versions of some of the functions above.
103 PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.
104 The interface may change in later versions of this library. But
105 the interface is designed following the principals used for the
106 other reentrant functions so the chances are good this is what the
107 POSIX people would choose. */
109 # if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN_EXTENDED
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));
118 extern int getpwnam_r __P ((__const char *__name, struct passwd *__resultbuf,
119 char *__buffer, size_t __buflen,
120 struct passwd **__result));
123 # ifdef __USE_SVID
124 /* Read an entry from STREAM. This function is not standardized and
125 probably never will. */
126 extern int fgetpwent_r __P ((FILE * __stream, struct passwd *__resultbuf,
127 char *__buffer, size_t __buflen,
128 struct passwd **__result));
129 # endif
131 #endif /* POSIX or reentrant */
134 __END_DECLS
136 #endif /* pwd.h */