Mercurial > masqmail
comparison src/route.c @ 366:41958685480d
Switched to `type *name' style
Andrew Koenig's ``C Traps and Pitfalls'' (Ch.2.1) convinced
me that it is best to go with the way C had been designed.
The ``declaration reflects use'' concept conflicts with a
``type* name'' notation. Hence I switched.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Thu, 22 Sep 2011 15:07:40 +0200 |
parents | ddb7b3fd3d08 |
children | b27f66555ba8 |
comparison
equal
deleted
inserted
replaced
365:934a223e4ee8 | 366:41958685480d |
---|---|
20 #include <fnmatch.h> | 20 #include <fnmatch.h> |
21 | 21 |
22 #include "masqmail.h" | 22 #include "masqmail.h" |
23 | 23 |
24 msgout_perhost* | 24 msgout_perhost* |
25 create_msgout_perhost(gchar * host) | 25 create_msgout_perhost(gchar *host) |
26 { | 26 { |
27 msgout_perhost *mo_ph = g_malloc(sizeof(msgout_perhost)); | 27 msgout_perhost *mo_ph = g_malloc(sizeof(msgout_perhost)); |
28 if (mo_ph) { | 28 if (mo_ph) { |
29 mo_ph->host = g_strdup(host); | 29 mo_ph->host = g_strdup(host); |
30 mo_ph->msgout_list = NULL; | 30 mo_ph->msgout_list = NULL; |
31 } | 31 } |
32 return mo_ph; | 32 return mo_ph; |
33 } | 33 } |
34 | 34 |
35 void | 35 void |
36 destroy_msgout_perhost(msgout_perhost * mo_ph) | 36 destroy_msgout_perhost(msgout_perhost *mo_ph) |
37 { | 37 { |
38 GList *mo_node; | 38 GList *mo_node; |
39 | 39 |
40 foreach(mo_ph->msgout_list, mo_node) { | 40 foreach(mo_ph->msgout_list, mo_node) { |
41 msg_out *mo = (msg_out *) (mo_node->data); | 41 msg_out *mo = (msg_out *) (mo_node->data); |
46 g_list_free(mo_ph->msgout_list); | 46 g_list_free(mo_ph->msgout_list); |
47 g_free(mo_ph); | 47 g_free(mo_ph); |
48 } | 48 } |
49 | 49 |
50 void | 50 void |
51 rewrite_headers(msg_out * msgout, connect_route * route) | 51 rewrite_headers(msg_out *msgout, connect_route *route) |
52 { | 52 { |
53 /* if set_h_from_domain is set, replace domain in all | 53 /* if set_h_from_domain is set, replace domain in all |
54 From: headers. | 54 From: headers. |
55 */ | 55 */ |
56 msgout->hdr_list = g_list_copy(msgout->msg->hdr_list); | 56 msgout->hdr_list = g_list_copy(msgout->msg->hdr_list); |
196 - those maching the patterns | 196 - those maching the patterns |
197 - those not matching the patterns | 197 - those not matching the patterns |
198 If patterns is NULL: only splitting between local and others is done. | 198 If patterns is NULL: only splitting between local and others is done. |
199 */ | 199 */ |
200 void | 200 void |
201 split_rcpts(GList* rcpt_list, GList* patterns, GList** rl_local, GList** rl_matching, GList** rl_others) | 201 split_rcpts(GList *rcpt_list, GList *patterns, GList **rl_local, GList **rl_matching, GList **rl_others) |
202 { | 202 { |
203 GList *rcpt_node; | 203 GList *rcpt_node; |
204 GList *host_node = NULL; | 204 GList *host_node = NULL; |
205 address *rcpt = NULL; | 205 address *rcpt = NULL; |
206 | 206 |
236 /* | 236 /* |
237 Return a new list of the local rcpts in the rcpt_list | 237 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? | 238 TODO: This function is almost exactly the same as remote_rcpts(). Merge? |
239 */ | 239 */ |
240 GList* | 240 GList* |
241 local_rcpts(GList* rcpt_list) | 241 local_rcpts(GList *rcpt_list) |
242 { | 242 { |
243 GList *rcpt_node; | 243 GList *rcpt_node; |
244 GList *local_rcpts = NULL; | 244 GList *local_rcpts = NULL; |
245 address *rcpt = NULL; | 245 address *rcpt = NULL; |
246 | 246 |
259 /* | 259 /* |
260 Return a new list of non-local rcpts in the rcpt_list | 260 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? | 261 TODO: This function is almost exactly the same as local_rcpts(). Merge? |
262 */ | 262 */ |
263 GList* | 263 GList* |
264 remote_rcpts(GList* rcpt_list) | 264 remote_rcpts(GList *rcpt_list) |
265 { | 265 { |
266 GList *rcpt_node; | 266 GList *rcpt_node; |
267 GList *remote_rcpts = NULL; | 267 GList *remote_rcpts = NULL; |
268 address *rcpt = NULL; | 268 address *rcpt = NULL; |
269 | 269 |
281 | 281 |
282 static gint | 282 static gint |
283 _g_list_addrcmp(gconstpointer pattern, gconstpointer addr) | 283 _g_list_addrcmp(gconstpointer pattern, gconstpointer addr) |
284 { | 284 { |
285 int res; | 285 int res; |
286 address* patternaddr = (address*) pattern; | 286 address *patternaddr = (address*) pattern; |
287 address* stringaddr = (address*) addr; | 287 address *stringaddr = (address*) addr; |
288 | 288 |
289 DEBUG(6) debugf("_g_list_addrcmp: pattern `%s' `%s' on string `%s' `%s'\n", | 289 DEBUG(6) debugf("_g_list_addrcmp: pattern `%s' `%s' on string `%s' `%s'\n", |
290 patternaddr->local_part, patternaddr->domain, | 290 patternaddr->local_part, patternaddr->domain, |
291 stringaddr->local_part, stringaddr->domain); | 291 stringaddr->local_part, stringaddr->domain); |
292 /* TODO: check if we should match here dependent on caseless_matching */ | 292 /* TODO: check if we should match here dependent on caseless_matching */ |
299 DEBUG(6) debugf("_g_list_addrcmp: ... %s\n", (res==0) ? "matched" : "failed on domain"); | 299 DEBUG(6) debugf("_g_list_addrcmp: ... %s\n", (res==0) ? "matched" : "failed on domain"); |
300 return res; | 300 return res; |
301 } | 301 } |
302 | 302 |
303 gboolean | 303 gboolean |
304 route_sender_is_allowed(connect_route * route, address * ret_path) | 304 route_sender_is_allowed(connect_route *route, address *ret_path) |
305 { | 305 { |
306 if (route->denied_senders && g_list_find_custom(route->denied_senders, ret_path, _g_list_addrcmp)) { | 306 if (route->denied_senders && g_list_find_custom(route->denied_senders, ret_path, _g_list_addrcmp)) { |
307 return FALSE; | 307 return FALSE; |
308 } | 308 } |
309 if (route->allowed_senders) { | 309 if (route->allowed_senders) { |
319 /* | 319 /* |
320 Make lists of matching/not matching rcpts. | 320 Make lists of matching/not matching rcpts. |
321 Local domains are NOT regared here, these should be sorted out previously | 321 Local domains are NOT regared here, these should be sorted out previously |
322 */ | 322 */ |
323 void | 323 void |
324 route_split_rcpts(connect_route * route, GList * rcpt_list, GList ** p_rcpt_list, GList ** p_non_rcpt_list) | 324 route_split_rcpts(connect_route *route, GList *rcpt_list, GList **p_rcpt_list, GList **p_non_rcpt_list) |
325 { | 325 { |
326 GList *tmp_list = NULL; | 326 GList *tmp_list = NULL; |
327 /* sort out those domains that can be sent over this connection: */ | 327 /* sort out those domains that can be sent over this connection: */ |
328 if (route->allowed_recipients) { | 328 if (route->allowed_recipients) { |
329 DEBUG(5) debugf("testing for route->allowed_recipients\n"); | 329 DEBUG(5) debugf("testing for route->allowed_recipients\n"); |
337 split_rcpts(tmp_list, route->denied_recipients, NULL, p_non_rcpt_list, p_rcpt_list); | 337 split_rcpts(tmp_list, route->denied_recipients, NULL, p_non_rcpt_list, p_rcpt_list); |
338 g_list_free(tmp_list); | 338 g_list_free(tmp_list); |
339 } | 339 } |
340 | 340 |
341 msg_out* | 341 msg_out* |
342 route_prepare_msgout(connect_route * route, msg_out * msgout) | 342 route_prepare_msgout(connect_route *route, msg_out *msgout) |
343 { | 343 { |
344 message *msg = msgout->msg; | 344 message *msg = msgout->msg; |
345 GList *rcpt_list = msgout->rcpt_list; | 345 GList *rcpt_list = msgout->rcpt_list; |
346 | 346 |
347 if (rcpt_list != NULL) { | 347 if (rcpt_list != NULL) { |
387 host. Used if there is no mail_host. | 387 host. Used if there is no mail_host. |
388 route param is not used, we leave it here because that may change. | 388 route param is not used, we leave it here because that may change. |
389 */ | 389 */ |
390 | 390 |
391 GList* | 391 GList* |
392 route_msgout_list(connect_route * route, GList * msgout_list) | 392 route_msgout_list(connect_route *route, GList *msgout_list) |
393 { | 393 { |
394 GList *mo_ph_list = NULL; | 394 GList *mo_ph_list = NULL; |
395 GList *msgout_node; | 395 GList *msgout_node; |
396 | 396 |
397 foreach(msgout_list, msgout_node) { | 397 foreach(msgout_list, msgout_node) { |