Merge branch 'master' into locus
Showing
14 changed files
with
431 additions
and
73 deletions
1 | GNU mailutils NEWS -- history of user-visible changes. 2017-06-01 | 1 | GNU mailutils NEWS -- history of user-visible changes. 2017-06-16 |
2 | Copyright (C) 2002-2017 Free Software Foundation, Inc. | 2 | Copyright (C) 2002-2017 Free Software Foundation, Inc. |
3 | See the end of file for copying conditions. | 3 | See the end of file for copying conditions. |
4 | 4 | ||
... | @@ -75,6 +75,13 @@ value is anything but "no", the settings from the global "tls" section | ... | @@ -75,6 +75,13 @@ value is anything but "no", the settings from the global "tls" section |
75 | will be used. In this case, it is an error if the global "tls" | 75 | will be used. In this case, it is an error if the global "tls" |
76 | section is not defined. | 76 | section is not defined. |
77 | 77 | ||
78 | * Source location API | ||
79 | |||
80 | Libmailutils provides functions for keeping track of locations in | ||
81 | source files for diagnostic purposes. | ||
82 | |||
83 | * Improve error reporting | ||
84 | |||
78 | * AM_GNU_MAILUTILS autoconf macro | 85 | * AM_GNU_MAILUTILS autoconf macro |
79 | 86 | ||
80 | Required version must be literal string. | 87 | Required version must be literal string. | ... | ... |
... | @@ -127,15 +127,16 @@ copy_message (mu_mailbox_t mbox, size_t n, const char *file) | ... | @@ -127,15 +127,16 @@ copy_message (mu_mailbox_t mbox, size_t n, const char *file) |
127 | return rc; | 127 | return rc; |
128 | } | 128 | } |
129 | 129 | ||
130 | static struct mh_optinit optinit[] = { | ||
131 | { "draftfolder", "Draft-Folder" }, | ||
132 | { "whatnowproc", "whatnowproc" }, | ||
133 | { NULL } | ||
134 | }; | ||
135 | |||
130 | int | 136 | int |
131 | main (int argc, char **argv) | 137 | main (int argc, char **argv) |
132 | { | 138 | { |
133 | mh_getopt (&argc, &argv, options, 0, args_doc, prog_doc, NULL); | 139 | mh_getopt_ext (&argc, &argv, options, 0, optinit, args_doc, prog_doc, NULL); |
134 | |||
135 | if (!draftfolder) | ||
136 | draftfolder = mh_global_profile_get ("Draft-Folder", NULL); | ||
137 | if (!whatnowproc) | ||
138 | whatnowproc = mh_global_profile_get ("whatnowproc", NULL); | ||
139 | 140 | ||
140 | if (use_draft) | 141 | if (use_draft) |
141 | draftmessage = "cur"; | 142 | draftmessage = "cur"; | ... | ... |
... | @@ -377,17 +377,19 @@ finish_draft () | ... | @@ -377,17 +377,19 @@ finish_draft () |
377 | mu_stream_destroy (&stream); | 377 | mu_stream_destroy (&stream); |
378 | } | 378 | } |
379 | 379 | ||
380 | static struct mh_optinit optinit[] = { | ||
381 | { "draftfolder", "Draft-Folder" }, | ||
382 | { "whatnowproc", "whatnowproc" }, | ||
383 | { NULL } | ||
384 | }; | ||
385 | |||
380 | int | 386 | int |
381 | main (int argc, char **argv) | 387 | main (int argc, char **argv) |
382 | { | 388 | { |
383 | int rc; | 389 | int rc; |
384 | 390 | ||
385 | mh_getopt (&argc, &argv, options, MH_GETOPT_DEFAULT_FOLDER, | 391 | mh_getopt_ext (&argc, &argv, options, MH_GETOPT_DEFAULT_FOLDER, optinit, |
386 | args_doc, prog_doc, NULL); | 392 | args_doc, prog_doc, NULL); |
387 | if (!draftfolder) | ||
388 | draftfolder = mh_global_profile_get ("Draft-Folder", NULL); | ||
389 | if (!whatnowproc) | ||
390 | whatnowproc = mh_global_profile_get ("whatnowproc", NULL); | ||
391 | if (!formfile) | 393 | if (!formfile) |
392 | mh_find_file ("forwcomps", &formfile); | 394 | mh_find_file ("forwcomps", &formfile); |
393 | 395 | ... | ... |
... | @@ -342,7 +342,11 @@ int mh_usedraft (const char *filename); | ... | @@ -342,7 +342,11 @@ int mh_usedraft (const char *filename); |
342 | int mh_file_copy (const char *from, const char *to); | 342 | int mh_file_copy (const char *from, const char *to); |
343 | char *mh_draft_name (void); | 343 | char *mh_draft_name (void); |
344 | char *mh_create_message_id (int); | 344 | char *mh_create_message_id (int); |
345 | int mh_whom (const char *filename, int check); | 345 | |
346 | int mh_whom_header (mu_header_t hdr); | ||
347 | int mh_whom_file (const char *filename, int check); | ||
348 | int mh_whom_message (mu_message_t msg, int check); | ||
349 | |||
346 | void mh_set_reply_regex (const char *str); | 350 | void mh_set_reply_regex (const char *str); |
347 | int mh_decode_2047 (char *text, char **decoded_text); | 351 | int mh_decode_2047 (char *text, char **decoded_text); |
348 | const char *mh_charset (const char *); | 352 | const char *mh_charset (const char *); | ... | ... |
... | @@ -502,6 +502,9 @@ int | ... | @@ -502,6 +502,9 @@ int |
502 | mh_read_aliases (void) | 502 | mh_read_aliases (void) |
503 | { | 503 | { |
504 | const char *p; | 504 | const char *p; |
505 | |||
506 | if (alias_list) | ||
507 | return 0; | ||
505 | 508 | ||
506 | p = mh_global_profile_get ("Aliasfile", NULL); | 509 | p = mh_global_profile_get ("Aliasfile", NULL); |
507 | if (p) | 510 | if (p) | ... | ... |
... | @@ -179,10 +179,39 @@ has_folder_option (struct mu_option *opt) | ... | @@ -179,10 +179,39 @@ has_folder_option (struct mu_option *opt) |
179 | return 0; | 179 | return 0; |
180 | } | 180 | } |
181 | 181 | ||
182 | static void | ||
183 | opt_init (struct mu_parseopt *po, | ||
184 | struct mu_option **optv, struct mh_optinit *optinit) | ||
185 | { | ||
186 | if (!optinit) | ||
187 | return; | ||
188 | for (; optinit->opt; optinit++) | ||
189 | { | ||
190 | size_t i; | ||
191 | for (i = 0; optv[i]; i++) | ||
192 | { | ||
193 | struct mu_option *opt; | ||
194 | for (opt = optv[i]; !MU_OPTION_IS_END (opt); opt++) | ||
195 | { | ||
196 | if (strcmp (opt->opt_long, optinit->opt) == 0) | ||
197 | { | ||
198 | char const *val = mh_global_profile_get (optinit->var, NULL); | ||
199 | if (val) | ||
200 | { | ||
201 | (opt->opt_set ? | ||
202 | opt->opt_set : mu_option_set_value) (po, opt, val); | ||
203 | } | ||
204 | break; | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | |||
182 | void | 211 | void |
183 | mh_getopt (int *pargc, char ***pargv, struct mu_option *options, | 212 | mh_getopt_ext (int *pargc, char ***pargv, struct mu_option *options, |
184 | int mhflags, | 213 | int mhflags, struct mh_optinit *optinit, |
185 | char *argdoc, char *progdoc, char *extradoc) | 214 | char *argdoc, char *progdoc, char *extradoc) |
186 | { | 215 | { |
187 | int argc = *pargc; | 216 | int argc = *pargc; |
188 | char **argv = *pargv; | 217 | char **argv = *pargv; |
... | @@ -256,6 +285,7 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options, | ... | @@ -256,6 +285,7 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options, |
256 | if (options) | 285 | if (options) |
257 | optv[i++] = options; | 286 | optv[i++] = options; |
258 | optv[i] = NULL; | 287 | optv[i] = NULL; |
288 | opt_init (&po, optv, optinit); | ||
259 | 289 | ||
260 | if (mu_parseopt (&po, argc, argv, optv, flags)) | 290 | if (mu_parseopt (&po, argc, argv, optv, flags)) |
261 | exit (po.po_exit_error); | 291 | exit (po.po_exit_error); |
... | @@ -285,6 +315,14 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options, | ... | @@ -285,6 +315,14 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options, |
285 | } | 315 | } |
286 | 316 | ||
287 | void | 317 | void |
318 | mh_getopt (int *pargc, char ***pargv, struct mu_option *options, | ||
319 | int mhflags, char *argdoc, char *progdoc, char *extradoc) | ||
320 | { | ||
321 | mh_getopt_ext (pargc, pargv, options, mhflags, NULL, argdoc, progdoc, | ||
322 | extradoc); | ||
323 | } | ||
324 | |||
325 | void | ||
288 | mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, char const *arg) | 326 | mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, char const *arg) |
289 | { | 327 | { |
290 | mu_error (_("option is not yet implemented: %s"), opt->opt_long); | 328 | mu_error (_("option is not yet implemented: %s"), opt->opt_long); | ... | ... |
... | @@ -20,9 +20,18 @@ | ... | @@ -20,9 +20,18 @@ |
20 | 20 | ||
21 | #define MH_GETOPT_DEFAULT_FOLDER 0x1 | 21 | #define MH_GETOPT_DEFAULT_FOLDER 0x1 |
22 | 22 | ||
23 | struct mh_optinit | ||
24 | { | ||
25 | char const *opt; /* Option name */ | ||
26 | char const *var; /* mh_property name */ | ||
27 | }; | ||
28 | |||
29 | void mh_getopt_ext (int *pargc, char ***pargv, struct mu_option *options, | ||
30 | int mhflags, struct mh_optinit *optinit, | ||
31 | char *argdoc, char *progdoc, char *extradoc); | ||
32 | |||
23 | void mh_getopt (int *pargc, char ***pargv, struct mu_option *options, | 33 | void mh_getopt (int *pargc, char ***pargv, struct mu_option *options, |
24 | int flags, | 34 | int flags, char *argdoc, char *progdoc, char *extradoc); |
25 | char *argdoc, char *progdoc, char *extradoc); | ||
26 | 35 | ||
27 | void mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, | 36 | void mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, |
28 | char const *arg); | 37 | char const *arg); | ... | ... |
... | @@ -544,9 +544,10 @@ whom (struct mh_whatnow_env *wh, int argc, char **argv, int *status) | ... | @@ -544,9 +544,10 @@ whom (struct mh_whatnow_env *wh, int argc, char **argv, int *status) |
544 | if (!wh->file) | 544 | if (!wh->file) |
545 | mu_error (_("no draft file to display")); | 545 | mu_error (_("no draft file to display")); |
546 | else | 546 | else |
547 | mh_whom (wh->file, (argc == 2 | 547 | mh_whom_file (wh->file, |
548 | && (strcmp (argv[1], "-check") == 0 | 548 | (argc == 2 |
549 | || strcmp (argv[1], "--check") == 0))); | 549 | && (strcmp (argv[1], "-check") == 0 |
550 | || strcmp (argv[1], "--check") == 0))); | ||
550 | return 0; | 551 | return 0; |
551 | } | 552 | } |
552 | 553 | ... | ... |
... | @@ -261,7 +261,46 @@ read_header (mu_stream_t stream) | ... | @@ -261,7 +261,46 @@ read_header (mu_stream_t stream) |
261 | } | 261 | } |
262 | 262 | ||
263 | int | 263 | int |
264 | mh_whom (const char *filename, int check) | 264 | mh_whom_header (mu_header_t hdr) |
265 | { | ||
266 | size_t count = 0; | ||
267 | int rc; | ||
268 | const char *val; | ||
269 | |||
270 | mh_read_aliases (); | ||
271 | |||
272 | if (mu_header_sget_value (hdr, MU_HEADER_TO, &val) == 0) | ||
273 | scan_addrs (val, 0); | ||
274 | if (mu_header_sget_value (hdr, MU_HEADER_CC, &val) == 0) | ||
275 | scan_addrs (val, 0); | ||
276 | if (mu_header_sget_value (hdr, MU_HEADER_BCC, &val) == 0) | ||
277 | scan_addrs (val, 1); | ||
278 | |||
279 | if (local_rcp) | ||
280 | { | ||
281 | printf (" %s\n", _("-- Local Recipients --")); | ||
282 | mu_list_foreach (local_rcp, _print_local_recipient, &count); | ||
283 | } | ||
284 | |||
285 | if (network_rcp) | ||
286 | { | ||
287 | printf (" %s\n", _("-- Network Recipients --")); | ||
288 | mu_list_foreach (network_rcp, _print_recipient, &count); | ||
289 | } | ||
290 | |||
291 | if (count == 0) | ||
292 | { | ||
293 | mu_error(_("no recipients")); | ||
294 | rc = -1; | ||
295 | } | ||
296 | |||
297 | destroy_addrs (&network_rcp); | ||
298 | destroy_addrs (&local_rcp); | ||
299 | return rc; | ||
300 | } | ||
301 | |||
302 | int | ||
303 | mh_whom_file (const char *filename, int check) | ||
265 | { | 304 | { |
266 | int rc = 0; | 305 | int rc = 0; |
267 | 306 | ||
... | @@ -272,11 +311,9 @@ mh_whom (const char *filename, int check) | ... | @@ -272,11 +311,9 @@ mh_whom (const char *filename, int check) |
272 | } | 311 | } |
273 | else | 312 | else |
274 | { | 313 | { |
275 | size_t count = 0; | ||
276 | mu_header_t hdr; | 314 | mu_header_t hdr; |
277 | mu_stream_t str; | 315 | mu_stream_t str; |
278 | int rc; | 316 | int rc; |
279 | const char *val; | ||
280 | 317 | ||
281 | rc = mu_file_stream_create (&str, filename, MU_STREAM_READ); | 318 | rc = mu_file_stream_create (&str, filename, MU_STREAM_READ); |
282 | if (rc) | 319 | if (rc) |
... | @@ -288,35 +325,26 @@ mh_whom (const char *filename, int check) | ... | @@ -288,35 +325,26 @@ mh_whom (const char *filename, int check) |
288 | hdr = read_header (str); | 325 | hdr = read_header (str); |
289 | mu_stream_unref (str); | 326 | mu_stream_unref (str); |
290 | 327 | ||
291 | mh_read_aliases (); | 328 | rc = mh_whom_header (hdr); |
292 | 329 | mu_header_destroy (&hdr); | |
293 | if (mu_header_sget_value (hdr, MU_HEADER_TO, &val) == 0) | 330 | } |
294 | scan_addrs (val, 0); | 331 | return rc; |
295 | if (mu_header_sget_value (hdr, MU_HEADER_CC, &val) == 0) | 332 | } |
296 | scan_addrs (val, 0); | ||
297 | if (mu_header_sget_value (hdr, MU_HEADER_BCC, &val) == 0) | ||
298 | scan_addrs (val, 1); | ||
299 | |||
300 | if (local_rcp) | ||
301 | { | ||
302 | printf (" %s\n", _("-- Local Recipients --")); | ||
303 | mu_list_foreach (local_rcp, _print_local_recipient, &count); | ||
304 | } | ||
305 | 333 | ||
306 | if (network_rcp) | 334 | int |
307 | { | 335 | mh_whom_message (mu_message_t msg, int check) |
308 | printf (" %s\n", _("-- Network Recipients --")); | 336 | { |
309 | mu_list_foreach (network_rcp, _print_recipient, &count); | 337 | mu_header_t hdr; |
310 | } | 338 | int rc; |
311 | 339 | ||
312 | if (count == 0) | 340 | rc = mu_message_get_header (msg, &hdr); |
313 | { | 341 | if (rc) |
314 | mu_error(_("no recipients")); | 342 | mu_error (_("can't get headers: %s"), mu_strerror (rc)); |
315 | rc = -1; | 343 | else |
316 | } | 344 | { |
345 | rc = mh_whom_header (hdr); | ||
317 | mu_header_destroy (&hdr); | 346 | mu_header_destroy (&hdr); |
318 | } | 347 | } |
319 | destroy_addrs (&network_rcp); | ||
320 | destroy_addrs (&local_rcp); | ||
321 | return rc; | 348 | return rc; |
322 | } | 349 | } |
350 | ... | ... |
... | @@ -289,19 +289,19 @@ make_draft (mu_mailbox_t mbox, int disp, struct mh_whatnow_env *wh) | ... | @@ -289,19 +289,19 @@ make_draft (mu_mailbox_t mbox, int disp, struct mh_whatnow_env *wh) |
289 | } | 289 | } |
290 | } | 290 | } |
291 | 291 | ||
292 | static struct mh_optinit optinit[] = { | ||
293 | { "draftfolder", "Draft-Folder" }, | ||
294 | { "whatnowproc", "whatnowproc" }, | ||
295 | { NULL } | ||
296 | }; | ||
297 | |||
292 | int | 298 | int |
293 | main (int argc, char **argv) | 299 | main (int argc, char **argv) |
294 | { | 300 | { |
295 | int rc; | 301 | int rc; |
296 | 302 | ||
297 | mh_getopt (&argc, &argv, options, MH_GETOPT_DEFAULT_FOLDER, | 303 | mh_getopt_ext (&argc, &argv, options, MH_GETOPT_DEFAULT_FOLDER, optinit, |
298 | args_doc, prog_doc, NULL); | 304 | args_doc, prog_doc, NULL); |
299 | |||
300 | if (!draftfolder) | ||
301 | draftfolder = mh_global_profile_get ("Draft-Folder", NULL); | ||
302 | if (!whatnowproc) | ||
303 | whatnowproc = mh_global_profile_get ("whatnowproc", NULL); | ||
304 | |||
305 | 305 | ||
306 | if (!format_str) | 306 | if (!format_str) |
307 | format_str = default_format_str; | 307 | format_str = default_format_str; | ... | ... |
... | @@ -193,6 +193,49 @@ message body | ... | @@ -193,6 +193,49 @@ message body |
193 | Seen by mhed | 193 | Seen by mhed |
194 | ]) | 194 | ]) |
195 | 195 | ||
196 | MH_CHECK([use Draft-Folder],[comp07 draftfolder], | ||
197 | [mkdir Mail/drafts | ||
198 | echo "Draft-Folder: +drafts" >> $MH | ||
199 | echo 'quit' | compcmd | cwdrepl | ||
200 | sed 's/ *$//' Mail/drafts/1 | ||
201 | ], | ||
202 | [0], | ||
203 | [-- Editor invocation: ./Mail/drafts/1 | ||
204 | -- Input file: | ||
205 | To: | ||
206 | cc: | ||
207 | Subject: | ||
208 | -------- | ||
209 | -- Input file end | ||
210 | What now? draft left on "./Mail/drafts/1". | ||
211 | To: | ||
212 | cc: | ||
213 | Subject: | ||
214 | -------- | ||
215 | Seen by mhed | ||
216 | ]) | ||
217 | |||
218 | MH_CHECK([-nodraftfolder],[comp08 nodraftfolder draftfolder], | ||
219 | [mkdir Mail/drafts | ||
220 | echo "Draft-Folder: +drafts" >> $MH | ||
221 | echo 'quit' | compcmd -nodraftfolder | cwdrepl | ||
222 | sed 's/ *$//' Mail/draft | ||
223 | ], | ||
224 | [0], | ||
225 | [-- Editor invocation: ./Mail/draft | ||
226 | -- Input file: | ||
227 | To: | ||
228 | cc: | ||
229 | Subject: | ||
230 | -------- | ||
231 | -- Input file end | ||
232 | What now? draft left on "./Mail/draft". | ||
233 | To: | ||
234 | cc: | ||
235 | Subject: | ||
236 | -------- | ||
237 | Seen by mhed | ||
238 | ]) | ||
196 | 239 | ||
197 | m4_popdef([compcmd]) | 240 | m4_popdef([compcmd]) |
198 | m4_popdef([MH_KEYWORDS]) | 241 | m4_popdef([MH_KEYWORDS]) | ... | ... |
... | @@ -397,6 +397,129 @@ message body | ... | @@ -397,6 +397,129 @@ message body |
397 | What now? draft left on "./Mail/draft". | 397 | What now? draft left on "./Mail/draft". |
398 | ]) | 398 | ]) |
399 | 399 | ||
400 | MH_CHECK([Draft-Folder],[forw07 forw-draftfolder draftfolder],[ | ||
401 | mkdir Mail/inbox | ||
402 | mkdir Mail/drafts | ||
403 | echo "Draft-Folder: +drafts" >> $MH | ||
404 | |||
405 | AT_DATA([Mail/inbox/1],[From: gray | ||
406 | To: root | ||
407 | Subject: test input | ||
408 | |||
409 | message body | ||
410 | ]) | ||
411 | |||
412 | echo "quit" | forwcmd 1 | cwdrepl | ||
413 | echo == Mail/drafts/1 == | ||
414 | cat Mail/drafts/1 | ||
415 | echo == Message == | ||
416 | sed '/^X-IMAPbase/d' Mail/inbox/1 | ||
417 | ], | ||
418 | [0], | ||
419 | [-- Editor invocation: ./Mail/drafts/1 | ||
420 | -- Input file: | ||
421 | To: | ||
422 | cc: | ||
423 | Subject: | ||
424 | -------- | ||
425 | |||
426 | ------- Forwarded message | ||
427 | From: gray | ||
428 | To: root | ||
429 | Subject: test input | ||
430 | |||
431 | message body | ||
432 | |||
433 | ------- End of Forwarded message | ||
434 | |||
435 | -- Input file end | ||
436 | What now? draft left on "./Mail/drafts/1". | ||
437 | == Mail/drafts/1 == | ||
438 | To: | ||
439 | cc: | ||
440 | Subject: | ||
441 | -------- | ||
442 | |||
443 | ------- Forwarded message | ||
444 | From: gray | ||
445 | To: root | ||
446 | Subject: test input | ||
447 | |||
448 | message body | ||
449 | |||
450 | ------- End of Forwarded message | ||
451 | |||
452 | Seen by mhed | ||
453 | == Message == | ||
454 | From: gray | ||
455 | To: root | ||
456 | Subject: test input | ||
457 | |||
458 | message body | ||
459 | ]) | ||
460 | |||
461 | MH_CHECK([-nodraftfolder],[forw08 forw-nodraftfolder nodraftfolder draftfolder],[ | ||
462 | mkdir Mail/inbox | ||
463 | mkdir Mail/drafts | ||
464 | echo "Draft-Folder: +drafts" >> $MH | ||
465 | |||
466 | AT_DATA([Mail/inbox/1],[From: gray | ||
467 | To: root | ||
468 | Subject: test input | ||
469 | |||
470 | message body | ||
471 | ]) | ||
472 | |||
473 | echo "quit" | forwcmd -nodraftfolder 1 | cwdrepl | ||
474 | echo == Mail/draft == | ||
475 | cat Mail/draft | ||
476 | echo == Message == | ||
477 | sed '/^X-IMAPbase/d' Mail/inbox/1 | ||
478 | ], | ||
479 | [0], | ||
480 | [-- Editor invocation: ./Mail/draft | ||
481 | -- Input file: | ||
482 | To: | ||
483 | cc: | ||
484 | Subject: | ||
485 | -------- | ||
486 | |||
487 | ------- Forwarded message | ||
488 | From: gray | ||
489 | To: root | ||
490 | Subject: test input | ||
491 | |||
492 | message body | ||
493 | |||
494 | ------- End of Forwarded message | ||
495 | |||
496 | -- Input file end | ||
497 | What now? draft left on "./Mail/draft". | ||
498 | == Mail/draft == | ||
499 | To: | ||
500 | cc: | ||
501 | Subject: | ||
502 | -------- | ||
503 | |||
504 | ------- Forwarded message | ||
505 | From: gray | ||
506 | To: root | ||
507 | Subject: test input | ||
508 | |||
509 | message body | ||
510 | |||
511 | ------- End of Forwarded message | ||
512 | |||
513 | Seen by mhed | ||
514 | == Message == | ||
515 | From: gray | ||
516 | To: root | ||
517 | Subject: test input | ||
518 | |||
519 | message body | ||
520 | ]) | ||
521 | |||
522 | |||
400 | m4_popdef([forwcmd]) | 523 | m4_popdef([forwcmd]) |
401 | m4_popdef([MH_KEYWORDS]) | 524 | m4_popdef([MH_KEYWORDS]) |
402 | 525 | ... | ... |
... | @@ -79,6 +79,70 @@ X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION) | ... | @@ -79,6 +79,70 @@ X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION) |
79 | Seen by mhed | 79 | Seen by mhed |
80 | ]) | 80 | ]) |
81 | 81 | ||
82 | MH_CHECK([Draft-Folder],[repl02 repl-draftfolder draftfolder],[ | ||
83 | mkdir Mail/inbox | ||
84 | mkdir Mail/drafts | ||
85 | echo "Draft-Folder: +drafts" >> $MH | ||
86 | |||
87 | AT_DATA([Mail/inbox/1],[From: gray@example.com | ||
88 | To: root@example.com | ||
89 | Subject: test input | ||
90 | |||
91 | message body | ||
92 | ]) | ||
93 | echo "quit" | replcmd +inbox 1 | cwdrepl | ||
94 | echo == Mail/drafts/1 == | ||
95 | cat Mail/drafts/1 | ||
96 | ], | ||
97 | [0], | ||
98 | [-- Editor invocation: ./Mail/drafts/1 | ||
99 | -- Input file: | ||
100 | To: <gray@example.com> | ||
101 | Subject: Re: test input | ||
102 | X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION) | ||
103 | -------- | ||
104 | -- Input file end | ||
105 | What now? draft left on "./Mail/drafts/1". | ||
106 | == Mail/drafts/1 == | ||
107 | To: <gray@example.com> | ||
108 | Subject: Re: test input | ||
109 | X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION) | ||
110 | -------- | ||
111 | Seen by mhed | ||
112 | ]) | ||
113 | |||
114 | MH_CHECK([-nodraftfolder],[repl03 repl-nodraftfolder nodraftfolder draftfolder],[ | ||
115 | mkdir Mail/inbox | ||
116 | mkdir Mail/drafts | ||
117 | echo "Draft-Folder: +drafts" >> $MH | ||
118 | |||
119 | AT_DATA([Mail/inbox/1],[From: gray@example.com | ||
120 | To: root@example.com | ||
121 | Subject: test input | ||
122 | |||
123 | message body | ||
124 | ]) | ||
125 | echo "quit" | replcmd -nodraftfolder +inbox 1 | cwdrepl | ||
126 | echo == Mail/draft == | ||
127 | cat Mail/draft | ||
128 | ], | ||
129 | [0], | ||
130 | [-- Editor invocation: ./Mail/draft | ||
131 | -- Input file: | ||
132 | To: <gray@example.com> | ||
133 | Subject: Re: test input | ||
134 | X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION) | ||
135 | -------- | ||
136 | -- Input file end | ||
137 | What now? draft left on "./Mail/draft". | ||
138 | == Mail/draft == | ||
139 | To: <gray@example.com> | ||
140 | Subject: Re: test input | ||
141 | X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION) | ||
142 | -------- | ||
143 | Seen by mhed | ||
144 | ]) | ||
145 | |||
82 | m4_popdef([replcmd]) | 146 | m4_popdef([replcmd]) |
83 | m4_popdef([MH_KEYWORDS]) | 147 | m4_popdef([MH_KEYWORDS]) |
84 | # End of repl.at | 148 | # End of repl.at | ... | ... |
... | @@ -21,7 +21,7 @@ static char prog_doc[] = N_("Report to whom a message would go"); | ... | @@ -21,7 +21,7 @@ static char prog_doc[] = N_("Report to whom a message would go"); |
21 | static char args_doc[] = "[FILE]"; | 21 | static char args_doc[] = "[FILE]"; |
22 | 22 | ||
23 | static int check_recipients; | 23 | static int check_recipients; |
24 | static int use_draft; /* Use the prepared draft */ | 24 | static char *message; |
25 | static const char *draft_folder; /* Use this draft folder */ | 25 | static const char *draft_folder; /* Use this draft folder */ |
26 | 26 | ||
27 | static void | 27 | static void |
... | @@ -45,7 +45,7 @@ static struct mu_option options[] = { | ... | @@ -45,7 +45,7 @@ static struct mu_option options[] = { |
45 | mu_c_string, NULL, add_alias }, | 45 | mu_c_string, NULL, add_alias }, |
46 | { "draft", 0, NULL, MU_OPTION_DEFAULT, | 46 | { "draft", 0, NULL, MU_OPTION_DEFAULT, |
47 | N_("use prepared draft"), | 47 | N_("use prepared draft"), |
48 | mu_c_bool, &use_draft }, | 48 | mu_c_string, &message, NULL, "draft" }, |
49 | { "draftfolder", 0, N_("FOLDER"), MU_OPTION_DEFAULT, | 49 | { "draftfolder", 0, N_("FOLDER"), MU_OPTION_DEFAULT, |
50 | N_("specify the folder for message drafts"), | 50 | N_("specify the folder for message drafts"), |
51 | mu_c_string, &draft_folder }, | 51 | mu_c_string, &draft_folder }, |
... | @@ -60,22 +60,57 @@ static struct mu_option options[] = { | ... | @@ -60,22 +60,57 @@ static struct mu_option options[] = { |
60 | mu_c_bool, &check_recipients }, | 60 | mu_c_bool, &check_recipients }, |
61 | MU_OPTION_END | 61 | MU_OPTION_END |
62 | }; | 62 | }; |
63 | |||
64 | static struct mh_optinit optinit[] = { | ||
65 | { "draftfolder", "Draft-Folder" }, | ||
66 | { NULL } | ||
67 | }; | ||
63 | 68 | ||
64 | int | 69 | int |
65 | main (int argc, char **argv) | 70 | main (int argc, char **argv) |
66 | { | 71 | { |
67 | char *name = "draft"; | 72 | int rc; |
68 | 73 | ||
69 | mh_getopt (&argc, &argv, options, 0, args_doc, prog_doc, NULL); | 74 | mh_getopt_ext (&argc, &argv, options, 0, optinit, args_doc, prog_doc, NULL); |
70 | 75 | ||
71 | if (!use_draft && argc > 0) | 76 | if (draft_folder) |
72 | name = argv[0]; | 77 | { |
78 | mu_mailbox_t mbox = mh_open_folder (draft_folder, MU_STREAM_READ); | ||
79 | mu_msgset_t msgset; | ||
80 | size_t msgno; | ||
81 | mu_message_t msg; | ||
82 | |||
83 | mh_msgset_parse (&msgset, mbox, argc, argv, "cur"); | ||
84 | if (!mh_msgset_single_message (msgset)) | ||
85 | { | ||
86 | mu_error (_("only one message at a time!")); | ||
87 | return 1; | ||
88 | } | ||
89 | msgno = mh_msgset_first (msgset, RET_MSGNO); | ||
90 | rc = mu_mailbox_get_message (mbox, msgno, &msg); | ||
91 | if (rc) | ||
92 | { | ||
93 | mu_error (_("can't read message: %s"), mu_strerror (rc)); | ||
94 | exit (1); | ||
95 | } | ||
96 | rc = mh_whom_message (msg, check_recipients); | ||
97 | } | ||
98 | else | ||
99 | { | ||
100 | if (argc > 0) | ||
101 | { | ||
102 | if (message || argc > 1) | ||
103 | { | ||
104 | mu_error (_("only one file at a time!")); | ||
105 | exit (1); | ||
106 | } | ||
107 | message = argv[0]; | ||
108 | } | ||
109 | else | ||
110 | message = "draft"; | ||
111 | rc = mh_whom_file (mh_expand_name (draft_folder, message, NAME_ANY), | ||
112 | check_recipients); | ||
113 | } | ||
73 | 114 | ||
74 | if (!draft_folder) | 115 | return rc ? 1 : 0; |
75 | draft_folder = mh_global_profile_get ("Draft-Folder", | ||
76 | mu_folder_directory ()); | ||
77 | |||
78 | |||
79 | return mh_whom (mh_expand_name (draft_folder, name, NAME_ANY), | ||
80 | check_recipients) ? 1 : 0; | ||
81 | } | 116 | } | ... | ... |
-
Please register or sign in to post a comment