struct terminalProfile {
	char		ttyid;			/* unique terminal id */
	char		filler1[3];
	char		config;			/* terminal is configured */
	char		filler2[3];
	char		console;		/* terminal is to be treated as a console */
	char		filler3[3];
	unsigned int	xmitBaud;		/* default xmit baud rate */
	unsigned int	recBaud;		/* default rec baud rate */
	unsigned char	parity;			/* default parity */
	char		filler4[3];
	char		clrScreen[7];		/* sequence required to clear the screen */
	char		filler5;
		unsigned int	securityCategory;
		unsigned int	integrityCategory;
		unsigned long	securityCompart;
	};

main(argc, argv)
int	argc;
char	*argv[];
{
register int		ifd, ofd, i;
char			packed[1 + 1 + 1 + /* filler */ 1 + 2 + 2 + 1 + /* filler */ 1 + 7 + /* filler */ 1 + 1+1+4];
struct terminalProfile	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;
	*to++ = *from++; *to++ = '\0'; *to++ = '\0'; *to++ = '\0';	/* ttyid */
	*to++ = *from++; *to++ = '\0'; *to++ = '\0'; *to++ = '\0';	/* config */
	*to++ = *from++; *to++ = '\0'; *to++ = '\0'; *to++ = '\0';	/* console */
	from++;		/* filler */
	*to++ = *from++; *to++ = *from++; *to++ = '\0'; *to++ = '\0';	/* xmitBaud */
	*to++ = *from++; *to++ = *from++; *to++ = '\0'; *to++ = '\0';	/* recBaud */
	*to++ = *from++; *to++ = '\0'; *to++ = '\0'; *to++ = '\0';	/* parity */
	from++;		/* filler */
	for (i = 0; i < 7; i++)
		*to++ = *from++;
	*to++ = '\0';
	from++;		/* filler */
	unpacked.securityCategory = *from++ & 0377; to += 4;
	unpacked.integrityCategory = *from++ & 0377; to += 4;
	for (i = 0; i < 4; i++)
		*to++ = *from++;	/* securityCompart */
	printf("tty id          : %d\n", unpacked.ttyid);
	if (unpacked.ttyid >= 50) {
		unpacked.ttyid += 51;	/* DH-11 -> DMF-32 */
		printf("                  CHANGED TO %d\n", unpacked.ttyid);
		}
	printf("configured      : %c\n", unpacked.config);
	printf("console         : %c\n", unpacked.console);
	printf("xmit baud       : %u\n", unpacked.xmitBaud);
	if (unpacked.xmitBaud == 300) {
		unpacked.xmitBaud = 1200;
		printf("                  CHANGED TO %u\n", unpacked.xmitBaud);
		}
	printf("recv baud       : %u\n", unpacked.recBaud);
	if (unpacked.recBaud == 300) {
		unpacked.recBaud = 1200;
		printf("                  CHANGED TO %u\n", unpacked.recBaud);
		}
	printf("parity          : %u\n", unpacked.parity);
	printf("clear screen    :");
	for (i = 0; i < 7; i++)
		printf(" %d", unpacked.clrScreen[i]);
	printf("\nsecurity cat    : %d\n", unpacked.securityCategory);
	printf("ingegrity cat   : %d\n", unpacked.integrityCategory);
	printf("security compart: 0x%lx\n\n", unpacked.securityCompart);
	(void)write(ofd, (char *)&unpacked, sizeof unpacked);
	}
(void)close(ifd);
(void)close(ofd);
}
