/*
* Copyright (c) 1998-2002, 2013 Proofpoint, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1983 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
*
*/
"@(#) Copyright (c) 1998-2002 Proofpoint, Inc. and its suppliers.\n\
All rights reserved.\n\
Copyright (c) 1988, 1993\n\
The Regents of the University of California. All rights reserved.\n")
#include <unistd.h>
#include <stddef.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
#ifdef EX_OK
#endif /* EX_OK */
#include <sysexits.h>
#include <sm/errstring.h>
#include <sendmail/sendmail.h>
#include <sendmail/mailstats.h>
#include <sendmail/pathnames.h>
int
int argc;
char **argv;
{
register int i;
int mno;
int save_errno;
char *sfile;
char *cfile;
bool mnames;
bool progmode;
bool trunc;
long dismsgs = 0;
long quarmsgs = 0;
extern char *ctime();
extern char *optarg;
extern int optind;
mnames = true;
progmode = false;
trunc = false;
{
switch (ch)
{
case 'c':
break;
case 'C':
break;
case 'f':
break;
case 'o':
mnames = false;
break;
case 'p':
trunc = true;
/* FALLTHROUGH */
case 'P':
progmode = true;
break;
case '?':
default:
"usage: mailstats [-C cffile] [-c] [-P] [-f stfile] [-o] [-p]\n");
}
}
if (argc != 0)
goto usage;
{
save_errno = errno;
errno = save_errno;
}
mno = 0;
{
register char *b;
char *s;
register char *m;
if (b == NULL)
if (b == NULL)
continue;
*++b = '\0';
b = buf;
switch (*b++)
{
case 'M': /* mailer definition */
break;
case 'O': /* option -- see if .st file */
{
/* new form -- find value */
b = strchr(b, '=');
if (b == NULL)
continue;
continue;
}
else if (*b++ != 'S')
{
/* something else boring */
continue;
}
/* this is the S or StatusFile option -- save it */
sizeof sfilebuf)
{
"StatusFile filename too long: %.30s...\n",
b);
}
default:
continue;
}
if (mno >= MAXMAILERS)
{
"Too many mailers defined, %d max.\n",
}
s = m + MNAMELEN; /* is [MNAMELEN + 1] */
*b != '\0' && m < s)
*m++ = *b++;
*m = '\0';
for (i = 0; i < mno; i++)
{
break;
}
if (i == mno)
mno++;
}
{
"mailstats: no statistics file located\n");
}
{
save_errno = errno;
errno = save_errno;
}
if (i == 0)
{
(void) sleep(1);
{
save_errno = errno;
"mailstats: ");
errno = save_errno;
}
else if (i == 0)
{
}
}
if (i != 0)
{
{
"mailstats: incorrect magic number in %s\n",
sfile);
}
{
"mailstats version (%d) incompatible with %s version (%d)\n",
}
{
"mailstats: file size changed.\n");
}
}
if (progmode)
{
}
else
{
"Statistics from %s",
" M msgsfr bytes_from msgsto bytes_to msgsrej msgsdis");
}
for (i = 0; i < MAXMAILERS; i++)
{
{
char *format;
if (progmode)
format = "%2d %8ld %10ld %8ld %10ld %6ld %6ld";
else
format = "%2d %8ld %10ldK %8ld %10ldK %6ld %6ld";
format, i,
if (mnames)
" %s",
mtable[i]);
}
}
if (progmode)
{
" T %8ld %10ld %8ld %10ld %6ld %6ld",
dismsgs);
" %6ld", quarmsgs);
" C %8ld %8ld %6ld\n",
if (trunc)
{
if (fd >= 0)
}
}
else
{
"=============================================================");
" T %8ld %10ldK %8ld %10ldK %6ld %6ld",
dismsgs);
" %6ld", quarmsgs);
" C %8ld %10s %8ld %10s %6ld\n",
}
/* NOTREACHED */
return EX_OK;
}