* Copyright (c) 1983 Eric P. Allman
* Copyright (c) 1988 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)stats.c 5.10 (Berkeley) 6/30/88";
#define ONE_K 1000 /* one thousand (twenty-four?) */
#define KBYTES(x) (((x) + (ONE_K - 1)) / ONE_K)
** MARKSTATS -- mark statistics
if (e
->e_from
.q_mailer
!= NULL
)
Stat
.stat_nf
[e
->e_from
.q_mailer
->m_mno
]++;
Stat
.stat_bf
[e
->e_from
.q_mailer
->m_mno
] +=
KBYTES(CurEnv
->e_msgsize
);
Stat
.stat_nt
[to
->q_mailer
->m_mno
]++;
Stat
.stat_bt
[to
->q_mailer
->m_mno
] += KBYTES(CurEnv
->e_msgsize
);
** POSTSTATS -- post statistics in the statistics file
** sfile -- the name of the statistics file.
** merges the Stat structure with the sfile file.
(void) time(&Stat
.stat_itime
);
Stat
.stat_size
= sizeof Stat
;
if (read(fd
, (char *) &stat
, sizeof stat
) == sizeof stat
&&
stat
.stat_size
== sizeof stat
)
/* merge current statistics into statfile */
for (i
= 0; i
< MAXMAILERS
; i
++)
stat
.stat_nf
[i
] += Stat
.stat_nf
[i
];
stat
.stat_bf
[i
] += Stat
.stat_bf
[i
];
stat
.stat_nt
[i
] += Stat
.stat_nt
[i
];
stat
.stat_bt
[i
] += Stat
.stat_bt
[i
];
bcopy((char *) &Stat
, (char *) &stat
, sizeof stat
);
(void) lseek(fd
, (off_t
) 0, 0);
(void) write(fd
, (char *) &stat
, sizeof stat
);