4.3BSD-Reno/share/man/cat3/getgrgid.0
GETGRENT(3) 1990 GETGRENT(3)
NNAAMMEE
getgrent, getgrnam, getgrgid, setgroupent, setgrfile, set-
grent, endgrent - get group file entry
SSYYNNOOPPSSIISS
##iinncclluuddee <<ggrrpp..hh>>
ssttrruucctt ggrroouupp **ggeettggrreenntt(())
ssttrruucctt ggrroouupp **ggeettggrrnnaamm((nnaammee))
cchhaarr **nnaammee;;
ssttrruucctt ggrroouupp **ggeettggrrggiidd((ggiidd))
ggiidd__tt ggiidd;;
sseettggrroouuppeenntt((ssttaayyooppeenn))
iinntt ssttaayyooppeenn;;
vvooiidd sseettggrrffiillee((nnaammee))
cchhaarr **nnaammee;;
sseettggrreenntt(())
vvooiidd eennddggrreenntt(())
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 a pointer to a
structure containing the broken-out fields of a line in the
group file. This structure is defined by the include file
<grp.h>, and contains the following fields:
struct group {
char *gr_name; /* group name */
char *gr_passwd; /* group password */
gid_t gr_gid; /* group id */
char **gr_mem; /* group members */
};
These fields are more completely described in _g_r_o_u_p(5).
_G_e_t_g_r_n_a_m and _g_e_t_g_r_g_i_d search the group database for a match-
ing group name or group id, respectively, returning the
first one encountered. Identical group names or group gids
may result in undefined behavior.
_G_e_t_g_r_e_n_t sequentially reads the group database and is
intended for programs that wish to step through the complete
list of groups.
All three routines will open the group file for reading, if
necesssary.
Printed 7/27/90 June 1
GETGRENT(3) 1990 GETGRENT(3)
_S_e_t_g_r_f_i_l_e changes the default group file to _f_i_l_e, thus
allowing the use of alternate group files.
_S_e_t_g_r_o_u_p_e_n_t opens the file, or rewinds it if it is already
open. If _s_t_a_y_o_p_e_n is non-zero, file descriptors are left
open, significantly speeding up subsequent calls. This
functionality is unnecessary for _g_e_t_g_r_e_n_t as it doesn't
close its file descriptors by default. It should also be
noted that it is dangerous for long-running programs to use
this functionality as the group file may be updated.
_S_e_t_g_r_e_n_t is identical to _s_e_t_g_r_o_u_p_e_n_t with an argument of
zero.
_E_n_d_g_r_e_n_t closes any open files.
FFIILLEESS
/etc/group
SSEEEE AALLSSOO
getpwent(3), group(5)
DDIIAAGGNNOOSSTTIICCSS
The routines _g_e_t_g_r_e_n_t, _g_e_t_g_r_n_a_m, and _g_e_t_g_r_g_i_d, return a null
pointer on EOF or error. _S_e_t_g_r_o_u_p_e_n_t and _s_e_t_g_r_e_n_t return 0
on failure, 1 on success. _E_n_d_g_r_e_n_t and _s_e_t_g_r_f_i_l_e have no
return value.
BBUUGGSS
All information is contained in a static buffer which is
overwritten by each new call. It must be copied elsewhere
to be retained.
The routines _g_e_t_g_r_e_n_t, _e_n_d_g_r_e_n_t, _s_e_t_g_r_o_u_p_e_n_t, and _s_e_t_g_r_e_n_t
are fairly useless in a networked environment and should be
avoided, if possible.
Printed 7/27/90 June 2