xref: /original-bsd/old/groups/groups.c (revision f0fd5f8a)
1 /*	groups.c	4.3	82/11/15	*/
2 
3 /*
4  * groups
5  */
6 
7 #include <sys/param.h>
8 #include <grp.h>
9 #include <pwd.h>
10 
11 int	groups[NGROUPS];
12 struct	group *gr, *getgrgid();
13 
14 main(argc, argv)
15 	int argc;
16 	char *argv[];
17 {
18 	int ngroups;
19 	char *sep = "";
20 	int i;
21 
22 	ngroups = getgroups(NGROUPS, groups);
23 	for (i = 0; i < ngroups; i++) {
24 		gr = getgrgid(groups[i]);
25 		if (gr == NULL)
26 			printf("%s%d", sep, groups[i]);
27 		else
28 			printf("%s%s", sep, gr->gr_name);
29 		sep = " ";
30 	}
31 	printf("\n");
32 	exit(0);
33 }
34