1/*++
2/* NAME
3/*	msg_stats_print
4/* SUMMARY
5/*	write MSG_STATS structure to stream
6/* SYNOPSIS
7/*	#include <msg_stats.h>
8/*
9/*	int	msg_stats_print(print_fn, stream, flags, ptr)
10/*	ATTR_PRINT_MASTER_FN print_fn;
11/*	VSTREAM *stream;
12/*	int	flags;
13/*	void	*ptr;
14/* DESCRIPTION
15/*	msg_stats_print() writes an MSG_STATS structure to the named
16/*	stream using the specified attribute print routine.
17/*	msg_stats_print() is meant to be passed as a call-back to
18/*	attr_print(), thusly:
19/*
20/*	... ATTR_TYPE_FUNC, msg_stats_print, (void *) stats, ...
21/* DIAGNOSTICS
22/*	Fatal: out of memory.
23/* LICENSE
24/* .ad
25/* .fi
26/*	The Secure Mailer license must be distributed with this software.
27/* AUTHOR(S)
28/*	Wietse Venema
29/*	IBM T.J. Watson Research
30/*	P.O. Box 704
31/*	Yorktown Heights, NY 10598, USA
32/*--*/
33
34/* System library. */
35
36#include <sys_defs.h>
37
38/* Utility library. */
39
40#include <attr.h>
41
42/* Global library. */
43
44#include <mail_proto.h>
45#include <msg_stats.h>
46
47/* msg_stats_print - write MSG_STATS to stream */
48
49int     msg_stats_print(ATTR_PRINT_MASTER_FN print_fn, VSTREAM *fp,
50			        int flags, void *ptr)
51{
52    int     ret;
53
54    /*
55     * Send the entire structure. This is not only simpler but also likely to
56     * be quicker than having the sender figure out what fields need to be
57     * sent, converting numbers to string and back, and having the receiver
58     * initialize the unused fields by hand.
59     */
60    ret = print_fn(fp, flags | ATTR_FLAG_MORE,
61		   ATTR_TYPE_DATA, MAIL_ATTR_TIME, sizeof(MSG_STATS), ptr,
62		   ATTR_TYPE_END);
63    return (ret);
64}
65