You can search the group database for information about a specific
group using getgrgid
or getgrnam
. These functions are
declared in `grp.h'.
getgrgid
.
A null pointer indicates there is no group with ID gid.
getgrgid
in that is returns
information about the group whose group ID is gid. But the result
is not placed in a static buffer. Instead the user supplied structure
pointed to by result_buf is filled with the information. The
first buflen bytes of the additional buffer pointed to by
buffer are used to contain additional information, normally
strings which are pointed to by the elements of the result structure.
If the return value is 0
the pointer returned in result
points to the record which contains the wanted data (i.e., result
contains the value result_buf). If the return value is non-zero
there is no group in the data base with group ID gid or the
buffer buffer is too small to contain all the needed information.
In the later case the global errno variable is set to
ERANGE
.
getgrnam
.
A null pointer indicates there is no group named name.
getgrnam
in that is returns
information about the group whose group name is name. But the result
is not placed in a static buffer. Instead the user supplied structure
pointed to by result_buf is filled with the information. The
first buflen bytes of the additional buffer pointed to by
buffer are used to contain additional information, normally
strings which are pointed to by the elements of the result structure.
If the return value is 0
the pointer returned in result
points to the record which contains the wanted data (i.e., result
contains the value result_buf). If the return value is non-zero
there is no group in the data base with group name name or the
buffer buffer is too small to contain all the needed information.
In the later case the global errno variable is set to
ERANGE
.
Go to the first, previous, next, last section, table of contents.