Commit 38ddd22f 38ddd22f66b0dda59a0a0a879fcd101884decda5 by Sergey Poznyakoff

Honour "outfolder" variable. If called without

arguments, deduce output file name from the number of current
message.
1 parent 10223423
...@@ -31,9 +31,6 @@ mail_write (int argc, char **argv) ...@@ -31,9 +31,6 @@ mail_write (int argc, char **argv)
31 stream_t stream; 31 stream_t stream;
32 FILE *output; 32 FILE *output;
33 char *filename = NULL; 33 char *filename = NULL;
34 char buffer[512];
35 off_t off = 0;
36 size_t n = 0;
37 msgset_t *msglist = NULL, *mp; 34 msgset_t *msglist = NULL, *mp;
38 int sender = 0; 35 int sender = 0;
39 size_t total_size = 0, total_lines = 0, size; 36 size_t total_size = 0, total_lines = 0, size;
...@@ -41,12 +38,15 @@ mail_write (int argc, char **argv) ...@@ -41,12 +38,15 @@ mail_write (int argc, char **argv)
41 if (isupper (argv[0][0])) 38 if (isupper (argv[0][0]))
42 sender = 1; 39 sender = 1;
43 else if (argc >= 2) 40 else if (argc >= 2)
44 filename = util_fullpath (argv[--argc]); 41 filename = util_outfolder_name (argv[--argc]);
45 /* FIXME: Should we use util_outfolder_name() and honour
46 outfolder variable? */
47 else 42 else
48 filename = strdup ("mbox"); 43 {
49 44 char *p = NULL;
45 asprintf (&p, "%d", cursor);
46 filename = util_outfolder_name (p);
47 free (p);
48 }
49
50 if (msgset_parse (argc, argv, &msglist)) 50 if (msgset_parse (argc, argv, &msglist))
51 { 51 {
52 if (filename) 52 if (filename)
...@@ -56,7 +56,7 @@ mail_write (int argc, char **argv) ...@@ -56,7 +56,7 @@ mail_write (int argc, char **argv)
56 56
57 if (sender) 57 if (sender)
58 { 58 {
59 filename = util_get_sender(msglist->msg_part[0], 1); 59 filename = util_outfolder_name (util_get_sender(msglist->msg_part[0], 1));
60 if (!filename) 60 if (!filename)
61 { 61 {
62 msgset_free (msglist); 62 msgset_free (msglist);
...@@ -77,6 +77,9 @@ mail_write (int argc, char **argv) ...@@ -77,6 +77,9 @@ mail_write (int argc, char **argv)
77 for (mp = msglist; mp; mp = mp->next) 77 for (mp = msglist; mp; mp = mp->next)
78 { 78 {
79 attribute_t attr; 79 attribute_t attr;
80 char buffer[512];
81 off_t off = 0;
82 size_t n = 0;
80 83
81 mailbox_get_message (mbox, mp->msg_part[0], &msg); 84 mailbox_get_message (mbox, mp->msg_part[0], &msg);
82 message_get_body (msg, &bod); 85 message_get_body (msg, &bod);
......