[0m


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



[1mNAME
     [0mgetpwent, getpwuid, getpwnam, setpwent, endpwent, setpwfile,
     fgetpwent - get password file entry

[1mSYNOPSIS
     #include <pwd.h>

     struct passwd *getpwuid(uid)
     int uid;

     struct passwd *getpwnam(name)
     char *name;

     struct passwd *getpwent()

     setpwent()

     endpwent()

     setpwfile(name)
     char *name;

     struct passwd *fgetpwent(f)
     FILE *f;

DESCRIPTION
     [0m_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.

	  [1mstruct    passwd { /* see getpwent(3) */
	       char *pw_name;
	       char *pw_passwd;
	       union { uid_t  _uid; int _pad1; } _uid;
	       union { gid_t  _gid; int _pad2; } _gid;
	       int  pw_quota;
	       char *pw_comment;
	       char *pw_gecos;
	       char *pw_dir;
	       char *pw_shell;
	  };
	  #define   pw_uid    _uid._uid
	  #define   pw_gid    _gid._gid

     [0mThe 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 13/5/93     Revision 1.5 of 24/07/90			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.

     _F_g_e_t_p_w_e_n_t returns a pointer to the next passwd  structure in
     the  stream f, which matches the format of the password file
     /etc/passwd.

[1mFILES
     [0m/etc/passwd

[1mSEE ALSO
     [0mgetlogin(3), getgrent(3), passwd(5), ypserv(8)

[1mDIAGNOSTICS
     [0mThe 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.

[1mBUGS
     [0mAll information is contained in a static area so it must  be
     copied if it is to be saved.



























Printed 13/5/93     Revision 1.5 of 24/07/90			2



[0m