Annotation of 43BSDReno/usr.sbin/sendmail/mailstats/mailstats.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1983 Eric P. Allman
                      3:  * Copyright (c) 1988 Regents of the University of California.
                      4:  * All rights reserved.
                      5:  *
                      6:  * Redistribution and use in source and binary forms are permitted provided
                      7:  * that: (1) source distributions retain this entire copyright notice and
                      8:  * comment, and (2) distributions including binaries display the following
                      9:  * acknowledgement:  ``This product includes software developed by the
                     10:  * University of California, Berkeley and its contributors'' in the
                     11:  * documentation or other materials provided with the distribution and in
                     12:  * all advertising materials mentioning features or use of this software.
                     13:  * Neither the name of the University nor the names of its contributors may
                     14:  * be used to endorse or promote products derived from this software without
                     15:  * specific prior written permission.
                     16:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     17:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     18:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     19:  *
                     20:  */
                     21: 
                     22: #ifndef lint
                     23: char copyright[] =
                     24: "@(#) Copyright (c) 1988 Regents of the University of California.\n\
                     25:  All rights reserved.\n";
                     26: #endif /* not lint */
                     27: 
                     28: #ifndef lint
                     29: static char sccsid[] = "@(#)mailstats.c        5.7 (Berkeley) 6/1/90";
                     30: #endif /* not lint */
                     31: 
                     32: #include <sys/file.h>
                     33: #include <sendmail.h>
                     34: #include <mailstats.h>
                     35: #include "pathnames.h"
                     36: 
                     37: main(argc, argv)
                     38:        int argc;
                     39:        char **argv;
                     40: {
                     41:        extern char *optarg;
                     42:        extern int optind;
                     43:        struct statistics stat;
                     44:        register int i;
                     45:        int ch, fd;
                     46:        char *sfile, *ctime();
                     47: 
                     48:        sfile = _PATH_MAILSTATS;
                     49:        while ((ch = getopt(argc, argv, "f:")) != EOF)
                     50:                switch((char)ch) {
                     51:                case 'f':
                     52:                        sfile = optarg;
                     53:                        break;
                     54:                case '?':
                     55:                default:
                     56:                        fputs("usage: mailstats [-f file]\n", stderr);
                     57:                        exit(EX_USAGE);
                     58:                }
                     59:        argc -= optind;
                     60:        argv += optind;
                     61: 
                     62:        if ((fd = open(sfile, O_RDONLY)) < 0) {
                     63:                fputs("mailstats: ", stderr);
                     64:                perror(sfile);
                     65:                exit(EX_NOINPUT);
                     66:        }
                     67:        if (read(fd, &stat, sizeof(stat)) != sizeof(stat) ||
                     68:            stat.stat_size != sizeof(stat)) {
                     69:                fputs("mailstats: file size changed.\n", stderr);
                     70:                exit(EX_OSERR);
                     71:        }
                     72: 
                     73:        printf("Statistics from %s", ctime(&stat.stat_itime));
                     74:        printf(" M msgsfr bytes_from  msgsto   bytes_to\n");
                     75:        for (i = 0; i < MAXMAILERS; i++)
                     76:                if (stat.stat_nf[i] || stat.stat_nt[i])
                     77:                        printf("%2d %6ld %10ldK %6ld %10ldK\n", i,
                     78:                            stat.stat_nf[i], stat.stat_bf[i],
                     79:                            stat.stat_nt[i], stat.stat_bt[i]);
                     80:        exit(0);
                     81: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.