getgrent.3c (2010 09)

g
getgrent(3C) getgrent(3C)
NAME
getgrent(), getgrgid(), getgrgid_r(), getgrnam(), getgrnam_r(), setgrent(), endgrent(), fgetgrent() - get
group file entry
SYNOPSIS
#include <grp.h>
struct group *getgrent(void);
struct group *getgrgid(gid_t gid);
int getgrgid_r(gid_t gid, struct group *grp, char *buffer,
size_t buflen, struct group ** result);
struct group *getgrnam(const char *name);
int getgrnam_r(const char *name, struct group *grp, char *buffer,
size_t buflen, struct group ** result);
void setgrent(void);
void endgrent(void);
struct group *fgetgrent(FILE *stream);
Obsolescent Interfaces
#include <grp.h>
int getgrent_r(struct group *result, char *buffer, int buflen,
FILE **grfp);
void setgrent_r(FILE **grfp);
void endgrent_r(FILE **grfp);
int fgetgrent_r(FILE *stream, struct group *result, char *buffer,
int buflen);
DESCRIPTION
getgrent(), getgrgid(), and getgrnam() are used to obtain group entries, and return a pointer
to an object of group structure. An entry may come from any of the sources for group
specified in the
/etc/nsswitch.conf
file. See nsswitch.conf(4).
The
group structure is defined in <grp.h> and includes 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; /* null-terminated array of pointers
to member names */
getgrent() When first called, getgrent() returns a pointer to the first group structure in
the group database; thereafter, it returns a pointer to the next group structure in
the database. In this way, successive calls can be used to search the entire data-
base;
setgrent() Has the effect of rewinding the group database to allow repeated searches;
endgrent() Can be called to indicate that group database processing is complete;
getgrgid() Searches from the beginning of the group database until a numeric group ID match-
ing gid is found, and returns a pointer to the particular structure in which it was
found;
getgrnam() Searches from the beginning of the group database until a group name matching
name is found, and returns a pointer to the particular structure in which it was
found;
fgetgrent() Returns a pointer to the next group structure in the standard I/O stream stream ,
which should be open for reading, and its contents should match the format of
/etc/group.
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1