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_COMMON_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 /*	... SEND_ATTR_FUNC(msg_stats_print, (const 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 /*	Wietse Venema
34 /*	Google, Inc.
35 /*	111 8th Avenue
36 /*	New York, NY 10011, USA
37 /*--*/
38 
39 /* System library. */
40 
41 #include <sys_defs.h>
42 
43 /* Utility library. */
44 
45 #include <attr.h>
46 
47 /* Global library. */
48 
49 #include <mail_proto.h>
50 #include <msg_stats.h>
51 
52 /* msg_stats_print - write MSG_STATS to stream */
53 
msg_stats_print(ATTR_PRINT_COMMON_FN print_fn,VSTREAM * fp,int flags,const void * ptr)54 int     msg_stats_print(ATTR_PRINT_COMMON_FN print_fn, VSTREAM *fp,
55 			        int flags, const void *ptr)
56 {
57     int     ret;
58 
59     /*
60      * Send the entire structure. This is not only simpler but also likely to
61      * be quicker than having the sender figure out what fields need to be
62      * sent, converting numbers to string and back, and having the receiver
63      * initialize the unused fields by hand.
64      */
65     ret = print_fn(fp, flags | ATTR_FLAG_MORE,
66 		   SEND_ATTR_DATA(MAIL_ATTR_TIME, sizeof(MSG_STATS), ptr),
67 		   ATTR_TYPE_END);
68     return (ret);
69 }
70