mh: improve forw; add tests.
* mh/forw.c (options): New option --file. (input_file): New variable. (opt_handler): Handle --file. (finish_draft): Remove a leftover path hack. Implement raw file forwarding. (main): Minor fix. * mh/mh_getopt.c (mh_option_init): Limit match_len to the actual length of the option string. * mh/tests/forw.at: New file. * mh/tests/Makefile.am (TESTSUITE_AT): Add forw.at. * mh/tests/testsuite.at: Include forw.at. * mh/tests/comp.at: Add more keywords.
Showing
6 changed files
with
526 additions
and
103 deletions
... | @@ -42,6 +42,8 @@ static struct argp_option options[] = { | ... | @@ -42,6 +42,8 @@ static struct argp_option options[] = { |
42 | N_("set the editor program to use")}, | 42 | N_("set the editor program to use")}, |
43 | {"noedit", ARG_NOEDIT, 0, 0, | 43 | {"noedit", ARG_NOEDIT, 0, 0, |
44 | N_("suppress the initial edit")}, | 44 | N_("suppress the initial edit")}, |
45 | {"file", ARG_FILE, N_("FILE"), 0, | ||
46 | N_("read message from FILE")}, | ||
45 | {"format", ARG_FORMAT, N_("BOOL"), 0, | 47 | {"format", ARG_FORMAT, N_("BOOL"), 0, |
46 | N_("format messages")}, | 48 | N_("format messages")}, |
47 | {"noformat", ARG_NOFORMAT, NULL, 0, | 49 | {"noformat", ARG_NOFORMAT, NULL, 0, |
... | @@ -74,26 +76,28 @@ static struct argp_option options[] = { | ... | @@ -74,26 +76,28 @@ static struct argp_option options[] = { |
74 | struct mh_option mh_option[] = { | 76 | struct mh_option mh_option[] = { |
75 | { "annotate", MH_OPT_BOOL }, | 77 | { "annotate", MH_OPT_BOOL }, |
76 | { "build" }, | 78 | { "build" }, |
77 | { "form", MH_OPT_ARG, "formatfile"}, | 79 | { "file", MH_OPT_ARG, "msgfile" }, |
78 | { "format", MH_OPT_ARG, "string"}, | 80 | { "form", MH_OPT_ARG, "formatfile" }, |
79 | { "draftfolder", MH_OPT_ARG, "folder"}, | 81 | { "format", MH_OPT_ARG, "string" }, |
82 | { "draftfolder", MH_OPT_ARG, "folder" }, | ||
80 | { "nodraftfolder" }, | 83 | { "nodraftfolder" }, |
81 | { "draftmessage" }, | 84 | { "draftmessage" }, |
82 | { "editor", MH_OPT_ARG, "program"}, | 85 | { "editor", MH_OPT_ARG, "program" }, |
83 | { "noedit" }, | 86 | { "noedit" }, |
84 | { "filter", MH_OPT_ARG, "program"}, | 87 | { "filter", MH_OPT_ARG, "program" }, |
85 | { "inplace", MH_OPT_BOOL }, | 88 | { "inplace", MH_OPT_BOOL }, |
86 | { "whatnowproc", MH_OPT_ARG, "program"}, | 89 | { "whatnowproc", MH_OPT_ARG, "program" }, |
87 | { "nowhatnowproc" }, | 90 | { "nowhatnowproc" }, |
88 | { "mime", MH_OPT_BOOL }, | 91 | { "mime", MH_OPT_BOOL }, |
89 | { NULL } | 92 | { NULL } |
90 | }; | 93 | }; |
91 | 94 | ||
92 | enum encap_type { | 95 | enum encap_type |
93 | encap_clear, | 96 | { |
94 | encap_mhl, | 97 | encap_clear, |
95 | encap_mime | 98 | encap_mhl, |
96 | }; | 99 | encap_mime |
100 | }; | ||
97 | 101 | ||
98 | static char *formfile; | 102 | static char *formfile; |
99 | struct mh_whatnow_env wh_env = { 0 }; | 103 | struct mh_whatnow_env wh_env = { 0 }; |
... | @@ -108,6 +112,7 @@ static int use_draft = 0; /* --use flag */ | ... | @@ -108,6 +112,7 @@ static int use_draft = 0; /* --use flag */ |
108 | static int width = 80; /* --width flag */ | 112 | static int width = 80; /* --width flag */ |
109 | static char *draftmessage = "new"; | 113 | static char *draftmessage = "new"; |
110 | static const char *draftfolder = NULL; | 114 | static const char *draftfolder = NULL; |
115 | static char *input_file; /* input file name (--file option) */ | ||
111 | 116 | ||
112 | static mh_msgset_t msgset; | 117 | static mh_msgset_t msgset; |
113 | static mu_mailbox_t mbox; | 118 | static mu_mailbox_t mbox; |
... | @@ -118,8 +123,7 @@ opt_handler (int key, char *arg, struct argp_state *state) | ... | @@ -118,8 +123,7 @@ opt_handler (int key, char *arg, struct argp_state *state) |
118 | switch (key) | 123 | switch (key) |
119 | { | 124 | { |
120 | case ARGP_KEY_INIT: | 125 | case ARGP_KEY_INIT: |
121 | draftfolder = mh_global_profile_get ("Draft-Folder", | 126 | draftfolder = mh_global_profile_get ("Draft-Folder", NULL); |
122 | mu_folder_directory ()); | ||
123 | whatnowproc = mh_global_profile_get ("whatnowproc", NULL); | 127 | whatnowproc = mh_global_profile_get ("whatnowproc", NULL); |
124 | break; | 128 | break; |
125 | 129 | ||
... | @@ -131,6 +135,10 @@ opt_handler (int key, char *arg, struct argp_state *state) | ... | @@ -131,6 +135,10 @@ opt_handler (int key, char *arg, struct argp_state *state) |
131 | build_only = 1; | 135 | build_only = 1; |
132 | break; | 136 | break; |
133 | 137 | ||
138 | case ARG_FILE: | ||
139 | input_file = arg; | ||
140 | break; | ||
141 | |||
134 | case ARG_DRAFTFOLDER: | 142 | case ARG_DRAFTFOLDER: |
135 | draftfolder = arg; | 143 | draftfolder = arg; |
136 | break; | 144 | break; |
... | @@ -218,7 +226,8 @@ opt_handler (int key, char *arg, struct argp_state *state) | ... | @@ -218,7 +226,8 @@ opt_handler (int key, char *arg, struct argp_state *state) |
218 | return 0; | 226 | return 0; |
219 | } | 227 | } |
220 | 228 | ||
221 | struct format_data { | 229 | struct format_data |
230 | { | ||
222 | int num; | 231 | int num; |
223 | mu_stream_t stream; | 232 | mu_stream_t stream; |
224 | mu_list_t format; | 233 | mu_list_t format; |
... | @@ -286,26 +295,41 @@ msg_copy (mu_message_t msg, mu_stream_t ostream) | ... | @@ -286,26 +295,41 @@ msg_copy (mu_message_t msg, mu_stream_t ostream) |
286 | } | 295 | } |
287 | 296 | ||
288 | void | 297 | void |
289 | format_message (mu_mailbox_t mbox, mu_message_t msg, size_t num, void *data) | 298 | format_message (mu_stream_t outstr, mu_message_t msg, int num, |
299 | mu_list_t format) | ||
290 | { | 300 | { |
291 | struct format_data *fp = data; | 301 | int rc = 0; |
292 | char *s; | ||
293 | int rc; | ||
294 | 302 | ||
295 | if (annotate) | 303 | if (annotate) |
296 | mu_list_append (wh_env.anno_list, msg); | 304 | mu_list_append (wh_env.anno_list, msg); |
297 | 305 | ||
298 | if (fp->num) | 306 | if (num) |
307 | rc = mu_stream_printf (outstr, "\n------- Message %d\n", num); | ||
308 | |||
309 | if (rc == 0) | ||
310 | { | ||
311 | if (format) | ||
312 | rc = mhl_format_run (format, width, 0, 0, msg, outstr); | ||
313 | else | ||
314 | rc = msg_copy (msg, outstr); | ||
315 | } | ||
316 | |||
317 | if (rc) | ||
299 | { | 318 | { |
300 | mu_asprintf (&s, "\n------- Message %d\n", fp->num++); | 319 | mu_error (_("cannot copy message: %s"), mu_strerror (rc)); |
301 | rc = mu_stream_write (fp->stream, s, strlen (s), NULL); | 320 | exit (1); |
302 | free (s); | ||
303 | } | 321 | } |
322 | } | ||
304 | 323 | ||
305 | if (fp->format) | 324 | void |
306 | rc = mhl_format_run (fp->format, width, 0, 0, msg, fp->stream); | 325 | format_message_itr (mu_mailbox_t mbox MU_ARG_UNUSED, |
307 | else | 326 | mu_message_t msg, size_t num, void *data) |
308 | rc = msg_copy (msg, fp->stream); | 327 | { |
328 | struct format_data *fp = data; | ||
329 | |||
330 | format_message (fp->stream, msg, fp->num, fp->format); | ||
331 | if (fp->num) | ||
332 | fp->num++; | ||
309 | } | 333 | } |
310 | 334 | ||
311 | void | 335 | void |
... | @@ -317,23 +341,6 @@ finish_draft () | ... | @@ -317,23 +341,6 @@ finish_draft () |
317 | struct format_data fd; | 341 | struct format_data fd; |
318 | char *str; | 342 | char *str; |
319 | 343 | ||
320 | if (!mhl_filter) | ||
321 | { | ||
322 | char *s = mh_expand_name (MHLIBDIR, "mhl.forward", 0); | ||
323 | if (access (s, R_OK) == 0) | ||
324 | mhl_filter = "mhl.forward"; | ||
325 | free (s); | ||
326 | } | ||
327 | |||
328 | if (mhl_filter) | ||
329 | { | ||
330 | char *s = mh_expand_name (MHLIBDIR, mhl_filter, 0); | ||
331 | format = mhl_format_compile (s); | ||
332 | if (!format) | ||
333 | exit (1); | ||
334 | free (s); | ||
335 | } | ||
336 | |||
337 | if ((rc = mu_file_stream_create (&stream, | 344 | if ((rc = mu_file_stream_create (&stream, |
338 | wh_env.file, | 345 | wh_env.file, |
339 | MU_STREAM_WRITE|MU_STREAM_CREAT))) | 346 | MU_STREAM_WRITE|MU_STREAM_CREAT))) |
... | @@ -345,73 +352,120 @@ finish_draft () | ... | @@ -345,73 +352,120 @@ finish_draft () |
345 | 352 | ||
346 | mu_stream_seek (stream, 0, SEEK_END, NULL); | 353 | mu_stream_seek (stream, 0, SEEK_END, NULL); |
347 | 354 | ||
348 | if (annotate) | 355 | if (input_file) |
349 | { | 356 | { |
350 | wh_env.anno_field = "Forwarded"; | 357 | mu_stream_t instr; |
351 | mu_list_create (&wh_env.anno_list); | 358 | int rc; |
352 | } | ||
353 | 359 | ||
354 | if (encap == encap_mime) | 360 | if ((rc = mu_file_stream_create (&stream, |
355 | { | 361 | wh_env.file, |
356 | mu_url_t url; | 362 | MU_STREAM_WRITE|MU_STREAM_CREAT))) |
357 | const char *mbox_path; | 363 | { |
358 | const char *p; | 364 | mu_error (_("cannot open output file `%s': %s"), |
359 | size_t i; | 365 | wh_env.file, mu_strerror (rc)); |
360 | 366 | exit (1); | |
361 | mu_mailbox_get_url (mbox, &url); | 367 | } |
368 | |||
369 | mu_stream_seek (stream, 0, SEEK_END, NULL); | ||
362 | 370 | ||
363 | mbox_path = mu_url_to_string (url); | 371 | rc = mu_file_stream_create (&instr, input_file, MU_STREAM_READ); |
364 | if (memcmp (mbox_path, "mh:", 3) == 0) | 372 | if (rc) |
365 | mbox_path += 3; | ||
366 | mu_asprintf (&str, "#forw [] +%s", mbox_path); | ||
367 | rc = mu_stream_write (stream, str, strlen (str), NULL); | ||
368 | free (str); | ||
369 | for (i = 0; rc == 0 && i < msgset.count; i++) | ||
370 | { | 373 | { |
371 | mu_message_t msg; | 374 | mu_diag_funcall (MU_DIAG_ERROR, "mu_file_stream_create", |
372 | size_t num; | 375 | input_file, rc); |
373 | 376 | exit (1); | |
374 | mu_mailbox_get_message (mbox, msgset.list[i], &msg); | ||
375 | if (annotate) | ||
376 | mu_list_append (wh_env.anno_list, msg); | ||
377 | mh_message_number (msg, &num); | ||
378 | p = mu_umaxtostr (0, num); | ||
379 | rc = mu_stream_write (stream, p, strlen (p), NULL); | ||
380 | } | 377 | } |
378 | |||
379 | rc = mu_stream_copy (stream, instr, 0, NULL); | ||
380 | mu_stream_unref (instr); | ||
381 | } | 381 | } |
382 | else | 382 | else |
383 | { | 383 | { |
384 | str = "\n------- "; | 384 | if (!mhl_filter) |
385 | rc = mu_stream_write (stream, str, strlen (str), NULL); | ||
386 | |||
387 | if (msgset.count == 1) | ||
388 | { | 385 | { |
389 | fd.num = 0; | 386 | char *s = mh_expand_name (MHLIBDIR, "mhl.forward", 0); |
390 | str = (char*) _("Forwarded message\n"); | 387 | if (access (s, R_OK) == 0) |
388 | mhl_filter = "mhl.forward"; | ||
389 | free (s); | ||
391 | } | 390 | } |
392 | else | 391 | |
392 | if (mhl_filter) | ||
393 | { | 393 | { |
394 | fd.num = 1; | 394 | char *s = mh_expand_name (MHLIBDIR, mhl_filter, 0); |
395 | str = (char*) _("Forwarded messages\n"); | 395 | format = mhl_format_compile (s); |
396 | if (!format) | ||
397 | exit (1); | ||
398 | free (s); | ||
396 | } | 399 | } |
397 | 400 | ||
398 | rc = mu_stream_write (stream, str, strlen (str), NULL); | 401 | if (annotate) |
399 | fd.stream = stream; | 402 | { |
400 | fd.format = format; | 403 | wh_env.anno_field = "Forwarded"; |
401 | rc = mh_iterate (mbox, &msgset, format_message, &fd); | 404 | mu_list_create (&wh_env.anno_list); |
405 | } | ||
402 | 406 | ||
403 | str = "\n------- "; | 407 | if (encap == encap_mime) |
404 | rc = mu_stream_write (stream, str, strlen (str), NULL); | 408 | { |
409 | mu_url_t url; | ||
410 | const char *mbox_path; | ||
411 | const char *p; | ||
412 | size_t i; | ||
405 | 413 | ||
406 | if (msgset.count == 1) | 414 | mu_mailbox_get_url (mbox, &url); |
407 | str = (char*) _("End of Forwarded message"); | 415 | mu_url_sget_path (url, &mbox_path); |
416 | mu_asprintf (&str, "#forw [] +%s", mbox_path); | ||
417 | rc = mu_stream_write (stream, str, strlen (str), NULL); | ||
418 | free (str); | ||
419 | for (i = 0; rc == 0 && i < msgset.count; i++) | ||
420 | { | ||
421 | mu_message_t msg; | ||
422 | size_t num; | ||
423 | |||
424 | mu_mailbox_get_message (mbox, msgset.list[i], &msg); | ||
425 | if (annotate) | ||
426 | mu_list_append (wh_env.anno_list, msg); | ||
427 | mh_message_number (msg, &num); | ||
428 | p = mu_umaxtostr (0, num); | ||
429 | rc = mu_stream_write (stream, " ", 1, NULL); | ||
430 | if (rc) | ||
431 | break; | ||
432 | rc = mu_stream_write (stream, p, strlen (p), NULL); | ||
433 | } | ||
434 | } | ||
408 | else | 435 | else |
409 | str = (char*) _("End of Forwarded messages"); | 436 | { |
437 | str = "\n------- "; | ||
438 | rc = mu_stream_write (stream, str, strlen (str), NULL); | ||
439 | |||
440 | if (msgset.count == 1) | ||
441 | { | ||
442 | fd.num = 0; | ||
443 | str = (char*) _("Forwarded message\n"); | ||
444 | } | ||
445 | else | ||
446 | { | ||
447 | fd.num = 1; | ||
448 | str = (char*) _("Forwarded messages\n"); | ||
449 | } | ||
450 | |||
451 | rc = mu_stream_write (stream, str, strlen (str), NULL); | ||
452 | fd.stream = stream; | ||
453 | fd.format = format; | ||
454 | rc = mh_iterate (mbox, &msgset, format_message_itr, &fd); | ||
455 | |||
456 | str = "\n------- "; | ||
457 | rc = mu_stream_write (stream, str, strlen (str), NULL); | ||
458 | |||
459 | if (msgset.count == 1) | ||
460 | str = (char*) _("End of Forwarded message"); | ||
461 | else | ||
462 | str = (char*) _("End of Forwarded messages"); | ||
463 | |||
464 | rc = mu_stream_write (stream, str, strlen (str), NULL); | ||
465 | } | ||
410 | 466 | ||
411 | rc = mu_stream_write (stream, str, strlen (str), NULL); | 467 | rc = mu_stream_write (stream, "\n\n", 2, NULL); |
412 | } | 468 | } |
413 | |||
414 | rc = mu_stream_write (stream, "\n\n", 2, NULL); | ||
415 | mu_stream_close (stream); | 469 | mu_stream_close (stream); |
416 | mu_stream_destroy (&stream); | 470 | mu_stream_destroy (&stream); |
417 | } | 471 | } |
... | @@ -431,27 +485,43 @@ main (int argc, char **argv) | ... | @@ -431,27 +485,43 @@ main (int argc, char **argv) |
431 | argc -= index; | 485 | argc -= index; |
432 | argv += index; | 486 | argv += index; |
433 | 487 | ||
434 | mbox = mh_open_folder (mh_current_folder (), 0); | 488 | if (input_file) |
435 | mh_msgset_parse (mbox, &msgset, argc, argv, "cur"); | 489 | { |
490 | if (encap == encap_mime) | ||
491 | { | ||
492 | mu_error (_("--build disables --mime")); | ||
493 | encap = encap_clear; | ||
494 | } | ||
495 | if (argc) | ||
496 | { | ||
497 | mu_error (_("can't mix files and folders/msgs")); | ||
498 | exit (1); | ||
499 | } | ||
500 | } | ||
501 | else | ||
502 | { | ||
503 | mbox = mh_open_folder (mh_current_folder (), 0); | ||
504 | mh_msgset_parse (mbox, &msgset, argc, argv, "cur"); | ||
505 | } | ||
436 | 506 | ||
437 | if (build_only || !draftfolder) | 507 | if (build_only || !draftfolder) |
438 | wh_env.file = mh_expand_name (NULL, "draft", 0); | 508 | wh_env.file = mh_expand_name (NULL, "draft", 0); |
439 | else | 509 | else if (draftfolder) |
440 | { | 510 | { |
441 | if (mh_draft_message (NULL, draftmessage, &wh_env.file)) | 511 | if (mh_draft_message (draftfolder, draftmessage, &wh_env.file)) |
442 | return 1; | 512 | return 1; |
443 | } | 513 | } |
444 | wh_env.draftfile = wh_env.file; | 514 | wh_env.draftfile = wh_env.file; |
445 | 515 | ||
446 | switch (build_only ? | 516 | switch (build_only ? |
447 | DISP_REPLACE : check_draft_disposition (&wh_env, use_draft)) | 517 | DISP_REPLACE : check_draft_disposition (&wh_env, use_draft)) |
448 | { | 518 | { |
449 | case DISP_QUIT: | 519 | case DISP_QUIT: |
450 | exit (0); | 520 | exit (0); |
451 | 521 | ||
452 | case DISP_USE: | 522 | case DISP_USE: |
453 | break; | 523 | break; |
454 | 524 | ||
455 | case DISP_REPLACE: | 525 | case DISP_REPLACE: |
456 | unlink (wh_env.draftfile); | 526 | unlink (wh_env.draftfile); |
457 | mh_comp_draft (formfile, "forwcomps", wh_env.file); | 527 | mh_comp_draft (formfile, "forwcomps", wh_env.file); | ... | ... |
... | @@ -187,7 +187,8 @@ mh_option_init (struct mh_option *opt) | ... | @@ -187,7 +187,8 @@ mh_option_init (struct mh_option *opt) |
187 | do | 187 | do |
188 | { | 188 | { |
189 | minlen++; | 189 | minlen++; |
190 | opt[j].match_len = minlen; | 190 | if (minlen <= strlen (opt[j].opt)) |
191 | opt[j].match_len = minlen; | ||
191 | if (minlen == sample_len) | 192 | if (minlen == sample_len) |
192 | break; | 193 | break; |
193 | } | 194 | } |
... | @@ -197,7 +198,8 @@ mh_option_init (struct mh_option *opt) | ... | @@ -197,7 +198,8 @@ mh_option_init (struct mh_option *opt) |
197 | else | 198 | else |
198 | break; | 199 | break; |
199 | } | 200 | } |
200 | opt[i].match_len = minlen; | 201 | if (minlen <= sample_len) |
202 | opt[i].match_len = minlen; | ||
201 | } | 203 | } |
202 | } | 204 | } |
203 | 205 | ... | ... |
... | @@ -143,7 +143,7 @@ Subject: test input | ... | @@ -143,7 +143,7 @@ Subject: test input |
143 | message body | 143 | message body |
144 | ]) | 144 | ]) |
145 | 145 | ||
146 | MH_CHECK([comp -draftfolder],[comp05 comp-draftfolder],[ | 146 | MH_CHECK([comp -draftfolder],[comp05 comp-draftfolder draftfolder],[ |
147 | mkdir Mail/drafts | 147 | mkdir Mail/drafts |
148 | dir=`pwd` | 148 | dir=`pwd` |
149 | echo 'quit' | compcmd -draftfolder drafts | sed "s|$dir/*||;s| *$||" | 149 | echo 'quit' | compcmd -draftfolder drafts | sed "s|$dir/*||;s| *$||" |
... | @@ -165,7 +165,7 @@ Subject: | ... | @@ -165,7 +165,7 @@ Subject: |
165 | Seen by mhed | 165 | Seen by mhed |
166 | ]) | 166 | ]) |
167 | 167 | ||
168 | MH_CHECK([comp +draftfolder -use],[comp06 comp-draftfolder-use],[ | 168 | MH_CHECK([comp +draftfolder -use],[comp06 comp-draftfolder-use draftfolder],[ |
169 | mkdir Mail/drafts | 169 | mkdir Mail/drafts |
170 | AT_DATA([Mail/drafts/1],[From: gray | 170 | AT_DATA([Mail/drafts/1],[From: gray |
171 | To: root | 171 | To: root |
... | @@ -201,3 +201,4 @@ Seen by mhed | ... | @@ -201,3 +201,4 @@ Seen by mhed |
201 | m4_popdef([compcmd]) | 201 | m4_popdef([compcmd]) |
202 | m4_popdef([MH_KEYWORDS]) | 202 | m4_popdef([MH_KEYWORDS]) |
203 | 203 | ||
204 | # End of comp.at | ... | ... |
mh/tests/forw.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2010 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | m4_pushdef([MH_KEYWORDS],[forw]) | ||
18 | m4_pushdef([forwcmd],[forw dnl | ||
19 | -form $abs_top_srcdir/mh/components dnl | ||
20 | -editor $abs_top_srcdir/mh/tests/mhed]) | ||
21 | |||
22 | MH_CHECK([forw msg],[forw00 forw-msg],[ | ||
23 | mkdir Mail/inbox | ||
24 | AT_DATA([Mail/inbox/1],[From: gray | ||
25 | To: root | ||
26 | Subject: test input | ||
27 | |||
28 | message body | ||
29 | ]) | ||
30 | |||
31 | dir=`pwd` | ||
32 | echo quit | forwcmd +inbox 1 | sed "s|$dir/*||;s| *$||" | ||
33 | echo == Mail/draft == | ||
34 | cat Mail/draft | ||
35 | echo == Message == | ||
36 | # FIXME: AMD adds this header to the first message. Find a better way. | ||
37 | # See also the same sed hacks below. | ||
38 | sed '/^X-IMAPbase/d' Mail/inbox/1 | ||
39 | ], | ||
40 | [0], | ||
41 | [-- Editor invocation: Mail/draft | ||
42 | -- Input file: | ||
43 | To: | ||
44 | cc: | ||
45 | Subject: | ||
46 | -------- | ||
47 | |||
48 | ------- Forwarded message | ||
49 | From: gray | ||
50 | To: root | ||
51 | Subject: test input | ||
52 | |||
53 | message body | ||
54 | |||
55 | ------- End of Forwarded message | ||
56 | |||
57 | -- Input file end | ||
58 | What now? draft left on "Mail/draft". | ||
59 | == Mail/draft == | ||
60 | To: | ||
61 | cc: | ||
62 | Subject: | ||
63 | -------- | ||
64 | |||
65 | ------- Forwarded message | ||
66 | From: gray | ||
67 | To: root | ||
68 | Subject: test input | ||
69 | |||
70 | message body | ||
71 | |||
72 | ------- End of Forwarded message | ||
73 | |||
74 | Seen by mhed | ||
75 | == Message == | ||
76 | From: gray | ||
77 | To: root | ||
78 | Subject: test input | ||
79 | |||
80 | message body | ||
81 | ]) | ||
82 | |||
83 | MH_CHECK([forw msgs],[forw01 forw-msgs],[ | ||
84 | mkdir Mail/inbox | ||
85 | AT_DATA([Mail/inbox/1],[From: gray | ||
86 | To: root | ||
87 | Subject: test input | ||
88 | |||
89 | message body | ||
90 | ]) | ||
91 | AT_DATA([Mail/inbox/2],[From: gray | ||
92 | To: marlow | ||
93 | Subject: 2nd message | ||
94 | |||
95 | 2nd message body | ||
96 | ]) | ||
97 | |||
98 | dir=`pwd` | ||
99 | echo quit | forwcmd +inbox 1 2 | sed "s|$dir/*||;s| *$||" | ||
100 | echo == Mail/draft == | ||
101 | cat Mail/draft | ||
102 | echo == Message 1 == | ||
103 | sed '/^X-IMAPbase/d' Mail/inbox/1 | ||
104 | echo == Message 2 == | ||
105 | cat Mail/inbox/2 | ||
106 | ], | ||
107 | [0], | ||
108 | [-- Editor invocation: Mail/draft | ||
109 | -- Input file: | ||
110 | To: | ||
111 | cc: | ||
112 | Subject: | ||
113 | -------- | ||
114 | |||
115 | ------- Forwarded messages | ||
116 | |||
117 | ------- Message 1 | ||
118 | From: gray | ||
119 | To: root | ||
120 | Subject: test input | ||
121 | |||
122 | message body | ||
123 | |||
124 | ------- Message 2 | ||
125 | From: gray | ||
126 | To: marlow | ||
127 | Subject: 2nd message | ||
128 | |||
129 | 2nd message body | ||
130 | |||
131 | ------- End of Forwarded messages | ||
132 | |||
133 | -- Input file end | ||
134 | What now? draft left on "Mail/draft". | ||
135 | == Mail/draft == | ||
136 | To: | ||
137 | cc: | ||
138 | Subject: | ||
139 | -------- | ||
140 | |||
141 | ------- Forwarded messages | ||
142 | |||
143 | ------- Message 1 | ||
144 | From: gray | ||
145 | To: root | ||
146 | Subject: test input | ||
147 | |||
148 | message body | ||
149 | |||
150 | ------- Message 2 | ||
151 | From: gray | ||
152 | To: marlow | ||
153 | Subject: 2nd message | ||
154 | |||
155 | 2nd message body | ||
156 | |||
157 | ------- End of Forwarded messages | ||
158 | |||
159 | Seen by mhed | ||
160 | == Message 1 == | ||
161 | From: gray | ||
162 | To: root | ||
163 | Subject: test input | ||
164 | |||
165 | message body | ||
166 | == Message 2 == | ||
167 | From: gray | ||
168 | To: marlow | ||
169 | Subject: 2nd message | ||
170 | |||
171 | 2nd message body | ||
172 | ]) | ||
173 | |||
174 | MH_CHECK([forw -build msg],[forw02 forw-build-msg],[ | ||
175 | mkdir Mail/inbox | ||
176 | AT_DATA([Mail/inbox/1],[From: gray | ||
177 | To: root | ||
178 | Subject: test input | ||
179 | |||
180 | message body | ||
181 | ]) | ||
182 | |||
183 | dir=`pwd` | ||
184 | forwcmd -build +inbox 1 | sed "s|$dir/*||;s| *$||" | ||
185 | echo == Mail/draft == | ||
186 | cat Mail/draft | ||
187 | echo == Message == | ||
188 | sed '/^X-IMAPbase/d' Mail/inbox/1 | ||
189 | ], | ||
190 | [0], | ||
191 | [== Mail/draft == | ||
192 | To: | ||
193 | cc: | ||
194 | Subject: | ||
195 | -------- | ||
196 | |||
197 | ------- Forwarded message | ||
198 | From: gray | ||
199 | To: root | ||
200 | Subject: test input | ||
201 | |||
202 | message body | ||
203 | |||
204 | ------- End of Forwarded message | ||
205 | |||
206 | == Message == | ||
207 | From: gray | ||
208 | To: root | ||
209 | Subject: test input | ||
210 | |||
211 | message body | ||
212 | ]) | ||
213 | |||
214 | MH_CHECK([forw -build -mime msgs],[forw03 forw-build-mime-msg],[ | ||
215 | mkdir Mail/inbox | ||
216 | AT_DATA([Mail/inbox/1],[From: gray | ||
217 | To: root | ||
218 | Subject: test input | ||
219 | |||
220 | message body | ||
221 | ]) | ||
222 | AT_DATA([Mail/inbox/2],[From: gray | ||
223 | To: marlow | ||
224 | Subject: 2nd message | ||
225 | |||
226 | 2nd message body | ||
227 | ]) | ||
228 | |||
229 | dir=`pwd` | ||
230 | forwcmd -build -mime +inbox 1 2 | sed "s|$dir/*||;s| *$||" | ||
231 | echo == Mail/draft == | ||
232 | sed "s|$dir/*||;s| *$||" Mail/draft | ||
233 | echo == Message 1 == | ||
234 | sed '/^X-IMAPbase/d' Mail/inbox/1 | ||
235 | echo == Message 2 == | ||
236 | cat Mail/inbox/2 | ||
237 | ], | ||
238 | [0], | ||
239 | [== Mail/draft == | ||
240 | To: | ||
241 | cc: | ||
242 | Subject: | ||
243 | -------- | ||
244 | #forw [] +Mail/inbox 1 2 | ||
245 | |||
246 | == Message 1 == | ||
247 | From: gray | ||
248 | To: root | ||
249 | Subject: test input | ||
250 | |||
251 | message body | ||
252 | == Message 2 == | ||
253 | From: gray | ||
254 | To: marlow | ||
255 | Subject: 2nd message | ||
256 | |||
257 | 2nd message body | ||
258 | ]) | ||
259 | |||
260 | MH_CHECK([forw -draftfolder],[forw04 forw-draftfolder draftfolder],[ | ||
261 | mkdir Mail/inbox | ||
262 | mkdir Mail/drafts | ||
263 | AT_DATA([Mail/inbox/1],[From: gray | ||
264 | To: root | ||
265 | Subject: test input | ||
266 | |||
267 | message body | ||
268 | ]) | ||
269 | |||
270 | echo "quit" | forwcmd -draftfolder drafts 1 | sed "s|$dir/*||;s| *$||" | ||
271 | echo == Mail/drafts/1 == | ||
272 | cat Mail/drafts/1 | ||
273 | echo == Message == | ||
274 | sed '/^X-IMAPbase/d' Mail/inbox/1 | ||
275 | ], | ||
276 | [0], | ||
277 | [-- Editor invocation: Mail/drafts/1 | ||
278 | -- Input file: | ||
279 | To: | ||
280 | cc: | ||
281 | Subject: | ||
282 | -------- | ||
283 | |||
284 | ------- Forwarded message | ||
285 | From: gray | ||
286 | To: root | ||
287 | Subject: test input | ||
288 | |||
289 | message body | ||
290 | |||
291 | ------- End of Forwarded message | ||
292 | |||
293 | -- Input file end | ||
294 | What now? draft left on "Mail/drafts/1". | ||
295 | == Mail/drafts/1 == | ||
296 | To: | ||
297 | cc: | ||
298 | Subject: | ||
299 | -------- | ||
300 | |||
301 | ------- Forwarded message | ||
302 | From: gray | ||
303 | To: root | ||
304 | Subject: test input | ||
305 | |||
306 | message body | ||
307 | |||
308 | ------- End of Forwarded message | ||
309 | |||
310 | Seen by mhed | ||
311 | == Message == | ||
312 | From: gray | ||
313 | To: root | ||
314 | Subject: test input | ||
315 | |||
316 | message body | ||
317 | ]) | ||
318 | |||
319 | MH_CHECK([forw -file],[forw05 forw-file],[ | ||
320 | AT_DATA([infile],[From: gray | ||
321 | To: root | ||
322 | Subject: test input | ||
323 | |||
324 | message body | ||
325 | ]) | ||
326 | |||
327 | echo "quit" | forwcmd -file infile | sed "s|$dir/*||;s| *$||" | ||
328 | ], | ||
329 | [0], | ||
330 | [-- Editor invocation: Mail/draft | ||
331 | -- Input file: | ||
332 | To: | ||
333 | cc: | ||
334 | Subject: | ||
335 | -------- | ||
336 | From: gray | ||
337 | To: root | ||
338 | Subject: test input | ||
339 | |||
340 | message body | ||
341 | -- Input file end | ||
342 | What now? draft left on "Mail/draft". | ||
343 | ]) | ||
344 | |||
345 | m4_popdef([forwcmd]) | ||
346 | m4_popdef([MH_KEYWORDS]) | ||
347 | |||
348 | # End of forw.at |
-
Please register or sign in to post a comment