unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (SunOS-4.1.3)
Page:
Section:
Apropos / Subsearch:
optional field

GETGRENT(3V)                                                      GETGRENT(3V)



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

SYNOPSIS
       #include <&lt;grp.h>&gt;

       struct group *getgrent()

       struct group *getgrgid(gid)
       int gid;

       struct group *getgrnam(name)
       char *name;

       void setgrent()

       void endgrent()

       struct group *fgetgrent(f)
       FILE *f;

DESCRIPTION
       getgrent(), getgrgid() and getgrnam() each return pointers to an object
       with  the  following  structure  containing the fields of a line in the
       group file.   Each  line  contains  a  "group"  structure,  defined  in
       <&lt;grp.h>&gt;.

              struct    group {
                   char *gr_name; /* name of the group */
                   char *gr_passwd;    /* encrypted password of the group */
                   gid_t     gr_gid;        /* numerical group ID */
                   char **gr_mem; /* null-terminated array of pointers to the
                                       individual member names */
              };

       getgrent()  when  first  called  returns  a  pointer to the first group
       structure in the file; thereafter, it returns a  pointer  to  the  next
       group structure in the file; so, successive calls may be used to search
       the entire file.  getgrgid() searches from the beginning  of  the  file
       until  a numerical group ID matching gid is found and returns a pointer
       to the particular structure in which it was found.  getgrnam() searches
       from  the  beginning  of  the  file until a group name matching name is
       found and returns a pointer to the particular structure in which it was
       found.   If an end-of-file or an error is encountered on reading, these
       functions return a NULL pointer.

       A call to setgrent() has the effect of  rewinding  the  group  file  to
       allow  repeated  searches.  endgrent() may be called to close the group
       file when processing is complete.

       fgetgrent() returns a pointer to the next group structure in the stream
       f,  which  must  refer  to an open file in the same format as the group
       file /etc/group.

RETURN VALUES
       getgrent(), getgrgid(), and getgrnam() return a pointer to struct group
       on success.  On EOF or error, they return NULL.

FILES
       /etc/group

SEE ALSO
       getlogin(3V), getpwent(3V), group(5), ypserv(8)

BUGS
       All  information is contained in a static area, so it must be copied if
       it is to be saved.

       Unlike the corresponding routines  for  passwords  (see  getpwent(3v)),
       which  always  search  the  entire file, these routines start searching
       from the current file location.

WARNING
       The above routines use the standard I/O library,  which  increases  the
       size  of  programs  not otherwise using standard I/O more than might be
       expected.



                                21 January 1990                   GETGRENT(3V)