diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-04-08 23:13:38 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-04-08 23:13:38 +0300 |
commit | 787121995cef1f77d279df9b70a9eb1f4fb35325 (patch) | |
tree | 795ae383ac877b97091d738ea6d4b9a50a5b80b8 /mh | |
parent | d02e8bf4ee35f5b1f81208b56b545e1f2d6ac2a9 (diff) | |
download | mailutils-787121995cef1f77d279df9b70a9eb1f4fb35325.tar.gz mailutils-787121995cef1f77d279df9b70a9eb1f4fb35325.tar.bz2 |
Fix all FIXMEs from b2c1b1ff. Revise attachment API.
* include/mailutils/message.h (mu_message_save_attachment)
(mu_message_encapsulate, mu_message_unencapsulate): Change type
of the last argument.
(mu_mime_io_buffer_create,mu_mime_io_buffer_destroy)
(mu_mime_io_buffer_set_size,mu_mime_io_buffer_get_size)
(mu_mime_io_buffer_set_charset,mu_mime_io_buffer_sget_charset)
(mu_mime_io_buffer_aget_charset): New prototypes.
(mu_mimehdr_get_disp,mu_mimehdr_aget_disp): Remove unneeded
parameter.
* include/mailutils/types.hin (mu_mime_io_buffer_t): New type.
* mailbox/attachment.c (_msg_info): Rename structure to
_mu_mime_io_buffer.
<header_buf,header_len,mu_header_size>: Remove unreferenced members.
<refcnt,bufsize,charset>: New members.
<ioffset,ooffset>: Change type to size_t.
(mu_mime_io_buffer_create,mu_mime_io_buffer_destroy)
(mu_mime_io_buffer_set_size,mu_mime_io_buffer_get_size)
(mu_mime_io_buffer_set_charset,mu_mime_io_buffer_sget_charset)
(mu_mime_io_buffer_aget_charset): New functions.
(mu_message_save_attachment)
(mu_message_encapsulate, mu_message_unencapsulate): Take
mu_mime_io_buffer_t as the last argument.
* mailbox/mimehdr.c (mu_mimehdr_get_disp): Remove unneeded
parameter.
(mu_mimehdr_aget_disp): Remove unneeded parameter. Store
return value into pvalue.
* examples/mimetest.c (message_display_parts): Use
mu_mimehdr_aget_disp and mu_mime_io_buffer_* functions.
* mailbox/testsuite/Mime: Update.
* mh/mhn.c (options, opt_handler): New option --charset.
(store_handler): Use mu_message_aget_decoded_attachment_name.
Diffstat (limited to 'mh')
-rw-r--r-- | mh/mh_getopt.h | 3 | ||||
-rw-r--r-- | mh/mhn.c | 31 |
2 files changed, 25 insertions, 9 deletions
diff --git a/mh/mh_getopt.h b/mh/mh_getopt.h index 4815b1205..bd26f832a 100644 --- a/mh/mh_getopt.h +++ b/mh/mh_getopt.h @@ -55,7 +55,8 @@ enum mh_arg { ARG_BUILD, ARG_CC, ARG_CFLAGS, - ARG_CHANGECUR, + ARG_CHANGECUR, + ARG_CHARSET, ARG_CHECK, ARG_CHUNKSIZE, ARG_CLEAR, @@ -74,16 +74,18 @@ static struct argp_option options[] = { {"auto", ARG_AUTO, N_("BOOL"), OPTION_ARG_OPTIONAL, N_("use filenames from the content headers"), 31}, {"noauto", ARG_NOAUTO, NULL, OPTION_HIDDEN, "", 31 }, - + {"charset", ARG_CHARSET, N_("NAME"), 0, + N_("use this charset to represent attachment file names"), 31}, + {N_("Other options"), 0, NULL, OPTION_DOC, NULL, 40}, {"part", ARG_PART, N_("PART"), 0, N_("limit the scope of the operation to the given part"), 41}, {"type", ARG_TYPE, N_("CONTENT"), 0, N_("operate on message part with given multipart content"), 41 }, - {"verbose", ARG_VERBOSE, N_("BOOL"), OPTION_ARG_OPTIONAL, + {"verbose", ARG_VERBOSE, N_("BOOL"), OPTION_ARG_OPTIONAL, N_("print additional information"), 41 }, - {"noverbose", ARG_NOVERBOSE, NULL, OPTION_HIDDEN, "", 41 }, - {"quiet", ARG_QUIET, 0, 0, + {"noverbose", ARG_NOVERBOSE, NULL, OPTION_HIDDEN, "", 41 }, + {"quiet", ARG_QUIET, 0, 0, N_("be quiet")}, {"license", ARG_LICENSE, 0, 0, N_("display software license"), -1}, @@ -144,6 +146,8 @@ static char *content_type; static char *content_subtype; static char *input_file; static int width = 80; +static char *charset; /* Charset for output file names. NULL means + no recoding is necessary. */ static mh_msgset_t msgset; static mu_mailbox_t mbox; @@ -397,6 +401,10 @@ opt_handler (int key, char *arg, struct argp_state *state) mh_license (argp_program_version); break; + case ARG_CHARSET: + charset = arg; + break; + default: return ARGP_ERR_UNKNOWN; } @@ -1589,14 +1597,21 @@ store_handler (mu_message_t msg, msg_part_t part, char *type, char *encoding, if (mode_options & OPT_AUTO) { char *val; - - /* FIXME: Take into account CS/Lang info and recode the value - if necessary */ - if (mu_message_aget_attachment_name (msg, &val, NULL) == 0) + int rc = mu_message_aget_decoded_attachment_name (msg, charset, + &val, NULL); + if (rc == 0) { name = normalize_path (dir, val); free (val); } + else if (rc != MU_ERR_NOENT) + { + char *pstr = msg_part_format (part); + mu_diag_output (MU_DIAG_WARNING, + _("%s: cannot decode attachment name: %s"), + pstr, mu_strerror (rc)); + free (pstr); + } } if (!name) |