NAME | SYNOPSIS | LIBRARY | API RESTRICTIONS | DESCRIPTION | RETURN VALUES | FILES | ATTRIBUTES | SEE ALSO | COMPATIBILITY | BUGS
$(OS_DIR)/lib/libc.a #include <sys/types.h> #include <grp.h>struct group * getgrent (void);
Standard C Library (libc, -lc).
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
These functions operate on the group database file /etc/group which is described in group(4CC) . Each line of the database is defined by the structure group found in the include file <grp.h> :
struct group { char *gr_name; /* group name */ char *gr_passwd; /* group password */ int gr_gid; /* group id */ char **gr_mem; /* group members */ };
The functions getgrnam() and getgrgid() 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 gids may result in undefined behavior.
The getgrent() 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 setgroupent() function opens the file, or rewinds it if it is already open. If stayopen is non-zero, file descriptors are left open, significantly speeding functions subsequent calls. This functionality is unnecessary for getgrent() 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 setgrent() function is identical to setgroupent() with an argument of zero.
The endgrent() function closes any open files.
When the yp(4) group database is enabled, the getgrnam() and getgrgid() functions use the YP maps ``group.byname'' and ``group.bygid'', respec- tively, if the requested group is not found in the local /etc/group file . The getgrent() function will step through the YP map ``group.byname'' if the entire map is enabled as described in group(4CC).
The functions getgrent() , getgrnam() , and getgrgid() , 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 functions setgroupent() and setgrent() return the value 1 if successful, otherwise the value 0 is returned. The functions endgrent() and setgrfile() have no return value.
/etc/group group database file.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
The historic function setgrfile() , which allowed the specification of alternate password databases, has been deprecated and is no longer available.
The functions getgrent() , getgrnam() , getgrid() , setgrupent() and setgrent() leave their results in an internal static object and return a pointer to that object. Subsequent calls to the same function will modify the same object.
NAME | SYNOPSIS | LIBRARY | API RESTRICTIONS | DESCRIPTION | RETURN VALUES | FILES | ATTRIBUTES | SEE ALSO | COMPATIBILITY | BUGS