From ff1a8a6e673923ab9407815155834971f1f2235f Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Wed, 19 Apr 2017 10:44:41 +0300 Subject: Minor changes * mail/mail.c (cli_attach): Exit if unable to attach file. * mail/mail.h (send_attach_file): Change prototype. * mail/send.c (send_attach_file): Return int. (add_body): Honor default_content_type --- mail/mail.c | 7 ++++--- mail/mail.h | 10 +++++----- mail/send.c | 20 +++++++++++--------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/mail/mail.c b/mail/mail.c index 3a3116991..4a50460a6 100644 --- a/mail/mail.c +++ b/mail/mail.c @@ -146,8 +146,9 @@ cli_attach (struct mu_parseopt *po, struct mu_option *opt, char const *arg) arg = NULL; fd = 0; } - send_attach_file (fd, arg, content_filename, content_name, - default_content_type, default_encoding); + if (send_attach_file (fd, arg, content_filename, content_name, + default_content_type, default_encoding)) + exit (po->po_exit_error); free (content_name); content_name = NULL; @@ -170,7 +171,7 @@ cli_attach_fd (struct mu_parseopt *po, struct mu_option *opt, char const *arg) send_attach_file (fd, NULL, content_filename, content_name, default_content_type, default_encoding); - + free (content_name); content_name = NULL; free (content_filename); diff --git a/mail/mail.h b/mail/mail.h index b729eb5b0..ab04896a1 100644 --- a/mail/mail.h +++ b/mail/mail.h @@ -263,11 +263,11 @@ extern char *mail_expand_name (const char *name); extern void send_append_header (char const *text); extern void send_append_header2 (char const *name, char const *value, int mode); -extern void send_attach_file (int fd, - const char *filename, - const char *content_filename, - const char *content_name, - const char *content_type, const char *encoding); +extern int send_attach_file (int fd, + const char *filename, + const char *content_filename, + const char *content_name, + const char *content_type, const char *encoding); extern int escape_check_args (int argc, char **argv, int minargs, int maxargs); diff --git a/mail/send.c b/mail/send.c index 3b9ab97ab..b8b74c2ea 100644 --- a/mail/send.c +++ b/mail/send.c @@ -324,19 +324,19 @@ attlist_copy (mu_list_t src) static mu_list_t attachment_list; -void +int send_attach_file (int fd, const char *realname, const char *content_filename, const char *content_name, const char *content_type, const char *encoding) { - attlist_attach_file (&attachment_list, - fd, - realname, - content_filename, - content_name, - content_type, - encoding); + return attlist_attach_file (&attachment_list, + fd, + realname, + content_filename, + content_name, + content_type, + encoding); } static void @@ -561,7 +561,9 @@ add_body (mu_message_t inmsg, mu_iterator_t itr, mu_mime_t mime) } /* 4. Add the content type and content ID headers. */ - mu_header_set_value (outhdr, MU_HEADER_CONTENT_TYPE, "text/plain", 0); + mu_header_set_value (outhdr, MU_HEADER_CONTENT_TYPE, + default_content_type ? default_content_type : "text/plain", + 0); mu_rfc2822_msg_id (0, &p); mu_header_set_value (outhdr, MU_HEADER_CONTENT_ID, p, 1); free (p); -- cgit v1.2.1