Commit d1b1cba2 d1b1cba265616c7b48948c7f27d4a15f335fd6ae by Sergey Poznyakoff

Bugfixes.

* mailbox/mimehdr.c (_header_get_param): If buf is NULL
on entry, make sure it alwaus points to allocated memory
afterwards.

* examples/mimetest.c (charset): New variable.
(main): New command line option -c.
(message_display_parts): Use mu_message_aget_decoded_attachment_name.
Pass fname to mu_message_save_attachment.
1 parent 7287e840
...@@ -35,6 +35,7 @@ void message_display_parts(mu_message_t msg, int indent); ...@@ -35,6 +35,7 @@ void message_display_parts(mu_message_t msg, int indent);
35 35
36 const char *from; 36 const char *from;
37 const char *subject; 37 const char *subject;
38 const char *charset = "UTF-8";
38 int print_attachments; 39 int print_attachments;
39 int indent_level = 4; 40 int indent_level = 4;
40 41
...@@ -72,7 +73,23 @@ main (int argc, char **argv) ...@@ -72,7 +73,23 @@ main (int argc, char **argv)
72 else if (strcmp (argv[i], "-p") == 0) 73 else if (strcmp (argv[i], "-p") == 0)
73 print_attachments = 1; 74 print_attachments = 1;
74 else if (strcmp (argv[i], "-i") == 0) 75 else if (strcmp (argv[i], "-i") == 0)
75 indent_level = strtoul (argv[++i], NULL, 0); 76 {
77 if (++i == argc)
78 {
79 mu_error ("-i requires argument");
80 exit (1);
81 }
82 indent_level = strtoul (argv[i], NULL, 0);
83 }
84 else if (strcmp (argv[i], "-c") == 0)
85 {
86 if (++i == argc)
87 {
88 mu_error ("-c requires argument");
89 exit (1);
90 }
91 charset = argv[i];
92 }
76 else 93 else
77 break; 94 break;
78 } 95 }
...@@ -242,8 +259,9 @@ message_display_parts (mu_message_t msg, int indent) ...@@ -242,8 +259,9 @@ message_display_parts (mu_message_t msg, int indent)
242 { 259 {
243 /* Save the attachements. */ 260 /* Save the attachements. */
244 char *fname = NULL; 261 char *fname = NULL;
245 /* FIXME: CS/Lang info is ignored */ 262
246 mu_message_aget_attachment_name (part, &fname, NULL); 263 mu_message_aget_decoded_attachment_name (part, charset,
264 &fname, NULL);
247 if (fname == NULL) 265 if (fname == NULL)
248 fname = mu_tempname (NULL); 266 fname = mu_tempname (NULL);
249 267
...@@ -251,7 +269,7 @@ message_display_parts (mu_message_t msg, int indent) ...@@ -251,7 +269,7 @@ message_display_parts (mu_message_t msg, int indent)
251 fname); 269 fname);
252 printf ("%*.*sBegin\n", indent, indent, ""); 270 printf ("%*.*sBegin\n", indent, indent, "");
253 /*FIXME: What is the 'data' argument for? */ 271 /*FIXME: What is the 'data' argument for? */
254 mu_message_save_attachment (part, NULL, NULL); 272 mu_message_save_attachment (part, fname, NULL);
255 if (print_attachments) 273 if (print_attachments)
256 print_file (fname, indent); 274 print_file (fname, indent);
257 free (fname); 275 free (fname);
......
...@@ -276,7 +276,7 @@ _header_get_param (const char *field_body, ...@@ -276,7 +276,7 @@ _header_get_param (const char *field_body,
276 res = ENOMEM; 276 res = ENOMEM;
277 break; 277 break;
278 } 278 }
279 mem = newmem; 279 buf = mem = newmem;
280 } 280 }
281 } 281 }
282 282
......