struct systemProfile {
	char		sysName[60];
	char		instName[60];
	unsigned int	sysNo;
		unsigned int	major;
		unsigned int	minor;
	unsigned long	genDate;
		unsigned int	systemMax_securityCategory;
		unsigned int	systemMax_integrityCategory;
		unsigned long	systemMax_securityCompart;
		unsigned int	currentMax_securityCategory;
		unsigned int	currentMax_integrityCategory;
		unsigned long	currentMax_securityCompart;
		unsigned int	currentMinMax_securityCategory;
		unsigned int	currentMinMax_integrityCategory;
		unsigned long	currentMinMax_securityCompart;
	};

main(argc, argv)
int	argc;
char	*argv[];
{
register int		ifd, ofd, i;
char			packed[60 + 60 + 2 + 2+2 + 4 + 1+1+4 + 1+1+4 + 1+1+4];
struct systemProfile	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);
	}
if (read(ifd, packed, sizeof packed) == sizeof packed) {
	from = (char *)&packed[0];
	to = (char *)&unpacked;
	for (i = 0; i < 60; i++)
		*to++ = *from++;	/* sysName */
	for (i = 0; i < 60; i++)
		*to++ = *from++;	/* instName */
	*to++ = *from++; *to++ = *from++; *to++ = '\0'; *to++ = '\0';	/* sysNo */
	*to++ = *from++; *to++ = *from++; *to++ = '\0'; *to++ = '\0';	/* major */
	*to++ = *from++; *to++ = *from++; *to++ = '\0'; *to++ = '\0';	/* minor */
	for (i = 0; i < 4; i++)
		*to++ = *from++;	/* genDate */
	unpacked.systemMax_securityCategory = *from++ & 0377; to += 4;
	unpacked.systemMax_integrityCategory = *from++ & 0377; to += 4;
	for (i = 0; i < 4; i++)
		*to++ = *from++;	/* securityCompart */
	unpacked.currentMax_securityCategory = *from++ & 0377; to += 4;
	unpacked.currentMax_integrityCategory = *from++ & 0377; to += 4;
	for (i = 0; i < 4; i++)
		*to++ = *from++;	/* securityCompart */
	unpacked.currentMinMax_securityCategory = *from++ & 0377; to += 4;
	unpacked.currentMinMax_integrityCategory = *from++ & 0377; to += 4;
	for (i = 0; i < 4; i++)
		*to++ = *from++;	/* securityCompart */
	printf("system name                : %s\n", unpacked.sysName);
	strcpy(unpacked.sysName, "Snoopy");
	printf("                  CHANGED TO %s\n", unpacked.sysName);
	printf("installation name          : %s\n", unpacked.instName);
	strcpy(unpacked.instName, "Logicon, Inc.");
	printf("                  CHANGED TO %s\n", unpacked.instName);
	printf("system number              : %d\n", unpacked.sysNo);
	unpacked.sysNo = 3;
	printf("                  CHANGED TO %d\n", unpacked.sysNo);
	printf("version                    : %d/%d\n", unpacked.major, unpacked.minor);
	unpacked.major = 0;
	unpacked.minor = 8;
	printf("                  CHANGED TO %d/%d\n", unpacked.major, unpacked.minor);
	printf("generation date            : %lu\n", unpacked.genDate);
	unpacked.genDate = 2735424000;	/* 1 September 1988 */
	printf("                  CHANGED TO %lu (1 September 1988)\n", unpacked.genDate);
	printf("sys max security cat       : %d\n", unpacked.systemMax_securityCategory);
	printf("sys max ingegrity cat      : %d\n", unpacked.systemMax_integrityCategory);
	printf("sys max security compart   : 0x%lx\n", unpacked.systemMax_securityCompart);
	printf("cur max security cat       : %d\n", unpacked.currentMax_securityCategory);
	printf("cur max ingegrity cat      : %d\n", unpacked.currentMax_integrityCategory);
	printf("cur max security compart   : 0x%lx\n", unpacked.currentMax_securityCompart);
	printf("cur minmax security cat    : %d\n", unpacked.currentMinMax_securityCategory);
	printf("cur minmax ingegrity cat   : %d\n", unpacked.currentMinMax_integrityCategory);
	printf("cur minmax security compart: 0x%lx\n", unpacked.currentMinMax_securityCompart);
	(void)write(ofd, (char *)&unpacked, sizeof unpacked);
	}
(void)close(ifd);
(void)close(ofd);
}
