From 17bd8d6216d3929a0090953ff3602c167561ecbc Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sat, 7 Jul 2018 12:06:31 +0100 Subject: [PATCH] create libmaildir --- Makefile.autosetup | 17 +++++++++++- browser.c | 1 + buffy.c | 1 + buffy.h | 2 -- mailbox.h | 3 --- maildir/maildir.h | 60 ++++++++++++++++++++++++++++++++++++++++++ mh.c => maildir/mh.c | 1 + mx.c | 1 + mx.h | 20 -------------- notmuch/mutt_notmuch.c | 1 + po/POTFILES.in | 2 +- 11 files changed, 82 insertions(+), 27 deletions(-) create mode 100644 maildir/maildir.h rename mh.c => maildir/mh.c (99%) diff --git a/Makefile.autosetup b/Makefile.autosetup index 8dce07a1f..469963b3a 100644 --- a/Makefile.autosetup +++ b/Makefile.autosetup @@ -66,7 +66,7 @@ NEOMUTTOBJS= addrbook.o alias.o bcache.o browser.o buffy.o \ conststrings.o copy.o curs_lib.o curs_main.o edit.o editmsg.o \ enriched.o enter.o filter.o flags.o from.o group.o handler.o \ hdrline.o help.o history.o hook.o init.o keymap.o \ - main.o menu.o mh.o muttlib.o mutt_account.o mutt_attach.o mutt_body.o mutt_header.o \ + main.o menu.o muttlib.o mutt_account.o mutt_attach.o mutt_body.o mutt_header.o \ mutt_logging.o mutt_signal.o mutt_socket.o mutt_thread.o mutt_window.o mx.o \ pager.o parse.o pattern.o \ postpone.o progress.o query.o recvattach.o recvcmd.o resize.o rfc1524.o \ @@ -129,6 +129,14 @@ MUTTLIBS+= $(LIBNOTMUCH) ALLOBJS+= $(LIBNOTMUCHOBJS) @endif +############################################################################### +# libmaildir +LIBMAILDIR= libmaildir.a +LIBMAILDIROBJS= maildir/mh.o +CLEANFILES+= $(LIBMAILDIR) $(LIBMAILDIROBJS) +MUTTLIBS+= $(LIBMAILDIR) +ALLOBJS+= $(LIBMAILDIROBJS) + ############################################################################### # libmutt LIBMUTT= libmutt.a @@ -294,6 +302,13 @@ $(LIBNOTMUCH): $(PWD)/notmuch $(LIBNOTMUCHOBJS) $(PWD)/notmuch: $(MKDIR_P) $(PWD)/notmuch +# libmaildir +$(LIBMAILDIR): $(PWD)/maildir $(LIBMAILDIROBJS) + $(AR) cr $@ $(LIBMAILDIROBJS) + $(RANLIB) $@ +$(PWD)/maildir: + $(MKDIR_P) $(PWD)/maildir + # libncrypt $(LIBNCRYPT): $(PWD)/ncrypt $(LIBNCRYPTOBJS) $(AR) cr $@ $(LIBNCRYPTOBJS) diff --git a/browser.c b/browser.c index e22e2743e..ce2e73ef8 100644 --- a/browser.c +++ b/browser.c @@ -45,6 +45,7 @@ #include "globals.h" #include "keymap.h" #include "mailbox.h" +#include "maildir/maildir.h" #include "mutt_attach.h" #include "mutt_curses.h" #include "mutt_menu.h" diff --git a/buffy.c b/buffy.c index c04e0504d..b8c2851eb 100644 --- a/buffy.c +++ b/buffy.c @@ -35,6 +35,7 @@ #include "context.h" #include "globals.h" #include "mailbox.h" +#include "maildir/maildir.h" #include "mutt_menu.h" #include "mutt_window.h" #include "mx.h" diff --git a/buffy.h b/buffy.h index 8368989d1..55d2468c2 100644 --- a/buffy.h +++ b/buffy.h @@ -76,8 +76,6 @@ void mutt_buffy_cleanup(const char *path, struct stat *st); /** mark mailbox just left as already notified */ void mutt_buffy_setnotified(const char *path); -bool mh_buffy(struct Buffy *mailbox, bool check_stats); - /* force flags passed to mutt_buffy_check() */ #define MUTT_BUFFY_CHECK_FORCE (1 << 0) #define MUTT_BUFFY_CHECK_FORCE_STATS (1 << 1) diff --git a/mailbox.h b/mailbox.h index ffe51fa00..2b765a1bc 100644 --- a/mailbox.h +++ b/mailbox.h @@ -105,7 +105,4 @@ bool mx_is_nntp(const char *p); int mx_access(const char *path, int flags); int mx_check_empty(const char *path); -bool mx_is_maildir(const char *path); -bool mx_is_mh(const char *path); - #endif /* _MUTT_MAILBOX_H */ diff --git a/maildir/maildir.h b/maildir/maildir.h new file mode 100644 index 000000000..344793342 --- /dev/null +++ b/maildir/maildir.h @@ -0,0 +1,60 @@ +/** + * @file + * Maildir local mailbox type + * + * @authors + * Copyright (C) 2018 Richard Russon + * + * @copyright + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * This program 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 General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#ifndef _MAILDIR_MAILDIR_H +#define _MAILDIR_MAILDIR_H + +#include +#include +#include "mx.h" +#ifdef USE_HCACHE +#include "hcache/hcache.h" +#endif + +struct Buffy; +struct Context; +struct Header; + +extern struct MxOps mx_maildir_ops; +extern struct MxOps mx_mh_ops; + +int maildir_check_empty(const char *path); +void maildir_flags(char *dest, size_t destlen, struct Header *hdr); +FILE * maildir_open_find_message(const char *folder, const char *msg, char **newname); +void maildir_parse_flags(struct Header *h, const char *path); +struct Header *maildir_parse_message(int magic, const char *fname, bool is_old, struct Header *h); +struct Header *maildir_parse_stream(int magic, FILE *f, const char *fname, bool is_old, struct Header *h); +bool maildir_update_flags(struct Context *ctx, struct Header *o, struct Header *n); + +bool mh_buffy(struct Buffy *mailbox, bool check_stats); +int mh_check_empty(const char *path); + +bool mx_is_maildir(const char *path); +bool mx_is_mh(const char *path); + +#ifdef USE_HCACHE +int mh_sync_mailbox_message(struct Context *ctx, int msgno, header_cache_t *hc); +#else +int mh_sync_mailbox_message(struct Context *ctx, int msgno); +#endif + +#endif /* _MAILDIR_MAILDIR_H */ diff --git a/mh.c b/maildir/mh.c similarity index 99% rename from mh.c rename to maildir/mh.c index 5c05eb7a5..7409f4a46 100644 --- a/mh.c +++ b/maildir/mh.c @@ -46,6 +46,7 @@ #include "copy.h" #include "globals.h" #include "mailbox.h" +#include "maildir.h" #include "mutt_thread.h" #include "mx.h" #include "options.h" diff --git a/mx.c b/mx.c index f6900daca..e1cb8ce8a 100644 --- a/mx.c +++ b/mx.c @@ -47,6 +47,7 @@ #include "globals.h" #include "keymap.h" #include "mailbox.h" +#include "maildir/maildir.h" #include "mbox/mbox.h" #include "mutt_header.h" #include "mutt_thread.h" diff --git a/mx.h b/mx.h index c137f99d5..1d0ff7559 100644 --- a/mx.h +++ b/mx.h @@ -158,37 +158,17 @@ enum MailboxFormat void mbox_reset_atime(struct Context *ctx, struct stat *st); -int mh_check_empty(const char *path); - -int maildir_check_empty(const char *path); - -struct Header *maildir_parse_message(int magic, const char *fname, bool is_old, struct Header *h); -struct Header *maildir_parse_stream(int magic, FILE *f, const char *fname, bool is_old, struct Header *h); -void maildir_parse_flags(struct Header *h, const char *path); -bool maildir_update_flags(struct Context *ctx, struct Header *o, struct Header *n); -void maildir_flags(char *dest, size_t destlen, struct Header *hdr); - -#ifdef USE_HCACHE -int mh_sync_mailbox_message(struct Context *ctx, int msgno, header_cache_t *hc); -#else -int mh_sync_mailbox_message(struct Context *ctx, int msgno); -#endif - #ifdef USE_NOTMUCH bool mx_is_notmuch(const char *p); #endif bool mx_tags_is_supported(struct Context *ctx); -FILE *maildir_open_find_message(const char *folder, const char *msg, char **newname); - void mx_alloc_memory(struct Context *ctx); void mx_update_context(struct Context *ctx, int new_messages); void mx_update_tables(struct Context *ctx, bool committing); struct MxOps *mx_get_ops(int magic); -extern struct MxOps mx_maildir_ops; -extern struct MxOps mx_mh_ops; /* This variable is backing for a config item */ WHERE short MboxType; diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index 2e31493fb..906c3f1e5 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -54,6 +54,7 @@ #include "context.h" #include "globals.h" #include "mailbox.h" +#include "maildir/maildir.h" #include "mutt_thread.h" #include "mx.h" #include "progress.h" diff --git a/po/POTFILES.in b/po/POTFILES.in index f85b721ca..f00d7a11a 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -63,10 +63,10 @@ imap/utf7.c imap/util.c init.c keymap.c +maildir/mh.c main.c mbox/mbox.c menu.c -mh.c mutt/base64.c mutt/buffer.c mutt/charset.c -- 2.40.0