man(1) Manual page archive


     GETGRENT(3)                                           GETGRENT(3)

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

     SYNOPSIS
          #include <grp.h>

          struct group *getgrent();

          struct group *getgrgid(gid)

          struct group *getgrnam(name)
          char *name;

          int setgrent();

          int endgrent();

     DESCRIPTION
          Getgrent, getgrgid and getgrnam each return pointers to a
          structure containing the broken-out fields of a line in
          struct group {
                 char  *gr_name;   the group name
                 char  *gr_passwd; the encrypted group passwd
                 int   gr_gid;     the numeric groupid
                 char  **gr_mem;   null-terminated vector of pointers to the individual member names
          };

          Getgrent simply reads the next line while getgrgid and
          getgrnam search until a matching gid or name 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.

          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.

     FILES
          overwritten by each call.