Manual Pages for UNIX Darwin command on man getgrnam_r
MyWebUniversity

Manual Pages for UNIX Darwin command on man getgrnam_r

GETGRENT(3) BSD Library Functions Manual GETGRENT(3)

NAME

eennddggrreenntt, ggeettggrreenntt, ggeettggrrggiidd, ggeettggrrggiiddrr, ggeettggrrnnaamm, ggeettggrrnnaammrr, sseettggrreenntt,

sseettggrroouuppeenntt - group database operations

LLIIBBRRAARRYY

Standard C Library (libc, -lc)

SYNOPSIS

##iinncclluuddee <>

void eennddggrreenntt(void); struct group * ggeettggrreenntt(void); struct group * ggeettggrrggiidd(gidt gid); int ggeettggrrggiiddrr(gidt gid, struct group *grp, char *buffer, sizet bufsize, struct group **result); struct group * ggeettggrrnnaamm(const char *name); int ggeettggrrnnaammrr(const char *name, struct group *grp, char *buffer, sizet bufsize, struct group **result); void sseettggrreenntt(void); int sseettggrroouuppeenntt(int stayopen);

DESCRIPTION

These functions operate on the group database file /etc/group, which is described in group(5). Each line of the database is defined by the structure group, found in the include file : struct group { char *grname; /* group name */ char *grpasswd; /* group password */ int grgid; /* group id */ char **grmem; /* group members */ }; The functions ggeettggrrnnaamm() and ggeettggrrggiidd() search the group database for the given group name (pointed to by name) or the group id (pointed to by gid), respectively, returning the first one encountered. Identical group names or group ids may result in undefined behavior.

All of these routines are thread-safe. The ggeettggrreenntt(), ggeettggrrggiidd(), and

ggeettggrrnnaamm() routines return a pointer to a result managed by the system

library in a thread-specific data structure. Every thread has space for

a pointer to a struct group and allocates its own storage for the result. Neither previously returned values in memory nor a previously returned pointer value should be used by a thread after calling any one of these three routines. Memory allocated by a thread is automatically released on subsequent calls by the same thread to any of these three routines, and when the thread exits. The functions ggeettggrrggiiddrr() and ggeettggrrnnaammrr() take additional arguments which supply storage space for the returned result. The grp parameter is a pointer to a struct group, which must be allocated by the caller. The buffer parameter is a pointer to a block of memory with a size specified by bufsize. This buffer is used to hold the values which are pointed to by values filled in the grp structure. Zero is returned on success. If insufficient memory is supplied, these routines return ERANGE. The ggeettggrreenntt() function sequentially reads the group database and is intended for programs that wish to step through the complete list of groups. All three routines will open the group file for reading, if necessary. The sseettggrroouuppeenntt() function opens the file, or rewinds it if it is already

open. If stayopen is non-zero, file descriptors are left open, signifi-

cantly speeding functions' subsequent calls. This functionality is unnecessary for ggeettggrreenntt(), as it doesn't close its file descriptors by

default. It should also be noted that it is dangerous for long-running

programs to use this functionality, as the group file may be updated. The sseettggrreenntt() function is identical to sseettggrroouuppeenntt() with an argument of zero. The eennddggrreenntt() function closes any open files.

RETURN VALUES

The functions ggeettggrreenntt(), ggeettggrrggiidd(), and ggeettggrrnnaamm() each return a

pointer to the group entry if successful; if end-of-file is reached or an

error occurs, a null pointer is returned. The function sseettggrroouuppeenntt() returns the value 1 if successful; otherwise, the value 0 is returned. The functions eennddggrreenntt(), sseettggrreenntt(), and sseettggrrffiillee() have no return value. FILES /etc/group group database file

LEGACY SYNOPSIS

##iinncclluuddee <>

int sseettggrreenntt(void); The function sseettggrreenntt() returns the value 1 if successful; otherwise, the value 0 is returned.

SEE ALSO

getpwent(3), yp(8), group(5) HISTORY The functions eennddggrreenntt(), ggeettggrreenntt(), ggeettggrrnnaamm(), ggeettggrrggiidd(), and sseettggrreenntt() appeared in Version 7 AT&T UNIX. The functions sseettggrrffiillee()

and sseettggrroouuppeenntt() appeared in 4.3BSD-Reno.

CCOOMMPPAATTIIBBIILLIITTYY The historic function sseettggrrffiillee(), which allowed the specification of

alternate password databases, has been deprecated and is no longer avail-

able.

BUGS

The functions ggeettggrreenntt(), ggeettggrrnnaamm(), and ggeettggrrggiidd(), leave their results

in internal thread-specific memory and return a pointer to that object.

Subsequent calls to any of these three routines by the same thread will release the object and return a new pointer value. BSD September 29, 1994 BSD




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™