summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-11-23 13:11:29 +0200
committerSergey Poznyakoff <gray@gnu.org>2020-11-23 13:20:58 +0200
commit9763fd4a43128bcd08de8e88cce4142473d38d06 (patch)
treec4d298e58eb19dd46cc2a11652013827ef9c264d /include
parentae91979e9664d99204beb116b9b5e4122e43938e (diff)
downloadmailutils-9763fd4a43128bcd08de8e88cce4142473d38d06.tar.gz
mailutils-9763fd4a43128bcd08de8e88cce4142473d38d06.tar.bz2
Implement mboxrb format (a replacement for the mbox used currently)
* configure.ac: New format: mboxrb * include/mailutils/filter.h (mu_fromrb_filter): New extern. * include/mailutils/registrar.h (mu_mboxrb_record): New extern. (mu_register_all_mbox_formats) (mu_register_local_mbox_formats): Add mu_mboxrb_record. * libmailutils/filter/filter.c (mu_filter_get_list): Add mu_fromrb_filter * libproto/Makefile.am [MU_COND_SUPPORT_MBOXRB]: Add mboxrb * bootstrap.conf: Remove special handling for testsuite/maildir (fixes 1d846d2d92). * testsuite/mbop.c: Implement the -r (--read-only) option. * include/mailutils/sys/Makefile.am: Add mboxrb.h * include/mailutils/sys/mboxrb.h: New file. * libmailutils/filter/Makefile.am (libfilter_la_SOURCES): Add fromrb.c * libmailutils/filter/fromrb.c: New file. * libmailutils/tests/Makefile.am: New file. * libmailutils/tests/fromrb.at: New file. * libmailutils/tests/testsuite.at: New file. * libproto/mboxrb/Makefile.am: New file. * libproto/mboxrb/mboxrb.c: New file. * libproto/mboxrb/message.c: New file. * libproto/mboxrb/tests/.gitignore: New file. * libproto/mboxrb/tests/Makefile.am: New file. * libproto/mboxrb/tests/atlocal.in: New file. * libproto/mboxrb/tests/attr.at: New file. * libproto/mboxrb/tests/autodetect.at: New file. * libproto/mboxrb/tests/body.at: New file. * libproto/mboxrb/tests/count.at: New file. * libproto/mboxrb/tests/env.at: New file. * libproto/mboxrb/tests/header.at: New file. * libproto/mboxrb/tests/testsuite.at: New file.
Diffstat (limited to 'include')
-rw-r--r--include/mailutils/filter.h1
-rw-r--r--include/mailutils/registrar.h4
-rw-r--r--include/mailutils/sys/Makefile.am1
-rw-r--r--include/mailutils/sys/mboxrb.h98
4 files changed, 104 insertions, 0 deletions
diff --git a/include/mailutils/filter.h b/include/mailutils/filter.h
index e5fdca8e5..2ef398335 100644
--- a/include/mailutils/filter.h
+++ b/include/mailutils/filter.h
@@ -127,6 +127,7 @@ extern mu_filter_record_t mu_htmlent_filter;
extern mu_filter_record_t mu_xml_filter;
extern mu_filter_record_t mu_percent_filter;
extern mu_filter_record_t mu_dq_filter;
+extern mu_filter_record_t mu_fromrb_filter;
enum mu_iconv_fallback_mode
{
diff --git a/include/mailutils/registrar.h b/include/mailutils/registrar.h
index 5feac383d..3c252fcaf 100644
--- a/include/mailutils/registrar.h
+++ b/include/mailutils/registrar.h
@@ -114,6 +114,8 @@ extern mu_record_t mu_pops_record;
/* Local Mailbox Unix Mailbox, "mbox:" */
extern mu_record_t mu_mbox_record;
+extern mu_record_t mu_mboxrb_record;
+
/* Local MH, "mh:" */
extern mu_record_t mu_mh_record;
/* Maildir, "maildir:" */
@@ -142,6 +144,7 @@ extern mu_record_t mu_dotmail_record;
#define mu_register_all_mbox_formats() do {\
mu_registrar_record (mu_mbox_record);\
+ mu_registrar_record (mu_mboxrb_record);\
mu_registrar_record (mu_dotmail_record);\
mu_registrar_record (mu_pop_record);\
mu_registrar_record (mu_pops_record);\
@@ -154,6 +157,7 @@ extern mu_record_t mu_dotmail_record;
#define mu_register_local_mbox_formats() do {\
mu_registrar_record (mu_mbox_record);\
+ mu_registrar_record (mu_mboxrb_record);\
mu_registrar_record (mu_dotmail_record);\
mu_registrar_record (mu_mh_record);\
mu_registrar_record (mu_maildir_record);\
diff --git a/include/mailutils/sys/Makefile.am b/include/mailutils/sys/Makefile.am
index 435792aa0..d29849814 100644
--- a/include/mailutils/sys/Makefile.am
+++ b/include/mailutils/sys/Makefile.am
@@ -40,6 +40,7 @@ sysinclude_HEADERS = \
mailcap.h\
mailer.h\
mapfile_stream.h\
+ mboxrb.h\
memory_stream.h\
message_stream.h\
message.h\
diff --git a/include/mailutils/sys/mboxrb.h b/include/mailutils/sys/mboxrb.h
new file mode 100644
index 000000000..05e7eb0c4
--- /dev/null
+++ b/include/mailutils/sys/mboxrb.h
@@ -0,0 +1,98 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2019-2020 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _MAILUTILS_SYS_MBOX2_H
+#define _MAILUTILS_SYS_MBOX2_H
+
+# include <mailutils/types.h>
+
+enum mu_mboxrb_hdr
+ {
+ mu_mboxrb_hdr_status,
+ mu_mboxrb_hdr_x_imapbase,
+ mu_mboxrb_hdr_x_uid,
+ MU_MBOXRB_HDR_MAX
+ };
+
+struct mu_mboxrb_message
+{
+ /* Offsets in the mailbox */
+ mu_off_t message_start; /* Start of message */
+ size_t from_length; /* Length of the From_ line */
+ int env_sender_len;
+ int env_date_start;
+ mu_off_t body_start; /* Start of body */
+ mu_off_t message_end; /* Offset of the last byte of the message */
+ /* Additional info */
+ unsigned long uid; /* IMAP-style uid. */
+
+ unsigned body_lines_scanned:1; /* True if body_lines is initialized */
+ unsigned body_from_escaped:1; /* True if body is from-escaped (valid if
+ body_lines_scanned is true) */
+ unsigned uid_modified:1;/* UID|uidvalidity|uidnext has been modified */
+
+ int attr_flags; /* Packed "Status:" attribute flags */
+
+ /* The following two are set only if body_lines_scanned is true */
+ size_t body_size; /* Number of octets in message body
+ (after >From unescape) */
+ size_t body_lines; /* Number of lines in message body */
+ mu_message_t message; /* Pointer to the message object if any */
+ /* Backlink to the mailbox */
+ struct mu_mboxrb_mailbox *mbox; /* Mailbox */
+ size_t num; /* Number of this message in the mailbox (0-based) */
+};
+
+struct mu_mboxrb_message_ref
+{
+ size_t orig_num; /* Original message index */
+ mu_off_t message_start; /* Start of message */
+ mu_off_t body_start; /* Start of body */
+ mu_off_t message_end; /* End of message */
+ int rescan;
+};
+
+struct mu_mboxrb_mailbox
+{
+ char *name; /* Disk file name */
+ mu_mailbox_t mailbox; /* Associated mailbox */
+ int stream_flags; /* Flags used to create the mailbox stream */
+
+ mu_off_t size; /* Size of the mailbox. */
+ unsigned long uidvalidity; /* Uidvalidity value */
+ unsigned long uidnext; /* Expected next UID value */
+ unsigned uidvalidity_scanned:1; /* True if uidvalidity is initialized */
+ unsigned uidvalidity_changed:1; /* True if uidvalidity or uidnext has changed */
+
+ size_t x_imapbase_off; /* Offset of the X-IMAPbase header */
+ size_t x_imapbase_len; /* Length if the header without trailing \n */
+
+ struct mu_mboxrb_message **mesg; /* Array of messages */
+ size_t mesg_count; /* Number of messages in mesgv */
+ size_t mesg_max; /* Actual capacity of mesg */
+};
+
+int mu_mboxrb_mailbox_init (mu_mailbox_t mailbox);
+void mu_mboxrb_message_free (struct mu_mboxrb_message *dmsg);
+int mu_mboxrb_message_get (struct mu_mboxrb_message *dmsg, mu_message_t *mptr);
+int mu_mboxrb_message_attr_load (struct mu_mboxrb_message *dmsg);
+int mu_mboxrb_mailbox_uid_setup (struct mu_mboxrb_mailbox *dmp);
+int mu_mboxrb_message_reconstruct (mu_stream_t dest,
+ struct mu_mboxrb_message *dmsg,
+ struct mu_mboxrb_message_ref *ref,
+ char const *x_imapbase);
+
+#endif

Return to:

Send suggestions and report system problems to the System administrator.