GETGRENT(3) UNIX Programmer's Manual GETGRENT(3) NNAAMMEE getgrent, getgrgid, getgrnam, setgrent, endgrent setgrfile - get group file entry SSYYNNOOPPSSIISS ##iinncclluuddee <<ggrrpp..hh>> ssttrruucctt ggrroouupp **ggeettggrreenntt(()) ssttrruucctt ggrroouupp **ggeettggrrggiidd((ggiidd)) iinntt ggiidd;; ssttrruucctt ggrroouupp **ggeettggrrnnaamm((nnaammee)) cchhaarr **nnaammee;; sseettggrreenntt(()) eennddggrreenntt(()) sseettggrrffiillee((nnaammee)) cchhaarr **nnaammee;; DDEESSCCRRIIPPTTIIOONN _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. /* 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 entire file. Printed 7/9/88 November 5, 1987 1 GETGRENT(3) UNIX Programmer's Manual GETGRENT(3) 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. _S_e_t_g_r_f_i_l_e changes the default group file to _n_a_m_e thus allow- ing alternate grioup files to be used. Note that it does _n_o_t close the previous file. If this is desired, _e_n_d_g_r_e_n_t should be called prior to it. FFIILLEESS /etc/group SSEEEE AALLSSOO getlogin(3), getpwent(3), group(5) DDIIAAGGNNOOSSTTIICCSS A null pointer (0) is returned 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 November 5, 1987 2