7 /* recipient buffer manager
9 /* #include <rcpt_buf.h>
12 /* RECIPIENT rcpt; /* convenience */
14 /* VSTRING *address; /* final recipient */
15 /* VSTRING *orig_addr; /* original recipient */
16 /* VSTRING *dsn_orcpt; /* dsn original recipient */
17 /* int dsn_notify; /* DSN notify flags */
18 /* long offset; /* REC_TYPE_RCPT byte */
22 /* RECIPIENT *RECIPIENT_FROM_RCPT_BUF(rcpb)
25 /* RCPT_BUF *rcpb_create(void)
27 /* void rcpb_reset(rcpb)
30 /* void rcpb_free(rcpb)
33 /* int rcpb_scan(scan_fn, stream, flags, ptr)
34 /* ATTR_SCAN_MASTER_FN scan_fn;
39 /* RECIPIENT_FROM_RCPT_BUF() populates the rcpt member with
40 /* a shallow copy of the contents of the other fields.
42 /* rcpb_scan() reads a recipient buffer from the named stream
43 /* using the specified attribute scan routine. rcpb_scan()
44 /* is meant to be passed as a call-back to attr_scan(), thusly:
46 /* ... ATTR_TYPE_FUNC, rcpb_scan, (void *) rcpt_buf, ...
48 /* rcpb_create(), rcpb_reset() and rcpb_free() create, wipe
49 /* and destroy recipient buffer instances.
51 /* Fatal: out of memory.
55 /* The Secure Mailer license must be distributed with this software.
58 /* IBM T.J. Watson Research
60 /* Yorktown Heights, NY 10598, USA
67 /* Utility library. */
75 #include <mail_proto.h>
78 /* Application-specific. */
80 /* rcpb_create - create recipient buffer */
82 RCPT_BUF
*rcpb_create(void)
86 rcpt
= (RCPT_BUF
*) mymalloc(sizeof(*rcpt
));
88 rcpt
->dsn_orcpt
= vstring_alloc(10);
90 rcpt
->orig_addr
= vstring_alloc(10);
91 rcpt
->address
= vstring_alloc(10);
95 /* rcpb_reset - reset recipient buffer */
97 void rcpb_reset(RCPT_BUF
*rcpt
)
99 #define BUF_TRUNCATE(s) (vstring_str(s)[0] = 0)
102 BUF_TRUNCATE(rcpt
->dsn_orcpt
);
103 rcpt
->dsn_notify
= 0;
104 BUF_TRUNCATE(rcpt
->orig_addr
);
105 BUF_TRUNCATE(rcpt
->address
);
108 /* rcpb_free - destroy recipient buffer */
110 void rcpb_free(RCPT_BUF
*rcpt
)
112 vstring_free(rcpt
->dsn_orcpt
);
113 vstring_free(rcpt
->orig_addr
);
114 vstring_free(rcpt
->address
);
115 myfree((char *) rcpt
);
118 /* rcpb_scan - receive recipient buffer */
120 int rcpb_scan(ATTR_SCAN_MASTER_FN scan_fn
, VSTREAM
*fp
,
121 int flags
, void *ptr
)
123 RCPT_BUF
*rcpt
= (RCPT_BUF
*) ptr
;
127 * The order of attributes is determined by historical compatibility and
128 * can be fixed after all the ad-hoc read/write code is replaced.
130 ret
= scan_fn(fp
, flags
| ATTR_FLAG_MORE
,
131 ATTR_TYPE_STR
, MAIL_ATTR_ORCPT
, rcpt
->orig_addr
,
132 ATTR_TYPE_STR
, MAIL_ATTR_RECIP
, rcpt
->address
,
133 ATTR_TYPE_LONG
, MAIL_ATTR_OFFSET
, &rcpt
->offset
,
134 ATTR_TYPE_STR
, MAIL_ATTR_DSN_ORCPT
, rcpt
->dsn_orcpt
,
135 ATTR_TYPE_INT
, MAIL_ATTR_DSN_NOTIFY
, &rcpt
->dsn_notify
,
137 return (ret
== 5 ? 1 : -1);