17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * Copyright (c) 1998-2002 Sendmail, Inc. and its suppliers. 37c478bd9Sstevel@tonic-gate * All rights reserved. 47c478bd9Sstevel@tonic-gate * Copyright (c) 1983 Eric P. Allman. All rights reserved. 57c478bd9Sstevel@tonic-gate * Copyright (c) 1988, 1993 67c478bd9Sstevel@tonic-gate * The Regents of the University of California. All rights reserved. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * By using this file, you agree to the terms and conditions set 97c478bd9Sstevel@tonic-gate * forth in the LICENSE file which can be found at the top level of 107c478bd9Sstevel@tonic-gate * the sendmail distribution. 117c478bd9Sstevel@tonic-gate * 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate */ 147c478bd9Sstevel@tonic-gate 157c478bd9Sstevel@tonic-gate #include <sm/gen.h> 167c478bd9Sstevel@tonic-gate 177c478bd9Sstevel@tonic-gate SM_IDSTR(copyright, 187c478bd9Sstevel@tonic-gate "@(#) Copyright (c) 1998-2002 Sendmail, Inc. and its suppliers.\n\ 197c478bd9Sstevel@tonic-gate All rights reserved.\n\ 207c478bd9Sstevel@tonic-gate Copyright (c) 1988, 1993\n\ 217c478bd9Sstevel@tonic-gate The Regents of the University of California. All rights reserved.\n") 227c478bd9Sstevel@tonic-gate 237c478bd9Sstevel@tonic-gate SM_IDSTR(id, "@(#)$Id: mailstats.c,v 8.100 2002/06/27 23:24:06 gshapiro Exp $") 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #include <unistd.h> 267c478bd9Sstevel@tonic-gate #include <stddef.h> 277c478bd9Sstevel@tonic-gate #include <stdlib.h> 287c478bd9Sstevel@tonic-gate #include <ctype.h> 297c478bd9Sstevel@tonic-gate #include <string.h> 307c478bd9Sstevel@tonic-gate #include <time.h> 317c478bd9Sstevel@tonic-gate #ifdef EX_OK 327c478bd9Sstevel@tonic-gate # undef EX_OK /* unistd.h may have another use for this */ 337c478bd9Sstevel@tonic-gate #endif /* EX_OK */ 347c478bd9Sstevel@tonic-gate #include <sysexits.h> 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #include <sm/errstring.h> 377c478bd9Sstevel@tonic-gate #include <sm/limits.h> 387c478bd9Sstevel@tonic-gate #include <sendmail/sendmail.h> 397c478bd9Sstevel@tonic-gate #include <sendmail/mailstats.h> 407c478bd9Sstevel@tonic-gate #include <sendmail/pathnames.h> 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #define MNAMELEN 20 /* max length of mailer name */ 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate int 467c478bd9Sstevel@tonic-gate main(argc, argv) 477c478bd9Sstevel@tonic-gate int argc; 487c478bd9Sstevel@tonic-gate char **argv; 497c478bd9Sstevel@tonic-gate { 507c478bd9Sstevel@tonic-gate register int i; 517c478bd9Sstevel@tonic-gate int mno; 527c478bd9Sstevel@tonic-gate int save_errno; 537c478bd9Sstevel@tonic-gate int ch, fd; 547c478bd9Sstevel@tonic-gate char *sfile; 557c478bd9Sstevel@tonic-gate char *cfile; 567c478bd9Sstevel@tonic-gate SM_FILE_T *cfp; 577c478bd9Sstevel@tonic-gate bool mnames; 587c478bd9Sstevel@tonic-gate bool progmode; 597c478bd9Sstevel@tonic-gate bool trunc; 607c478bd9Sstevel@tonic-gate long frmsgs = 0, frbytes = 0, tomsgs = 0, tobytes = 0, rejmsgs = 0; 617c478bd9Sstevel@tonic-gate long dismsgs = 0; 627c478bd9Sstevel@tonic-gate long quarmsgs = 0; 637c478bd9Sstevel@tonic-gate time_t now; 647c478bd9Sstevel@tonic-gate char mtable[MAXMAILERS][MNAMELEN + 1]; 657c478bd9Sstevel@tonic-gate char sfilebuf[MAXPATHLEN]; 667c478bd9Sstevel@tonic-gate char buf[MAXLINE]; 677c478bd9Sstevel@tonic-gate struct statistics stats; 687c478bd9Sstevel@tonic-gate extern char *ctime(); 697c478bd9Sstevel@tonic-gate extern char *optarg; 707c478bd9Sstevel@tonic-gate extern int optind; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate cfile = getcfname(0, 0, SM_GET_SENDMAIL_CF, NULL); 737c478bd9Sstevel@tonic-gate sfile = NULL; 747c478bd9Sstevel@tonic-gate mnames = true; 757c478bd9Sstevel@tonic-gate progmode = false; 767c478bd9Sstevel@tonic-gate trunc = false; 777c478bd9Sstevel@tonic-gate while ((ch = getopt(argc, argv, "cC:f:opP")) != -1) 787c478bd9Sstevel@tonic-gate { 797c478bd9Sstevel@tonic-gate switch (ch) 807c478bd9Sstevel@tonic-gate { 817c478bd9Sstevel@tonic-gate case 'c': 827c478bd9Sstevel@tonic-gate cfile = getcfname(0, 0, SM_GET_SUBMIT_CF, NULL); 837c478bd9Sstevel@tonic-gate break; 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate case 'C': 867c478bd9Sstevel@tonic-gate cfile = optarg; 877c478bd9Sstevel@tonic-gate break; 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate case 'f': 907c478bd9Sstevel@tonic-gate sfile = optarg; 917c478bd9Sstevel@tonic-gate break; 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate case 'o': 947c478bd9Sstevel@tonic-gate mnames = false; 957c478bd9Sstevel@tonic-gate break; 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate case 'p': 987c478bd9Sstevel@tonic-gate trunc = true; 997c478bd9Sstevel@tonic-gate /* FALLTHROUGH */ 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate case 'P': 1027c478bd9Sstevel@tonic-gate progmode = true; 1037c478bd9Sstevel@tonic-gate break; 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate case '?': 1067c478bd9Sstevel@tonic-gate default: 1077c478bd9Sstevel@tonic-gate usage: 1087c478bd9Sstevel@tonic-gate (void) sm_io_fputs(smioerr, SM_TIME_DEFAULT, 1097c478bd9Sstevel@tonic-gate "usage: mailstats [-C cffile] [-c] [-P] [-f stfile] [-o] [-p]\n"); 1107c478bd9Sstevel@tonic-gate exit(EX_USAGE); 1117c478bd9Sstevel@tonic-gate } 1127c478bd9Sstevel@tonic-gate } 1137c478bd9Sstevel@tonic-gate argc -= optind; 1147c478bd9Sstevel@tonic-gate argv += optind; 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate if (argc != 0) 1177c478bd9Sstevel@tonic-gate goto usage; 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate if ((cfp = sm_io_open(SmFtStdio, SM_TIME_DEFAULT, cfile, SM_IO_RDONLY, 1207c478bd9Sstevel@tonic-gate NULL)) == NULL) 1217c478bd9Sstevel@tonic-gate { 1227c478bd9Sstevel@tonic-gate save_errno = errno; 1237c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "mailstats: "); 1247c478bd9Sstevel@tonic-gate errno = save_errno; 1257c478bd9Sstevel@tonic-gate sm_perror(cfile); 1267c478bd9Sstevel@tonic-gate exit(EX_NOINPUT); 1277c478bd9Sstevel@tonic-gate } 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate mno = 0; 1307c478bd9Sstevel@tonic-gate (void) sm_strlcpy(mtable[mno++], "prog", MNAMELEN + 1); 1317c478bd9Sstevel@tonic-gate (void) sm_strlcpy(mtable[mno++], "*file*", MNAMELEN + 1); 1327c478bd9Sstevel@tonic-gate (void) sm_strlcpy(mtable[mno++], "*include*", MNAMELEN + 1); 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate while (sm_io_fgets(cfp, SM_TIME_DEFAULT, buf, sizeof(buf)) != NULL) 1357c478bd9Sstevel@tonic-gate { 1367c478bd9Sstevel@tonic-gate register char *b; 1377c478bd9Sstevel@tonic-gate char *s; 1387c478bd9Sstevel@tonic-gate register char *m; 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate b = strchr(buf, '#'); 1417c478bd9Sstevel@tonic-gate if (b == NULL) 1427c478bd9Sstevel@tonic-gate b = strchr(buf, '\n'); 1437c478bd9Sstevel@tonic-gate if (b == NULL) 1447c478bd9Sstevel@tonic-gate b = &buf[strlen(buf)]; 1457c478bd9Sstevel@tonic-gate while (isascii(*--b) && isspace(*b)) 1467c478bd9Sstevel@tonic-gate continue; 1477c478bd9Sstevel@tonic-gate *++b = '\0'; 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate b = buf; 1507c478bd9Sstevel@tonic-gate switch (*b++) 1517c478bd9Sstevel@tonic-gate { 1527c478bd9Sstevel@tonic-gate case 'M': /* mailer definition */ 1537c478bd9Sstevel@tonic-gate break; 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate case 'O': /* option -- see if .st file */ 1567c478bd9Sstevel@tonic-gate if (sm_strncasecmp(b, " StatusFile", 11) == 0 && 1577c478bd9Sstevel@tonic-gate !(isascii(b[11]) && isalnum(b[11]))) 1587c478bd9Sstevel@tonic-gate { 1597c478bd9Sstevel@tonic-gate /* new form -- find value */ 1607c478bd9Sstevel@tonic-gate b = strchr(b, '='); 1617c478bd9Sstevel@tonic-gate if (b == NULL) 1627c478bd9Sstevel@tonic-gate continue; 1637c478bd9Sstevel@tonic-gate while (isascii(*++b) && isspace(*b)) 1647c478bd9Sstevel@tonic-gate continue; 1657c478bd9Sstevel@tonic-gate } 1667c478bd9Sstevel@tonic-gate else if (*b++ != 'S') 1677c478bd9Sstevel@tonic-gate { 1687c478bd9Sstevel@tonic-gate /* something else boring */ 1697c478bd9Sstevel@tonic-gate continue; 1707c478bd9Sstevel@tonic-gate } 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate /* this is the S or StatusFile option -- save it */ 1737c478bd9Sstevel@tonic-gate if (sm_strlcpy(sfilebuf, b, sizeof sfilebuf) >= 1747c478bd9Sstevel@tonic-gate sizeof sfilebuf) 1757c478bd9Sstevel@tonic-gate { 1767c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, 1777c478bd9Sstevel@tonic-gate "StatusFile filename too long: %.30s...\n", 1787c478bd9Sstevel@tonic-gate b); 1797c478bd9Sstevel@tonic-gate exit(EX_CONFIG); 1807c478bd9Sstevel@tonic-gate } 1817c478bd9Sstevel@tonic-gate if (sfile == NULL) 1827c478bd9Sstevel@tonic-gate sfile = sfilebuf; 183fec46055SToomas Soome /* FALLTHROUGH */ 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate default: 1867c478bd9Sstevel@tonic-gate continue; 1877c478bd9Sstevel@tonic-gate } 1887c478bd9Sstevel@tonic-gate 1897c478bd9Sstevel@tonic-gate if (mno >= MAXMAILERS) 1907c478bd9Sstevel@tonic-gate { 1917c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, 1927c478bd9Sstevel@tonic-gate "Too many mailers defined, %d max.\n", 1937c478bd9Sstevel@tonic-gate MAXMAILERS); 1947c478bd9Sstevel@tonic-gate exit(EX_SOFTWARE); 1957c478bd9Sstevel@tonic-gate } 1967c478bd9Sstevel@tonic-gate m = mtable[mno]; 1977c478bd9Sstevel@tonic-gate s = m + MNAMELEN; /* is [MNAMELEN + 1] */ 1987c478bd9Sstevel@tonic-gate while (*b != ',' && !(isascii(*b) && isspace(*b)) && 1997c478bd9Sstevel@tonic-gate *b != '\0' && m < s) 2007c478bd9Sstevel@tonic-gate *m++ = *b++; 2017c478bd9Sstevel@tonic-gate *m = '\0'; 2027c478bd9Sstevel@tonic-gate for (i = 0; i < mno; i++) 2037c478bd9Sstevel@tonic-gate { 2047c478bd9Sstevel@tonic-gate if (strcmp(mtable[i], mtable[mno]) == 0) 2057c478bd9Sstevel@tonic-gate break; 2067c478bd9Sstevel@tonic-gate } 2077c478bd9Sstevel@tonic-gate if (i == mno) 2087c478bd9Sstevel@tonic-gate mno++; 2097c478bd9Sstevel@tonic-gate } 2107c478bd9Sstevel@tonic-gate (void) sm_io_close(cfp, SM_TIME_DEFAULT); 2117c478bd9Sstevel@tonic-gate for (; mno < MAXMAILERS; mno++) 2127c478bd9Sstevel@tonic-gate mtable[mno][0] = '\0'; 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate if (sfile == NULL) 2157c478bd9Sstevel@tonic-gate { 2167c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, 2177c478bd9Sstevel@tonic-gate "mailstats: no statistics file located\n"); 2187c478bd9Sstevel@tonic-gate exit(EX_OSFILE); 2197c478bd9Sstevel@tonic-gate } 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate fd = open(sfile, O_RDONLY, 0600); 2227c478bd9Sstevel@tonic-gate if ((fd < 0) || (i = read(fd, &stats, sizeof stats)) < 0) 2237c478bd9Sstevel@tonic-gate { 2247c478bd9Sstevel@tonic-gate save_errno = errno; 2257c478bd9Sstevel@tonic-gate (void) sm_io_fputs(smioerr, SM_TIME_DEFAULT, "mailstats: "); 2267c478bd9Sstevel@tonic-gate errno = save_errno; 2277c478bd9Sstevel@tonic-gate sm_perror(sfile); 2287c478bd9Sstevel@tonic-gate exit(EX_NOINPUT); 2297c478bd9Sstevel@tonic-gate } 2307c478bd9Sstevel@tonic-gate if (i == 0) 2317c478bd9Sstevel@tonic-gate { 2327c478bd9Sstevel@tonic-gate (void) sleep(1); 2337c478bd9Sstevel@tonic-gate if ((i = read(fd, &stats, sizeof stats)) < 0) 2347c478bd9Sstevel@tonic-gate { 2357c478bd9Sstevel@tonic-gate save_errno = errno; 2367c478bd9Sstevel@tonic-gate (void) sm_io_fputs(smioerr, SM_TIME_DEFAULT, 2377c478bd9Sstevel@tonic-gate "mailstats: "); 2387c478bd9Sstevel@tonic-gate errno = save_errno; 2397c478bd9Sstevel@tonic-gate sm_perror(sfile); 2407c478bd9Sstevel@tonic-gate exit(EX_NOINPUT); 2417c478bd9Sstevel@tonic-gate } 2427c478bd9Sstevel@tonic-gate else if (i == 0) 2437c478bd9Sstevel@tonic-gate { 2447c478bd9Sstevel@tonic-gate memset((ARBPTR_T) &stats, '\0', sizeof stats); 2457c478bd9Sstevel@tonic-gate (void) time(&stats.stat_itime); 2467c478bd9Sstevel@tonic-gate } 2477c478bd9Sstevel@tonic-gate } 2487c478bd9Sstevel@tonic-gate if (i != 0) 2497c478bd9Sstevel@tonic-gate { 2507c478bd9Sstevel@tonic-gate if (stats.stat_magic != STAT_MAGIC) 2517c478bd9Sstevel@tonic-gate { 2527c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, 2537c478bd9Sstevel@tonic-gate "mailstats: incorrect magic number in %s\n", 2547c478bd9Sstevel@tonic-gate sfile); 2557c478bd9Sstevel@tonic-gate exit(EX_OSERR); 2567c478bd9Sstevel@tonic-gate } 2577c478bd9Sstevel@tonic-gate else if (stats.stat_version != STAT_VERSION) 2587c478bd9Sstevel@tonic-gate { 2597c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, 2607c478bd9Sstevel@tonic-gate "mailstats version (%d) incompatible with %s version (%d)\n", 2617c478bd9Sstevel@tonic-gate STAT_VERSION, sfile, 2627c478bd9Sstevel@tonic-gate stats.stat_version); 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate exit(EX_OSERR); 2657c478bd9Sstevel@tonic-gate } 2667c478bd9Sstevel@tonic-gate else if (i != sizeof stats || stats.stat_size != sizeof(stats)) 2677c478bd9Sstevel@tonic-gate { 2687c478bd9Sstevel@tonic-gate (void) sm_io_fputs(smioerr, SM_TIME_DEFAULT, 2697c478bd9Sstevel@tonic-gate "mailstats: file size changed.\n"); 2707c478bd9Sstevel@tonic-gate exit(EX_OSERR); 2717c478bd9Sstevel@tonic-gate } 2727c478bd9Sstevel@tonic-gate } 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate if (progmode) 2757c478bd9Sstevel@tonic-gate { 2767c478bd9Sstevel@tonic-gate (void) time(&now); 2777c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "%ld %ld\n", 2787c478bd9Sstevel@tonic-gate (long) stats.stat_itime, (long) now); 2797c478bd9Sstevel@tonic-gate } 2807c478bd9Sstevel@tonic-gate else 2817c478bd9Sstevel@tonic-gate { 2827c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, 2837c478bd9Sstevel@tonic-gate "Statistics from %s", 2847c478bd9Sstevel@tonic-gate ctime(&stats.stat_itime)); 2857c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, 2867c478bd9Sstevel@tonic-gate " M msgsfr bytes_from msgsto bytes_to msgsrej msgsdis"); 2877c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, " msgsqur"); 2887c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "%s\n", 2897c478bd9Sstevel@tonic-gate mnames ? " Mailer" : ""); 2907c478bd9Sstevel@tonic-gate } 2917c478bd9Sstevel@tonic-gate for (i = 0; i < MAXMAILERS; i++) 2927c478bd9Sstevel@tonic-gate { 2937c478bd9Sstevel@tonic-gate if (stats.stat_nf[i] || stats.stat_nt[i] || 2947c478bd9Sstevel@tonic-gate stats.stat_nq[i] || 2957c478bd9Sstevel@tonic-gate stats.stat_nr[i] || stats.stat_nd[i]) 2967c478bd9Sstevel@tonic-gate { 2977c478bd9Sstevel@tonic-gate char *format; 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate if (progmode) 3007c478bd9Sstevel@tonic-gate format = "%2d %8ld %10ld %8ld %10ld %6ld %6ld"; 3017c478bd9Sstevel@tonic-gate else 3027c478bd9Sstevel@tonic-gate format = "%2d %8ld %10ldK %8ld %10ldK %6ld %6ld"; 3037c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, 3047c478bd9Sstevel@tonic-gate format, i, 3057c478bd9Sstevel@tonic-gate stats.stat_nf[i], 3067c478bd9Sstevel@tonic-gate stats.stat_bf[i], 3077c478bd9Sstevel@tonic-gate stats.stat_nt[i], 3087c478bd9Sstevel@tonic-gate stats.stat_bt[i], 3097c478bd9Sstevel@tonic-gate stats.stat_nr[i], 3107c478bd9Sstevel@tonic-gate stats.stat_nd[i]); 3117c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, 3127c478bd9Sstevel@tonic-gate " %6ld", stats.stat_nq[i]); 3137c478bd9Sstevel@tonic-gate if (mnames) 3147c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, 3157c478bd9Sstevel@tonic-gate " %s", 3167c478bd9Sstevel@tonic-gate mtable[i]); 3177c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "\n"); 3187c478bd9Sstevel@tonic-gate frmsgs += stats.stat_nf[i]; 3197c478bd9Sstevel@tonic-gate frbytes += stats.stat_bf[i]; 3207c478bd9Sstevel@tonic-gate tomsgs += stats.stat_nt[i]; 3217c478bd9Sstevel@tonic-gate tobytes += stats.stat_bt[i]; 3227c478bd9Sstevel@tonic-gate rejmsgs += stats.stat_nr[i]; 3237c478bd9Sstevel@tonic-gate dismsgs += stats.stat_nd[i]; 3247c478bd9Sstevel@tonic-gate quarmsgs += stats.stat_nq[i]; 3257c478bd9Sstevel@tonic-gate } 3267c478bd9Sstevel@tonic-gate } 3277c478bd9Sstevel@tonic-gate if (progmode) 3287c478bd9Sstevel@tonic-gate { 3297c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, 3307c478bd9Sstevel@tonic-gate " T %8ld %10ld %8ld %10ld %6ld %6ld", 3317c478bd9Sstevel@tonic-gate frmsgs, frbytes, tomsgs, tobytes, rejmsgs, 3327c478bd9Sstevel@tonic-gate dismsgs); 3337c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, 3347c478bd9Sstevel@tonic-gate " %6ld", quarmsgs); 3357c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "\n"); 3367c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, 3377c478bd9Sstevel@tonic-gate " C %8ld %8ld %6ld\n", 3387c478bd9Sstevel@tonic-gate stats.stat_cf, stats.stat_ct, 3397c478bd9Sstevel@tonic-gate stats.stat_cr); 3407c478bd9Sstevel@tonic-gate (void) close(fd); 3417c478bd9Sstevel@tonic-gate if (trunc) 3427c478bd9Sstevel@tonic-gate { 3437c478bd9Sstevel@tonic-gate fd = open(sfile, O_RDWR | O_TRUNC, 0600); 3447c478bd9Sstevel@tonic-gate if (fd >= 0) 3457c478bd9Sstevel@tonic-gate (void) close(fd); 3467c478bd9Sstevel@tonic-gate } 3477c478bd9Sstevel@tonic-gate } 3487c478bd9Sstevel@tonic-gate else 3497c478bd9Sstevel@tonic-gate { 3507c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, 3517c478bd9Sstevel@tonic-gate "============================================================="); 3527c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "========"); 3537c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "\n"); 3547c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, 3557c478bd9Sstevel@tonic-gate " T %8ld %10ldK %8ld %10ldK %6ld %6ld", 3567c478bd9Sstevel@tonic-gate frmsgs, frbytes, tomsgs, tobytes, rejmsgs, 3577c478bd9Sstevel@tonic-gate dismsgs); 3587c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, 3597c478bd9Sstevel@tonic-gate " %6ld", quarmsgs); 3607c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "\n"); 3617c478bd9Sstevel@tonic-gate (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, 3627c478bd9Sstevel@tonic-gate " C %8ld %10s %8ld %10s %6ld\n", 3637c478bd9Sstevel@tonic-gate stats.stat_cf, "", stats.stat_ct, "", 3647c478bd9Sstevel@tonic-gate stats.stat_cr); 3657c478bd9Sstevel@tonic-gate } 3667c478bd9Sstevel@tonic-gate exit(EX_OK); 3677c478bd9Sstevel@tonic-gate /* NOTREACHED */ 3687c478bd9Sstevel@tonic-gate return EX_OK; 3697c478bd9Sstevel@tonic-gate } 370