xref: /original-bsd/lib/libc/gen/getgrent.3 (revision 6f738a42)
Copyright (c) 1988 Regents of the University of California.
All rights reserved. The Berkeley software License Agreement
specifies the terms and conditions for redistribution.

@(#)getgrent.3 6.3 (Berkeley) 09/17/88

GETGRENT 3 ""
.AT 3
NAME
getgrent, getgrgid, getgrnam, setgrent, endgrent setgrfile - get group file entry
SYNOPSIS
 #include <sys/types.h>  #include <grp.h> 

struct group *getgrent()

struct group *getgrgid(gid) gid_t gid;

struct group *getgrnam(name) char *name;

setgrent()

void endgrent()

void setgrfile(name) char *name;

DESCRIPTION
Getgrent, getgrgid and getgrnam each return pointers to an object with the following structure containing the broken-out fields of a line in the group file, as described in < grp.h > .

struct group {
 char *gr_name;
 char *gr_passwd;
 gid_t gr_gid;
 char **gr_mem;
};

The fields have meanings described in grp (5).

Setgrfile changes the default group file to name , thus allowing usage of alternate group files.

Setgrent opens the file (closing any previously opened file) or rewinds it if it it already open.

Endgrent closes any open files.

Getgrgid and getgrnam search the entire file (opening it if necessary) for a matching gid or name .

For programs wishing to read the entire database, getgrent reads the next entry (opening the file if necessary).

FILES
/etc/group
"SEE ALSO"
getlogin(3), getpwent(3), group(5)
DIAGNOSTICS
The routines getgrent , getgruid , and getgrnam , return a null pointer (0) on EOF or error. Setgrent returns 0 on failure, 1 on success. Endgrent and setgrfile have no return value.
BUGS
All information is contained in a static area so it must be copied if it is to be saved.