No empty .Rs/.Re
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / cleanup / cleanup_state.c
blobd96bd0d6467803defcbece119f5469b7cc7f606a
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* cleanup_state 3
6 /* SUMMARY
7 /* per-message state variables
8 /* SYNOPSIS
9 /* #include "cleanup.h"
11 /* CLEANUP_STATE *cleanup_state_alloc(src)
12 /* VSTREAM *src;
14 /* void cleanup_state_free(state)
15 /* CLEANUP_STATE *state;
16 /* DESCRIPTION
17 /* This module maintains about two dozen state variables
18 /* that are used by many routines in the course of processing one
19 /* message.
21 /* cleanup_state_alloc() initializes the per-message state variables.
23 /* cleanup_state_free() cleans up.
24 /* LICENSE
25 /* .ad
26 /* .fi
27 /* The Secure Mailer license must be distributed with this software.
28 /* AUTHOR(S)
29 /* Wietse Venema
30 /* IBM T.J. Watson Research
31 /* P.O. Box 704
32 /* Yorktown Heights, NY 10598, USA
33 /*--*/
35 /* System library. */
37 #include <sys_defs.h>
39 /* Utility library. */
41 #include <mymalloc.h>
42 #include <vstring.h>
43 #include <htable.h>
45 /* Global library. */
47 #include <been_here.h>
48 #include <mail_params.h>
49 #include <mime_state.h>
50 #include <mail_proto.h>
52 /* Milter library. */
54 #include <milter.h>
56 /* Application-specific. */
58 #include "cleanup.h"
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);
71 state->src = src;
72 state->dst = 0;
73 state->handle = 0;
74 state->queue_name = 0;
75 state->queue_id = 0;
76 state->arrival_time.tv_sec = state->arrival_time.tv_usec = 0;
77 state->fullname = 0;
78 state->sender = 0;
79 state->recip = 0;
80 state->orig_rcpt = 0;
81 state->return_receipt = 0;
82 state->errors_to = 0;
83 state->flags = 0;
84 state->qmgr_opts = 0;
85 state->errs = 0;
86 state->err_mask = 0;
87 state->headers_seen = 0;
88 state->hop_count = 0;
89 state->resent = "";
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;
103 state->reason = 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;
110 state->filter = 0;
111 state->redirect = 0;
112 state->dsn_envid = 0;
113 state->dsn_ret = 0;
114 state->dsn_notify = 0;
115 state->dsn_orcpt = 0;
116 state->verp_delims = 0;
117 state->milters = 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;
127 return (state);
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);
139 if (state->fullname)
140 myfree(state->fullname);
141 if (state->sender)
142 myfree(state->sender);
143 if (state->recip)
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);
153 if (state->queue_id)
154 myfree(state->queue_id);
155 been_here_free(state->dups);
156 if (state->reason)
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);
163 if (state->filter)
164 myfree(state->filter);
165 if (state->redirect)
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);
173 if (state->milters)
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);