1: /*
   2:  * Copyright (c) 1988 Regents of the University of California.
   3:  * All rights reserved.
   4:  *
   5:  * Redistribution and use in source and binary forms are permitted
   6:  * provided that this notice is preserved and that due credit is given
   7:  * to the University of California at Berkeley. The name of the University
   8:  * may not be used to endorse or promote products derived from this
   9:  * software without specific prior written permission. This software
  10:  * is provided ``as is'' without express or implied warranty.
  11:  *
  12:  *  Sendmail
  13:  *  Copyright (c) 1983  Eric P. Allman
  14:  *  Berkeley, California
  15:  */
  16: 
  17: #if !defined(lint) && defined(DOSCCS)
  18: char copyright[] =
  19: "@(#) Copyright (c) 1988 Regents of the University of California.\n\
  20:  All rights reserved.\n";
  21: 
  22: static char sccsid[] = "@(#)mailstats.c	5.4.1 (2.11BSD) 1996/10/24";
  23: #endif
  24: 
  25: #include <sys/file.h>
  26: #include <sendmail.h>
  27: #include <mailstats.h>
  28: 
  29: main(argc, argv)
  30:     int argc;
  31:     char **argv;
  32: {
  33:     extern char *optarg;
  34:     extern int optind;
  35:     struct statistics stat;
  36:     register int i;
  37:     int ch, fd;
  38:     char *sfile, *ctime();
  39: 
  40:     sfile = "/var/log/sendmail.st";
  41:     while ((ch = getopt(argc, argv, "f:")) != EOF)
  42:         switch((char)ch) {
  43:         case 'f':
  44:             sfile = optarg;
  45:             break;
  46:         case '?':
  47:         default:
  48:             fputs("usage: mailstats [-f file]\n", stderr);
  49:             exit(EX_USAGE);
  50:         }
  51:     argc -= optind;
  52:     argv += optind;
  53: 
  54:     if ((fd = open(sfile, O_RDONLY)) < 0) {
  55:         fputs("mailstats: ", stderr);
  56:         perror(sfile);
  57:         exit(EX_NOINPUT);
  58:     }
  59:     if (read(fd, &stat, sizeof(stat)) != sizeof(stat) ||
  60:         stat.stat_size != sizeof(stat)) {
  61:         fputs("mailstats: file size changed.\n", stderr);
  62:         exit(EX_OSERR);
  63:     }
  64: 
  65:     printf("Statistics from %s", ctime(&stat.stat_itime));
  66:     printf(" M msgsfr bytes_from  msgsto   bytes_to\n");
  67:     for (i = 0; i < MAXMAILERS; i++)
  68:         if (stat.stat_nf[i] || stat.stat_nt[i])
  69:             printf("%2d %6ld %10ldK %6ld %10ldK\n", i,
  70:                 stat.stat_nf[i], stat.stat_bf[i],
  71:                 stat.stat_nt[i], stat.stat_bt[i]);
  72:     exit(0);
  73: }

Defined functions

main defined in line 29; never used

Defined variables

copyright defined in line 18; never used
sccsid defined in line 22; never used
Last modified: 1996-10-25
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2481
Valid CSS Valid XHTML 1.0 Strict