summaryrefslogtreecommitdiff
path: root/lib/libc/grp/getgrgid.c
blob: 4ce43129d67133c4fe0de7e78f0c34c5ae8d9c5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <grp.h>       // for getgrgid_r, getgrgid, group
#include <limits.h>    // for LINE_MAX
#include <stddef.h>    // for NULL
#include <sys/types.h> // for gid_t

struct group *getgrgid(gid_t gid)
{
	static struct group grp;
	static char buf[LINE_MAX * 2];
	struct group *res;

	if (getgrgid_r(gid, &grp, buf, sizeof(buf), &res) != 0)
		return NULL;

	return res;
}