4.3BSD-UWisc/man/cat3/getpwent.3

Compare this file to the similar file:
Show the results in this format:




GETPWENT(3)         UNIX Programmer's Manual          GETPWENT(3)



NAME
     getpwent, getpwuid, getpwnam, setpwent, endpwent, setpwfile
     - get password file entry

SYNOPSIS
     #include <pwd.h>

     struct passwd *getpwuid(uid)
     int uid;

     struct passwd *getpwnam(name)
     char *name;

     struct passwd *getpwent()

     setpwent()

     endpwent()

     setpwfile(name)
     char *name;

DESCRIPTION
     _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.

          /*
           * RCS Info
           *   $Header: pwd.h,v 1.1 86/09/05 08:02:44 tadl Exp $
           *   $Locker: tadl $
           */
          /*   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).





Printed 12/27/86          May 15, 1986                          1






GETPWENT(3)         UNIX Programmer's Manual          GETPWENT(3)



     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.

     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.

FILES
     /etc/passwd

SEE ALSO
     getlogin(3), getgrent(3), passwd(5)

DIAGNOSTICS
     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.

BUGS
     All information is contained in a static area so it must  be
     copied if it is to be saved.

























Printed 12/27/86          May 15, 1986                          2