aboutsummaryrefslogtreecommitdiff
path: root/src/mail.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mail.c')
-rw-r--r--src/mail.c68
1 files changed, 23 insertions, 45 deletions
diff --git a/src/mail.c b/src/mail.c
index c2e92f9..270c2f5 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -270,14 +270,12 @@ mail_send_message (mu_address_t rcpt, const char *text,
{
int rc;
mu_message_t msg;
mu_stream_t stream = NULL;
mu_header_t hdr;
static char *x_mailer = "wydawca (" PACKAGE_STRING ")";
- size_t size;
- char *buf;
const char *sval;
mu_static_memory_stream_create (&stream, text, strlen (text));
rc = mu_stream_to_message (stream, &msg);
mu_stream_unref (stream);
if (rc)
@@ -287,26 +285,21 @@ mail_send_message (mu_address_t rcpt, const char *text,
}
mu_message_get_header (msg, &hdr);
mu_header_append (hdr, "X-Mailer", x_mailer);
if (rcpt)
{
- mu_address_to_string (rcpt, NULL, 0, &size);
- buf = grecs_malloc (size + 1);
- mu_address_to_string (rcpt, buf, size + 1, NULL);
-
- mu_header_set_value (hdr, "To", buf, 1);
- free (buf);
-
+ const char *s;
+
+ if (mu_address_sget_printable (rcpt, &s) == 0)
+ mu_header_set_value (hdr, "To", s, 1);
+
if (from_address && mu_header_sget_value (hdr, "From", &sval))
{
- mu_address_to_string (from_address, NULL, 0, &size);
- buf = grecs_malloc (size + 1);
- mu_address_to_string (from_address, buf, size + 1, NULL);
- mu_header_set_value (hdr, "From", buf, 1);
- free (buf);
+ if (mu_address_sget_printable (from_address, &s) == 0)
+ mu_header_set_value (hdr, "From", s, 1);
}
}
if (debug_level > 1)
{
mu_debug_level_t level;
@@ -428,19 +421,16 @@ mail_stats ()
logmsg (LOG_ERR, _("cannot mail statistics: admin-address not defined"));
return;
}
if (debug_level)
{
- size_t size;
- char *buf;
- mu_address_to_string (admin_address, NULL, 0, &size);
- buf = grecs_malloc (size + 1);
- mu_address_to_string (admin_address, buf, size + 1, NULL);
- logmsg (LOG_DEBUG, _("sending stats to %s"), buf);
- free (buf);
+ const char *s;
+
+ if (mu_address_sget_printable (admin_address, &s) == 0)
+ logmsg (LOG_DEBUG, _("sending stats to %s"), s);
}
tc = timer_get_count () * 3;
exp = make_stat_expansion (tc + 1);
time (&t);
exp[0].kw = "date";
@@ -592,20 +582,17 @@ do_notify (struct file_triplet *trp, enum notification_event ev,
}
if (debug_level)
{
if (rcpt)
{
- size_t size;
- char *buf;
- mu_address_to_string (rcpt, NULL, 0, &size);
- buf = grecs_malloc (size + 1);
- mu_address_to_string (rcpt, buf, size + 1, NULL);
- logmsg (LOG_DEBUG, _("notifying %s (project %s) about %s"),
- buf, trp->project, notification_event_str (ev));
- free (buf);
+ const char *s;
+
+ if (mu_address_sget_printable (rcpt, &s) == 0)
+ logmsg (LOG_DEBUG, _("notifying %s (project %s) about %s"),
+ s, trp->project, notification_event_str (ev));
}
else
logmsg (LOG_DEBUG,
_("notifying message recipients (project %s) about %s"),
trp->project, notification_event_str (ev));
}
@@ -635,48 +622,39 @@ notify (struct notification *notification_list,
/* FIXME */
}
const char *
expand_email_admin (struct metadef *def, void *data)
{
- size_t size;
- if (mu_address_to_string (admin_address, NULL, 0, &size) == 0)
- {
- size++;
- def->storage = grecs_malloc (size);
- mu_address_to_string (admin_address, def->storage, size, NULL);
- def->value = def->storage;
- }
+ if (mu_address_aget_printable (admin_address, &def->storage) == 0)
+ def->value = def->storage;
else
def->value = "";
return def->value;
}
const char *
expand_email_owner (struct metadef *def, void *data)
{
struct file_triplet *trp = data;
mu_address_t addr;
const char *errp;
- size_t size;
addr = get_recipient (trp->spool->dictionary[project_owner_dict],
trp, &errp);
if (!addr)
{
logmsg (LOG_ERR, _("cannot get email of the %s's owner: %s"),
trp->project, gettext (errp));
def->value = "";
}
- else if (mu_address_to_string (addr, NULL, 0, &size) == 0)
+ else
{
- size++;
- def->storage = grecs_malloc (size);
- mu_address_to_string (addr, def->storage, size, NULL);
- def->value = def->storage;
+ if (mu_address_aget_printable (addr, &def->storage) == 0)
+ def->value = def->storage;
+ else
+ def->value = "";
mu_address_destroy (&addr);
}
- else
- def->value = "";
return def->value;
}

Return to:

Send suggestions and report system problems to the System administrator.