Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getlogin(3)

getpwent(3)

group(5)

ypserv(8)

GETGRENT(3)  —  C LIBRARY FUNCTIONS

NAME

getgrent, getgrgid, getgrnam, setgrent, endgrent, fgetgrent − get group file entry

SYNOPSIS

#include <grp.h>

struct group ∗getgrent()

struct group ∗getgrgid(gid)
int gid;

struct group ∗getgrnam(name)
char ∗name;

setgrent()

endgrent()

struct group ∗fgetgrent(f)

FILE
∗f;

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.  Each line contains a “group” structure, defined in the <grp.h> header file. 

structgroup {
char∗gr_name;
char∗gr_passwd;
intgr_gid;
char∗∗gr_mem;
};

The members of this structure are:

gr_name The name of the group. 

gr_passwd The encrypted password of the group. 

gr_gid The numerical group ID. 

gr_mem A null-terminated array of pointers to the individual member names. 

Getgrent when first called returns a pointer to the first group structure in the file; thereafter, it returns a pointer to the next group structure in the file; so, successive calls may be used to search the entire file.  Getgrgid searches from the beginning of the file until a numerical 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 file until a group name matching name is found and returns a pointer to the particular structure in which it was found.  If an end-of-file or an error is encountered on reading, these functions return a NULL pointer. 

A call to setgrent has the effect of rewinding the group file to allow repeated searches.  Endgrent may be called to close the group file when processing is complete. 

Fgetgrent returns a pointer to the next group structure in the stream f, which must refer to an open file in the same format as the group file /etc/group. 

FILES

/etc/group
/etc/yp/domainname/group.byname
/etc/yp/domainname/group.bygid

SEE ALSO

getlogin(3), getpwent(3), group(5), ypserv(8)

DIAGNOSTICS

A NULL pointer is returned on EOF or error. 

WARNING

The above routines use <stdio.h>, which causes them to increase the size of programs, not otherwise using standard I/O, more than might be expected. 

BUGS

All information is contained in a static area, so it must be copied if it is to be saved. 

Unlike the corresponding routines for passwords (see getwpent(3)), which always search the entire file, these routines start searching from the current file location.

Sun Release 3.2  —  Last change: 15 May 1986

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026