1 # include "sendmail.h"
2 
3 static char	SccsId[] =	"@(#)mailstats.c	3.1	09/12/81";
4 
5 /*
6 **  MAILSTATS -- print mail statistics.
7 **
8 **	Flags:
9 **		-Ffile		Name of statistics file.
10 **
11 **	Exit Status:
12 **		zero.
13 */
14 
15 main(argc, argv)
16 	char  **argv;
17 {
18 	register int fd;
19 	struct statistics stat;
20 	char *sfile = "/usr/eric/mailstats";
21 	register int i;
22 
23 	fd = open(sfile, 0);
24 	if (fd < 0)
25 	{
26 		perror(sfile);
27 		exit(EX_NOINPUT);
28 	}
29 	if (read(fd, &stat, sizeof stat) != sizeof stat ||
30 	    stat.stat_size != sizeof stat)
31 	{
32 		sprintf(stderr, "File size change\n");
33 		exit(EX_OSERR);
34 	}
35 
36 	printf(" M msgsfr bytes_from  msgsto   bytes_to\n");
37 	for (i = 0; i < MAXMAILERS; i++)
38 	{
39 		if (stat.stat_nf[i] == 0 && stat.stat_nt[i] == 0)
40 			continue;
41 		printf("%2d ", i);
42 		printf("%6d %10dK ", stat.stat_nf[i], stat.stat_bf[i]);
43 		printf("%6d %10dK\n", stat.stat_nt[i], stat.stat_bt[i]);
44 	}
45 }
46