1 /*++
2 /* NAME
3 /*	rcpt_print
4 /* SUMMARY
5 /*	write RECIPIENT structure to stream
6 /* SYNOPSIS
7 /*	#include <rcpt_print.h>
8 /*
9 /*	int     rcpt_print(print_fn, stream, flags, ptr)
10 /*	ATTR_PRINT_COMMON_FN print_fn;
11 /*	VSTREAM *stream;
12 /*	int	flags;
13 /*	void	*ptr;
14 /* DESCRIPTION
15 /*	rcpt_print() writes the contents of a RECIPIENT structure
16 /*	to the named stream using the specified attribute print
17 /*	routine. rcpt_print() is meant to be passed as a call-back
18 /*	to attr_print(), thusly:
19 /*
20 /*	... SEND_ATTR_FUNC(rcpt_print, (const void *) recipient), ...
21 /* DIAGNOSTICS
22 /*	Fatal: out of memory.
23 /* LICENSE
24 /* .ad
25 /* .fi
26 /*	The Secure Mailer license must be distributed with this
27 /*	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 <recipient_list.h>
52 #include <rcpt_print.h>
53 
54 /* rcpt_print - write recipient to stream */
55 
rcpt_print(ATTR_PRINT_COMMON_FN print_fn,VSTREAM * fp,int flags,const void * ptr)56 int     rcpt_print(ATTR_PRINT_COMMON_FN print_fn, VSTREAM *fp,
57 		           int flags, const void *ptr)
58 {
59     RECIPIENT *rcpt = (RECIPIENT *) ptr;
60     int     ret;
61 
62     /*
63      * The attribute order is determined by backwards compatibility. It can
64      * be sanitized after all the ad-hoc recipient read/write code is
65      * replaced.
66      */
67     ret =
68 	print_fn(fp, flags | ATTR_FLAG_MORE,
69 		 SEND_ATTR_STR(MAIL_ATTR_ORCPT, rcpt->orig_addr),
70 		 SEND_ATTR_STR(MAIL_ATTR_RECIP, rcpt->address),
71 		 SEND_ATTR_LONG(MAIL_ATTR_OFFSET, rcpt->offset),
72 		 SEND_ATTR_STR(MAIL_ATTR_DSN_ORCPT, rcpt->dsn_orcpt),
73 		 SEND_ATTR_INT(MAIL_ATTR_DSN_NOTIFY, rcpt->dsn_notify),
74 		 ATTR_TYPE_END);
75     return (ret);
76 }
77