Standardize on the vi editing directives being on the first line.
[oweals/busybox.git] / include / pwd_.h
1 /* vi: set sw=4 ts=4: */
2 /* Copyright (C) 1991,92,95,96,97,98,99,2001 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 #if !defined CONFIG_USE_BB_PWD_GRP
25 #include <pwd.h>
26
27 #else
28
29 #ifndef _PWD_H
30 #define _PWD_H  1
31
32 #include <sys/types.h>
33 #include <features.h>
34 #include <stdio.h>
35
36 /* The passwd structure.  */
37 struct passwd
38 {
39     char *pw_name;              /* Username.  */
40     char *pw_passwd;            /* Password.  */
41     uid_t pw_uid;                       /* User ID.  */
42     gid_t pw_gid;                       /* Group ID.  */
43     char *pw_gecos;             /* Real name.  */
44     char *pw_dir;                       /* Home directory.  */
45     char *pw_shell;             /* Shell program.  */
46 };
47
48
49 /* Rewind the password-file stream.  */
50 extern void setpwent (void);
51
52 /* Close the password-file stream.  */
53 extern void endpwent (void);
54
55 /* Read an entry from the password-file stream, opening it if necessary.  */
56 extern struct passwd *getpwent (void);
57
58 /* Read an entry from STREAM.  */
59 extern struct passwd *fgetpwent (FILE *__stream);
60
61 /* Write the given entry onto the given stream.  */
62 extern int putpwent (__const struct passwd *__restrict __p,
63                      FILE *__restrict __f);
64
65 /* Search for an entry with a matching user ID.  */
66 extern struct passwd *getpwuid (uid_t __uid);
67
68 /* Search for an entry with a matching username.  */
69 extern struct passwd *getpwnam (__const char *__name);
70
71 /* Reentrant versions of some of the functions above.
72
73    PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.
74    The interface may change in later versions of this library.  But
75    the interface is designed following the principals used for the
76    other reentrant functions so the chances are good this is what the
77    POSIX people would choose.  */
78
79 extern int getpwent_r (struct passwd *__restrict __resultbuf,
80                        char *__restrict __buffer, size_t __buflen,
81                        struct passwd **__restrict __result);
82
83 extern int getpwuid_r (uid_t __uid,
84                        struct passwd *__restrict __resultbuf,
85                        char *__restrict __buffer, size_t __buflen,
86                        struct passwd **__restrict __result);
87
88 extern int getpwnam_r (__const char *__restrict __name,
89                        struct passwd *__restrict __resultbuf,
90                        char *__restrict __buffer, size_t __buflen,
91                        struct passwd **__restrict __result);
92
93
94 /* Read an entry from STREAM.  This function is not standardized and
95    probably never will.  */
96 extern int fgetpwent_r (FILE *__restrict __stream,
97                         struct passwd *__restrict __resultbuf,
98                         char *__restrict __buffer, size_t __buflen,
99                         struct passwd **__restrict __result);
100
101 /* Re-construct the password-file line for the given uid
102    in the given buffer.  This knows the format that the caller
103    will expect, but this need not be the format of the password file.  */
104 extern int getpw (uid_t __uid, char *__buffer);
105
106 #endif /* pwd.h  */
107 #endif