struct gaadb {
	char		groupName[8];
	char		groupPassword[11];
	char		filler;
	unsigned int	groupid;
		unsigned int	max_securityCategory;
		unsigned int	max_integrityCategory;
		unsigned long	max_securityCompart;
	int		groupAdmin;
	};

main(argc, argv)
int	argc;
char	*argv[];
{
register int		ifd, ofd, i;
char			packed[8 + 11 + /* filler */ 1 + 2 + 1+1+4 + 2];
struct gaadb		unpacked;
register char		*from, *to;

if (argc != 3) {
	printf("Usage: %s input_file output_file\n", argv[0]);
	printf("       Use krd to get the input file and kwr to install the output file.\n");
	exit(1);
	}
if ((ifd = open(argv[1], 0)) < 0) {
	perror(argv[1]);
	exit(2);
	}
if ((ofd = creat(argv[2], 0666)) < 0) {
	perror(argv[2]);
	(void)close(ifd);
	exit(3);
	}
while (read(ifd, packed, sizeof packed) == sizeof packed) {
	from = (char *)&packed[0];
	to = (char *)&unpacked;
	for (i = 0; i < 8; i++)
		*to++ = *from++;	/* groupName */
	for (i = 0; i < 11; i++)
		*to++ = *from++;	/* groupPassword */
	*to++ = *from++;		/* filler */
	*to++ = *from++; *to++ = *from++; *to++ = '\0'; *to++ = '\0';	/* groupid */
	unpacked.max_securityCategory = *from++ & 0377; to += 4;
	unpacked.max_integrityCategory = *from++ & 0377; to += 4;
	for (i = 0; i < 4; i++)
		*to++ = *from++;	/* max_securityCompart */
	*to++ = *from++; *to++ = *from++; *to++ = '\0'; *to++ = '\0';	/* groupAdmin */
	if (unpacked.groupAdmin > 32767)
		unpacked.groupAdmin |= (65535 << 16);
	printf("group name          : %s\n", unpacked.groupName);
	printf("group password      : %s\n", unpacked.groupPassword);
	printf("group id            : %u\n", unpacked.groupid);
	printf("max security cat    : %d\n", unpacked.max_securityCategory);
	printf("max ingegrity cat   : %d\n", unpacked.max_integrityCategory);
	printf("max security compart: 0x%lx\n", unpacked.max_securityCompart);
	printf("group admin         : %d\n\n", unpacked.groupAdmin);
	(void)write(ofd, (char *)&unpacked, sizeof unpacked);
	}
(void)close(ifd);
(void)close(ofd);
}
