-
-
Notifications
You must be signed in to change notification settings - Fork 3
qgetgrent_r.3
qgetgrent_r - get group file entry reentrantly
#include <qgetpwgr.h>
int qgetgrent_r(struct group *gbuf, char *buf, size_t buflen, struct group **gbufp);
The function qgetgrent_r() is the reentrant versions of qgetgrent(3). It reads the next group entry from the stream initialized by qsetgrent(3).
The group structure is defined in <grp.h> as follows:
struct group {
char *gr_name; /* group name */
char *gr_passwd; /* group password */
gid_t gr_gid; /* group ID */
char **gr_mem; /* NULL-terminated array of pointers
to names of group members */
};
For more information about the fields of this structure, see group(5).
The nonreentrant function return a pointer to static storage, where this static storage contains further pointers to group name, password and members. The reentrant function described here return all of that in caller-provided buffers. First of all there is the buffer gbuf that can hold a struct group. And next the buffer buf of size buflen that can hold additional strings. The result of these functions, the struct group read from the stream, is stored in the provided buffer *gbuf, and a pointer to this struct group is returned in *gbufp.
On success, this function return 0 and *gbufp is a pointer to the struct group. On error, these functions return an error value and *gbufp is NULL.
ENOENT
No more entries.
ERANGE
Insufficient buffer space supplied. Try again with larger buffer.
ETXTBUSY
Temporary error happened.
The function qgetgrent_r() is not really reentrant since it shares the reading position in the stream with all other threads.
qgetgrent(3), qgetgrnam(3), qgetgrgid(3), qgetgrnam_r(3), qgetgrgid_r(3), grpscan(3), group(5)