Home | History | Annotate | Line # | Download | only in global
      1 /*	$NetBSD: dsn_print.c,v 1.3 2022/10/08 16:12:45 christos Exp $	*/
      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_COMMON_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 /*	... SEND_ATTR_FUNC(dsn_print, (const 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 /*	Wietse Venema
     35 /*	Google, Inc.
     36 /*	111 8th Avenue
     37 /*	New York, NY 10011, USA
     38 /*--*/
     39 
     40 /* System library. */
     41 
     42 #include <sys_defs.h>
     43 
     44 /* Utility library. */
     45 
     46 #include <attr.h>
     47 
     48 /* Global library. */
     49 
     50 #include <mail_proto.h>
     51 #include <dsn_print.h>
     52 
     53 /* dsn_print - write DSN to stream */
     54 
     55 int     dsn_print(ATTR_PRINT_COMMON_FN print_fn, VSTREAM *fp,
     56 		          int flags, const void *ptr)
     57 {
     58     DSN    *dsn = (DSN *) ptr;
     59     int     ret;
     60 
     61     /*
     62      * The attribute order is determined by backwards compatibility. It can
     63      * be sanitized after all the ad-hoc DSN read/write code is replaced.
     64      */
     65     ret = print_fn(fp, flags | ATTR_FLAG_MORE,
     66 		   SEND_ATTR_STR(MAIL_ATTR_DSN_STATUS, dsn->status),
     67 		   SEND_ATTR_STR(MAIL_ATTR_DSN_DTYPE, dsn->dtype),
     68 		   SEND_ATTR_STR(MAIL_ATTR_DSN_DTEXT, dsn->dtext),
     69 		   SEND_ATTR_STR(MAIL_ATTR_DSN_MTYPE, dsn->mtype),
     70 		   SEND_ATTR_STR(MAIL_ATTR_DSN_MNAME, dsn->mname),
     71 		   SEND_ATTR_STR(MAIL_ATTR_DSN_ACTION, dsn->action),
     72 		   SEND_ATTR_STR(MAIL_ATTR_WHY, dsn->reason),
     73 		   ATTR_TYPE_END);
     74     return (ret);
     75 }
     76