xref: /netbsd-src/external/ibm-public/postfix/dist/src/global/rcpt_print.c (revision 413d532bcc3f62d122e56d92e13ac64825a40baf)
1 /*	$NetBSD: rcpt_print.c,v 1.1.1.1 2009/06/23 10:08:47 tron 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 /*	... ATTR_TYPE_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 IBM T.J. Watson Research P.O. Box 704 Yorktown
32 /*	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 <recipient_list.h>
47 #include <rcpt_print.h>
48 
49 /* rcpt_print - write recipient to stream */
50 
51 int     rcpt_print(ATTR_PRINT_MASTER_FN print_fn, VSTREAM *fp,
52 		           int flags, void *ptr)
53 {
54     RECIPIENT *rcpt = (RECIPIENT *) ptr;
55     int     ret;
56 
57     /*
58      * The attribute order is determined by backwards compatibility. It can
59      * be sanitized after all the ad-hoc recipient read/write code is
60      * replaced.
61      */
62     ret =
63 	print_fn(fp, flags | ATTR_FLAG_MORE,
64 		 ATTR_TYPE_STR, MAIL_ATTR_ORCPT, rcpt->orig_addr,
65 		 ATTR_TYPE_STR, MAIL_ATTR_RECIP, rcpt->address,
66 		 ATTR_TYPE_LONG, MAIL_ATTR_OFFSET, rcpt->offset,
67 		 ATTR_TYPE_STR, MAIL_ATTR_DSN_ORCPT, rcpt->dsn_orcpt,
68 		 ATTR_TYPE_INT, MAIL_ATTR_DSN_NOTIFY, rcpt->dsn_notify,
69 		 ATTR_TYPE_END);
70     return (ret);
71 }
72