summaryrefslogtreecommitdiff
path: root/mh/repl.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-12-30 19:52:49 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2011-12-30 20:17:31 +0200
commita01bb419262e90164a558075e3607fb3b0514443 (patch)
tree6b034965e51fba477b15d5098a598ee7cfc5e9be /mh/repl.c
parent26cfa2197d5a2866f1a08c48f94d65504fdef7b1 (diff)
downloadmailutils-a01bb419262e90164a558075e3607fb3b0514443.tar.gz
mailutils-a01bb419262e90164a558075e3607fb3b0514443.tar.bz2
Improve msgset interface. Use it in MH.
* libmailutils/msgset/Makefile.am (libmsgset_la_SOURCES): Add new files. * libmailutils/msgset/addset.c: New file. * libmailutils/msgset/count.c: New file. * libmailutils/msgset/foreachmsgno.c: New file. * libmailutils/msgset/foreachuid.c: New file. * libmailutils/msgset/isempty.c: New file. * libmailutils/msgset/subset.c: New file. * libmailutils/msgset/trans.c: New file. * libmailutils/msgset/add.c (mu_msgset_add_range): Take fourth argument specifying the conversion mode. Translate numbers as necessary. * libmailutils/msgset/foreachmsg.c: Translate numbers as necessary. * libmailutils/msgset/foreachnum.c: Rewrite. * libmailutils/msgset/negate.c (_invert_range) (mu_msgset_add_range): Update calls to mu_msgset_add_range. * libmailutils/msgset/parse.c (parse_msgnum_env)<mode>: New member. (parse_msgrange): Update calls to mu_msgset_add_range. (mu_msgset_parse_imap): Change signature. All callers updated. * libmailutils/msgset/sub.c (mu_msgset_sub_range): Take fourth argument specifying the conversion mode. Translate numbers as necessary. * imap4d/copy.c (imap4d_copy0): Update calls to mu_msgset_create and mu_msgset_parse_imap. * imap4d/fetch.c (fetch_thunk): Likewise. * imap4d/search.c (parse_simple_key): Likewise. * imap4d/store.c (store_thunk): Likewise. * include/mailutils/msgset.h (MU_MSGSET_NUM,MU_MSGSET_UID): New defines. (mu_msgset_add,mu_msgset_sub): New protos. (mu_msgset_add_range,mu_msgset_sub_range): Take 4 arguments. All callers changed. * include/mailutils/sys/msgset.h (_mu_msgset_translate_pair) (_mu_msgset_translate_range): New protos. * libmailutils/tests/msgset.c: Reflect the above changes. * testsuite/msgset.c: Likewise. * libproto/imap/mbox.c: Update calls to mu_msgset functions. * mh/mh.h (mh_msgset_t): Remove. (mh_iterator_fp): Remove typedef. (mh_msgset_parse): Change signature. (mh_msgset_member,mh_msgset_reverse,mh_msgset_negate) (mh_msgset_current,mh_msgset_free,mh_msgset_uids): Remove protos. (mh_msgset_parse_string): New proto. (mh_msgset_first_current,mh_msgset_first): New proto. (mh_iterate: Remove proto. Use mu_msgset_foreach* functions instead. (mh_seq_add,mh_seq_delete): Change signatures. * mh/mh_init.c (mh_iterate): Remove. * mh/mh_msgset.c: Rewrite using mu_msgset_t. * mh/mh_sequence.c: Likewise. * mh/anno.c: Use new msgset functions. * mh/burst.c: Likewise. * mh/comp.c: Likewise. * mh/folder.c: Likewise. * mh/forw.c: Likewise. * mh/mark.c: Likewise. * mh/mhn.c: Likewise. * mh/mhpath.c: Likewise. * mh/mhseq.c: Likewise. * mh/pick.c: Likewise. * mh/refile.c: Likewise. * mh/repl.c: Likewise. * mh/rmm.c: Likewise. * mh/scan.c: Likewise. * mh/send.c: Likewise. * mh/sortm.c: Likewise. * mh/whatnowenv.c: Likewise. * mh/tests/mark.at: Reflect changes in the format of the saved sequences, which may contain ranges now. * mu/imap.c: Update calls to mu_msgset functions.
Diffstat (limited to 'mh/repl.c')
-rw-r--r--mh/repl.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/mh/repl.c b/mh/repl.c
index c70081a2a..9b5157ba2 100644
--- a/mh/repl.c
+++ b/mh/repl.c
@@ -112,7 +112,7 @@ static int width = 80;
struct mh_whatnow_env wh_env = { 0 };
static int initial_edit = 1;
static const char *whatnowproc;
-static mh_msgset_t msgset;
+static mu_msgset_t msgset;
static mu_mailbox_t mbox;
static int build_only = 0; /* --build flag */
static int query_mode = 0; /* --query flag */
@@ -281,6 +281,7 @@ make_draft (mu_mailbox_t mbox, int disp, struct mh_whatnow_env *wh)
int rc;
mu_message_t msg;
struct stat st;
+ size_t msgno;
/* First check if the draft exists */
if (!build_only && stat (wh->draftfile, &st) == 0)
@@ -309,12 +310,13 @@ make_draft (mu_mailbox_t mbox, int disp, struct mh_whatnow_env *wh)
unlink (wh->draftfile);
break;
}
-
- rc = mu_mailbox_get_message (mbox, msgset.list[0], &msg);
+
+ msgno = mh_msgset_first (msgset);
+ rc = mu_mailbox_get_message (mbox, msgno, &msg);
if (rc)
{
mu_error (_("cannot read message %s: %s"),
- mu_umaxtostr (0, msgset.list[0]),
+ mu_umaxtostr (0, msgno),
mu_strerror (rc));
exit (1);
}
@@ -349,11 +351,11 @@ make_draft (mu_mailbox_t mbox, int disp, struct mh_whatnow_env *wh)
mu_message_get_header (tmp_msg, &hdr);
text = obstack_finish (&fcc_stack);
mu_header_set_value (hdr, MU_HEADER_FCC, text, 0);
- mh_format (&format, tmp_msg, msgset.list[0], width, &buf);
+ mh_format (&format, tmp_msg, msgno, width, &buf);
mu_message_destroy (&tmp_msg, NULL);
}
else
- mh_format (&format, msg, msgset.list[0], width, &buf);
+ mh_format (&format, msg, msgno, width, &buf);
mu_stream_write (str, buf, strlen (buf), NULL);
@@ -409,8 +411,8 @@ main (int argc, char **argv)
}
mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
- mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur");
- if (msgset.count != 1)
+ mh_msgset_parse (&msgset, mbox, argc - index, argv + index, "cur");
+ if (!mh_msgset_single_message (msgset))
{
mu_error (_("only one message at a time!"));
return 1;

Return to:

Send suggestions and report system problems to the System administrator.