summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2017-06-15 19:09:30 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2017-06-16 06:50:36 (GMT)
commitc1f2442cd53e43cf11cc8f5b649b454b3f2cb03f (patch) (unidiff)
tree6ef0b4a8d01cb81d8f4f1ae2757ad4047ebb03f5
parent8b5715db380634336a231b0c8573c350992c8dce (diff)
parentfe90e86dac8c9c91a35347ee5bb4513195263ee2 (diff)
downloadmailutils-c1f2442cd53e43cf11cc8f5b649b454b3f2cb03f.tar.gz
mailutils-c1f2442cd53e43cf11cc8f5b649b454b3f2cb03f.tar.bz2
Merge branch 'master' into locus
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--NEWS9
-rw-r--r--mh/comp.c13
-rw-r--r--mh/forw.c14
-rw-r--r--mh/mh.h6
-rw-r--r--mh/mh_alias_gram.y3
-rw-r--r--mh/mh_getopt.c44
-rw-r--r--mh/mh_getopt.h13
-rw-r--r--mh/mh_whatnow.c7
-rw-r--r--mh/mh_whom.c86
-rw-r--r--mh/repl.c16
-rw-r--r--mh/tests/comp.at43
-rw-r--r--mh/tests/forw.at123
-rw-r--r--mh/tests/repl.at64
-rw-r--r--mh/whom.c63
14 files changed, 431 insertions, 73 deletions
diff --git a/NEWS b/NEWS
index 266a999..e351691 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
1GNU mailutils NEWS -- history of user-visible changes. 2017-06-01 1GNU mailutils NEWS -- history of user-visible changes. 2017-06-16
2Copyright (C) 2002-2017 Free Software Foundation, Inc. 2Copyright (C) 2002-2017 Free Software Foundation, Inc.
3See the end of file for copying conditions. 3See 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
75will be used. In this case, it is an error if the global "tls" 75will be used. In this case, it is an error if the global "tls"
76section is not defined. 76section is not defined.
77 77
78* Source location API
79
80Libmailutils provides functions for keeping track of locations in
81source files for diagnostic purposes.
82
83* Improve error reporting
84
78* AM_GNU_MAILUTILS autoconf macro 85* AM_GNU_MAILUTILS autoconf macro
79 86
80Required version must be literal string. 87Required version must be literal string.
diff --git a/mh/comp.c b/mh/comp.c
index 075bb45..29389c6 100644
--- a/mh/comp.c
+++ b/mh/comp.c
@@ -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
130static struct mh_optinit optinit[] = {
131 { "draftfolder", "Draft-Folder" },
132 { "whatnowproc", "whatnowproc" },
133 { NULL }
134};
135
130int 136int
131main (int argc, char **argv) 137main (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";
diff --git a/mh/forw.c b/mh/forw.c
index 5e0e08b..016ac84 100644
--- a/mh/forw.c
+++ b/mh/forw.c
@@ -377,17 +377,19 @@ finish_draft ()
377 mu_stream_destroy (&stream); 377 mu_stream_destroy (&stream);
378} 378}
379 379
380static struct mh_optinit optinit[] = {
381 { "draftfolder", "Draft-Folder" },
382 { "whatnowproc", "whatnowproc" },
383 { NULL }
384};
385
380int 386int
381main (int argc, char **argv) 387main (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
diff --git a/mh/mh.h b/mh/mh.h
index 69be72d..76bc85e 100644
--- a/mh/mh.h
+++ b/mh/mh.h
@@ -342,7 +342,11 @@ int mh_usedraft (const char *filename);
342int mh_file_copy (const char *from, const char *to); 342int mh_file_copy (const char *from, const char *to);
343char *mh_draft_name (void); 343char *mh_draft_name (void);
344char *mh_create_message_id (int); 344char *mh_create_message_id (int);
345int mh_whom (const char *filename, int check); 345
346int mh_whom_header (mu_header_t hdr);
347int mh_whom_file (const char *filename, int check);
348int mh_whom_message (mu_message_t msg, int check);
349
346void mh_set_reply_regex (const char *str); 350void mh_set_reply_regex (const char *str);
347int mh_decode_2047 (char *text, char **decoded_text); 351int mh_decode_2047 (char *text, char **decoded_text);
348const char *mh_charset (const char *); 352const char *mh_charset (const char *);
diff --git a/mh/mh_alias_gram.y b/mh/mh_alias_gram.y
index d722998..26b13ec 100644
--- a/mh/mh_alias_gram.y
+++ b/mh/mh_alias_gram.y
@@ -502,6 +502,9 @@ int
502mh_read_aliases (void) 502mh_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)
diff --git a/mh/mh_getopt.c b/mh/mh_getopt.c
index 65fe3e8..16a6e5c 100644
--- a/mh/mh_getopt.c
+++ b/mh/mh_getopt.c
@@ -179,10 +179,39 @@ has_folder_option (struct mu_option *opt)
179 return 0; 179 return 0;
180} 180}
181 181
182static void
183opt_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
182void 211void
183mh_getopt (int *pargc, char ***pargv, struct mu_option *options, 212mh_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 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} 315}
286 316
287void 317void
318mh_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
325void
288mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, char const *arg) 326mh_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);
diff --git a/mh/mh_getopt.h b/mh/mh_getopt.h
index 2aa90b6..684ace6 100644
--- a/mh/mh_getopt.h
+++ b/mh/mh_getopt.h
@@ -20,9 +20,18 @@
20 20
21#define MH_GETOPT_DEFAULT_FOLDER 0x1 21#define MH_GETOPT_DEFAULT_FOLDER 0x1
22 22
23struct mh_optinit
24{
25 char const *opt; /* Option name */
26 char const *var; /* mh_property name */
27};
28
29void 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
23void mh_getopt (int *pargc, char ***pargv, struct mu_option *options, 33void 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
27void mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, 36void mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt,
28 char const *arg); 37 char const *arg);
diff --git a/mh/mh_whatnow.c b/mh/mh_whatnow.c
index 5dc15b5..0bd2aca 100644
--- a/mh/mh_whatnow.c
+++ b/mh/mh_whatnow.c
@@ -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
diff --git a/mh/mh_whom.c b/mh/mh_whom.c
index bbdef7a..f3067d1 100644
--- a/mh/mh_whom.c
+++ b/mh/mh_whom.c
@@ -261,7 +261,46 @@ read_header (mu_stream_t stream)
261} 261}
262 262
263int 263int
264mh_whom (const char *filename, int check) 264mh_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
302int
303mh_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 } 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 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) 334int
307 { 335mh_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
diff --git a/mh/repl.c b/mh/repl.c
index 1cc1929..169f977 100644
--- a/mh/repl.c
+++ b/mh/repl.c
@@ -289,19 +289,19 @@ make_draft (mu_mailbox_t mbox, int disp, struct mh_whatnow_env *wh)
289 } 289 }
290} 290}
291 291
292static struct mh_optinit optinit[] = {
293 { "draftfolder", "Draft-Folder" },
294 { "whatnowproc", "whatnowproc" },
295 { NULL }
296};
297
292int 298int
293main (int argc, char **argv) 299main (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;
diff --git a/mh/tests/comp.at b/mh/tests/comp.at
index 563310c..7a63e5f 100644
--- a/mh/tests/comp.at
+++ b/mh/tests/comp.at
@@ -193,6 +193,49 @@ message body
193Seen by mhed 193Seen by mhed
194]) 194])
195 195
196MH_CHECK([use Draft-Folder],[comp07 draftfolder],
197[mkdir Mail/drafts
198echo "Draft-Folder: +drafts" >> $MH
199echo 'quit' | compcmd | cwdrepl
200sed 's/ *$//' Mail/drafts/1
201],
202[0],
203[-- Editor invocation: ./Mail/drafts/1
204-- Input file:
205To:
206cc:
207Subject:
208--------
209-- Input file end
210What now? draft left on "./Mail/drafts/1".
211To:
212cc:
213Subject:
214--------
215Seen by mhed
216])
217
218MH_CHECK([-nodraftfolder],[comp08 nodraftfolder draftfolder],
219[mkdir Mail/drafts
220echo "Draft-Folder: +drafts" >> $MH
221echo 'quit' | compcmd -nodraftfolder | cwdrepl
222sed 's/ *$//' Mail/draft
223],
224[0],
225[-- Editor invocation: ./Mail/draft
226-- Input file:
227To:
228cc:
229Subject:
230--------
231-- Input file end
232What now? draft left on "./Mail/draft".
233To:
234cc:
235Subject:
236--------
237Seen by mhed
238])
196 239
197m4_popdef([compcmd]) 240m4_popdef([compcmd])
198m4_popdef([MH_KEYWORDS]) 241m4_popdef([MH_KEYWORDS])
diff --git a/mh/tests/forw.at b/mh/tests/forw.at
index e0566df..f668a33 100644
--- a/mh/tests/forw.at
+++ b/mh/tests/forw.at
@@ -397,6 +397,129 @@ message body
397What now? draft left on "./Mail/draft". 397What now? draft left on "./Mail/draft".
398]) 398])
399 399
400MH_CHECK([Draft-Folder],[forw07 forw-draftfolder draftfolder],[
401mkdir Mail/inbox
402mkdir Mail/drafts
403echo "Draft-Folder: +drafts" >> $MH
404
405AT_DATA([Mail/inbox/1],[From: gray
406To: root
407Subject: test input
408
409message body
410])
411
412echo "quit" | forwcmd 1 | cwdrepl
413echo == Mail/drafts/1 ==
414cat Mail/drafts/1
415echo == Message ==
416sed '/^X-IMAPbase/d' Mail/inbox/1
417],
418[0],
419[-- Editor invocation: ./Mail/drafts/1
420-- Input file:
421To:
422cc:
423Subject:
424--------
425
426------- Forwarded message
427From: gray
428To: root
429Subject: test input
430
431message body
432
433------- End of Forwarded message
434
435-- Input file end
436What now? draft left on "./Mail/drafts/1".
437== Mail/drafts/1 ==
438To:
439cc:
440Subject:
441--------
442
443------- Forwarded message
444From: gray
445To: root
446Subject: test input
447
448message body
449
450------- End of Forwarded message
451
452Seen by mhed
453== Message ==
454From: gray
455To: root
456Subject: test input
457
458message body
459])
460
461MH_CHECK([-nodraftfolder],[forw08 forw-nodraftfolder nodraftfolder draftfolder],[
462mkdir Mail/inbox
463mkdir Mail/drafts
464echo "Draft-Folder: +drafts" >> $MH
465
466AT_DATA([Mail/inbox/1],[From: gray
467To: root
468Subject: test input
469
470message body
471])
472
473echo "quit" | forwcmd -nodraftfolder 1 | cwdrepl
474echo == Mail/draft ==
475cat Mail/draft
476echo == Message ==
477sed '/^X-IMAPbase/d' Mail/inbox/1
478],
479[0],
480[-- Editor invocation: ./Mail/draft
481-- Input file:
482To:
483cc:
484Subject:
485--------
486
487------- Forwarded message
488From: gray
489To: root
490Subject: test input
491
492message body
493
494------- End of Forwarded message
495
496-- Input file end
497What now? draft left on "./Mail/draft".
498== Mail/draft ==
499To:
500cc:
501Subject:
502--------
503
504------- Forwarded message
505From: gray
506To: root
507Subject: test input
508
509message body
510
511------- End of Forwarded message
512
513Seen by mhed
514== Message ==
515From: gray
516To: root
517Subject: test input
518
519message body
520])
521
522
400m4_popdef([forwcmd]) 523m4_popdef([forwcmd])
401m4_popdef([MH_KEYWORDS]) 524m4_popdef([MH_KEYWORDS])
402 525
diff --git a/mh/tests/repl.at b/mh/tests/repl.at
index bd58e9f..f8a194c 100644
--- a/mh/tests/repl.at
+++ b/mh/tests/repl.at
@@ -79,6 +79,70 @@ X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
79Seen by mhed 79Seen by mhed
80]) 80])
81 81
82MH_CHECK([Draft-Folder],[repl02 repl-draftfolder draftfolder],[
83mkdir Mail/inbox
84mkdir Mail/drafts
85echo "Draft-Folder: +drafts" >> $MH
86
87AT_DATA([Mail/inbox/1],[From: gray@example.com
88To: root@example.com
89Subject: test input
90
91message body
92])
93echo "quit" | replcmd +inbox 1 | cwdrepl
94echo == Mail/drafts/1 ==
95cat Mail/drafts/1
96],
97[0],
98[-- Editor invocation: ./Mail/drafts/1
99-- Input file:
100To: <gray@example.com>
101Subject: Re: test input
102X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
103--------
104-- Input file end
105What now? draft left on "./Mail/drafts/1".
106== Mail/drafts/1 ==
107To: <gray@example.com>
108Subject: Re: test input
109X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
110--------
111Seen by mhed
112])
113
114MH_CHECK([-nodraftfolder],[repl03 repl-nodraftfolder nodraftfolder draftfolder],[
115mkdir Mail/inbox
116mkdir Mail/drafts
117echo "Draft-Folder: +drafts" >> $MH
118
119AT_DATA([Mail/inbox/1],[From: gray@example.com
120To: root@example.com
121Subject: test input
122
123message body
124])
125echo "quit" | replcmd -nodraftfolder +inbox 1 | cwdrepl
126echo == Mail/draft ==
127cat Mail/draft
128],
129[0],
130[-- Editor invocation: ./Mail/draft
131-- Input file:
132To: <gray@example.com>
133Subject: Re: test input
134X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
135--------
136-- Input file end
137What now? draft left on "./Mail/draft".
138== Mail/draft ==
139To: <gray@example.com>
140Subject: Re: test input
141X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
142--------
143Seen by mhed
144])
145
82m4_popdef([replcmd]) 146m4_popdef([replcmd])
83m4_popdef([MH_KEYWORDS]) 147m4_popdef([MH_KEYWORDS])
84# End of repl.at 148# End of repl.at
diff --git a/mh/whom.c b/mh/whom.c
index 7c3c5ab..97deabb 100644
--- a/mh/whom.c
+++ b/mh/whom.c
@@ -21,7 +21,7 @@ static char prog_doc[] = N_("Report to whom a message would go");
21static char args_doc[] = "[FILE]"; 21static char args_doc[] = "[FILE]";
22 22
23static int check_recipients; 23static int check_recipients;
24static int use_draft; /* Use the prepared draft */ 24static char *message;
25static const char *draft_folder; /* Use this draft folder */ 25static const char *draft_folder; /* Use this draft folder */
26 26
27static void 27static void
@@ -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 mu_c_bool, &check_recipients }, 60 mu_c_bool, &check_recipients },
61 MU_OPTION_END 61 MU_OPTION_END
62}; 62};
63
64static struct mh_optinit optinit[] = {
65 { "draftfolder", "Draft-Folder" },
66 { NULL }
67};
63 68
64int 69int
65main (int argc, char **argv) 70main (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}

Return to:

Send suggestions and report system problems to the System administrator.