xref: /netbsd-src/external/ibm-public/postfix/dist/src/global/rcpt_print.c (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1 /*	$NetBSD: rcpt_print.c,v 1.2 2017/02/14 01:16:45 christos Exp $	*/
2 
3 /*++
4 /* NAME
5 /*	rcpt_print
6 /* SUMMARY
7 /*	write RECIPIENT structure to stream
8 /* SYNOPSIS
9 /*	#include <rcpt_print.h>
10 /*
11 /*	int     rcpt_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 /*	rcpt_print() writes the contents of a RECIPIENT structure
18 /*	to the named stream using the specified attribute print
19 /*	routine. rcpt_print() is meant to be passed as a call-back
20 /*	to attr_print(), thusly:
21 /*
22 /*	... SEND_ATTR_FUNC(rcpt_print, (void *) recipient), ...
23 /* DIAGNOSTICS
24 /*	Fatal: out of memory.
25 /* LICENSE
26 /* .ad
27 /* .fi
28 /*	The Secure Mailer license must be distributed with this
29 /*	software.
30 /* AUTHOR(S)
31 /*	Wietse Venema
32 /*	IBM T.J. Watson Research
33 /*	P.O. Box 704
34 /*	Yorktown Heights, NY 10598, USA
35 /*--*/
36 
37 /* System library. */
38 
39 #include <sys_defs.h>
40 
41 /* Utility library. */
42 
43 #include <attr.h>
44 
45 /* Global library. */
46 
47 #include <mail_proto.h>
48 #include <recipient_list.h>
49 #include <rcpt_print.h>
50 
51 /* rcpt_print - write recipient to stream */
52 
53 int     rcpt_print(ATTR_PRINT_MASTER_FN print_fn, VSTREAM *fp,
54 		           int flags, void *ptr)
55 {
56     RECIPIENT *rcpt = (RECIPIENT *) ptr;
57     int     ret;
58 
59     /*
60      * The attribute order is determined by backwards compatibility. It can
61      * be sanitized after all the ad-hoc recipient read/write code is
62      * replaced.
63      */
64     ret =
65 	print_fn(fp, flags | ATTR_FLAG_MORE,
66 		 SEND_ATTR_STR(MAIL_ATTR_ORCPT, rcpt->orig_addr),
67 		 SEND_ATTR_STR(MAIL_ATTR_RECIP, rcpt->address),
68 		 SEND_ATTR_LONG(MAIL_ATTR_OFFSET, rcpt->offset),
69 		 SEND_ATTR_STR(MAIL_ATTR_DSN_ORCPT, rcpt->dsn_orcpt),
70 		 SEND_ATTR_INT(MAIL_ATTR_DSN_NOTIFY, rcpt->dsn_notify),
71 		 ATTR_TYPE_END);
72     return (ret);
73 }
74