summaryrefslogtreecommitdiff
path: root/mh/whom.c
diff options
context:
space:
mode:
Diffstat (limited to 'mh/whom.c')
-rw-r--r--mh/whom.c63
1 files changed, 49 insertions, 14 deletions
diff --git a/mh/whom.c b/mh/whom.c
index 7c3c5ab99..97deabb38 100644
--- a/mh/whom.c
+++ b/mh/whom.c
@@ -23,3 +23,3 @@ static char args_doc[] = "[FILE]";
static int check_recipients;
-static int use_draft; /* Use the prepared draft */
+static char *message;
static const char *draft_folder; /* Use this draft folder */
@@ -47,3 +47,3 @@ static struct mu_option options[] = {
N_("use prepared draft"),
- mu_c_bool, &use_draft },
+ mu_c_string, &message, NULL, "draft" },
{ "draftfolder", 0, N_("FOLDER"), MU_OPTION_DEFAULT,
@@ -62,2 +62,7 @@ static struct mu_option options[] = {
};
+
+static struct mh_optinit optinit[] = {
+ { "draftfolder", "Draft-Folder" },
+ { NULL }
+};
@@ -66,16 +71,46 @@ main (int argc, char **argv)
{
- char *name = "draft";
-
- mh_getopt (&argc, &argv, options, 0, args_doc, prog_doc, NULL);
+ int rc;
+
+ mh_getopt_ext (&argc, &argv, options, 0, optinit, args_doc, prog_doc, NULL);
- if (!use_draft && argc > 0)
- name = argv[0];
+ if (draft_folder)
+ {
+ mu_mailbox_t mbox = mh_open_folder (draft_folder, MU_STREAM_READ);
+ mu_msgset_t msgset;
+ size_t msgno;
+ mu_message_t msg;
+
+ mh_msgset_parse (&msgset, mbox, argc, argv, "cur");
+ if (!mh_msgset_single_message (msgset))
+ {
+ mu_error (_("only one message at a time!"));
+ return 1;
+ }
+ msgno = mh_msgset_first (msgset, RET_MSGNO);
+ rc = mu_mailbox_get_message (mbox, msgno, &msg);
+ if (rc)
+ {
+ mu_error (_("can't read message: %s"), mu_strerror (rc));
+ exit (1);
+ }
+ rc = mh_whom_message (msg, check_recipients);
+ }
+ else
+ {
+ if (argc > 0)
+ {
+ if (message || argc > 1)
+ {
+ mu_error (_("only one file at a time!"));
+ exit (1);
+ }
+ message = argv[0];
+ }
+ else
+ message = "draft";
+ rc = mh_whom_file (mh_expand_name (draft_folder, message, NAME_ANY),
+ check_recipients);
+ }
- if (!draft_folder)
- draft_folder = mh_global_profile_get ("Draft-Folder",
- mu_folder_directory ());
-
-
- return mh_whom (mh_expand_name (draft_folder, name, NAME_ANY),
- check_recipients) ? 1 : 0;
+ return rc ? 1 : 0;
}

Return to:

Send suggestions and report system problems to the System administrator.