Deleted Added
sdiff udiff text old ( 111367 ) new ( 132946 )
full compact
1/*
2 * Copyright (c) 1998-2002 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 * Copyright (c) 1983 Eric P. Allman. All rights reserved.
5 * Copyright (c) 1988, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * By using this file, you agree to the terms and conditions set
9 * forth in the LICENSE file which can be found at the top level of
10 * the sendmail distribution.
11 *
12 *
13 */
14
15#include <sm/gen.h>
16
17SM_IDSTR(copyright,
18"@(#) Copyright (c) 1998-2002 Sendmail, Inc. and its suppliers.\n\
19 All rights reserved.\n\
20 Copyright (c) 1988, 1993\n\
21 The Regents of the University of California. All rights reserved.\n")
22
23SM_IDSTR(id, "@(#)$Id: mailstats.c,v 8.100 2002/06/27 23:24:06 gshapiro Exp $")
24
25#include <unistd.h>
26#include <stddef.h>
27#include <stdlib.h>
28#include <ctype.h>
29#include <string.h>
30#include <time.h>
31#ifdef EX_OK

--- 22 unchanged lines hidden (view full) ---

54 char *sfile;
55 char *cfile;
56 SM_FILE_T *cfp;
57 bool mnames;
58 bool progmode;
59 bool trunc;
60 long frmsgs = 0, frbytes = 0, tomsgs = 0, tobytes = 0, rejmsgs = 0;
61 long dismsgs = 0;
62 long quarmsgs = 0;
63 time_t now;
64 char mtable[MAXMAILERS][MNAMELEN + 1];
65 char sfilebuf[MAXPATHLEN];
66 char buf[MAXLINE];
67 struct statistics stats;
68 extern char *ctime();
69 extern char *optarg;
70 extern int optind;

--- 207 unchanged lines hidden (view full) ---

278 }
279 else
280 {
281 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
282 "Statistics from %s",
283 ctime(&stats.stat_itime));
284 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
285 " M msgsfr bytes_from msgsto bytes_to msgsrej msgsdis");
286 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, " msgsqur");
287 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "%s\n",
288 mnames ? " Mailer" : "");
289 }
290 for (i = 0; i < MAXMAILERS; i++)
291 {
292 if (stats.stat_nf[i] || stats.stat_nt[i] ||
293 stats.stat_nq[i] ||
294 stats.stat_nr[i] || stats.stat_nd[i])
295 {
296 char *format;
297
298 if (progmode)
299 format = "%2d %8ld %10ld %8ld %10ld %6ld %6ld";
300 else
301 format = "%2d %8ld %10ldK %8ld %10ldK %6ld %6ld";
302 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
303 format, i,
304 stats.stat_nf[i],
305 stats.stat_bf[i],
306 stats.stat_nt[i],
307 stats.stat_bt[i],
308 stats.stat_nr[i],
309 stats.stat_nd[i]);
310 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
311 " %6ld", stats.stat_nq[i]);
312 if (mnames)
313 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
314 " %s",
315 mtable[i]);
316 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "\n");
317 frmsgs += stats.stat_nf[i];
318 frbytes += stats.stat_bf[i];
319 tomsgs += stats.stat_nt[i];
320 tobytes += stats.stat_bt[i];
321 rejmsgs += stats.stat_nr[i];
322 dismsgs += stats.stat_nd[i];
323 quarmsgs += stats.stat_nq[i];
324 }
325 }
326 if (progmode)
327 {
328 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
329 " T %8ld %10ld %8ld %10ld %6ld %6ld",
330 frmsgs, frbytes, tomsgs, tobytes, rejmsgs,
331 dismsgs);
332 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
333 " %6ld", quarmsgs);
334 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "\n");
335 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
336 " C %8ld %8ld %6ld\n",
337 stats.stat_cf, stats.stat_ct,
338 stats.stat_cr);
339 (void) close(fd);
340 if (trunc)
341 {
342 fd = open(sfile, O_RDWR | O_TRUNC, 0600);
343 if (fd >= 0)
344 (void) close(fd);
345 }
346 }
347 else
348 {
349 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
350 "=============================================================");
351 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "========");
352 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "\n");
353 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
354 " T %8ld %10ldK %8ld %10ldK %6ld %6ld",
355 frmsgs, frbytes, tomsgs, tobytes, rejmsgs,
356 dismsgs);
357 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
358 " %6ld", quarmsgs);
359 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "\n");
360 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
361 " C %8ld %10s %8ld %10s %6ld\n",
362 stats.stat_cf, "", stats.stat_ct, "",
363 stats.stat_cr);
364 }
365 exit(EX_OK);
366 /* NOTREACHED */
367 return EX_OK;
368}