Commit 15e24c25 15e24c25a90d424cb730dcf9c754771dec4e29ac by Sam Roberts

address parsing now creates email addresses for unqualified "unix"

style mailboxes by using the mu_get_user_email_domain().
1 parent 8fe9f929
...@@ -583,45 +583,55 @@ static address_t new_mb(void) { ...@@ -583,45 +583,55 @@ static address_t new_mb(void) {
583 return calloc(1, sizeof(struct _address)); 583 return calloc(1, sizeof(struct _address));
584 } 584 }
585 585
586 static int fill_mb( 586 static int
587 address_t* a, 587 fill_mb (address_t * a,
588 char* comments, char* personal, char* local, char* domain) 588 char *comments, char *personal, char *local, char *domain)
589 { 589 {
590 int rc = EOK; 590 int rc = EOK;
591 591
592 *a = new_mb(); 592 *a = new_mb ();
593 593
594 if(!*a) { 594 if (!*a)
595 return ENOMEM; 595 {
596 return ENOMEM;
596 } 597 }
597 598
598 (*a)->comments = comments; 599 (*a)->comments = comments;
599 (*a)->personal = personal; 600 (*a)->personal = personal;
600 601
601 do { 602 do
602 /* loop exists only to break out of */ 603 {
603 if(!local || !domain) { 604 /* loop exists only to break out of */
605 const char *d = domain;
606 if (!d)
607 {
608 mu_get_user_email_domain (&d);
609 }
610 if (!local || !d)
611 {
604 /* no email to construct */ 612 /* no email to construct */
605 break; 613 break;
606 } 614 }
607 if((rc = parse822_quote_local_part(&(*a)->email, local))) 615 if ((rc = parse822_quote_local_part (&(*a)->email, local)))
608 break; 616 break;
609 if((rc = str_append(&(*a)->email, "@"))) 617 if ((rc = str_append (&(*a)->email, "@")))
610 break; 618 break;
611 if((rc = str_append(&(*a)->email, domain))) 619 if ((rc = str_append (&(*a)->email, d)))
612 break; 620 break;
613 } while(0); 621 }
622 while (0);
614 623
615 (*a)->local_part = local; 624 (*a)->local_part = local;
616 (*a)->domain = domain; 625 (*a)->domain = domain;
617 626
618 if(rc != EOK) { 627 if (rc != EOK)
619 /* note that the arguments have NOT been freed, we only own 628 {
620 * them on success. */ 629 /* note that the arguments have NOT been freed, we only own
621 free(*a); 630 * them on success. */
631 free (*a);
622 } 632 }
623 633
624 return rc; 634 return rc;
625 } 635 }
626 636
627 int parse822_address_list(address_t* a, const char* s) 637 int parse822_address_list(address_t* a, const char* s)
......