Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getgrent(3C) — sys5 — Apollo

Media Vault

Software Library

Restoration Projects

Artifacts Sought



GETGRENT(3C)    DOMAIN/IX Reference Manual (SYS5)    GETGRENT(3C)



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

USAGE
     #include <grp.h>

     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.  This structure con-
     tains the broken-out fields of a line in the /etc/group
     file.  Each line contains a ``group'' structure, which is
     defined in the <grp.h> header file.

     struct    group {
          char *gr_name; /* the name of the group */
          char *gr_passwd;    /* the encrypted group password */
          int  gr_gid;   /* the numerical group ID */
          char **gr_mem; /* vector of pointers to member names */
     };


     Getgrent returns a pointer to the first group structure in
     the file, the first time the program calls it.  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 it finds a numerical group ID that matches gid and
     returns a pointer to the particular structure in which the
     ID was found.  Getgrnam searches from the beginning of the
     file until it finds a group name that matches name and
     returns a pointer to the particular structure in which it
     was found.  If these functions encounter an end-of-file or
     an error while reading, they 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



Printed 5/10/85                                        GETGRENT-1





GETGRENT(3C)    DOMAIN/IX Reference Manual (SYS5)    GETGRENT(3C)



     close the group file when processing is complete.

     Fgetgrent returns a pointer to the next group structure in
     the stream f, which matches the format of /etc/group.

NOTES
     These routines use <stdio.h>, which causes them to increase
     the size of programs, even if the programs don't otherwise
     use standard I/O, more than you might expect.

     All information is contained in a static area, so it must be
     copied if you wish to save it.

DIAGNOSTICS
     A NULL pointer is returned on EOF or error.

FILES
     /etc/group

RELATED INFORMATION
     getlogin(3C), getpwent(3C), group(4)


































GETGRENT-2                                        Printed 5/10/85



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026