7 /* DSN embedding in SMTP
9 /* #include <dsn_mask.h>
11 /* int dsn_notify_mask(str)
14 /* const char *dsn_notify_str(mask)
17 /* int dsn_ret_code(str)
20 /* const char *dsn_ret_str(code)
23 /* dsn_ret_code() converts the parameters of a MAIL FROM ..
24 /* RET option to internal form.
26 /* dsn_ret_str() converts internal form to the representation
27 /* used in the MAIL FROM .. RET command. The result is in
28 /* stable and static memory.
30 /* dsn_notify_mask() converts the parameters of a RCPT TO ..
31 /* NOTIFY option to internal form.
33 /* dsn_notify_str() converts internal form to the representation
34 /* used in the MAIL FROM .. NOTIFY command. The result is in
35 /* volatile memory and is clobbered whenever str_name_mask()
40 /* Information received with the MAIL FROM or RCPT TO command.
42 /* Internal representation.
44 /* dsn_ret_code() and dsn_notify_mask() return 0 when the string
45 /* specifies an invalid request.
47 /* dsn_ret_str() and dsn_notify_str() abort on failure.
51 /* The Secure Mailer license must be distributed with this software.
54 /* IBM T.J. Watson Research
56 /* Yorktown Heights, NY 10598, USA
64 /* Utility library. */
66 #include <name_code.h>
67 #include <name_mask.h>
74 /* Application-specific. */
76 static const NAME_MASK dsn_notify_table
[] = {
77 "NEVER", DSN_NOTIFY_NEVER
,
78 "SUCCESS", DSN_NOTIFY_SUCCESS
,
79 "FAILURE", DSN_NOTIFY_FAILURE
,
80 "DELAY", DSN_NOTIFY_DELAY
,
84 static const NAME_CODE dsn_ret_table
[] = {
90 /* dsn_ret_code - string to mask */
92 int dsn_ret_code(const char *str
)
94 return (name_code(dsn_ret_table
, NAME_CODE_FLAG_NONE
, str
));
97 /* dsn_ret_str - mask to string */
99 const char *dsn_ret_str(int code
)
103 if ((cp
= str_name_code(dsn_ret_table
, code
)) == 0)
104 msg_panic("dsn_ret_str: unknown code %d", code
);
108 /* dsn_notify_mask - string to mask */
110 int dsn_notify_mask(const char *str
)
112 int mask
= name_mask_opt("DSN NOTIFY command", dsn_notify_table
,
113 str
, NAME_MASK_ANY_CASE
| NAME_MASK_RETURN
);
115 return (DSN_NOTIFY_OK(mask
) ? mask
: 0);
118 /* dsn_notify_str - mask to string */
120 const char *dsn_notify_str(int mask
)
122 return (str_name_mask_opt((VSTRING
*) 0, "DSN NOTIFY command",
123 dsn_notify_table
, mask
,
124 NAME_MASK_FATAL
| NAME_MASK_COMMA
));