/* $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */
#ident "$Header: groups.c 1.3 90/08/23 $@(#)groups:groups.c      1.41"

#include <sys/types.h>
#include <sys/param.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>

gid_t groups[NGROUPS+1];
extern struct group *getgrgid();
extern gid_t getgid();
static void show();

main()
{
	register int ngroups, i;
	gid_t mygid = getgid();

	show(mygid);
	ngroups = getgroups(NGROUPS, groups);
	for (i = 0; i < ngroups; i++) {
		if (groups[i] != mygid) {
			show(groups[i]);
		}
	}
	(void)printf("\n");
	return(0);
}

static void
show(gid)
	gid_t gid;
{
	register struct group *grp;

	grp = getgrgid(gid);
	if (grp == NULL)
		(void)printf("%d ", gid);
	else
		(void)printf("%s ", grp->gr_name);
}
