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