Add copyright
[unix-history] / usr / src / usr.sbin / sendmail / mailstats / mailstats.c
CommitLineData
aeb2545d
DF
1/*
2** Sendmail
3** Copyright (c) 1983 Eric P. Allman
4** Berkeley, California
5**
6** Copyright (c) 1983 Regents of the University of California.
7** All rights reserved. The Berkeley software License Agreement
8** specifies the terms and conditions for redistribution.
9*/
10
11#ifndef lint
12char copyright[] =
13"@(#) Copyright (c) 1980 Regents of the University of California.\n\
14 All rights reserved.\n";
15#endif not lint
16
17#ifndef lint
18static char SccsId[] = "@(#)mailstats.c 5.1 (Berkeley) %G%";
19#endif not lint
9064e1ea
EA
20# include "sendmail.h"
21
aeb2545d 22SCCSID(@(#)mailstats.c 5.1 %G%);
9064e1ea
EA
23
24/*
25** MAILSTATS -- print mail statistics.
26**
27** Flags:
28** -Ffile Name of statistics file.
29**
30** Exit Status:
31** zero.
32*/
33
34main(argc, argv)
35 char **argv;
36{
37 register int fd;
38 struct statistics stat;
71df6b97 39 char *sfile = "/usr/lib/sendmail.st";
9064e1ea 40 register int i;
387e90c7 41 extern char *ctime();
9064e1ea
EA
42
43 fd = open(sfile, 0);
44 if (fd < 0)
45 {
46 perror(sfile);
47 exit(EX_NOINPUT);
48 }
49 if (read(fd, &stat, sizeof stat) != sizeof stat ||
50 stat.stat_size != sizeof stat)
51 {
4e5e456f 52 (void) sprintf(stderr, "File size change\n");
9064e1ea
EA
53 exit(EX_OSERR);
54 }
55
387e90c7 56 printf("Statistics from %s", ctime(&stat.stat_itime));
9064e1ea
EA
57 printf(" M msgsfr bytes_from msgsto bytes_to\n");
58 for (i = 0; i < MAXMAILERS; i++)
59 {
60 if (stat.stat_nf[i] == 0 && stat.stat_nt[i] == 0)
61 continue;
62 printf("%2d ", i);
4b13af04
EA
63 printf("%6ld %10ldK ", stat.stat_nf[i], stat.stat_bf[i]);
64 printf("%6ld %10ldK\n", stat.stat_nt[i], stat.stat_bt[i]);
9064e1ea
EA
65 }
66}