Mercurial > sm-archive
comparison src/sm-archive.cpp @ 8:ed73e6361570 stable-1-0
initial version
author | carl |
---|---|
date | Fri, 10 Mar 2006 12:55:07 -0800 |
parents | 5241a079fe03 |
children | 48880e61ce5e |
comparison
equal
deleted
inserted
replaced
7:5241a079fe03 | 8:ed73e6361570 |
---|---|
84 mlfiPriv::mlfiPriv() { | 84 mlfiPriv::mlfiPriv() { |
85 pthread_mutex_lock(&config_mutex); | 85 pthread_mutex_lock(&config_mutex); |
86 pc = config; | 86 pc = config; |
87 pc->reference_count++; | 87 pc->reference_count++; |
88 pthread_mutex_unlock(&config_mutex); | 88 pthread_mutex_unlock(&config_mutex); |
89 mailaddr = NULL; | 89 mailaddr = NULL; |
90 queueid = NULL; | 90 queueid = NULL; |
91 processed_from = false; | |
92 } | 91 } |
93 | 92 |
94 mlfiPriv::~mlfiPriv() { | 93 mlfiPriv::~mlfiPriv() { |
95 pthread_mutex_lock(&config_mutex); | 94 pthread_mutex_lock(&config_mutex); |
96 pc->reference_count--; | 95 pc->reference_count--; |
97 pthread_mutex_unlock(&config_mutex); | 96 pthread_mutex_unlock(&config_mutex); |
98 reset(true); | 97 reset(true); |
99 } | 98 } |
100 | 99 |
101 void mlfiPriv::reset(bool final) { | 100 void mlfiPriv::reset(bool final) { |
102 processed_from = false; | 101 targets.clear(); |
103 if (mailaddr) free(mailaddr); | 102 if (mailaddr) free(mailaddr); |
104 if (queueid) free(queueid); | 103 if (queueid) free(queueid); |
105 if (!final) { | 104 if (!final) { |
106 mailaddr = NULL; | 105 mailaddr = NULL; |
107 queueid = NULL; | 106 queueid = NULL; |
174 mlfiPriv &priv = *MLFIPRIV; | 173 mlfiPriv &priv = *MLFIPRIV; |
175 priv.mailaddr = to_lower_string(from[0]); | 174 priv.mailaddr = to_lower_string(from[0]); |
176 return SMFIS_CONTINUE; | 175 return SMFIS_CONTINUE; |
177 } | 176 } |
178 | 177 |
179 void add_target(mlfiPriv &priv, SMFICTX *ctx, char *target); | 178 void add_target(mlfiPriv &priv, char *target); |
180 void add_target(mlfiPriv &priv, SMFICTX *ctx, char *target) | 179 void add_target(mlfiPriv &priv, char *target) |
181 { | 180 { |
182 if (target) { | 181 if (target) { |
183 smfi_addrcpt(ctx, target); | 182 string_set::iterator i = priv.targets.find(target); |
184 if (debug_syslog > 1) { | 183 if (i == priv.targets.end()) priv.targets.insert(target); |
185 char msg[maxlen]; | |
186 snprintf(msg, sizeof(msg), "adding recipient <%s>", target); | |
187 my_syslog(&priv, msg); | |
188 } | |
189 } | 184 } |
190 } | 185 } |
191 | 186 |
192 sfsistat mlfi_envrcpt(SMFICTX *ctx, char **rcpt) | 187 sfsistat mlfi_envrcpt(SMFICTX *ctx, char **rcpt) |
193 { | 188 { |
199 char msg[maxlen]; | 194 char msg[maxlen]; |
200 snprintf(msg, sizeof(msg), "from <%s> to <%s>", priv.mailaddr, rcptaddr); | 195 snprintf(msg, sizeof(msg), "from <%s> to <%s>", priv.mailaddr, rcptaddr); |
201 my_syslog(&priv, msg); | 196 my_syslog(&priv, msg); |
202 } | 197 } |
203 char *target = dc.find_to(rcptaddr); | 198 char *target = dc.find_to(rcptaddr); |
204 add_target(priv, ctx, target); | |
205 free(rcptaddr); | 199 free(rcptaddr); |
206 if (!priv.processed_from) { | 200 add_target(priv, target); |
207 target = dc.find_from(priv.mailaddr); | |
208 add_target(priv, ctx, target); | |
209 priv.processed_from = true; | |
210 } | |
211 return SMFIS_CONTINUE; | 201 return SMFIS_CONTINUE; |
212 } | 202 } |
213 | 203 |
214 sfsistat mlfi_eom(SMFICTX *ctx) | 204 sfsistat mlfi_eom(SMFICTX *ctx) |
215 { | 205 { |
206 mlfiPriv &priv = *MLFIPRIV; | |
207 CONFIG &dc = *priv.pc; | |
208 char *target = dc.find_from(priv.mailaddr); | |
209 add_target(priv, target); | |
210 for (string_set::iterator i=priv.targets.begin(); i!=priv.targets.end(); i++) { | |
211 target = (*i); | |
212 smfi_addrcpt(ctx, target); | |
213 if (debug_syslog > 1) { | |
214 char msg[maxlen]; | |
215 snprintf(msg, sizeof(msg), "adding recipient <%s>", target); | |
216 my_syslog(&priv, msg); | |
217 } | |
218 } | |
216 // reset for a new message on the same connection | 219 // reset for a new message on the same connection |
217 mlfi_abort(ctx); | 220 mlfi_abort(ctx); |
218 return SMFIS_CONTINUE; | 221 return SMFIS_CONTINUE; |
219 } | 222 } |
220 | 223 |