summaryrefslogtreecommitdiff
path: root/mh
diff options
context:
space:
mode:
Diffstat (limited to 'mh')
-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
13 files changed, 423 insertions, 72 deletions
diff --git a/mh/comp.c b/mh/comp.c
index 075bb4516..29389c69e 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 5e0e08b97..016ac84bc 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 69be72de2..76bc85e37 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 d7229983a..26b13ec83 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 65fe3e8c7..16a6e5c55 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 2aa90b669..684ace678 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 5dc15b553..0bd2acabe 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 bbdef7ac5..f3067d1ab 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)