Annotation of 43BSDTahoe/usr.lib/sendmail/aux/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
                      7:  * provided that the above copyright notice and this paragraph are
                      8:  * duplicated in all such forms and that any documentation,
                      9:  * advertising materials, and other materials related to such
                     10:  * distribution and use acknowledge that the software was developed
                     11:  * by the University of California, Berkeley.  The name of the
                     12:  * University may not be used to endorse or promote products derived
                     13:  * from this software without specific prior written permission.
                     14:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     15:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     16:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     17:  *
                     18:  */
                     19: 
                     20: #ifndef lint
                     21: char copyright[] =
                     22: "@(#) Copyright (c) 1988 Regents of the University of California.\n\
                     23:  All rights reserved.\n";
                     24: #endif /* not lint */
                     25: 
                     26: #ifndef lint
                     27: static char sccsid[] = "@(#)mailstats.c        5.5 (Berkeley) 6/29/88";
                     28: #endif /* not lint */
                     29: 
                     30: #include <sys/file.h>
                     31: #include <sendmail.h>
                     32: #include <mailstats.h>
                     33: 
                     34: main(argc, argv)
                     35:        int argc;
                     36:        char **argv;
                     37: {
                     38:        extern char *optarg;
                     39:        extern int optind;
                     40:        struct statistics stat;
                     41:        register int i;
                     42:        int ch, fd;
                     43:        char *sfile, *ctime();
                     44: 
                     45:        sfile = "/usr/lib/sendmail.st";
                     46:        while ((ch = getopt(argc, argv, "f:")) != EOF)
                     47:                switch((char)ch) {
                     48:                case 'f':
                     49:                        sfile = optarg;
                     50:                        break;
                     51:                case '?':
                     52:                default:
                     53:                        fputs("usage: mailstats [-f file]\n", stderr);
                     54:                        exit(EX_USAGE);
                     55:                }
                     56:        argc -= optind;
                     57:        argv += optind;
                     58: 
                     59:        if ((fd = open(sfile, O_RDONLY)) < 0) {
                     60:                fputs("mailstats: ", stderr);
                     61:                perror(sfile);
                     62:                exit(EX_NOINPUT);
                     63:        }
                     64:        if (read(fd, &stat, sizeof(stat)) != sizeof(stat) ||
                     65:            stat.stat_size != sizeof(stat)) {
                     66:                fputs("mailstats: file size changed.\n", stderr);
                     67:                exit(EX_OSERR);
                     68:        }
                     69: 
                     70:        printf("Statistics from %s", ctime(&stat.stat_itime));
                     71:        printf(" M msgsfr bytes_from  msgsto   bytes_to\n");
                     72:        for (i = 0; i < MAXMAILERS; i++)
                     73:                if (stat.stat_nf[i] || stat.stat_nt[i])
                     74:                        printf("%2d %6ld %10ldK %6ld %10ldK\n", i,
                     75:                            stat.stat_nf[i], stat.stat_bf[i],
                     76:                            stat.stat_nt[i], stat.stat_bt[i]);
                     77:        exit(0);
                     78: }

unix.superglobalmegacorp.com

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