endgrent() — Group database entry functions
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
Format
#define _XOPEN_SOURCE_EXTENDED 1
#include <grp.h>
void endgrent(void),
struct group *getgrent (void);
void setgrent(void);
General description
The getgrent() function returns a pointer to the broken-out fields of a line in the group database, mapped by the group structure defined in the <grp.h> header file. Repeated calls to getgrent() return a pointer to the next group structure in the database, until End Of File (EOF), at which point a NULL pointer is returned. setgrent() interrupts this sequential search and rewinds the user database to the beginning, such that the next getgrent() returns a pointer to the first group structure. Use of setgrent() is optional after an End Of File (EOF), as the next getgrent() after end of file again returns a pointer to the first group structure. endgrent() is optionally used to close the user database when searching is complete.
The setgrent() function effectively rewinds the group database to allow repeated searches.
The endgrent() function may be called to close the group database when processing is complete.
Returned value
When first called, getgrent() returns a pointer to the next group structure in the group database. Upon subsequent calls it returns a pointer to a group structure, or it returns a NULL pointer on either End Of File (EOF) or an error. The return value may point to static data that is overwritten by each call.
There are no documented errno values.
Related information
- grp.h
- getgrgid() — Access the group database by ID
- getgrgid_r() — Get group database entry for a group ID
- getgrnam() — Access the group database by name
- getgrnam_r() — Search group database for a name
- getlogin() — Get the user login name
- getlogin_r() — Get login name
- getpwent() — Get user database entry
- getpwnam() — Access the user database by user name
- getpwnam_r() — Search user database for a name
- getpwuid() — Access the user database by user ID
- getpwuid_r() — Search user database for a user ID