HP-UX Reference (11i v1 05/09) - 3 Library Functions A-M (vol 6)

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 database;
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 matching
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 .
Obsolescent Interfaces
getgrent_r() , setgrent_r() , endgrent_r() , fgetgrent_r() get group file entry.
HP-UX 11i Version 1: September 2005 1 Hewlett-Packard Company Section 3325