GETGRENT(3,L) AIX Technical Reference GETGRENT(3,L)
-------------------------------------------------------------------------------
getgrent, getgrgid, getgrnam, setgrent, endgrent
PURPOSE
Accesses group file entries.
LIBRARY
Standard C Library (libc.a)
SYNTAX
#include <grp.h>
struct group *getgrent ( ) struct group *getgrnam (name)
char *name;
struct group *getgrgid (gid)
int gid; void setgrent ( )
void endgrent ( )
DESCRIPTION
The getgrent, getgrgid, and getgrnam subroutines return a pointer to a
structure containing the broken-out fields of a line in the /etc/group file.
The group structure is defined in the grp.h header file, and it contains the
following members:
char *gr_name; /* The name of the group */
char *gr_passwd; /* The encrypted group password */
gid_t gr_gid; /* The numerical group ID */
char **gr_mem; /* Array of pointers to member names */
The getgrent subroutine, when first called, returns a pointer to the first
group structure in the file. On the next call, it returns a pointer to the
next group structure in the file. You can call getgrent repeatedly to search
the entire file.
The getgrgid subroutine searches from the beginning of the file until it finds
a numerical group ID matching the gid parameter. The subroutine then returns a
pointer to the structure in which it was found.
Processed November 7, 1990 GETGRENT(3,L) 1
GETGRENT(3,L) AIX Technical Reference GETGRENT(3,L)
The getgrnam subroutine searches from the beginning of the file until it finds
a group name matching the name parameter. The subroutine then returns a
pointer to the structure in which it was found.
These subroutines return a pointer to a group structure contained in the static
area, which must be copied if it is to be saved. If an end-of-file condition
or an error is encountered on reading, these functions return a NULL pointer.
The setgrent subroutine rewinds the group file to allow repeated searches.
The endgrent subroutine closes the group file when processing is complete.
FILE
/etc/group
ERROR CONDITIONS
The getgrgid and getgrnam subroutines fail if one or more of the following are
true:
EIO An I/O error has occurred.
EINTR A signal was caught during the function.
EMFILE Too many file descriptors are currently open for the process.
ENFILE The system file table is full.
RELATED INFORMATION
In this book: "getlogin," "getpwent, getpwuid, getpwnam, setpwent, endpwent,"
and "group."
"Introduction to International Character Support" in Managing the AIX Operating
System.
Processed November 7, 1990 GETGRENT(3,L) 2