Mercurial > masqmail
comparison src/route.c @ 367:b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
Now we use:
/*
** comment
*/
This makes the indent style simpler, too.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Thu, 20 Oct 2011 10:20:59 +0200 |
parents | 41958685480d |
children | 4cab237ce923 |
comparison
equal
deleted
inserted
replaced
366:41958685480d | 367:b27f66555ba8 |
---|---|
1 /* MasqMail | 1 /* |
2 Copyright (C) 1999-2001 Oliver Kurth | 2 ** MasqMail |
3 Copyright (C) 2010 markus schnalke <meillo@marmaro.de> | 3 ** Copyright (C) 1999-2001 Oliver Kurth |
4 | 4 ** Copyright (C) 2010 markus schnalke <meillo@marmaro.de> |
5 This program is free software; you can redistribute it and/or modify | 5 ** |
6 it under the terms of the GNU General Public License as published by | 6 ** This program is free software; you can redistribute it and/or modify |
7 the Free Software Foundation; either version 2 of the License, or | 7 ** it under the terms of the GNU General Public License as published by |
8 (at your option) any later version. | 8 ** the Free Software Foundation; either version 2 of the License, or |
9 | 9 ** (at your option) any later version. |
10 This program is distributed in the hope that it will be useful, | 10 ** |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 ** This program is distributed in the hope that it will be useful, |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 GNU General Public License for more details. | 13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | 14 ** GNU General Public License for more details. |
15 You should have received a copy of the GNU General Public License | 15 ** |
16 along with this program; if not, write to the Free Software | 16 ** You should have received a copy of the GNU General Public License |
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 ** along with this program; if not, write to the Free Software |
18 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 */ | 19 */ |
19 | 20 |
20 #include <fnmatch.h> | 21 #include <fnmatch.h> |
21 | 22 |
22 #include "masqmail.h" | 23 #include "masqmail.h" |
48 } | 49 } |
49 | 50 |
50 void | 51 void |
51 rewrite_headers(msg_out *msgout, connect_route *route) | 52 rewrite_headers(msg_out *msgout, connect_route *route) |
52 { | 53 { |
53 /* if set_h_from_domain is set, replace domain in all | 54 /* |
54 From: headers. | 55 ** if set_h_from_domain is set, replace domain in all |
55 */ | 56 ** From: headers. |
57 */ | |
56 msgout->hdr_list = g_list_copy(msgout->msg->hdr_list); | 58 msgout->hdr_list = g_list_copy(msgout->msg->hdr_list); |
57 | 59 |
58 /* map from addresses */ | 60 /* map from addresses */ |
59 if (route->map_h_from_addresses != NULL) { | 61 if (route->map_h_from_addresses != NULL) { |
60 GList *hdr_node; | 62 GList *hdr_node; |
189 } | 191 } |
190 DEBUG(5) debugf("rewrite_headers() returning\n"); | 192 DEBUG(5) debugf("rewrite_headers() returning\n"); |
191 } | 193 } |
192 | 194 |
193 /* | 195 /* |
194 Split a recipient list into the three groups: | 196 ** Split a recipient list into the three groups: |
195 - local recipients | 197 ** - local recipients |
196 - those maching the patterns | 198 ** - those maching the patterns |
197 - those not matching the patterns | 199 ** - those not matching the patterns |
198 If patterns is NULL: only splitting between local and others is done. | 200 ** If patterns is NULL: only splitting between local and others is done. |
199 */ | 201 */ |
200 void | 202 void |
201 split_rcpts(GList *rcpt_list, GList *patterns, GList **rl_local, GList **rl_matching, GList **rl_others) | 203 split_rcpts(GList *rcpt_list, GList *patterns, GList **rl_local, |
204 GList **rl_matching, GList **rl_others) | |
202 { | 205 { |
203 GList *rcpt_node; | 206 GList *rcpt_node; |
204 GList *host_node = NULL; | 207 GList *host_node = NULL; |
205 address *rcpt = NULL; | 208 address *rcpt = NULL; |
206 | 209 |
213 | 216 |
214 if (addr_is_local(rcpt)) { | 217 if (addr_is_local(rcpt)) { |
215 if (rl_local) | 218 if (rl_local) |
216 *rl_local = g_list_append(*rl_local, rcpt); | 219 *rl_local = g_list_append(*rl_local, rcpt); |
217 } else { | 220 } else { |
218 /* if patterns is NULL, host_node will be NULL, | 221 /* |
219 hence all non-locals are put to others */ | 222 ** if patterns is NULL, host_node will be NULL, |
223 ** hence all non-locals are put to others | |
224 */ | |
220 foreach(patterns, host_node) { | 225 foreach(patterns, host_node) { |
221 gchar *host = (gchar *) (host_node->data); | 226 gchar *host = (gchar *) (host_node->data); |
222 if (fnmatch(host, rcpt->domain, FNM_CASEFOLD) == 0) | 227 if (fnmatch(host, rcpt->domain, FNM_CASEFOLD) == 0) |
223 break; | 228 break; |
224 } | 229 } |
232 } | 237 } |
233 } | 238 } |
234 } | 239 } |
235 | 240 |
236 /* | 241 /* |
237 Return a new list of the local rcpts in the rcpt_list | 242 ** Return a new list of the local rcpts in the rcpt_list |
238 TODO: This function is almost exactly the same as remote_rcpts(). Merge? | 243 ** TODO: This function is almost exactly the same as remote_rcpts(). Merge? |
239 */ | 244 */ |
240 GList* | 245 GList* |
241 local_rcpts(GList *rcpt_list) | 246 local_rcpts(GList *rcpt_list) |
242 { | 247 { |
243 GList *rcpt_node; | 248 GList *rcpt_node; |
255 } | 260 } |
256 return local_rcpts; | 261 return local_rcpts; |
257 } | 262 } |
258 | 263 |
259 /* | 264 /* |
260 Return a new list of non-local rcpts in the rcpt_list | 265 ** Return a new list of non-local rcpts in the rcpt_list |
261 TODO: This function is almost exactly the same as local_rcpts(). Merge? | 266 ** TODO: This function is almost exactly the same as local_rcpts(). Merge? |
262 */ | 267 */ |
263 GList* | 268 GList* |
264 remote_rcpts(GList *rcpt_list) | 269 remote_rcpts(GList *rcpt_list) |
265 { | 270 { |
266 GList *rcpt_node; | 271 GList *rcpt_node; |
315 } | 320 } |
316 return TRUE; | 321 return TRUE; |
317 } | 322 } |
318 | 323 |
319 /* | 324 /* |
320 Make lists of matching/not matching rcpts. | 325 ** Make lists of matching/not matching rcpts. |
321 Local domains are NOT regared here, these should be sorted out previously | 326 ** Local domains are NOT regared here, these should be sorted out previously |
322 */ | 327 */ |
323 void | 328 void |
324 route_split_rcpts(connect_route *route, GList *rcpt_list, GList **p_rcpt_list, GList **p_non_rcpt_list) | 329 route_split_rcpts(connect_route *route, GList *rcpt_list, GList **p_rcpt_list, GList **p_non_rcpt_list) |
325 { | 330 { |
326 GList *tmp_list = NULL; | 331 GList *tmp_list = NULL; |
354 debugf(" rcpt for routed delivery: <%s@%s>\n", | 359 debugf(" rcpt for routed delivery: <%s@%s>\n", |
355 rcpt->local_part, rcpt->domain); | 360 rcpt->local_part, rcpt->domain); |
356 } | 361 } |
357 } | 362 } |
358 | 363 |
359 /* rewrite return path if there is a table, use that | 364 /* |
360 if an address is found and if it has a domain, use that | 365 ** rewrite return path if there is a table, use that |
361 */ | 366 ** if an address is found and if it has a domain, use that |
367 */ | |
362 if (route->map_return_path_addresses) { | 368 if (route->map_return_path_addresses) { |
363 address *ret_path = NULL; | 369 address *ret_path = NULL; |
364 DEBUG(5) debugf("looking up %s in map_return_path_addresses\n", msg->return_path->local_part); | 370 DEBUG(5) debugf("looking up %s in map_return_path_addresses\n", msg->return_path->local_part); |
365 ret_path = (address *) table_find_fnmatch(route->map_return_path_addresses, msg->return_path->local_part); | 371 ret_path = (address *) table_find_fnmatch(route->map_return_path_addresses, msg->return_path->local_part); |
366 if (ret_path) { | 372 if (ret_path) { |
381 return msgout; | 387 return msgout; |
382 } | 388 } |
383 return NULL; | 389 return NULL; |
384 } | 390 } |
385 | 391 |
386 /* put msgout's is msgout_list into bins (msgout_perhost structs) for each | 392 /* |
387 host. Used if there is no mail_host. | 393 ** put msgout's is msgout_list into bins (msgout_perhost structs) for each |
388 route param is not used, we leave it here because that may change. | 394 ** host. Used if there is no mail_host. |
389 */ | 395 ** route param is not used, we leave it here because that may change. |
390 | 396 */ |
391 GList* | 397 GList* |
392 route_msgout_list(connect_route *route, GList *msgout_list) | 398 route_msgout_list(connect_route *route, GList *msgout_list) |
393 { | 399 { |
394 GList *mo_ph_list = NULL; | 400 GList *mo_ph_list = NULL; |
395 GList *msgout_node; | 401 GList *msgout_node; |
413 } | 419 } |
414 if (mo_ph_node != NULL) { | 420 if (mo_ph_node != NULL) { |
415 /* there is already a rcpt for this host */ | 421 /* there is already a rcpt for this host */ |
416 msg_out *msgout_last = (msg_out *) ((g_list_last(mo_ph->msgout_list))->data); | 422 msg_out *msgout_last = (msg_out *) ((g_list_last(mo_ph->msgout_list))->data); |
417 if (msgout_last->msg == msgout->msg) { | 423 if (msgout_last->msg == msgout->msg) { |
418 /* if it is also the same message, it must be the last one appended | 424 /* |
419 to mo_ph->msgout_list (since outer loop goes through msgout_list) */ | 425 ** if it is also the same message, |
426 ** it must be the last one | |
427 ** appended to mo_ph->msgout_list | |
428 ** (since outer loop goes through | |
429 ** msgout_list) | |
430 */ | |
420 msgout_last->rcpt_list = g_list_append(msgout_last->rcpt_list, rcpt); | 431 msgout_last->rcpt_list = g_list_append(msgout_last->rcpt_list, rcpt); |
421 } else { | 432 } else { |
422 /* if not, we append a new msgout */ | 433 /* if not, we append a new msgout */ |
423 /* make a copy of msgout */ | 434 /* make a copy of msgout */ |
424 msgout_new = create_msg_out(msgout->msg); | 435 msgout_new = create_msg_out(msgout->msg); |