Lines Matching refs:state
14 /* void cleanup_control(state, flags)
15 /* CLEANUP_STATE *state;
18 /* void CLEANUP_RECORD(state, type, buf, len)
19 /* CLEANUP_STATE *state;
24 /* int cleanup_flush(state)
25 /* CLEANUP_STATE *state;
27 /* int cleanup_free(state)
28 /* CLEANUP_STATE *state;
67 /* little state machine. The last record in a valid message has type
69 /* the caller is encouraged to test the CLEANUP_OUT_OK(state) macro.
76 /* the state->reason member. In all other cases, use cleanup_strerror()
142 CLEANUP_STATE *state;
152 * Initialize private state.
154 state = cleanup_state_alloc(src);
163 state->queue_name = mystrdup(MAIL_QUEUE_INCOMING);
164 state->handle = mail_stream_file(state->queue_name,
166 state->dst = state->handle->stream;
167 cleanup_path = mystrdup(VSTREAM_PATH(state->dst));
168 state->queue_id = mystrdup(state->handle->id);
182 if (mail_queue_remove(*cpp, state->queue_id) == 0)
183 msg_warn("%s: removed spurious %s log", *cpp, state->queue_id);
185 msg_fatal("%s: remove %s log: %m", *cpp, state->queue_id);
187 return (state);
192 void cleanup_control(CLEANUP_STATE *state, int flags)
205 if ((state->flags = flags) & CLEANUP_FLAG_BOUNCE) {
206 state->err_mask = CLEANUP_STAT_MASK_INCOMPLETE;
208 state->err_mask = ~0;
210 if (state->flags & CLEANUP_FLAG_SMTPUTF8)
211 state->smtputf8 = SMTPUTF8_FLAG_REQUESTED;
216 int cleanup_flush(CLEANUP_STATE *state)
225 if (CLEANUP_OUT_OK(state)) {
226 if (state->recip == 0)
227 state->errs |= CLEANUP_STAT_RCPT;
228 if ((state->flags & CLEANUP_FLAG_END_SEEN) == 0)
229 state->errs |= CLEANUP_STAT_BAD;
236 if (state->flags & CLEANUP_FLAG_DISCARD)
237 state->errs = 0;
244 if (CLEANUP_MILTER_OK(state)) {
245 if (state->milters)
246 cleanup_milter_inspect(state, state->milters);
248 cleanup_milter_emul_data(state, cleanup_milters);
249 if (CLEANUP_MILTER_OK(state))
250 cleanup_milter_inspect(state, cleanup_milters);
258 if (CLEANUP_OUT_OK(state))
259 cleanup_final(state);
284 ((state->errs & CLEANUP_STAT_MASK_CANT_BOUNCE) == 0 \
285 && state->sender != 0 \
286 && (state->flags & CLEANUP_FLAG_BOUNCE) != 0)
288 if (state->errs != 0 && CAN_BOUNCE())
289 cleanup_bounce(state);
301 if (state->errs == 0 && (state->flags & CLEANUP_FLAG_DISCARD) == 0) {
302 if ((state->flags & CLEANUP_FLAG_HOLD) != 0
304 || state->defer_delay > 0
307 myfree(state->queue_name);
309 state->queue_name = mystrdup((state->flags & CLEANUP_FLAG_HOLD) ?
312 state->queue_name = mystrdup(MAIL_QUEUE_HOLD);
314 mail_stream_ctl(state->handle,
315 CA_MAIL_STREAM_CTL_QUEUE(state->queue_name),
319 CA_MAIL_STREAM_CTL_DELAY(state->defer_delay),
323 cleanup_path = mystrdup(VSTREAM_PATH(state->handle->stream));
334 state->errs = mail_stream_finish(state->handle, (VSTRING *) 0);
344 mail_stream_cleanup(state->handle);
346 state->handle = 0;
347 state->dst = 0;
354 if (state->errs != 0 || (state->flags & CLEANUP_FLAG_DISCARD) != 0) {
376 * Cleanup internal state. This is simply complementary to the
380 msg_info("cleanup_flush: status %d", state->errs);
381 status = state->errs;
387 void cleanup_free(CLEANUP_STATE *state)
394 if (cleanup_milters != 0 && state->milters == 0)
396 cleanup_state_free(state);