4.3BSD-Tahoe/usr/man/cat3/endpwent.0
GETPWENT(3) UNIX Programmer's Manual GETPWENT(3)
NNAAMMEE
getpwent, getpwuid, getpwnam, setpwent, endpwent, setpwfile
- get password file entry
SSYYNNOOPPSSIISS
##iinncclluuddee <<ppwwdd..hh>>
ssttrruucctt ppaasssswwdd **ggeettppwwuuiidd((uuiidd))
iinntt uuiidd;;
ssttrruucctt ppaasssswwdd **ggeettppwwnnaamm((nnaammee))
cchhaarr **nnaammee;;
ssttrruucctt ppaasssswwdd **ggeettppwweenntt(())
sseettppwweenntt(())
eennddppwweenntt(())
sseettppwwffiillee((nnaammee))
cchhaarr **nnaammee;;
DDEESSCCRRIIPPTTIIOONN
_G_e_t_p_w_e_n_t, _g_e_t_p_w_u_i_d and _g_e_t_p_w_n_a_m each return a pointer to an
object with the following structure containing the broken-
out fields of a line in the password file.
/* pwd.h 4.1 83/05/03 */
struct passwd { /* see getpwent(3) */
char *pw_name;
char *pw_passwd;
int pw_uid;
int pw_gid;
int pw_quota;
char *pw_comment;
char *pw_gecos;
char *pw_dir;
char *pw_shell;
};
struct passwd *getpwent(), *getpwuid(), *getpwnam();
The fields _p_w__q_u_o_t_a and _p_w__c_o_m_m_e_n_t are unused; the others
have meanings described in _p_a_s_s_w_d(5).
Searching of the password file is done using the _n_d_b_m data-
base access routines. _S_e_t_p_w_e_n_t opens the database; _e_n_d_p_w_e_n_t
closes it. _G_e_t_p_w_u_i_d and _g_e_t_p_w_n_a_m search the database (open-
ing it if necessary) for a matching _u_i_d or _n_a_m_e. EOF is
returned if there is no entry.
Printed 7/9/88 May 15, 1986 1
GETPWENT(3) UNIX Programmer's Manual GETPWENT(3)
For programs wishing to read the entire database, _g_e_t_p_w_e_n_t
reads the next line (opening the database if necessary). In
addition to opening the database, _s_e_t_p_w_e_n_t can be used to
make _g_e_t_p_w_e_n_t begin its search from the beginning of the
database.
_S_e_t_p_w_f_i_l_e changes the default password file to _n_a_m_e thus
allowing alternate password files to be used. Note that it
does _n_o_t close the previous file. If this is desired,
_e_n_d_p_w_e_n_t should be called prior to it.
FFIILLEESS
/etc/passwd
SSEEEE AALLSSOO
getlogin(3), getgrent(3), passwd(5)
DDIIAAGGNNOOSSTTIICCSS
The routines _g_e_t_p_w_e_n_t, _g_e_t_p_w_u_i_d, and _g_e_t_p_w_n_a_m, return a null
pointer (0) on EOF or error.
BBUUGGSS
All information is contained in a static area so it must be
copied if it is to be saved.
Printed 7/9/88 May 15, 1986 2