1/* $NetBSD$ */ 2 3/*++ 4/* NAME 5/* dsn_print 6/* SUMMARY 7/* write DSN structure to stream 8/* SYNOPSIS 9/* #include <dsn_print.h> 10/* 11/* int dsn_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/* dsn_print() writes a DSN structure to the named stream using 18/* the specified attribute print routine. dsn_print() is meant 19/* to be passed as a call-back to attr_print(), thusly: 20/* 21/* ... ATTR_TYPE_FUNC, dsn_print, (void *) dsn, ... 22/* DIAGNOSTICS 23/* Fatal: out of memory. 24/* LICENSE 25/* .ad 26/* .fi 27/* The Secure Mailer license must be distributed with this software. 28/* AUTHOR(S) 29/* Wietse Venema 30/* IBM T.J. Watson Research 31/* P.O. Box 704 32/* Yorktown Heights, NY 10598, USA 33/*--*/ 34 35/* System library. */ 36 37#include <sys_defs.h> 38 39/* Utility library. */ 40 41#include <attr.h> 42 43/* Global library. */ 44 45#include <mail_proto.h> 46#include <dsn_print.h> 47 48/* dsn_print - write DSN to stream */ 49 50int dsn_print(ATTR_PRINT_MASTER_FN print_fn, VSTREAM *fp, 51 int flags, void *ptr) 52{ 53 DSN *dsn = (DSN *) ptr; 54 int ret; 55 56 /* 57 * The attribute order is determined by backwards compatibility. It can 58 * be sanitized after all the ad-hoc DSN read/write code is replaced. 59 */ 60 ret = print_fn(fp, flags | ATTR_FLAG_MORE, 61 ATTR_TYPE_STR, MAIL_ATTR_DSN_STATUS, dsn->status, 62 ATTR_TYPE_STR, MAIL_ATTR_DSN_DTYPE, dsn->dtype, 63 ATTR_TYPE_STR, MAIL_ATTR_DSN_DTEXT, dsn->dtext, 64 ATTR_TYPE_STR, MAIL_ATTR_DSN_MTYPE, dsn->mtype, 65 ATTR_TYPE_STR, MAIL_ATTR_DSN_MNAME, dsn->mname, 66 ATTR_TYPE_STR, MAIL_ATTR_DSN_ACTION, dsn->action, 67 ATTR_TYPE_STR, MAIL_ATTR_WHY, dsn->reason, 68 ATTR_TYPE_END); 69 return (ret); 70} 71