blob: d161c0e8f963ea00bc92cfeae711f8afec5ccca5 [file] [log] [blame]
"Robert P. J. Day"63fc1a92006-07-02 19:47:05 +00001/* vi: set sw=4 ts=4: */
Eric Andersen9615a082004-07-15 12:53:49 +00002/* 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 */
Eric Andersenab050f52001-01-27 06:01:43 +000023
Robert Grieblea1a63a2002-06-04 20:10:23 +000024#if !defined CONFIG_USE_BB_PWD_GRP
Eric Andersen887ca792002-07-03 23:19:26 +000025#include <pwd.h>
Robert Grieblea1a63a2002-06-04 20:10:23 +000026
Eric Andersenab050f52001-01-27 06:01:43 +000027#else
28
Eric Andersen9615a082004-07-15 12:53:49 +000029#ifndef _PWD_H
30#define _PWD_H 1
31
Eric Andersenab050f52001-01-27 06:01:43 +000032#include <sys/types.h>
33#include <features.h>
34#include <stdio.h>
35
36/* The passwd structure. */
37struct passwd
38{
Eric Andersen9615a082004-07-15 12:53:49 +000039 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. */
Eric Andersenab050f52001-01-27 06:01:43 +000046};
47
Eric Andersenab050f52001-01-27 06:01:43 +000048
Eric Andersen9615a082004-07-15 12:53:49 +000049/* Rewind the password-file stream. */
50extern void setpwent (void);
Eric Andersenab050f52001-01-27 06:01:43 +000051
Eric Andersen9615a082004-07-15 12:53:49 +000052/* Close the password-file stream. */
53extern void endpwent (void);
Eric Andersenab050f52001-01-27 06:01:43 +000054
Eric Andersen9615a082004-07-15 12:53:49 +000055/* Read an entry from the password-file stream, opening it if necessary. */
56extern struct passwd *getpwent (void);
Eric Andersenab050f52001-01-27 06:01:43 +000057
Eric Andersen9615a082004-07-15 12:53:49 +000058/* Read an entry from STREAM. */
59extern struct passwd *fgetpwent (FILE *__stream);
Eric Andersenab050f52001-01-27 06:01:43 +000060
Eric Andersen9615a082004-07-15 12:53:49 +000061/* Write the given entry onto the given stream. */
62extern int putpwent (__const struct passwd *__restrict __p,
63 FILE *__restrict __f);
Eric Andersenab050f52001-01-27 06:01:43 +000064
Eric Andersen9615a082004-07-15 12:53:49 +000065/* Search for an entry with a matching user ID. */
66extern struct passwd *getpwuid (uid_t __uid);
67
68/* Search for an entry with a matching username. */
69extern 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
79extern int getpwent_r (struct passwd *__restrict __resultbuf,
80 char *__restrict __buffer, size_t __buflen,
81 struct passwd **__restrict __result);
82
83extern int getpwuid_r (uid_t __uid,
84 struct passwd *__restrict __resultbuf,
85 char *__restrict __buffer, size_t __buflen,
86 struct passwd **__restrict __result);
87
88extern 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. */
96extern 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. */
104extern int getpw (uid_t __uid, char *__buffer);
105
106#endif /* pwd.h */
107#endif