Commit dfae7b2b dfae7b2baeb620fe266e5ac6aa6000a7c3acfb5c by Sergey Poznyakoff

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.
1 parent d971eaba
......@@ -31,7 +31,7 @@
#define EPARSE MU_ERR_NOENT
struct _mu_address hint;
struct mu_address hint;
int hflags;
static int
......
......@@ -41,7 +41,7 @@ extern "C" {
*
* Capitalized names are from RFC 822, section 6.1 (Address Syntax).
*/
struct _mu_address
struct mu_address
{
char *addr;
/* the original string that this list of addresses was created
......@@ -60,7 +60,7 @@ struct _mu_address
char *route;
/* the optional ROUTE in the ROUTE-ADDR form of MAILBOX */
struct _mu_address *next;
struct mu_address *next;
};
extern int mu_address_create_hint (mu_address_t *, const char *,
......
/* GNU Mailutils -- a suite of utilities for electronic mail -*- c -*-
Copyright (C) 1999, 2000, 2001, 2005, 2007,
2008 Free Software Foundation, Inc.
2008, 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -38,7 +38,7 @@
extern "C" {
#endif
struct _mu_address;
struct mu_address;
struct _mu_attribute;
struct _mu_authority;
struct _mu_body;
......@@ -73,7 +73,7 @@ struct _mu_tcp_server;
typedef _MU_OFF_TYPE_ mu_off_t;
typedef struct _mu_address *mu_address_t;
typedef struct mu_address *mu_address_t;
typedef struct _mu_attribute *mu_attribute_t;
typedef struct _mu_authority *mu_authority_t;
typedef struct _mu_body *mu_body_t;
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2005, 2007 Free Software Foundation, Inc.
Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -478,60 +478,63 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
return -1;
mu_mime_get_message (mime, &newmsg);
mu_message_get_header (newmsg, &newhdr);
rc = mu_address_create (&to_addr, to);
if (rc)
{
mu_sieve_error (mach,
_("%d: cannot create recipient address <%s>: %s"),
mu_sieve_get_message_num (mach), from, mu_strerror (rc));
return -1;
}
mu_header_set_value (newhdr, MU_HEADER_TO, to, 0);
vacation_subject (mach, tags, msg, newhdr);
if (from)
{
if (mu_address_create (&from_addr, from))
from_addr = NULL;
}
else
{
from_addr = NULL;
}
if (mu_rfc2822_in_reply_to (msg, &value) == 0)
{
mu_header_set_value (newhdr, MU_HEADER_IN_REPLY_TO, value, 1);
free (value);
}
if (mu_rfc2822_references (msg, &value) == 0)
{
mu_header_set_value (newhdr, MU_HEADER_REFERENCES, value, 1);
free (value);
}
mailer = mu_sieve_get_mailer (mach);
rc = mu_mailer_open (mailer, 0);
if (rc)
{
mu_url_t url = NULL;
mu_mailer_get_url (mailer, &url);
mu_header_set_value (newhdr, MU_HEADER_TO, to, 0);
mu_sieve_error (mach,
_("%d: cannot open mailer %s: %s"),
mu_sieve_get_message_num (mach),
mu_url_to_string (url), mu_strerror (rc));
return -1;
}
else
{
rc = mu_mailer_send_message (mailer, newmsg, from_addr, to_addr);
mu_mailer_close (mailer);
vacation_subject (mach, tags, msg, newhdr);
if (from)
{
if (mu_address_create (&from_addr, from))
from_addr = NULL;
}
else
{
from_addr = NULL;
}
if (mu_rfc2822_in_reply_to (msg, &value) == 0)
{
mu_header_set_value (newhdr, MU_HEADER_IN_REPLY_TO, value, 1);
free (value);
}
if (mu_rfc2822_references (msg, &value) == 0)
{
mu_header_set_value (newhdr, MU_HEADER_REFERENCES, value, 1);
free (value);
}
mailer = mu_sieve_get_mailer (mach);
rc = mu_mailer_open (mailer, 0);
if (rc)
{
mu_url_t url = NULL;
mu_mailer_get_url (mailer, &url);
mu_sieve_error (mach,
_("%d: cannot open mailer %s: %s"),
mu_sieve_get_message_num (mach),
mu_url_to_string (url), mu_strerror (rc));
}
else
{
rc = mu_mailer_send_message (mailer, newmsg, from_addr, to_addr);
mu_mailer_close (mailer);
}
mu_mailer_destroy (&mailer);
}
mu_address_destroy (&to_addr);
mu_address_destroy (&from_addr);
mu_mime_destroy (&mime);
return rc;
}
......
......@@ -138,12 +138,14 @@ remote_mbox_append_message (mu_mailbox_t mbox, mu_message_t msg)
mkaddr (mbox, property, "TO", &to);
if (!to)
{
const char *rcpt, *host;
char *domain = NULL;
const char *rcpt;
status = mu_url_sget_user (mbox->url, &rcpt);
if (status != MU_ERR_NOENT)
{
const char *host;
struct mu_address hint;
if (status)
{
MU_DEBUG1 (mbox->debug, MU_DEBUG_ERROR,
......@@ -152,13 +154,10 @@ remote_mbox_append_message (mu_mailbox_t mbox, mu_message_t msg)
return status;
}
/* FIXME: Set before if? */
mu_aget_user_email_domain (&domain);
mu_url_sget_host (mbox->url, &host);
mu_set_user_email_domain (host);
status = mu_address_create (&to, rcpt);
mu_set_user_email_domain (domain);
free (domain);
hint.domain = (char*) host;
status = mu_address_create_hint (&to, rcpt, &hint,
MU_ADDR_HINT_DOMAIN);
if (status)
{
......
......@@ -481,6 +481,7 @@ int
main (int argc, char *argv[])
{
int arg_index;
mu_debug_t debug;
/* Preparative work: close inherited fds, force a reasonable umask
and prepare a logging. */
......@@ -535,16 +536,18 @@ main (int argc, char *argv[])
if (log_to_stderr == -1)
log_to_stderr = url_option || (!lmtp_mode && (current_uid != 0));
mu_diag_get_debug (&debug);
if (!log_to_stderr)
{
mu_debug_t debug;
openlog (MU_LOG_TAG (), LOG_PID, mu_log_facility);
mu_diag_get_debug (&debug);
mu_debug_set_print (debug, mu_diag_syslog_printer, NULL);
mu_debug_default_printer = mu_debug_syslog_printer;
}
else
{
mu_debug_set_print (debug, mu_diag_stderr_printer, NULL);
mu_debug_default_printer = mu_debug_stderr_printer;
}
argc -= arg_index;
argv += arg_index;
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2003,
2005, 2007 Free Software Foundation, Inc.
2005, 2007, 2009 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
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)
mu_address_t address = NULL;
if (mu_address_create (&address, from) == 0)
{
char name[128];
size_t len;
char *name;
const char *email;
if (mu_address_sget_email (address, 1, &email) == 0)
......@@ -53,7 +52,8 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data)
{
char *tmp;
if (mu_header_aget_value_unfold (hdr, MU_HEADER_TO, &tmp) == 0)
if (mu_header_aget_value_unfold (hdr, MU_HEADER_TO,
&tmp) == 0)
{
mu_address_t addr_to;
if (mu_address_create (&addr_to, tmp) == 0)
......@@ -66,16 +66,14 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data)
}
}
len = strlen (from) + 1;
*name = '\0';
mu_address_get_personal (address, 1, name, sizeof name, NULL);
if (*name && len)
if ((mu_address_aget_personal (address, 1, &name) == 0
&& name)
|| (mu_address_aget_email (address, 1, &name) == 0
&& name))
{
strncpy (from, name, len - 1);
from[len - 1] = '\0';
free (from);
from = name;
}
else
mu_address_get_email (address, 1, from, len, NULL);
mu_address_destroy (&address);
}
}
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2001, 2002, 2005, 2007 Free Software Foundation, Inc.
Copyright (C) 1999, 2001, 2002, 2005, 2007,
2009 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
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)
COMPOSE_SINGLE_LINE);
}
mu_address_destroy (&addr);
/* Finally, add any Ccs */
if (mu_header_aget_value (hdr, MU_HEADER_CC, &str) == 0)
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,
int
mu_address_create (mu_address_t *a, const char *s)
{
struct _mu_address hint;
struct mu_address hint;
const char *d;
mu_get_user_email_domain (&d);
hint.domain = (char*) d;
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005,
2007, 2008 Free Software Foundation, Inc.
2007, 2008, 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
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,
if (status)
return status;
status = mu_address_create(addr, value);
return status;
return mu_address_create (addr, value);
}
......
......@@ -705,7 +705,7 @@ mu_parse822_phrase (const char **p, const char *e, char **phrase)
static mu_address_t
new_mb (void)
{
return calloc (1, sizeof (struct _mu_address));
return calloc (1, sizeof (struct mu_address));
}
static char *
......