7 /* per-message state variables
9 /* #include "cleanup.h"
11 /* CLEANUP_STATE *cleanup_state_alloc(src)
14 /* void cleanup_state_free(state)
15 /* CLEANUP_STATE *state;
17 /* This module maintains about two dozen state variables
18 /* that are used by many routines in the course of processing one
21 /* cleanup_state_alloc() initializes the per-message state variables.
23 /* cleanup_state_free() cleans up.
27 /* The Secure Mailer license must be distributed with this software.
30 /* IBM T.J. Watson Research
32 /* Yorktown Heights, NY 10598, USA
39 /* Utility library. */
47 #include <been_here.h>
48 #include <mail_params.h>
49 #include <mime_state.h>
50 #include <mail_proto.h>
56 /* Application-specific. */
60 /* cleanup_state_alloc - initialize global state */
62 CLEANUP_STATE
*cleanup_state_alloc(VSTREAM
*src
)
64 CLEANUP_STATE
*state
= (CLEANUP_STATE
*) mymalloc(sizeof(*state
));
66 state
->attr_buf
= vstring_alloc(10);
67 state
->temp1
= vstring_alloc(10);
68 state
->temp2
= vstring_alloc(10);
69 if (cleanup_strip_chars
)
70 state
->stripped_buf
= vstring_alloc(10);
74 state
->queue_name
= 0;
76 state
->arrival_time
.tv_sec
= state
->arrival_time
.tv_usec
= 0;
81 state
->return_receipt
= 0;
87 state
->headers_seen
= 0;
90 state
->dups
= been_here_init(var_dup_filter_limit
, BH_FLAG_FOLD
);
91 state
->action
= cleanup_envelope
;
92 state
->data_offset
= -1;
93 state
->body_offset
= -1;
94 state
->xtra_offset
= -1;
95 state
->cont_length
= 0;
96 state
->sender_pt_offset
= -1;
97 state
->sender_pt_target
= -1;
98 state
->append_rcpt_pt_offset
= -1;
99 state
->append_rcpt_pt_target
= -1;
100 state
->append_hdr_pt_offset
= -1;
101 state
->append_hdr_pt_target
= -1;
102 state
->rcpt_count
= 0;
104 state
->smtp_reply
= 0;
105 state
->attr
= nvtable_create(10);
106 nvtable_update(state
->attr
, MAIL_ATTR_LOG_ORIGIN
, MAIL_ATTR_ORG_LOCAL
);
107 state
->mime_state
= 0;
108 state
->mime_errs
= 0;
109 state
->hdr_rewrite_context
= MAIL_ATTR_RWR_LOCAL
;
112 state
->dsn_envid
= 0;
114 state
->dsn_notify
= 0;
115 state
->dsn_orcpt
= 0;
116 state
->verp_delims
= 0;
118 state
->client_name
= 0;
119 state
->reverse_name
= 0;
120 state
->client_addr
= 0;
121 state
->client_af
= 0;
122 state
->client_port
= 0;
123 state
->milter_ext_from
= 0;
124 state
->milter_ext_rcpt
= 0;
125 state
->milter_err_text
= 0;
126 state
->free_regions
= state
->body_regions
= state
->curr_body_region
= 0;
130 /* cleanup_state_free - destroy global state */
132 void cleanup_state_free(CLEANUP_STATE
*state
)
134 vstring_free(state
->attr_buf
);
135 vstring_free(state
->temp1
);
136 vstring_free(state
->temp2
);
137 if (cleanup_strip_chars
)
138 vstring_free(state
->stripped_buf
);
140 myfree(state
->fullname
);
142 myfree(state
->sender
);
144 myfree(state
->recip
);
145 if (state
->orig_rcpt
)
146 myfree(state
->orig_rcpt
);
147 if (state
->return_receipt
)
148 myfree(state
->return_receipt
);
149 if (state
->errors_to
)
150 myfree(state
->errors_to
);
151 if (state
->queue_name
)
152 myfree(state
->queue_name
);
154 myfree(state
->queue_id
);
155 been_here_free(state
->dups
);
157 myfree(state
->reason
);
158 if (state
->smtp_reply
)
159 myfree(state
->smtp_reply
);
160 nvtable_free(state
->attr
);
161 if (state
->mime_state
)
162 mime_state_free(state
->mime_state
);
164 myfree(state
->filter
);
166 myfree(state
->redirect
);
167 if (state
->dsn_envid
)
168 myfree(state
->dsn_envid
);
169 if (state
->dsn_orcpt
)
170 myfree(state
->dsn_orcpt
);
171 if (state
->verp_delims
)
172 myfree(state
->verp_delims
);
174 milter_free(state
->milters
);
175 if (state
->milter_ext_from
)
176 vstring_free(state
->milter_ext_from
);
177 if (state
->milter_ext_rcpt
)
178 vstring_free(state
->milter_ext_rcpt
);
179 if (state
->milter_err_text
)
180 vstring_free(state
->milter_err_text
);
181 cleanup_region_done(state
);
182 myfree((char *) state
);