#include <vstring.h>
#include <vstream.h>
#include <argv.h>
#include <nvtable.h>
#include <maps.h>
#include <tok822.h>
#include <been_here.h>
#include <mail_stream.h>
#include <mail_conf.h>
#include <mime_state.h>
#include <string_list.h>
typedef struct CLEANUP_STATE {
VSTRING *temp1;
VSTRING *temp2;
VSTREAM *dst;
MAIL_STREAM *handle;
char *queue_name;
char *queue_id;
time_t time;
char *fullname;
char *sender;
char *from;
char *resent_from;
char *recip;
char *orig_rcpt;
char *return_receipt;
char *errors_to;
int flags;
int qmgr_opts;
int errs;
int err_mask;
int headers_seen;
int hop_count;
char *resent;
BH_TABLE *dups;
void (*action) (struct CLEANUP_STATE *, int, const char *, int);
off_t data_offset;
off_t xtra_offset;
int rcpt_count;
char *reason;
NVTABLE *attr;
MIME_STATE *mime_state;
int mime_errs;
char *filter;
char *redirect;
} CLEANUP_STATE;
#define CLEANUP_FLAG_INRCPT (1<<16)
#define CLEANUP_FLAG_WARN_SEEN (1<<17)
#define CLEANUP_FLAG_END_SEEN (1<<18)
extern MAPS *cleanup_comm_canon_maps;
extern MAPS *cleanup_send_canon_maps;
extern MAPS *cleanup_rcpt_canon_maps;
extern MAPS *cleanup_header_checks;
extern MAPS *cleanup_mimehdr_checks;
extern MAPS *cleanup_nesthdr_checks;
extern MAPS *cleanup_body_checks;
extern MAPS *cleanup_virt_alias_maps;
extern ARGV *cleanup_masq_domains;
extern STRING_LIST *cleanup_masq_exceptions;
extern int cleanup_masq_flags;
extern MAPS *cleanup_send_bcc_maps;
extern MAPS *cleanup_rcpt_bcc_maps;
#define CLEANUP_MASQ_FLAG_ENV_FROM (1<<0)
#define CLEANUP_MASQ_FLAG_ENV_RCPT (1<<1)
#define CLEANUP_MASQ_FLAG_HDR_FROM (1<<2)
#define CLEANUP_MASQ_FLAG_HDR_RCPT (1<<3)
extern int cleanup_ext_prop_mask;
extern char *cleanup_path;
extern CLEANUP_STATE *cleanup_state_alloc(void);
extern void cleanup_state_free(CLEANUP_STATE *);
extern CLEANUP_STATE *cleanup_open(void);
extern void cleanup_control(CLEANUP_STATE *, int);
extern int cleanup_flush(CLEANUP_STATE *);
extern void cleanup_free(CLEANUP_STATE *);
extern void cleanup_all(void);
extern void cleanup_pre_jail(char *, char **);
extern void cleanup_post_jail(char *, char **);
extern CONFIG_INT_TABLE cleanup_int_table[];
extern CONFIG_BOOL_TABLE cleanup_bool_table[];
extern CONFIG_STR_TABLE cleanup_str_table[];
extern CONFIG_TIME_TABLE cleanup_time_table[];
#define CLEANUP_RECORD(s, t, b, l) ((s)->action((s), (t), (b), (l)))
extern void cleanup_out(CLEANUP_STATE *, int, const char *, int);
extern void cleanup_out_string(CLEANUP_STATE *, int, const char *);
extern void PRINTFLIKE(3, 4) cleanup_out_format(CLEANUP_STATE *, int, const char *,...);
#define CLEANUP_OUT_BUF(s, t, b) \
cleanup_out((s), (t), vstring_str((b)), VSTRING_LEN((b)))
#define CLEANUP_OUT_OK(s) \
(!((s)->errs & (s)->err_mask) && !((s)->flags & CLEANUP_FLAG_DISCARD))
extern void cleanup_envelope(CLEANUP_STATE *, int, const char *, int);
extern void cleanup_message(CLEANUP_STATE *, int, const char *, int);
extern void cleanup_extracted(CLEANUP_STATE *, int, const char *, int);
extern void cleanup_rewrite_external(VSTRING *, const char *);
extern void cleanup_rewrite_internal(VSTRING *, const char *);
extern void cleanup_rewrite_tree(TOK822 *);
extern void cleanup_map11_external(CLEANUP_STATE *, VSTRING *, MAPS *, int);
extern void cleanup_map11_internal(CLEANUP_STATE *, VSTRING *, MAPS *, int);
extern void cleanup_map11_tree(CLEANUP_STATE *, TOK822 *, MAPS *, int);
ARGV *cleanup_map1n_internal(CLEANUP_STATE *, const char *, MAPS *, int);
extern void cleanup_masquerade_external(VSTRING *, ARGV *);
extern void cleanup_masquerade_internal(VSTRING *, ARGV *);
extern void cleanup_masquerade_tree(TOK822 *, ARGV *);
extern void cleanup_out_recipient(CLEANUP_STATE *, const char *, const char *);
extern void cleanup_addr_sender(CLEANUP_STATE *, const char *);
extern void cleanup_addr_recipient(CLEANUP_STATE *, const char *);
extern void cleanup_addr_bcc(CLEANUP_STATE *, const char *);