MentOS  0.8.0
The Mentoring Operating System
Classes | Macros | Typedefs | Functions
grp.h File Reference

Defines the structures and functions for managing groups. More...

Go to the source code of this file.

Classes

struct  group
 Contains user group informations. More...
 

Macros

#define MAX_MEMBERS_PER_GROUP   64
 Maximum number of users per group.
 

Typedefs

typedef struct group group_t
 Contains user group informations.
 

Functions

group_tgetgrgid (gid_t gid)
 Provides access to the group database entry for uid. More...
 
group_tgetgrnam (const char *name)
 Provides access to the group database entry for name. More...
 
int getgrgid_r (gid_t gid, group_t *group, char *buf, size_t buflen, group_t **result)
 Provides the same information as getgrgid but it stores the results inside group, and the string information are store store inside buf. More...
 
int getgrnam_r (const char *name, group_t *group, char *buf, size_t buflen, group_t **result)
 Provides the same information as getgrnam but it stores the results inside group, and the string information are store store inside buf. More...
 
group_tgetgrent (void)
 Returns a pointer to a structure containing the broken-out fields of an entry in the group database. More...
 
void endgrent (void)
 Rewinds the group database to allow repeated searches.
 
void setgrent (void)
 May be called to close the group database when processing is complete.
 

Detailed Description

Defines the structures and functions for managing groups.

Function Documentation

◆ getgrent()

group_t* getgrent ( void  )

Returns a pointer to a structure containing the broken-out fields of an entry in the group database.

Returns
pointer to the group entry.

When first called returns a pointer to a group structure containing the first entry in the group database. Thereafter, it returns a pointer to a group structure containing the next group structure in the group database, so successive calls may be used to search the entire database.

◆ getgrgid()

group_t* getgrgid ( gid_t  gid)

Provides access to the group database entry for uid.

Parameters
gidThe gid to search inside the database.
Returns
A pointer to the structure containing the database entry.

◆ getgrgid_r()

int getgrgid_r ( gid_t  gid,
group_t group,
char *  buf,
size_t  buflen,
group_t **  result 
)

Provides the same information as getgrgid but it stores the results inside group, and the string information are store store inside buf.

Parameters
gidThe uid to search inside the database.
groupThe structure containing pointers to the entry fields.
bufThe buffer where the strings should be stored.
buflenThe lenght of the buffer.
resultA pointer to the result or NULL is stored here.
Returns
If the entry was found returns zero and set *result to group, if the entry was not found returns zero and set *result to NULL, on failure returns a number and sets and set *result to NULL.

◆ getgrnam()

group_t* getgrnam ( const char *  name)

Provides access to the group database entry for name.

Parameters
nameThe name to search inside the database.
Returns
A pointer to the structure containing the database entry.

◆ getgrnam_r()

int getgrnam_r ( const char *  name,
group_t group,
char *  buf,
size_t  buflen,
group_t **  result 
)

Provides the same information as getgrnam but it stores the results inside group, and the string information are store store inside buf.

Parameters
nameThe name to search inside the database.
groupThe structure containing pointers to the entry fields.
bufThe buffer where the strings should be stored.
buflenThe lenght of the buffer.
resultA pointer to the result or NULL is stored here.
Returns
If the entry was found returns zero and set *result to group, if the entry was not found returns zero and set *result to NULL, on failure returns a number and sets and set *result to NULL.