getgrent.3c (2010 09)

g
getgrent(3C) getgrent(3C)
Obsolescent Interfaces
getgrent_r(), setgrent_r(), endgrent_r(), fgetgrent_r()
get group file entry.
Reentrant Interfaces
getgrgid_r() and getgrnam_r() both update the struct
group pointed to by grp and store a
pointer to that structure at the location pointed to by
result. The structure shall contain an entry from
the group database with a matching
gid
or name. Storage referenced by the group structure pointed to
by
grp shall be allocated from the memory provided with the
buffer parameter, which is buflen in
size. The maximum size needed for this buffer can be determined with the
_SC_GETGR_R_SIZE_MAX
sysconf() parameter. A NULL pointer is returned at the location pointed to by
result on error or if
the requested entry is not found.
RETURN VALUE
getgrent(), getgrgid(), getgrnam(), and fgetgrent()
return a NULL pointer if an end-of-
file or error is encountered on reading. Otherwise, the return value points to an internal static area con-
taining a valid
group structure.
getgrgid_r() and getgrnam_r() return zero upon success. Otherwise, an error number is
returned to indicate the error.
ERRORS
getgrent(), getgrgid(), getgrnam() and fgetgrent() fail if any of the following are true:
[EIO] An I/O error has occurred.
[EMFILE] OPEN_MAX file descriptors are currently open in the calling process.
[ENFILE] The maximum allowable number of files is currently open in the system.
The
getgrgid_r() and getgrnam_r() functions will fail if:
[ERANGE] Insufficient storage was supplied via buffer and bufsize to contain the data to be refer-
enced by the resulting group structure.
WARNINGS
The value returned by
getgrent(), getgrgid(), getgrnam(), and fgetgrent() points to an
area that is overwritten by each call to any of the functions. It must be copied if it is to be saved.
Users of
getgrgid_r() and getgrnam_r() should note that these interfaces now conform with
POSIX.1c. getgrent_r(), setgrent_r(), endgrent_r() and fgetgrent_r()
are obsolescent
interfaces. These interfaces and the old prototypes of
getgrgid_r() and getgrnam_r() are sup-
ported for compatibility with existing DCE applications only.
The interfaces
setgrent(), getgrent(), endgrent(), getgrgid(), getgrnam(),
getgrgid_r() and getgrgnam_r() use the Dynamic Name Service Switch. (See nsswitch.conf(4).)
An application that uses these interfaces cannot be fully archive bound.
DEPENDENCIES
NFS
Files
/var/yp/domainname /group.byname
/var/yp/domainname /group.bygid
See Also
ypcat (1).
FILES
/etc/group
SEE ALSO
ypcat(1), getgroups(2), getpwent(3C), stdio(3S), group(4), thread_safety(5).
STANDARDS CONFORMANCE
getgrent(): SVID2, SVID3, XPG2
endgrent(): SVID2, SVID3, XPG2
2 Hewlett-Packard Company − 2 − HP-UX 11i Version 3: September 2010