Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getlogin(3C)

getpwent(3C)

group(4)

GETGRENT(3C)  —  Silicon Graphics

NAME

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

SYNOPSIS

#include <grp.h>

struct group ∗getgrent ( )

struct group ∗getgrgid (gid)
int gid;

struct group ∗getgrnam (name)
char ∗name;

void setgrent ( )

void endgrent ( )

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

structgroup {
char∗gr_name;/∗ the name of the group ∗/
char∗gr_passwd;/∗ the encrypted group password ∗/
intgr_gid;/∗ the numerical group ID ∗/
char∗∗gr_mem;/∗ vector of pointers to 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. 

FILES

/etc/group

SEE ALSO

getlogin(3C), getpwent(3C), group(4). 

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. 

NOTE

There are two versions of the primitives documented in this manual entry:  a vanilla version and a Yellow Pages version.  The programmatic interface of both versions is identical.  The vanilla version gets its information from an ASCII file in /etc. The Yellow Pages version knows about Sun’s Yellow Pages distributed lookup service. If you want the Yellow Pages version, link the program according to the instructions for (3Y) primitives as described in intro(3). Refer to ypserv(1M) and the NFS User’s Guide for more information about the Yellow Pages. 

BUGS

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

Version 2.5r1  —  October 29, 1986

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