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

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




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



NAME
     getgrent, getgrgid, getgrnam, setgrent, endgrent - get group
     file entry

SYNOPSIS
     #include <grp.h>

     struct group *getgrent()

     struct group *getgrgid(gid)
     int gid;

     struct group *getgrnam(name)
     char *name;

     setgrent()

     endgrent()

DESCRIPTION
     _G_e_t_g_r_e_n_t, _g_e_t_g_r_g_i_d and _g_e_t_g_r_n_a_m each return pointers to an
     object with the following structure containing the broken-
     out fields of a line in the group file.

          /*
           * RCS Info
           *   $Header: grp.h,v 1.1 86/09/05 08:02:20 tadl Exp $
           *   $Locker: tadl $
           */
          /*   grp.h     4.1  83/05/03  */

          struct    group { /* see getgrent(3) */
               char *gr_name;
               char *gr_passwd;
               int  gr_gid;
               char **gr_mem;
          };

          struct group *getgrent(), *getgrgid(), *getgrnam();

     The members of this structure are:

     gr_name    The name of the group.
     gr_passwd  The encrypted password of the group.
     gr_gid     The numerical group-ID.
     gr_mem     Null-terminated vector of pointers to the indivi-
                dual member names.

     _G_e_t_g_r_e_n_t simply reads the next line while _g_e_t_g_r_g_i_d and _g_e_t_-
     _g_r_n_a_m search until a matching _g_i_d or _n_a_m_e is found (or until
     EOF is encountered).  Each routine picks up where the others
     leave off so successive calls may be used to search the



Printed 12/27/86          May 15, 1985                          1






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



     entire file.

     A call to _s_e_t_g_r_e_n_t has the effect of rewinding the group
     file to allow repeated searches.  _E_n_d_g_r_e_n_t may be called to
     close the group file when processing is complete.

FILES
     /etc/group

SEE ALSO
     getlogin(3), getpwent(3), group(5)

DIAGNOSTICS
     A null pointer (0) is returned 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, 1985                          2