7 /* cleanup flags code to string
9 /* #include <cleanup_user.h>
11 /* const char *cleanup_strflags(code)
14 /* cleanup_strflags() maps a CLEANUP_FLAGS code to printable string.
15 /* The result is for read purposes only. The result is overwritten
20 /* The Secure Mailer license must be distributed with this software.
23 /* IBM T.J. Watson Research
25 /* Yorktown Heights, NY 10598, USA
32 /* Utility library. */
39 #include "cleanup_user.h"
42 * Mapping from flags code to printable string.
44 struct cleanup_flag_map
{
49 static struct cleanup_flag_map cleanup_flag_map
[] = {
50 CLEANUP_FLAG_BOUNCE
, "enable_bad_mail_bounce",
51 CLEANUP_FLAG_FILTER
, "enable_header_body_filter",
52 CLEANUP_FLAG_HOLD
, "hold_message",
53 CLEANUP_FLAG_DISCARD
, "discard_message",
54 CLEANUP_FLAG_BCC_OK
, "enable_automatic_bcc",
55 CLEANUP_FLAG_MAP_OK
, "enable_address_mapping",
56 CLEANUP_FLAG_MILTER
, "enable_milters",
57 CLEANUP_FLAG_SMTP_REPLY
, "enable_smtp_reply",
60 /* cleanup_strflags - map flags code to printable string */
62 const char *cleanup_strflags(unsigned flags
)
64 static VSTRING
*result
;
71 result
= vstring_alloc(20);
73 VSTRING_RESET(result
);
75 for (i
= 0; i
< sizeof(cleanup_flag_map
) / sizeof(cleanup_flag_map
[0]); i
++) {
76 if (cleanup_flag_map
[i
].flag
& flags
) {
77 vstring_sprintf_append(result
, "%s ", cleanup_flag_map
[i
].text
);
78 flags
&= ~cleanup_flag_map
[i
].flag
;
82 if (flags
!= 0 || VSTRING_LEN(result
) == 0)
83 msg_panic("cleanup_strflags: unrecognized flag value(s) 0x%x", flags
);
85 vstring_truncate(result
, VSTRING_LEN(result
) - 1);
86 VSTRING_TERMINATE(result
);
88 return (vstring_str(result
));