Mercurial > masqmail
comparison src/accept.c @ 13:49dab67fe461
code beautifying
author | meillo@marmaro.de |
---|---|
date | Wed, 29 Oct 2008 21:10:18 +0100 |
parents | 26e34ae9a3e3 |
children | a8f3424347dc |
comparison
equal
deleted
inserted
replaced
12:9fb7ddbaf129 | 13:49dab67fe461 |
---|---|
304 addr = g_strdup(hdr->value); | 304 addr = g_strdup(hdr->value); |
305 g_strchomp(addr); | 305 g_strchomp(addr); |
306 | 306 |
307 if ((msg->return_path = create_address_qualified(addr, FALSE, msg->received_host)) != NULL) { | 307 if ((msg->return_path = create_address_qualified(addr, FALSE, msg->received_host)) != NULL) { |
308 DEBUG(3) debugf("setting return_path to %s\n", addr_string(msg->return_path)); | 308 DEBUG(3) debugf("setting return_path to %s\n", addr_string(msg->return_path)); |
309 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN, "X-Warning: return path set from %s address\n", hdr->id == HEAD_SENDER ? "Sender:" : "From:")); | 309 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN, |
310 "X-Warning: return path set from %s address\n", | |
311 hdr->id == HEAD_SENDER ? "Sender:" : "From:")); | |
310 } | 312 } |
311 g_free(addr); | 313 g_free(addr); |
312 } | 314 } |
313 if (msg->return_path == NULL) { /* no Sender: or From: or create_address_qualified failed */ | 315 if (msg->return_path == NULL) { /* no Sender: or From: or create_address_qualified failed */ |
314 msg->return_path = create_address_qualified("postmaster", TRUE, conf.host_name); | 316 msg->return_path = create_address_qualified("postmaster", TRUE, conf.host_name); |
315 DEBUG(3) debugf("setting return_path to %s\n", addr_string(msg->return_path)); | 317 DEBUG(3) debugf("setting return_path to %s\n", addr_string(msg->return_path)); |
316 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN, "X-Warning: real return path is unkown\n")); | 318 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN, |
319 "X-Warning: real return path is unkown\n")); | |
317 } | 320 } |
318 } | 321 } |
319 | 322 |
320 if (flags & ACC_DEL_RCPTS) { | 323 if (flags & ACC_DEL_RCPTS) { |
321 GList *rcpt_node; | 324 GList *rcpt_node; |
340 if (!(has_sender || has_from)) { | 343 if (!(has_sender || has_from)) { |
341 DEBUG(3) debugf("adding 'From' header\n"); | 344 DEBUG(3) debugf("adding 'From' header\n"); |
342 msg->hdr_list = g_list_append(msg->hdr_list, | 345 msg->hdr_list = g_list_append(msg->hdr_list, |
343 msg->full_sender_name | 346 msg->full_sender_name |
344 ? | 347 ? |
345 create_header(HEAD_FROM, | 348 create_header(HEAD_FROM, "From: \"%s\" <%s@%s>\n", msg->full_sender_name, |
346 "From: \"%s\" <%s@%s>\n", | 349 msg->return_path->local_part, msg->return_path->domain) |
347 msg->full_sender_name, | |
348 msg->return_path->local_part, | |
349 msg->return_path-> | |
350 domain) | |
351 : | 350 : |
352 create_header(HEAD_FROM, "From: <%s@%s>\n", | 351 create_header(HEAD_FROM, "From: <%s@%s>\n", |
353 msg->return_path->local_part, | 352 msg->return_path->local_part, msg->return_path->domain) |
354 msg->return_path->domain) | |
355 ); | 353 ); |
356 } | 354 } |
357 if ((flags & ACC_HEAD_FROM_RCPT) && !has_rcpt) { | 355 if ((flags & ACC_HEAD_FROM_RCPT) && !has_rcpt) { |
358 GList *node; | 356 GList *node; |
359 DEBUG(3) debugf("adding 'To' header(s)\n"); | 357 DEBUG(3) debugf("adding 'To' header(s)\n"); |
360 for (node = g_list_first(msg->rcpt_list); node; node = g_list_next(node)) { | 358 for (node = g_list_first(msg->rcpt_list); node; node = g_list_next(node)) { |
361 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_TO, "To: %s\n", addr_string(msg-> return_path))); | 359 msg->hdr_list = g_list_append(msg->hdr_list, |
360 create_header(HEAD_TO, "To: %s\n", addr_string(msg-> return_path))); | |
362 } | 361 } |
363 } | 362 } |
364 if ((flags & ACC_DEL_BCC) && !has_to_or_cc) { | 363 if ((flags & ACC_DEL_BCC) && !has_to_or_cc) { |
365 /* Bcc headers have been removed, and there are no remaining rcpt headers */ | 364 /* Bcc headers have been removed, and there are no remaining rcpt headers */ |
366 DEBUG(3) debugf("adding empty 'Bcc:' header\n"); | 365 DEBUG(3) debugf("adding empty 'Bcc:' header\n"); |
370 DEBUG(3) debugf("adding 'Date:' header\n"); | 369 DEBUG(3) debugf("adding 'Date:' header\n"); |
371 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_DATE, "Date: %s\n", rec_timestamp())); | 370 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_DATE, "Date: %s\n", rec_timestamp())); |
372 } | 371 } |
373 if (!has_id) { | 372 if (!has_id) { |
374 DEBUG(3) debugf("adding 'Message-ID:' header\n"); | 373 DEBUG(3) debugf("adding 'Message-ID:' header\n"); |
375 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_MESSAGE_ID, "Message-ID: <%s@%s>\n", msg->uid, conf.host_name)); | 374 msg->hdr_list = g_list_append(msg->hdr_list, |
375 create_header(HEAD_MESSAGE_ID, "Message-ID: <%s@%s>\n", msg->uid, conf.host_name)); | |
376 } | 376 } |
377 } | 377 } |
378 | 378 |
379 /* Received header: */ | 379 /* Received header: */ |
380 /* At this point because we have to know the rcpts for the 'for' part */ | 380 /* At this point because we have to know the rcpts for the 'for' part */ |
388 address *addr = (address *) (g_list_first(msg->rcpt_list)->data); | 388 address *addr = (address *) (g_list_first(msg->rcpt_list)->data); |
389 for_string = g_strdup_printf(" for %s", addr_string(addr)); | 389 for_string = g_strdup_printf(" for %s", addr_string(addr)); |
390 } | 390 } |
391 | 391 |
392 if (msg->received_host == NULL) { | 392 if (msg->received_host == NULL) { |
393 hdr = create_header(HEAD_RECEIVED, | 393 hdr = create_header(HEAD_RECEIVED, "Received: from %s by %s with %s (%s %s) id %s%s; %s\n", |
394 "Received: from %s by %s" | 394 passwd->pw_name, conf.host_name, prot_names[msg->received_prot], |
395 " with %s (%s %s) id %s%s;" | 395 PACKAGE, VERSION, msg->uid, for_string ? for_string : "", rec_timestamp()); |
396 " %s\n", | |
397 passwd->pw_name, conf.host_name, | |
398 prot_names[msg->received_prot], | |
399 PACKAGE, VERSION, | |
400 msg->uid, for_string ? for_string : "", | |
401 rec_timestamp()); | |
402 } else { | 396 } else { |
403 #ifdef ENABLE_IDENT | 397 #ifdef ENABLE_IDENT |
404 DEBUG(5) debugf("adding 'Received:' header (5)\n"); | 398 DEBUG(5) debugf("adding 'Received:' header (5)\n"); |
405 hdr = create_header(HEAD_RECEIVED, | 399 hdr = create_header(HEAD_RECEIVED, "Received: from %s (ident=%s) by %s with %s (%s %s) id %s%s; %s\n", |
406 "Received: from %s (ident=%s) by %s" | 400 msg->received_host, msg->ident ? msg->ident : "unknown", conf.host_name, |
407 " with %s (%s %s) id %s%s;" | 401 prot_names[msg->received_prot], PACKAGE, VERSION, msg->uid, for_string ? for_string : "", |
408 " %s\n", | |
409 msg->received_host, | |
410 msg->ident ? msg->ident : "unknown", | |
411 conf.host_name, | |
412 prot_names[msg->received_prot], | |
413 PACKAGE, VERSION, | |
414 msg->uid, for_string ? for_string : "", | |
415 rec_timestamp()); | 402 rec_timestamp()); |
416 #else | 403 #else |
417 hdr = create_header(HEAD_RECEIVED, | 404 hdr = create_header(HEAD_RECEIVED, "Received: from %s by %s with %s (%s %s) id %s%s; %s\n", |
418 "Received: from %s by %s" | 405 msg->received_host, conf.host_name, prot_names[msg->received_prot], |
419 " with %s (%s %s) id %s%s;" | 406 PACKAGE, VERSION, msg->uid, for_string ? for_string : "", rec_timestamp()); |
420 " %s\n", | |
421 msg->received_host, | |
422 conf.host_name, | |
423 prot_names[msg->received_prot], | |
424 PACKAGE, VERSION, | |
425 msg->uid, for_string ? for_string : "", | |
426 rec_timestamp()); | |
427 #endif | 407 #endif |
428 } | 408 } |
429 header_fold(hdr); | 409 header_fold(hdr); |
430 msg->hdr_list = g_list_prepend(msg->hdr_list, hdr); | 410 msg->hdr_list = g_list_prepend(msg->hdr_list, hdr); |
431 | 411 |
433 g_free(for_string); | 413 g_free(for_string); |
434 } | 414 } |
435 | 415 |
436 /* write message to spool: */ | 416 /* write message to spool: */ |
437 /* accept is no longer responsible for this | 417 /* accept is no longer responsible for this |
438 if(!spool_write(msg, TRUE)) | 418 if (!spool_write(msg, TRUE)) |
439 return AERR_NOSPOOL; | 419 return AERR_NOSPOOL; |
440 */ | 420 */ |
441 return AERR_OK; | 421 return AERR_OK; |
442 } | 422 } |
443 | 423 |
444 accept_error | 424 accept_error |