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