1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-23 00:43:28 +00:00
freebsd-ports/x11/apwal/files/group_member.c
Pav Lucistnik 8661561f12 Add apwal, a simple and powerful application launcher.
It is composed in 2 parts: the application launcher itself and
a good looking easy to use editor.

PR:		ports/59940
Submitted by:	Volker Stolz <stolz@i2.informatik.rwth-aachen.de>
2003-12-06 13:07:52 +00:00

26 lines
465 B
C

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int group_member(gid_t gid) {
gid_t *grouplist = NULL;
int res,i;
res = getgroups(0,NULL);
if (res >= 0) {
grouplist = calloc(sizeof(gid_t),res);
res = getgroups(res,grouplist);
if (res >=0) {
for(i=0;i<res;i++) {
if (grouplist[i] == gid) break;
}
}
}
if (res == -1) {
perror("Can't get number of groups!");
return -1;
} else {
return (i<res);
}
}