home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 5
/
FreshFish_July-August1994.bin
/
bbs
/
gnu
/
ixemul-39.47-env-bin.lha
/
man
/
cat3
/
getgrent.0
< prev
next >
Wrap
Text File
|
1993-12-07
|
5KB
|
133 lines
GETGRENT(3) UNIX Programmer's Manual GETGRENT(3)
NNAAMMEE
ggeettggrreenntt, ggeettggrrnnaamm, ggeettggrrggiidd, sseettggrroouuppeenntt, sseettggrreenntt, eennddggrreenntt - group
database operations
SSYYNNOOPPSSIISS
##iinncclluuddee <<ggrrpp..hh>>
_s_t_r_u_c_t _g_r_o_u_p _*
ggeettggrreenntt(_v_o_i_d)
_s_t_r_u_c_t _g_r_o_u_p _*
ggeettggrrnnaammee(_c_o_n_s_t _c_h_a_r _*_n_a_m_e)
_s_t_r_u_c_t _g_r_o_u_p _*
ggeettggrrggiidd(_g_i_d___t _g_i_d)
_s_t_r_u_c_t _g_r_o_u_p _*
sseettggrroouuppeenntt(_i_n_t _s_t_a_y_o_p_e_n)
_i_n_t
sseettggrreenntt(_v_o_i_d)
_v_o_i_d
eennddggrreenntt(_v_o_i_d)
DDEESSCCRRIIPPTTIIOONN
These functions operate on the group database file _/_e_t_c_/_g_r_o_u_p which is
described in group(5). Each line of the database is defined by the
structure _g_r_o_u_p found in the include file <_g_r_p_._h>:
struct group {
char *gr_name; /* group name */
char *gr_passwd; /* group password */
gid_t gr_gid; /* group id */
char **gr_mem; /* group members */
};
The functions ggeettggrrnnaamm() and ggeettggrrggiidd() search the group database for the
given group name pointed to by _n_a_m_e or the group id pointed to by _g_i_d,
respectively, returning the first one encountered. Identical group names
or group gids may result in undefined behavior.
The ggeettggrreenntt() function sequentially reads the group database and is in
tended for programs that wish to step through the complete list of
groups.
All three routines will open the group file for reading, if necesssary.
The sseettggrroouuppeenntt() function opens the file, or rewinds it if it is already
open. If _s_t_a_y_o_p_e_n is nonzero, file descriptors are left open, signifi
cantly speeding functions subsequent calls. This functionality is unnec
essary for ggeettggrreenntt() as it doesn't close its file descriptors by de
fault. It should also be noted that it is dangerous for longrunning
programs to use this functionality as the group file may be updated.
The sseettggrreenntt() function is identical to sseettggrroouuppeenntt() with an argument of
zero.
The eennddggrreenntt() function closes any open files.
RREETTUURRNN VVAALLUUEESS
The functions ggeettggrreenntt(), ggeettggrrnnaamm(), and ggeettggrrggiidd(), return a pointer to
the group entry if successful; if endoffile is reached or an error oc
curs a null pointer is returned. The functions sseettggrroouuppeenntt() and
sseettggrreenntt() return the value 1 if successful, otherwise the value 0 is re
turned. The functions eennddggrreenntt() and sseettggrrffiillee() have no return value.
FFIILLEESS
/etc/group group database file
SSEEEE AALLSSOO
ggeettppwweenntt(_3), ggrroouupp(_5)
HHIISSTTOORRYY
The functions eennddggrreenntt(), ggeettggrreenntt(), ggeettggrrnnaamm(), ggeettggrrggiidd(), and
sseettggrreenntt() appeared in Version 7 AT&T UNIX. The functions sseettggrrffiillee()
and sseettggrroouuppeenntt() appeared in 4.3BSD-Reno.
CCOOMMPPAATTIIBBIILLIITTYY
The historic function sseettggrrffiillee(), which allowed the specification of al
ternate password databases, has been deprecated and is no longer avail
able.
BBUUGGSS
The functions ggeettggrreenntt(), ggeettggrrnnaamm(), ggeettggrrggiidd(), sseettggrroouuppeenntt() and
sseettggrreenntt() leave their results in an internal static object and return a
pointer to that object. Subsequent calls to the same function will modify
the same object.
The functions ggeettggrreenntt(), eennddggrreenntt(), sseettggrroouuppeenntt(), and sseettggrreenntt() are
fairly useless in a networked environment and should be avoided, if pos
sible.
BSD Experimental April 20, 1991 2