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

#ifdef MSDOS
const char *dirname = ".";
#ifndef OPTIONAL
#define OPTIONAL
#endif
#else
const char *dirname = NOSDIR;
#endif
#define NULLFILE (FILE *) 0

#ifndef _lint
static char rcsid[] OPTIONAL = "$Id: ctlcheck.c,v 1.11 2000/05/09 14:18:54 brian Exp $";
#endif

typedef unsigned short int16;

/* a mailbox entry */
struct let {
	long	start;
	long	size;
	long	bid;
	int16	status;
};	/*lint !e770 */


int main (int argc OPTIONAL, char *argv[])
{
char buf[128];
struct let ff;
FILE *fp;
int k = 1;

	if (argc < 2)	{
		puts ("Usage: ctlcheck areaname\n");
		exit (1);
	}
	sprintf (buf, "%s/spool/mail/control/%s.ctl", dirname, argv[1]);
	if ((fp = fopen (buf, "rb")) != NULLFILE)	{
		printf (" #   START      SIZE      BID     STAT\n");
		while (!feof (fp))	{
			(void) fread (&ff, sizeof(struct let), 1, fp);
			if (feof (fp))
				continue;
			printf ("%02d) %08lx  %08lx  %08lx  %04x\n", k, ff.start, ff.size, ff.bid, ff.status);
			k++;
		}
		fclose (fp);
	}
    return 0;
}
