1 /*        $NetBSD: rcpt_print.c,v 1.3 2022/10/08 16:12: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_COMMON_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, (const 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 /*        Wietse Venema
37 /*        Google, Inc.
38 /*        111 8th Avenue
39 /*        New York, NY 10011, USA
40 /*--*/
41 
42 /* System library. */
43 
44 #include <sys_defs.h>
45 
46 /* Utility library. */
47 
48 #include <attr.h>
49 
50 /* Global library. */
51 
52 #include <mail_proto.h>
53 #include <recipient_list.h>
54 #include <rcpt_print.h>
55 
56 /* rcpt_print - write recipient to stream */
57 
rcpt_print(ATTR_PRINT_COMMON_FN print_fn,VSTREAM * fp,int flags,const void * ptr)58 int     rcpt_print(ATTR_PRINT_COMMON_FN print_fn, VSTREAM *fp,
59                                int flags, const void *ptr)
60 {
61     RECIPIENT *rcpt = (RECIPIENT *) ptr;
62     int     ret;
63 
64     /*
65      * The attribute order is determined by backwards compatibility. It can
66      * be sanitized after all the ad-hoc recipient read/write code is
67      * replaced.
68      */
69     ret =
70           print_fn(fp, flags | ATTR_FLAG_MORE,
71                      SEND_ATTR_STR(MAIL_ATTR_ORCPT, rcpt->orig_addr),
72                      SEND_ATTR_STR(MAIL_ATTR_RECIP, rcpt->address),
73                      SEND_ATTR_LONG(MAIL_ATTR_OFFSET, rcpt->offset),
74                      SEND_ATTR_STR(MAIL_ATTR_DSN_ORCPT, rcpt->dsn_orcpt),
75                      SEND_ATTR_INT(MAIL_ATTR_DSN_NOTIFY, rcpt->dsn_notify),
76                      ATTR_TYPE_END);
77     return (ret);
78 }
79