Commit b264f32c b264f32c7734360dd7307b669b94c1404ef6a31a by Sergey Poznyakoff

(opt_handler, make_draft): Handle --fcc

1 parent 8b47e90e
Showing 1 changed file with 30 additions and 2 deletions
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
19 /* MH repl command */ 19 /* MH repl command */
20 20
21 #include <mh.h> 21 #include <mh.h>
22 #include <mh_format.h>
22 #include <sys/stat.h> 23 #include <sys/stat.h>
23 #include <unistd.h> 24 #include <unistd.h>
24 25
...@@ -52,7 +53,7 @@ static struct argp_option options[] = { ...@@ -52,7 +53,7 @@ static struct argp_option options[] = {
52 N_("Construct a group or followup reply") }, 53 N_("Construct a group or followup reply") },
53 {"editor", ARG_EDITOR, N_("PROG"), 0, N_("Set the editor program to use")}, 54 {"editor", ARG_EDITOR, N_("PROG"), 0, N_("Set the editor program to use")},
54 {"noedit", ARG_NOEDIT, 0, 0, N_("Suppress the initial edit")}, 55 {"noedit", ARG_NOEDIT, 0, 0, N_("Suppress the initial edit")},
55 {"fcc", ARG_FCC, N_("FOLDER"), 0, N_("* Set the folder to receive Fcc's")}, 56 {"fcc", ARG_FCC, N_("FOLDER"), 0, N_("Set the folder to receive Fcc's")},
56 {"filter", ARG_FILTER, N_("MHL-FILTER"), 0, 57 {"filter", ARG_FILTER, N_("MHL-FILTER"), 0,
57 N_("Set the mhl filter to preprocess the body of the message being replied")}, 58 N_("Set the mhl filter to preprocess the body of the message being replied")},
58 {"form", ARG_FORM, N_("FILE"), 0, N_("Read format from given file")}, 59 {"form", ARG_FORM, N_("FILE"), 0, N_("Read format from given file")},
...@@ -123,6 +124,8 @@ static int use_draft = 0; /* --use flag */ ...@@ -123,6 +124,8 @@ static int use_draft = 0; /* --use flag */
123 static char *mhl_filter = NULL; /* --filter flag */ 124 static char *mhl_filter = NULL; /* --filter flag */
124 static int annotate; /* --annotate flag */ 125 static int annotate; /* --annotate flag */
125 static char *draftmessage = "new"; 126 static char *draftmessage = "new";
127 static struct obstack fcc_stack;
128 static int has_fcc;
126 129
127 static int 130 static int
128 decode_cc_flag (const char *opt, const char *arg) 131 decode_cc_flag (const char *opt, const char *arg)
...@@ -243,6 +246,16 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) ...@@ -243,6 +246,16 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
243 break; 246 break;
244 247
245 case ARG_FCC: 248 case ARG_FCC:
249 if (!has_fcc)
250 {
251 obstack_init (&fcc_stack);
252 has_fcc = 1;
253 }
254 else
255 obstack_grow (&fcc_stack, ", ", 2);
256 obstack_grow (&fcc_stack, arg, strlen (arg));
257 break;
258
246 case ARG_INPLACE: 259 case ARG_INPLACE:
247 case ARG_WHATNOWPROC: 260 case ARG_WHATNOWPROC:
248 case ARG_NOWHATNOWPROC: 261 case ARG_NOWHATNOWPROC:
...@@ -335,7 +348,22 @@ make_draft (mu_mailbox_t mbox, int disp, struct mh_whatnow_env *wh) ...@@ -335,7 +348,22 @@ make_draft (mu_mailbox_t mbox, int disp, struct mh_whatnow_env *wh)
335 exit (1); 348 exit (1);
336 } 349 }
337 350
338 mh_format (&format, msg, msgset.list[0], width, &buf); 351 if (has_fcc)
352 {
353 mu_message_t tmp_msg;
354 mu_header_t hdr;
355 char *text;
356
357 mu_message_create_copy (&tmp_msg, msg);
358 mu_message_get_header (tmp_msg, &hdr);
359 text = obstack_finish (&fcc_stack);
360 mu_header_set_value (hdr, MU_HEADER_FCC, text, 0);
361 mh_format (&format, tmp_msg, msgset.list[0], width, &buf);
362 mu_message_destroy (&tmp_msg, NULL);
363 }
364 else
365 mh_format (&format, msg, msgset.list[0], width, &buf);
366
339 mu_stream_sequential_write (str, buf, strlen (buf)); 367 mu_stream_sequential_write (str, buf, strlen (buf));
340 368
341 if (mhl_filter) 369 if (mhl_filter)
......