getgrent(3)
_________________________________________________________________
getgrent, getgrgid, getgrnam, setgrent, endgrent, Subroutine
fgetgrent
get group file entry
_________________________________________________________________
SYNTAX
#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 containing the broken-out fields of
a line in the /etc/group file. Each line contains a group
structure, 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, 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. You can use successive calls
to search the entire file.
Getgrgid searches from the beginning of the file until a
numerical group ID matching gid is found. It returns a pointer to
the structure where the match was found.
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
getgrent(3)
Getgrnam searches from the beginning of the file for a group name
matching name. It returns a pointer to the structure where the
match was found.
Setgrent rewinds the group file, thus allowing repeated searches.
Endgrent closes the group file.
fgetgrent returns a pointer to the next group structure in the
stream f, which matches the format of /etc/group.
ERRORS
If an end-of-file or an error is encountered while reading,
getgrent, getgrgid, getgrname, and fgetgrent will return a NULL
pointer.
FILES
/etc/group
SEE ALSO
getlogin(3C), getpwent(3C), group(4).
DIAGNOSTICS
A NULL pointer is returned on EOF or error.
WARNING
The above routines use <stdio.h>, which causes them to increase
the size of programs that don't otherwise use standard I/O. The
size increases more than you might expect.
CAVEAT
All information is in a static area, so it must be copied if you
want to save it.
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)