#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>

/*
 * fishrec.c - Reads "fishcon" formatted fish disk contents reports, and
 * produces input for loaddb.
 */

static char RCS_ID[] =
{
	" $Id: fishrec.c,v 2.2 1994/01/15 11:15:58 D_Lowrey Exp $ "};

int disk_num;
char line[90], *line_ptr, title[90];

main()
{

	disk_num = 0;

	while (gets(line) != NULL)
	{
/*
 * Throw away any leading title pages
 */
		if (!strncmp(line, "======", 6))
			continue;

		if (!strncmp(line, "Below is a listing", 18))
			continue;

		if (!strncmp(line, "PAGE ", 5))
			continue;

		if (line[0] == NULL)
			continue;

		if (isalnum(line[0]))
		{
			if (!strncmp(line, "This is disk ", 13))
			{
				disk_num = atoi(&line[13]);
				continue;
			}
			else
			{
				sscanf(line, "%s", title);
				printf("#R\n");
				printf("#H %s (Disk %03d)\n", title, disk_num);
				printf("#K disk/%03d\n", disk_num);
				printf("#K pgm/%s\n", title);
				printf("%s\n", line);
			}
		}
		else
			printf("%s\n", line);
	}
}
