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-2001 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.98 2002/05/24 23:10:15 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#if _FFR_QUARANTINE
63 long quarmsgs = 0;
64#endif /* _FFR_QUARANTINE */
65 time_t now;
66 char mtable[MAXMAILERS][MNAMELEN + 1];
67 char sfilebuf[MAXPATHLEN];
68 char buf[MAXLINE];
69 struct statistics stats;
70 extern char *ctime();
71 extern char *optarg;
72 extern int optind;

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

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