getfstype has been removed
[unix-history] / usr / src / lib / libc / gen / getpwent.3
CommitLineData
1e00f4a7 1.\" @(#)getpwent.3 6.3 (Berkeley) %G%
4e6e003a 2.\"
3fb9eae6 3.TH GETPWENT 3 ""
4e6e003a
KM
4.AT 3
5.SH NAME
3fb9eae6 6getpwent, getpwuid, getpwnam, setpwent, endpwent, setpwfile \- get password file entry
4e6e003a
KM
7.SH SYNOPSIS
8.nf
9.B #include <pwd.h>
10.PP
4e6e003a
KM
11.B struct passwd *getpwuid(uid)
12.B int uid;
13.PP
14.B struct passwd *getpwnam(name)
15.B char *name;
16.PP
1e00f4a7
KM
17.B struct passwd *getpwent()
18.PP
c5892565 19.B setpwent()
4e6e003a 20.PP
c5892565 21.B endpwent()
3fb9eae6
KM
22.PP
23.B setpwfile(name)
24.B char *name;
4e6e003a
KM
25.fi
26.SH DESCRIPTION
27.I Getpwent,
28.I getpwuid
29and
30.I getpwnam
31each return a pointer to an object with the
32following structure
33containing the broken-out
34fields of a line in the password file.
35.RS
36.PP
37.nf
38.so /usr/include/pwd.h
39.ft R
40.ad
41.fi
42.RE
43.PP
44The fields
45.I pw_quota
46and
47.I pw_comment
48are unused; the others have meanings described in
49.IR passwd (5).
50.PP
1e00f4a7
KM
51Searching of the password file is done using the \fIndbm\fP
52database access routines.
53.I Setpwent
54opens the database;
4e6e003a
KM
55.I endpwent
56closes it.
1e00f4a7
KM
57.I Getpwuid
58and
59.I getpwnam
60search the database (opening it if necessary) for a matching
61.I uid
62or
63.IR name .
64EOF is returned if there is no entry.
65.PP
66For programs wishing to read the entire database,
67.I getpwent
68reads the next
69line (opening the database if necessary).
70In addition to opening the database,
71.I setpwent
72can be used to make
73.I getpwent
74begin its search from the beginning of the database.
4e6e003a 75.PP
3fb9eae6
KM
76.I Setpwfile
77changes the default password file to
78.I name
79thus allowing alternate password files to be used.
80Note that it does
81.I not
82close the previous file.
83If this is desired,
84.I endpwent
85should be called prior to it.
4e6e003a
KM
86.SH FILES
87/etc/passwd
88.SH "SEE ALSO"
89getlogin(3), getgrent(3), passwd(5)
90.SH DIAGNOSTICS
c5892565
KM
91The routines
92.IR getpwent ,
93.IR getpwuid ,
94and
95.IR getpwnam ,
96return a null pointer (0) on EOF or error.
4e6e003a
KM
97.SH BUGS
98All information
99is contained in a static area
100so it must be copied if it is
101to be saved.