7 /* map EHLO keywords to bit mask
9 /* #include <ehlo_mask.h>
11 /* #define EHLO_MASK_8BITMIME (1<<0)
12 /* #define EHLO_MASK_PIPELINING (1<<1)
13 /* #define EHLO_MASK_SIZE (1<<2)
14 /* #define EHLO_MASK_VRFY (1<<3)
15 /* #define EHLO_MASK_ETRN (1<<4)
16 /* #define EHLO_MASK_AUTH (1<<5)
17 /* #define EHLO_MASK_VERP (1<<6)
18 /* #define EHLO_MASK_STARTTLS (1<<7)
19 /* #define EHLO_MASK_XCLIENT (1<<8)
20 /* #define EHLO_MASK_XFORWARD (1<<9)
21 /* #define EHLO_MASK_ENHANCEDSTATUSCODES (1<<10)
22 /* #define EHLO_MASK_DSN (1<<11)
23 /* #define EHLO_MASK_SILENT (1<<15)
25 /* int ehlo_mask(keyword_list)
26 /* const char *keyword_list;
28 /* const char *str_ehlo_mask(bitmask)
31 /* ehlo_mask() computes the bit-wise OR of the masks that correspond
32 /* to the names listed in the \fIkeyword_list\fR argument, separated by
33 /* comma and/or whitespace characters. Undefined names are silently
36 /* str_ehlo_mask() translates a mask into its equivalent names.
37 /* The result is written to a static buffer that is overwritten
38 /* upon each call. Undefined bits cause a fatal run-time error.
40 /* Fatal: str_ehlo_mask() found an undefined bit.
44 /* The Secure Mailer license must be distributed with this software.
47 /* IBM T.J. Watson Research
49 /* Yorktown Heights, NY 10598, USA
56 /* Utility library. */
58 #include <name_mask.h>
62 #include <ehlo_mask.h>
67 static const NAME_MASK ehlo_mask_table
[] = {
68 "8BITMIME", EHLO_MASK_8BITMIME
,
69 "AUTH", EHLO_MASK_AUTH
,
70 "ETRN", EHLO_MASK_ETRN
,
71 "PIPELINING", EHLO_MASK_PIPELINING
,
72 "SIZE", EHLO_MASK_SIZE
,
73 "VERP", EHLO_MASK_VERP
,
74 "VRFY", EHLO_MASK_VRFY
,
75 "XCLIENT", EHLO_MASK_XCLIENT
,
76 "XFORWARD", EHLO_MASK_XFORWARD
,
77 "STARTTLS", EHLO_MASK_STARTTLS
,
78 "ENHANCEDSTATUSCODES", EHLO_MASK_ENHANCEDSTATUSCODES
,
80 "SILENT-DISCARD", EHLO_MASK_SILENT
, /* XXX In-band signaling */
84 /* ehlo_mask - string to bit mask */
86 int ehlo_mask(const char *mask_str
)
90 * We allow "STARTTLS" besides "starttls, because EHLO keywords are often
91 * spelled in uppercase. We ignore non-existent EHLO keywords so people
92 * can switch between Postfix versions without trouble.
94 return (name_mask_opt("ehlo string mask", ehlo_mask_table
,
95 mask_str
, NAME_MASK_ANY_CASE
));
98 /* str_ehlo_mask - mask to string */
100 const char *str_ehlo_mask(int mask_bits
)
104 * We don't allow non-existent bits. Doing so makes no sense at this
107 return (str_name_mask("ehlo bitmask", ehlo_mask_table
, mask_bits
));
113 * Stand-alone test program.
118 #include <vstring_vstream.h>
120 int main(int unused_argc
, char **unused_argv
)
123 VSTRING
*buf
= vstring_alloc(1);
124 const char *mask_string
;
126 while (vstring_get_nonl(buf
, VSTREAM_IN
) != VSTREAM_EOF
) {
127 mask_bits
= ehlo_mask(vstring_str(buf
));
128 mask_string
= str_ehlo_mask(mask_bits
);
129 vstream_printf("%s -> 0x%x -> %s\n", vstring_str(buf
), mask_bits
,
131 vstream_fflush(VSTREAM_OUT
);