aboutsummaryrefslogtreecommitdiff
path: root/mailutils/makemime.c
diff options
context:
space:
mode:
Diffstat (limited to 'mailutils/makemime.c')
-rw-r--r--mailutils/makemime.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/mailutils/makemime.c b/mailutils/makemime.c
index a9ff03d03..1dadd715f 100644
--- a/mailutils/makemime.c
+++ b/mailutils/makemime.c
@@ -1,7 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * makemime: create MIME-encoded message 3 * makemime: create MIME-encoded message
4 * reformime: parse MIME-encoded message
5 * 4 *
6 * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com> 5 * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
7 * 6 *
@@ -133,21 +132,44 @@ Content-Transfer-Encoding: 7bit
133//usage: "Create multipart MIME-encoded message from FILEs\n" 132//usage: "Create multipart MIME-encoded message from FILEs\n"
134/* //usage: "Transfer encoding is base64, disposition is inline (not attachment)\n" */ 133/* //usage: "Transfer encoding is base64, disposition is inline (not attachment)\n" */
135//usage: "\n -o FILE Output. Default: stdout" 134//usage: "\n -o FILE Output. Default: stdout"
136//usage: "\n -a HDR Add header. Examples:" 135//usage: "\n -a HDR Add header(s). Examples:"
137//usage: "\n \"From: user@host.org\", \"Date: `date -R`\"" 136//usage: "\n \"From: user@host.org\", \"Date: `date -R`\""
138//usage: "\n -c CT Content type. Default: text/plain" 137//usage: "\n -c CT Content type. Default: application/octet-stream"
139//usage: "\n -C CS Charset. Default: " CONFIG_FEATURE_MIME_CHARSET 138//usage: "\n -C CS Charset. Default: " CONFIG_FEATURE_MIME_CHARSET
140/* //usage: "\n -e ENC Transfer encoding. Ignored. base64 is assumed" */ 139/* //usage: "\n -e ENC Transfer encoding. Ignored. base64 is assumed" */
141//usage: "\n" 140//usage: "\n"
142//usage: "\nOther options are silently ignored" 141//usage: "\nOther options are silently ignored"
143 142
143/*
144 * -c [Content-Type] should create just one MIME section
145 * with "Content-Type:", "Content-Transfer-Encoding:", and HDRs from "-a HDR".
146 * NB: without "Content-Disposition:" auto-added, unlike we do now
147 * NB2: -c has *optional* param which nevertheless _can_ be specified after a space :(
148 *
149 * -m [multipart/mixed] should create multipart MIME section
150 * with "Content-Type:", "Content-Transfer-Encoding:", and HDRs from "-a HDR",
151 * and add FILE to it _verbatim_:
152 * HEADERS
153 *
154 * --=_1_1321709112_1605
155 * FILE_CONTENTS
156 * --=_1_1321709112_1605
157 * without any encoding of FILE_CONTENTS. (Basically, it expects that FILE
158 * is the result of "makemime -c").
159 *
160 * -j MULTIPART_FILE1 SINGLE_FILE2 should output MULTIPART_FILE1 + SINGLE_FILE2
161 *
162 * Our current behavior is a mutant "-m + -c + -j" one: we create multipart MIME
163 * and we put "-c" encoded FILEs into many multipart sections.
164 */
165
144int makemime_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 166int makemime_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
145int makemime_main(int argc UNUSED_PARAM, char **argv) 167int makemime_main(int argc UNUSED_PARAM, char **argv)
146{ 168{
147 llist_t *opt_headers = NULL, *l; 169 llist_t *opt_headers = NULL, *l;
148 const char *opt_output; 170 const char *opt_output;
171 const char *content_type = "application/octet-stream";
149#define boundary opt_output 172#define boundary opt_output
150
151 enum { 173 enum {
152 OPT_c = 1 << 0, // create (non-multipart) section 174 OPT_c = 1 << 0, // create (non-multipart) section
153 OPT_e = 1 << 1, // Content-Transfer-Encoding. Ignored. Assumed base64 175 OPT_e = 1 << 1, // Content-Transfer-Encoding. Ignored. Assumed base64
@@ -164,8 +186,8 @@ int makemime_main(int argc UNUSED_PARAM, char **argv)
164 // parse options 186 // parse options
165 opt_complementary = "a::"; 187 opt_complementary = "a::";
166 opts = getopt32(argv, 188 opts = getopt32(argv,
167 "c:e:o:C:N:a:", //:m:j:", 189 "c:e:o:C:N:a:", // "m:j:",
168 &G.content_type, NULL, &opt_output, &G.opt_charset, NULL, &opt_headers //, NULL, NULL 190 &content_type, NULL, &opt_output, &G.opt_charset, NULL, &opt_headers //, NULL, NULL
169 ); 191 );
170 //argc -= optind; 192 //argc -= optind;
171 argv += optind; 193 argv += optind;
@@ -202,7 +224,7 @@ int makemime_main(int argc UNUSED_PARAM, char **argv)
202 "Content-Disposition: inline; filename=\"%s\"\n" 224 "Content-Disposition: inline; filename=\"%s\"\n"
203 "Content-Transfer-Encoding: base64\n" 225 "Content-Transfer-Encoding: base64\n"
204 , boundary 226 , boundary
205 , G.content_type 227 , content_type
206 , G.opt_charset 228 , G.opt_charset
207 , bb_get_last_path_component_strip(*argv) 229 , bb_get_last_path_component_strip(*argv)
208 ); 230 );