* Copyright (c) 1983 Eric P. Allman
* Copyright (c) 1988 Regents of the University of California.
* %sccs.include.redist.c%
"@(#) Copyright (c) 1988 Regents of the University of California.\n\
static char sccsid
[] = "@(#)mailstats.c 6.2 (Berkeley) %G%";
#define MNAMELEN 20 /* max length of mailer name */
char mtable
[MAXMAILERS
][MNAMELEN
+1];
cfile
= _PATH_SENDMAILCF
;
while ((ch
= getopt(argc
, argv
, "C:f:o")) != EOF
)
fputs("usage: mailstats [-C cffile] [-f stfile]\n", stderr
);
if ((cfp
= fopen(cfile
, "r")) == NULL
)
fprintf(stderr
, "mailstats: ");
(void) strcpy(mtable
[mno
++], "prog");
(void) strcpy(mtable
[mno
++], "*file*");
(void) strcpy(mtable
[mno
++], "*include*");
while (fgets(buf
, sizeof(buf
), cfp
) != NULL
)
case 'M': /* mailer definition */
case 'O': /* option -- see if .st file */
b
= strchr(sfilebuf
, '\n');
"Too many mailers defined, %d max.\n",
s
= m
+ MNAMELEN
; /* is [MNAMELEN+1] */
while (*b
!= ',' && !isspace(*b
) && *b
!= '\0' && m
< s
)
for (i
= 0; i
< mno
; i
++)
if (strcmp(mtable
[i
], mtable
[mno
]) == 0)
for (; mno
< MAXMAILERS
; mno
++)
fprintf(stderr
, "mailstats: no statistics file located\n");
if ((fd
= open(sfile
, O_RDONLY
)) < 0) {
fputs("mailstats: ", stderr
);
if (read(fd
, &stat
, sizeof(stat
)) != sizeof(stat
) ||
stat
.stat_size
!= sizeof(stat
))
fputs("mailstats: file size changed.\n", stderr
);
printf("Statistics from %s", ctime(&stat
.stat_itime
));
printf(" M msgsfr bytes_from msgsto bytes_to%s\n",
mnames
? " Mailer" : "");
for (i
= 0; i
< MAXMAILERS
; i
++)
if (stat
.stat_nf
[i
] || stat
.stat_nt
[i
])
printf("%2d %6ld %10ldK %6ld %10ldK", i
,
stat
.stat_nf
[i
], stat
.stat_bf
[i
],
stat
.stat_nt
[i
], stat
.stat_bt
[i
]);
printf(" %s", mtable
[i
]);