// make executable with the command:
//        bcc -ms bug.c \borlandc\lib\wildargs.obj

#include <stdio.h>

#define NULLFILE (FILE *) 0
#define NULLCHAR (char *) 0

/* a mailbox entry */
struct let {
	long	start;
	long	size;
	long	bid;
	int	status;
};

main (argc, argv)
int argc;
char *argv[];
{
register FILE *cfp;
char buf[256];
struct let lt;
int cnt, k;

	for (k = 1; k < argc; k++)	{
		sprintf (buf, "control\\%s", argv[k]);
		if (strstr (buf, ".TXT") || strstr (buf, ".txt"))
			strcpy (&buf[strlen(buf) - 3], "ctl");
		else
			strcat (buf, ".ctl");
		if((cfp = fopen(buf,"rb")) == NULLFILE)	{
			printf ("Can't open control file '%s'\n", buf);
			continue;
		}
		printf ("Reading Control File: '%s'\n", buf);
		cnt = 1;
		while(fread(&lt,sizeof(struct let),1, cfp) != NULLCHAR){
			printf ("Entry #%-d: start=%-ld, size=%-ld, bid=%-ld, status=%-d\n",
				cnt, lt.start, lt.size, lt.bid, lt.status);
			cnt++;
		}
		fclose(cfp);
	}
}

