Minor changes.
* include/mailutils/address.h (struct _mu_address): Rename to struct mu_address: it is public interface. * include/mailutils/types.hin: Likewise. * examples/addr.c: Likewise. * mailbox/address.c: Likewise. * mailbox/parse822.c: Likewise. * libmu_sieve/extensions/vacation.c (vacation_reply): Fix memory leaks. * libproto/mailer/mbox.c (remote_mbox_append_message): Use mu_address_create_hint instead of mu_set_user_email_domain/mu_address_create. * maidag/maidag.c (main): Set both diag and debug printers explicitly. * mail/from.c (mail_from0): minor change. * mail/reply.c (reply0): Fix memory leak. * mailbox/header.c: minor change.
Showing
11 changed files
with
45 additions
and
41 deletions
... | @@ -41,7 +41,7 @@ extern "C" { | ... | @@ -41,7 +41,7 @@ extern "C" { |
41 | * | 41 | * |
42 | * Capitalized names are from RFC 822, section 6.1 (Address Syntax). | 42 | * Capitalized names are from RFC 822, section 6.1 (Address Syntax). |
43 | */ | 43 | */ |
44 | struct _mu_address | 44 | struct mu_address |
45 | { | 45 | { |
46 | char *addr; | 46 | char *addr; |
47 | /* the original string that this list of addresses was created | 47 | /* the original string that this list of addresses was created |
... | @@ -60,7 +60,7 @@ struct _mu_address | ... | @@ -60,7 +60,7 @@ struct _mu_address |
60 | char *route; | 60 | char *route; |
61 | /* the optional ROUTE in the ROUTE-ADDR form of MAILBOX */ | 61 | /* the optional ROUTE in the ROUTE-ADDR form of MAILBOX */ |
62 | 62 | ||
63 | struct _mu_address *next; | 63 | struct mu_address *next; |
64 | }; | 64 | }; |
65 | 65 | ||
66 | extern int mu_address_create_hint (mu_address_t *, const char *, | 66 | extern int mu_address_create_hint (mu_address_t *, const char *, | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail -*- c -*- | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail -*- c -*- |
2 | Copyright (C) 1999, 2000, 2001, 2005, 2007, | 2 | Copyright (C) 1999, 2000, 2001, 2005, 2007, |
3 | 2008 Free Software Foundation, Inc. | 3 | 2008, 2009 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
... | @@ -38,7 +38,7 @@ | ... | @@ -38,7 +38,7 @@ |
38 | extern "C" { | 38 | extern "C" { |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | struct _mu_address; | 41 | struct mu_address; |
42 | struct _mu_attribute; | 42 | struct _mu_attribute; |
43 | struct _mu_authority; | 43 | struct _mu_authority; |
44 | struct _mu_body; | 44 | struct _mu_body; |
... | @@ -73,7 +73,7 @@ struct _mu_tcp_server; | ... | @@ -73,7 +73,7 @@ struct _mu_tcp_server; |
73 | 73 | ||
74 | typedef _MU_OFF_TYPE_ mu_off_t; | 74 | typedef _MU_OFF_TYPE_ mu_off_t; |
75 | 75 | ||
76 | typedef struct _mu_address *mu_address_t; | 76 | typedef struct mu_address *mu_address_t; |
77 | typedef struct _mu_attribute *mu_attribute_t; | 77 | typedef struct _mu_attribute *mu_attribute_t; |
78 | typedef struct _mu_authority *mu_authority_t; | 78 | typedef struct _mu_authority *mu_authority_t; |
79 | typedef struct _mu_body *mu_body_t; | 79 | typedef struct _mu_body *mu_body_t; | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 2005, 2007 Free Software Foundation, Inc. | 2 | Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public | 5 | modify it under the terms of the GNU Lesser General Public |
... | @@ -485,9 +485,9 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, | ... | @@ -485,9 +485,9 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, |
485 | mu_sieve_error (mach, | 485 | mu_sieve_error (mach, |
486 | _("%d: cannot create recipient address <%s>: %s"), | 486 | _("%d: cannot create recipient address <%s>: %s"), |
487 | mu_sieve_get_message_num (mach), from, mu_strerror (rc)); | 487 | mu_sieve_get_message_num (mach), from, mu_strerror (rc)); |
488 | return -1; | ||
489 | } | 488 | } |
490 | 489 | else | |
490 | { | ||
491 | mu_header_set_value (newhdr, MU_HEADER_TO, to, 0); | 491 | mu_header_set_value (newhdr, MU_HEADER_TO, to, 0); |
492 | 492 | ||
493 | vacation_subject (mach, tags, msg, newhdr); | 493 | vacation_subject (mach, tags, msg, newhdr); |
... | @@ -525,13 +525,16 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, | ... | @@ -525,13 +525,16 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, |
525 | _("%d: cannot open mailer %s: %s"), | 525 | _("%d: cannot open mailer %s: %s"), |
526 | mu_sieve_get_message_num (mach), | 526 | mu_sieve_get_message_num (mach), |
527 | mu_url_to_string (url), mu_strerror (rc)); | 527 | mu_url_to_string (url), mu_strerror (rc)); |
528 | return -1; | ||
529 | } | 528 | } |
530 | else | 529 | else |
531 | { | 530 | { |
532 | rc = mu_mailer_send_message (mailer, newmsg, from_addr, to_addr); | 531 | rc = mu_mailer_send_message (mailer, newmsg, from_addr, to_addr); |
533 | mu_mailer_close (mailer); | 532 | mu_mailer_close (mailer); |
534 | } | 533 | } |
534 | mu_mailer_destroy (&mailer); | ||
535 | } | ||
536 | mu_address_destroy (&to_addr); | ||
537 | mu_address_destroy (&from_addr); | ||
535 | mu_mime_destroy (&mime); | 538 | mu_mime_destroy (&mime); |
536 | return rc; | 539 | return rc; |
537 | } | 540 | } | ... | ... |
... | @@ -138,12 +138,14 @@ remote_mbox_append_message (mu_mailbox_t mbox, mu_message_t msg) | ... | @@ -138,12 +138,14 @@ remote_mbox_append_message (mu_mailbox_t mbox, mu_message_t msg) |
138 | mkaddr (mbox, property, "TO", &to); | 138 | mkaddr (mbox, property, "TO", &to); |
139 | if (!to) | 139 | if (!to) |
140 | { | 140 | { |
141 | const char *rcpt, *host; | 141 | const char *rcpt; |
142 | char *domain = NULL; | ||
143 | 142 | ||
144 | status = mu_url_sget_user (mbox->url, &rcpt); | 143 | status = mu_url_sget_user (mbox->url, &rcpt); |
145 | if (status != MU_ERR_NOENT) | 144 | if (status != MU_ERR_NOENT) |
146 | { | 145 | { |
146 | const char *host; | ||
147 | struct mu_address hint; | ||
148 | |||
147 | if (status) | 149 | if (status) |
148 | { | 150 | { |
149 | MU_DEBUG1 (mbox->debug, MU_DEBUG_ERROR, | 151 | MU_DEBUG1 (mbox->debug, MU_DEBUG_ERROR, |
... | @@ -152,13 +154,10 @@ remote_mbox_append_message (mu_mailbox_t mbox, mu_message_t msg) | ... | @@ -152,13 +154,10 @@ remote_mbox_append_message (mu_mailbox_t mbox, mu_message_t msg) |
152 | return status; | 154 | return status; |
153 | } | 155 | } |
154 | 156 | ||
155 | /* FIXME: Set before if? */ | ||
156 | mu_aget_user_email_domain (&domain); | ||
157 | mu_url_sget_host (mbox->url, &host); | 157 | mu_url_sget_host (mbox->url, &host); |
158 | mu_set_user_email_domain (host); | 158 | hint.domain = (char*) host; |
159 | status = mu_address_create (&to, rcpt); | 159 | status = mu_address_create_hint (&to, rcpt, &hint, |
160 | mu_set_user_email_domain (domain); | 160 | MU_ADDR_HINT_DOMAIN); |
161 | free (domain); | ||
162 | 161 | ||
163 | if (status) | 162 | if (status) |
164 | { | 163 | { | ... | ... |
... | @@ -481,6 +481,7 @@ int | ... | @@ -481,6 +481,7 @@ int |
481 | main (int argc, char *argv[]) | 481 | main (int argc, char *argv[]) |
482 | { | 482 | { |
483 | int arg_index; | 483 | int arg_index; |
484 | mu_debug_t debug; | ||
484 | 485 | ||
485 | /* Preparative work: close inherited fds, force a reasonable umask | 486 | /* Preparative work: close inherited fds, force a reasonable umask |
486 | and prepare a logging. */ | 487 | and prepare a logging. */ |
... | @@ -535,16 +536,18 @@ main (int argc, char *argv[]) | ... | @@ -535,16 +536,18 @@ main (int argc, char *argv[]) |
535 | if (log_to_stderr == -1) | 536 | if (log_to_stderr == -1) |
536 | log_to_stderr = url_option || (!lmtp_mode && (current_uid != 0)); | 537 | log_to_stderr = url_option || (!lmtp_mode && (current_uid != 0)); |
537 | 538 | ||
539 | mu_diag_get_debug (&debug); | ||
538 | if (!log_to_stderr) | 540 | if (!log_to_stderr) |
539 | { | 541 | { |
540 | mu_debug_t debug; | ||
541 | |||
542 | openlog (MU_LOG_TAG (), LOG_PID, mu_log_facility); | 542 | openlog (MU_LOG_TAG (), LOG_PID, mu_log_facility); |
543 | mu_diag_get_debug (&debug); | ||
544 | mu_debug_set_print (debug, mu_diag_syslog_printer, NULL); | 543 | mu_debug_set_print (debug, mu_diag_syslog_printer, NULL); |
545 | |||
546 | mu_debug_default_printer = mu_debug_syslog_printer; | 544 | mu_debug_default_printer = mu_debug_syslog_printer; |
547 | } | 545 | } |
546 | else | ||
547 | { | ||
548 | mu_debug_set_print (debug, mu_diag_stderr_printer, NULL); | ||
549 | mu_debug_default_printer = mu_debug_stderr_printer; | ||
550 | } | ||
548 | 551 | ||
549 | argc -= arg_index; | 552 | argc -= arg_index; |
550 | argv += arg_index; | 553 | argv += arg_index; | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2003, | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2003, |
3 | 2005, 2007 Free Software Foundation, Inc. | 3 | 2005, 2007, 2009 Free Software Foundation, Inc. |
4 | 4 | ||
5 | GNU Mailutils is free software; you can redistribute it and/or modify | 5 | GNU Mailutils is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
... | @@ -42,8 +42,7 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) | ... | @@ -42,8 +42,7 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) |
42 | mu_address_t address = NULL; | 42 | mu_address_t address = NULL; |
43 | if (mu_address_create (&address, from) == 0) | 43 | if (mu_address_create (&address, from) == 0) |
44 | { | 44 | { |
45 | char name[128]; | 45 | char *name; |
46 | size_t len; | ||
47 | const char *email; | 46 | const char *email; |
48 | 47 | ||
49 | if (mu_address_sget_email (address, 1, &email) == 0) | 48 | if (mu_address_sget_email (address, 1, &email) == 0) |
... | @@ -53,7 +52,8 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) | ... | @@ -53,7 +52,8 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) |
53 | { | 52 | { |
54 | char *tmp; | 53 | char *tmp; |
55 | 54 | ||
56 | if (mu_header_aget_value_unfold (hdr, MU_HEADER_TO, &tmp) == 0) | 55 | if (mu_header_aget_value_unfold (hdr, MU_HEADER_TO, |
56 | &tmp) == 0) | ||
57 | { | 57 | { |
58 | mu_address_t addr_to; | 58 | mu_address_t addr_to; |
59 | if (mu_address_create (&addr_to, tmp) == 0) | 59 | if (mu_address_create (&addr_to, tmp) == 0) |
... | @@ -66,16 +66,14 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) | ... | @@ -66,16 +66,14 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | len = strlen (from) + 1; | 69 | if ((mu_address_aget_personal (address, 1, &name) == 0 |
70 | *name = '\0'; | 70 | && name) |
71 | mu_address_get_personal (address, 1, name, sizeof name, NULL); | 71 | || (mu_address_aget_email (address, 1, &name) == 0 |
72 | if (*name && len) | 72 | && name)) |
73 | { | 73 | { |
74 | strncpy (from, name, len - 1); | 74 | free (from); |
75 | from[len - 1] = '\0'; | 75 | from = name; |
76 | } | 76 | } |
77 | else | ||
78 | mu_address_get_email (address, 1, from, len, NULL); | ||
79 | mu_address_destroy (&address); | 77 | mu_address_destroy (&address); |
80 | } | 78 | } |
81 | } | 79 | } | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2001, 2002, 2005, 2007 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2001, 2002, 2005, 2007, |
3 | 2009 Free Software Foundation, Inc. | ||
3 | 4 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 5 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
... | @@ -91,6 +92,8 @@ reply0 (msgset_t *mspec, mu_message_t msg, void *data) | ... | @@ -91,6 +92,8 @@ reply0 (msgset_t *mspec, mu_message_t msg, void *data) |
91 | COMPOSE_SINGLE_LINE); | 92 | COMPOSE_SINGLE_LINE); |
92 | } | 93 | } |
93 | 94 | ||
95 | mu_address_destroy (&addr); | ||
96 | |||
94 | /* Finally, add any Ccs */ | 97 | /* Finally, add any Ccs */ |
95 | if (mu_header_aget_value (hdr, MU_HEADER_CC, &str) == 0) | 98 | if (mu_header_aget_value (hdr, MU_HEADER_CC, &str) == 0) |
96 | compose_header_set (&env, MU_HEADER_TO, str, COMPOSE_SINGLE_LINE); | 99 | compose_header_set (&env, MU_HEADER_TO, str, COMPOSE_SINGLE_LINE); | ... | ... |
... | @@ -73,7 +73,7 @@ mu_address_create_hint (mu_address_t *a, const char *s, mu_address_t hint, | ... | @@ -73,7 +73,7 @@ mu_address_create_hint (mu_address_t *a, const char *s, mu_address_t hint, |
73 | int | 73 | int |
74 | mu_address_create (mu_address_t *a, const char *s) | 74 | mu_address_create (mu_address_t *a, const char *s) |
75 | { | 75 | { |
76 | struct _mu_address hint; | 76 | struct mu_address hint; |
77 | const char *d; | 77 | const char *d; |
78 | mu_get_user_email_domain (&d); | 78 | mu_get_user_email_domain (&d); |
79 | hint.domain = (char*) d; | 79 | hint.domain = (char*) d; | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2004, 2005, | 2 | Copyright (C) 1999, 2000, 2001, 2004, 2005, |
3 | 2007, 2008 Free Software Foundation, Inc. | 3 | 2007, 2008, 2009 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
... | @@ -761,9 +761,7 @@ mu_header_get_address_n (mu_header_t header, const char *name, int n, | ... | @@ -761,9 +761,7 @@ mu_header_get_address_n (mu_header_t header, const char *name, int n, |
761 | if (status) | 761 | if (status) |
762 | return status; | 762 | return status; |
763 | 763 | ||
764 | status = mu_address_create(addr, value); | 764 | return mu_address_create (addr, value); |
765 | |||
766 | return status; | ||
767 | } | 765 | } |
768 | 766 | ||
769 | 767 | ... | ... |
... | @@ -705,7 +705,7 @@ mu_parse822_phrase (const char **p, const char *e, char **phrase) | ... | @@ -705,7 +705,7 @@ mu_parse822_phrase (const char **p, const char *e, char **phrase) |
705 | static mu_address_t | 705 | static mu_address_t |
706 | new_mb (void) | 706 | new_mb (void) |
707 | { | 707 | { |
708 | return calloc (1, sizeof (struct _mu_address)); | 708 | return calloc (1, sizeof (struct mu_address)); |
709 | } | 709 | } |
710 | 710 | ||
711 | static char * | 711 | static char * | ... | ... |
-
Please register or sign in to post a comment