1 diff -udprP mutt-1.5.16.orig/Makefile.am mutt-1.5.16/Makefile.am
2 --- mutt-1.5.16.orig/Makefile.am 2007-06-04 07:20:01.000000000 +0300
3 +++ mutt-1.5.16/Makefile.am 2007-06-12 14:22:35.000000000 +0300
4 @@ -18,6 +18,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.
5 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
6 mutt_SOURCES = $(BUILT_SOURCES) \
7 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
10 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
11 edit.c enter.c flags.c init.c filter.c from.c \
12 @@ -67,6 +68,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
14 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
17 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
18 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
19 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
20 diff -udprP mutt-1.5.16.orig/Makefile.in mutt-1.5.16/Makefile.in
21 --- mutt-1.5.16.orig/Makefile.in 2007-06-10 05:43:26.000000000 +0300
22 +++ mutt-1.5.16/Makefile.in 2007-06-12 14:22:35.000000000 +0300
27 +mutt_SOURCES += compress.c
28 +EXTRA_DIST += compress.h
29 +mutt_OBJECTS += compress.o
33 top_srcdir = @top_srcdir@
34 diff -udprP mutt-1.5.16.orig/Muttrc.head mutt-1.5.16/Muttrc.head
35 --- mutt-1.5.16.orig/Muttrc.head 2007-06-06 19:02:56.000000000 +0300
36 +++ mutt-1.5.16/Muttrc.head 2007-06-12 14:22:35.000000000 +0300
37 @@ -24,6 +24,11 @@ macro generic,pager <F1> "<shell-escape>
38 macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
41 +# Use folders which match on \\.gz$ as gzipped folders:
42 +# open-hook \\.gz$ "gzip -cd %f > %t"
43 +# close-hook \\.gz$ "gzip -c %t > %f"
44 +# append-hook \\.gz$ "gzip -c %t >> %f"
46 # If Mutt is unable to determine your site's domain name correctly, you can
47 # set the default here.
49 diff -udprP mutt-1.5.16.orig/PATCHES mutt-1.5.16/PATCHES
50 --- mutt-1.5.16.orig/PATCHES 2007-04-30 05:07:48.000000000 +0300
51 +++ mutt-1.5.16/PATCHES 2007-06-12 14:22:35.000000000 +0300
54 diff -udprP mutt-1.5.16.orig/compress.c mutt-1.5.16/compress.c
55 --- mutt-1.5.16.orig/compress.c 1970-01-01 03:00:00.000000000 +0300
56 +++ mutt-1.5.16/compress.c 2007-06-12 14:22:35.000000000 +0300
59 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
61 + * This program is free software; you can redistribute it and/or modify
62 + * it under the terms of the GNU General Public License as published by
63 + * the Free Software Foundation; either version 2 of the License, or
64 + * (at your option) any later version.
66 + * This program is distributed in the hope that it will be useful,
67 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
68 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69 + * GNU General Public License for more details.
71 + * You should have received a copy of the GNU General Public License
72 + * along with this program; if not, write to the Free Software
73 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
82 +#ifdef USE_COMPRESSED
86 +#include "mutt_curses.h"
91 +#include <sys/stat.h>
95 + const char *close; /* close-hook command */
96 + const char *open; /* open-hook command */
97 + const char *append; /* append-hook command */
98 + off_t size; /* size of real folder */
101 +char echo_cmd[HUGE_STRING];
104 + * ctx - context to lock
105 + * excl - exclusive lock?
106 + * retry - should retry if unable to lock?
108 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
112 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
114 + else if (retry && !excl)
123 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
129 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
134 +static int is_new (const char *path)
136 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
139 +static const char* find_compress_hook (int type, const char *path)
141 + const char* c = mutt_find_hook (type, path);
142 + return (!c || !*c) ? NULL : c;
145 +int mutt_can_read_compressed (const char *path)
147 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
150 +/* if the file is new, we really do not append, but create, and so use
151 + * close-hook, and not append-hook
153 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
155 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
156 + return (is_new (path)) ? ci->close : ci->append;
159 +int mutt_can_append_compressed (const char *path)
164 + return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
166 + magic = mx_get_magic (path);
168 + if (magic != 0 && magic != M_COMPRESSED)
171 + return (find_compress_hook (M_APPENDHOOK, path)
172 + || (find_compress_hook (M_OPENHOOK, path)
173 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
176 +/* open a compressed mailbox */
177 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
181 + /* Now lets uncompress this thing */
182 + ci = safe_malloc (sizeof (COMPRESS_INFO));
183 + ctx->compressinfo = (void*) ci;
184 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
185 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
186 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
190 +static void set_path (CONTEXT* ctx)
192 + char tmppath[_POSIX_PATH_MAX];
194 + /* Setup the right paths */
195 + ctx->realpath = ctx->path;
197 + /* Uncompress to /tmp */
198 + mutt_mktemp (tmppath);
199 + ctx->path = safe_malloc (strlen (tmppath) + 1);
200 + strcpy (ctx->path, tmppath);
203 +static int get_size (const char* path)
206 + if (stat (path, &sb) != 0)
208 + return (sb.st_size);
211 +static void store_size (CONTEXT* ctx)
213 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
214 + ci->size = get_size (ctx->realpath);
218 +compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
219 + const char *fmt, const char *ifstring,
220 + const char *elsestring, unsigned long data,
223 + char tmp[SHORT_STRING];
225 + CONTEXT *ctx = (CONTEXT *) data;
229 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
230 + snprintf (dest, destlen, tmp, ctx->realpath);
233 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
234 + snprintf (dest, destlen, tmp, ctx->path);
240 +/* check that the command has both %f and %t
241 + * 0 means OK, -1 means error
243 +int mutt_test_compress_command (const char* cmd)
245 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
248 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
250 + char expanded[_POSIX_PATH_MAX];
251 + mutt_FormatString (expanded, sizeof (expanded), 0, cmd, compresshook_format_str,
252 + (unsigned long) ctx, 0);
253 + return safe_strdup (expanded);
256 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
258 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
259 + if (ci->size != get_size (ctx->realpath))
261 + FREE (&ctx->compressinfo);
262 + FREE (&ctx->realpath);
263 + mutt_error _("Mailbox was corrupted!");
269 +int mutt_open_read_compressed (CONTEXT *ctx)
275 + COMPRESS_INFO *ci = set_compress_info (ctx);
278 + FREE (ctx->compressinfo);
281 + if (!ci->close || access (ctx->path, W_OK) != 0)
288 + mutt_message (_("Decompressing %s..."), ctx->realpath);
290 + cmd = get_compression_cmd (ci->open, ctx);
293 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
295 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
297 + mutt_perror (ctx->realpath);
301 + mutt_block_signals ();
302 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
305 + mutt_unblock_signals ();
306 + mutt_error _("Unable to lock mailbox!");
313 + sprintf(echo_cmd,_("echo Decompressing %s..."),ctx->realpath);
314 + mutt_system(echo_cmd);
315 + rc = mutt_system (cmd);
316 + mbox_unlock_compressed (ctx, fp);
317 + mutt_unblock_signals ();
322 + mutt_any_key_to_continue (NULL);
324 + FREE (ctx->compressinfo);
325 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
331 + if (mutt_check_mailbox_compressed (ctx))
334 + ctx->magic = mx_get_magic (ctx->path);
339 +void restore_path (CONTEXT* ctx)
342 + ctx->path = ctx->realpath;
345 +/* remove the temporary mailbox */
346 +void remove_file (CONTEXT* ctx)
348 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
349 + remove (ctx->path);
352 +int mutt_open_append_compressed (CONTEXT *ctx)
355 + COMPRESS_INFO *ci = set_compress_info (ctx);
357 + if (!get_append_command (ctx->path, ctx))
359 + if (ci->open && ci->close)
360 + return (mutt_open_read_compressed (ctx));
363 + FREE (&ctx->compressinfo);
369 + ctx->magic = DefaultMagic;
371 + if (!is_new (ctx->realpath))
372 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
373 + if ((fh = fopen (ctx->path, "w")))
375 + /* No error checking - the parent function will catch it */
380 +/* close a compressed mailbox */
381 +void mutt_fast_close_compressed (CONTEXT *ctx)
383 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
386 + if (ctx->compressinfo)
391 + /* if the folder was removed, remove the gzipped folder too */
392 + if (access (ctx->path, F_OK) != 0 && ! option (OPTSAVEEMPTY))
393 + remove (ctx->realpath);
397 + restore_path (ctx);
398 + FREE (&ctx->compressinfo);
402 +/* return 0 on success, -1 on failure */
403 +int mutt_sync_compressed (CONTEXT* ctx)
408 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
411 + mutt_message (_("Compressing %s..."), ctx->realpath);
413 + cmd = get_compression_cmd (ci->close, ctx);
417 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
419 + mutt_perror (ctx->realpath);
423 + mutt_block_signals ();
424 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
427 + mutt_unblock_signals ();
428 + mutt_error _("Unable to lock mailbox!");
436 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
440 + sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath);
441 + mutt_system(echo_cmd);
442 + if (mutt_system (cmd))
444 + mutt_any_key_to_continue (NULL);
445 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
449 + mbox_unlock_compressed (ctx, fp);
450 + mutt_unblock_signals ();
460 +int mutt_slow_close_compressed (CONTEXT *ctx)
463 + const char *append;
465 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
467 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
471 + && ((append = get_append_command (ctx->realpath, ctx))
472 + || (append = ci->close))))
473 + { /* if we can not or should not append,
474 + * we only have to remove the compressed info, because sync was already
477 + mutt_fast_close_compressed (ctx);
487 + if (append == ci->close)
488 + mutt_message (_("Compressing %s..."), ctx->realpath);
490 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
493 + cmd = get_compression_cmd (append, ctx);
497 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
499 + mutt_perror (ctx->realpath);
503 + mutt_block_signals ();
504 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
507 + mutt_unblock_signals ();
508 + mutt_error _("Unable to lock mailbox!");
513 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
518 + if (append == ci->close)
519 + sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath);
521 + sprintf(echo_cmd,_("echo Compressed-appending to %s..."), ctx->realpath);
522 + mutt_system(echo_cmd);
524 + if (mutt_system (cmd))
526 + mutt_any_key_to_continue (NULL);
527 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
530 + mbox_unlock_compressed (ctx, fp);
531 + mutt_unblock_signals ();
536 + mbox_unlock_compressed (ctx, fp);
537 + mutt_unblock_signals ();
540 + restore_path (ctx);
542 + FREE (&ctx->compressinfo);
547 +#endif /* USE_COMPRESSED */
548 diff -udprP mutt-1.5.16.orig/compress.h mutt-1.5.16/compress.h
549 --- mutt-1.5.16.orig/compress.h 1970-01-01 03:00:00.000000000 +0300
550 +++ mutt-1.5.16/compress.h 2007-06-12 14:22:35.000000000 +0300
553 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
555 + * This program is free software; you can redistribute it and/or modify
556 + * it under the terms of the GNU General Public License as published by
557 + * the Free Software Foundation; either version 2 of the License, or
558 + * (at your option) any later version.
560 + * This program is distributed in the hope that it will be useful,
561 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
562 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
563 + * GNU General Public License for more details.
565 + * You should have received a copy of the GNU General Public License
566 + * along with this program; if not, write to the Free Software
567 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
570 +int mutt_can_read_compressed (const char *);
571 +int mutt_can_append_compressed (const char *);
572 +int mutt_open_read_compressed (CONTEXT *);
573 +int mutt_open_append_compressed (CONTEXT *);
574 +int mutt_slow_close_compressed (CONTEXT *);
575 +int mutt_sync_compressed (CONTEXT *);
576 +int mutt_test_compress_command (const char *);
577 +int mutt_check_mailbox_compressed (CONTEXT *);
578 +void mutt_fast_close_compressed (CONTEXT *);
579 diff -udprP mutt-1.5.16.orig/config.h.in mutt-1.5.16/config.h.in
580 --- mutt-1.5.16.orig/config.h.in 2007-06-10 05:44:57.000000000 +0300
581 +++ mutt-1.5.16/config.h.in 2007-06-12 14:22:35.000000000 +0300
584 /* Define to enable Sun mailtool attachments support. */
585 #undef SUN_ATTACHMENT
587 +/* The compressed mailboxes support */
588 +#undef USE_COMPRESSED
590 /* Define to use dotlocking for mailboxes. */
592 diff -udprP mutt-1.5.16.orig/configure mutt-1.5.16/configure
593 --- mutt-1.5.16.orig/configure 2007-06-10 05:43:29.000000000 +0300
594 +++ mutt-1.5.16/configure 2007-06-12 14:22:35.000000000 +0300
595 @@ -1350,6 +1350,7 @@ Optional Features:
596 --disable-warnings Turn off compiler warnings (not recommended)
597 --enable-nfs-fix Work around an NFS with broken attributes caching
598 --enable-mailtool Enable Sun mailtool attachments support
599 + --enable-compressed Enable compressed folders support
600 --enable-locales-fix The result of isprint() is unreliable
601 --enable-exact-address Enable regeneration of email addresses
602 --enable-hcache Enable header caching
603 @@ -14414,6 +14415,18 @@ echo "${ECHO_T}$mutt_cv_regex_broken" >&
608 +# Check whether --enable-compressed or --disable-compressed was given.
609 +if test "${enable_compressed+set}" = set; then
610 + enableval="$enable_compressed"
611 + if test x$enableval = xyes; then
612 + cat >> confdefs.h <<\EOF
613 +#define USE_COMPRESSED 1
619 if test $mutt_cv_regex = yes; then
621 cat >>confdefs.h <<\_ACEOF
622 diff -udprP mutt-1.5.16.orig/configure.ac mutt-1.5.16/configure.ac
623 --- mutt-1.5.16.orig/configure.ac 2007-06-04 07:20:01.000000000 +0300
624 +++ mutt-1.5.16/configure.ac 2007-06-12 14:22:35.000000000 +0300
625 @@ -780,6 +780,11 @@ AC_ARG_ENABLE(mailtool, AC_HELP_STRING([
626 AC_DEFINE(SUN_ATTACHMENT,1,[ Define to enable Sun mailtool attachments support. ])
629 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
630 + [if test x$enableval = xyes; then
631 + AC_DEFINE(USE_COMPRESSED,1,[ Define to enable compressed folders support. ])
634 AC_ARG_ENABLE(locales-fix, AC_HELP_STRING([--enable-locales-fix], [The result of isprint() is unreliable]),
635 [if test x$enableval = xyes; then
636 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
637 diff -udprP mutt-1.5.16.orig/curs_main.c mutt-1.5.16/curs_main.c
638 --- mutt-1.5.16.orig/curs_main.c 2007-05-20 10:30:00.000000000 +0300
639 +++ mutt-1.5.16/curs_main.c 2007-06-12 14:22:35.000000000 +0300
640 @@ -1111,6 +1111,11 @@ int mutt_index_menu (void)
644 +#ifdef USE_COMPRESSED
645 + if (Context->compressinfo && Context->realpath)
646 + mutt_str_replace (&LastFolder, Context->realpath);
649 mutt_str_replace (&LastFolder, Context->path);
650 oldcount = Context ? Context->msgcount : 0;
652 diff -udprP mutt-1.5.16.orig/doc/Makefile.am mutt-1.5.16/doc/Makefile.am
653 --- mutt-1.5.16.orig/doc/Makefile.am 2007-04-13 19:43:45.000000000 +0300
654 +++ mutt-1.5.16/doc/Makefile.am 2007-06-12 14:22:35.000000000 +0300
655 @@ -27,7 +27,7 @@ EXTRA_DIST = dotlock.man \
657 HTML_DOCFILES = manual.html index.html intro.html gettingstarted.html \
658 configuration.html mimesupport.html advancedusage.html \
659 - tuning.html reference.html miscellany.html
660 + tuning.html reference.html miscellany.html compressed-folders.html
662 BUILT_DISTFILES = stamp-doc-xml stamp-doc-chunked manual.txt $(HTML_DOCFILES)
664 diff -udprP mutt-1.5.16.orig/doc/Makefile.in mutt-1.5.16/doc/Makefile.in
665 --- mutt-1.5.16.orig/doc/Makefile.in 2007-06-10 05:43:25.000000000 +0300
666 +++ mutt-1.5.16/doc/Makefile.in 2007-06-12 14:22:35.000000000 +0300
667 @@ -223,7 +223,7 @@ EXTRA_DIST = dotlock.man \
669 HTML_DOCFILES = manual.html index.html intro.html gettingstarted.html \
670 configuration.html mimesupport.html advancedusage.html \
671 - tuning.html reference.html miscellany.html
672 + tuning.html reference.html miscellany.html compressed-folders.html
674 BUILT_DISTFILES = stamp-doc-xml stamp-doc-chunked manual.txt $(HTML_DOCFILES)
675 srcdir_DOCFILES = PGP-Notes.txt applying-patches.txt \
676 diff -udprP mutt-1.5.16.orig/doc/manual.xml.head mutt-1.5.16/doc/manual.xml.head
677 --- mutt-1.5.16.orig/doc/manual.xml.head 2007-04-04 08:37:13.000000000 +0300
678 +++ mutt-1.5.16/doc/manual.xml.head 2007-06-12 14:22:35.000000000 +0300
679 @@ -4083,6 +4083,24 @@ configuration option/command. See
680 <link linkend="fcc-save-hook">fcc-save-hook</link>
686 +<link linkend="open-hook">open-hook</link>
692 +<link linkend="close-hook">close-hook</link>
698 +<link linkend="append-hook">append-hook</link>
704 @@ -4910,6 +4928,254 @@ becomes an issue as mutt will silently f
708 +<chapter id="compressed-folders">
709 +<title>Compressed folders Support (OPTIONAL)</title>
712 +If Mutt was compiled with compressed folders support (by running the
713 +<emphasis>configure</emphasis> script with the
714 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
715 +stored in an arbitrary format, provided that the user has a script to
716 +convert from/to this format to one of the accepted.
720 +The most common use is to open compressed archived folders e.g. with
725 +In addition, the user can provide a script that gets a folder in an
726 +accepted format and appends its context to the folder in the
727 +user-defined format, which may be faster than converting the entire
728 +folder to the accepted format, appending to it and converting back to
729 +the user-defined format.
733 +There are three hooks defined
734 +(<link linkend="open-hook">open-hook</link>,
735 +<link linkend="close-hook">close-hook</link> and
736 +<link linkend="append-hook">append-hook</link>) which define commands
737 +to uncompress and compress a folder and to append messages to an
738 +existing compressed folder respectively.
745 +open-hook \\.gz$ "gzip -cd %f > %t"
746 +close-hook \\.gz$ "gzip -c %t > %f"
747 +append-hook \\.gz$ "gzip -c %t >> %f"
752 +You do not have to specify all of the commands. If you omit
753 +<link linkend="append-hook">append-hook</link>, the folder will be open
754 +and closed again each time you will add to it. If you omit
755 +<link linkend="close-hook">close-hook</link> (or give empty command),
756 +the folder will be open in the mode. If you specify
757 +<link linkend="append-hook">append-hook</link> though you'll be able to
758 +append to the folder.
762 +Note that Mutt will only try to use hooks if the file is not in one of
763 +the accepted formats. In particular, if the file is empty, mutt
764 +supposes it is not compressed. This is important because it allows the
765 +use of programs that do not have well defined extensions. Just use
766 +``.'' as a regexp. But this may be surprising if your compressing
767 +script produces empty files. In this situation, unset
768 +<link linkend="save-empty">$save_empty</link>, so that
769 +the compressed file will be removed if you delete all of the messages.
772 +<sect1 id="open-hook">
773 +<title>Open a compressed mailbox for reading</title>
776 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis>
780 +The <emphasis>command</emphasis> is the command that can be used for
781 +opening the folders whose names match <emphasis>regexp</emphasis>.
785 +The <emphasis>command</emphasis> string is the printf-like format
786 +string, and it should accept two parameters: %f, which is
787 +replaced with the (compressed) folder name, and %t which is
788 +replaced with the name of the temporary folder to which to write.
792 +%f and %t can be repeated any number of times in the
793 +command string, and all of the entries are replaced with the
794 +appropriate folder name. In addition, %% is replaced by
795 +%, as in printf, and any other %anything is left as is.
799 +The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis>
800 +remove the original compressed file. The <emphasis>command</emphasis>
801 +should return non-zero exit status if it fails, so mutt knows
809 +open-hook \\.gz$ "gzip -cd %f > %t"
814 +If the <emphasis>command</emphasis> is empty, this operation is
815 +disabled for this file type.
820 +<sect1 id="close-hook">
821 +<title>Write a compressed mailbox</title>
824 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis>
828 +This is used to close the folder that was open with the
829 +<link linkend="open-hook">open-hook</link> command after some changes
834 +The <emphasis>command</emphasis> string is the command that can be
835 +used for closing the folders whose names match <emphasis>regexp</emphasis>.
836 +It has the same format as in the <link linkend="open-hook">open-hook</link>
837 +command. Temporary folder in this case is the folder previously
838 +produced by the <link linkend="open-hook">open-hook</link> command.
842 +The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis>
843 +remove the decompressed file. The <emphasis>command</emphasis> should
844 +return non-zero exit status if it fails, so mutt knows something's
852 +close-hook \\.gz$ "gzip -c %t > %f"
857 +If the <emphasis>command</emphasis> is empty, this operation is
858 +disabled for this file type, and the file can only be open in the
863 +<link linkend="close-hook">close-hook</link> is not called when you
864 +exit from the folder if the folder was not changed.
869 +<sect1 id="append-hook">
870 +<title>Append a message to a compressed mailbox</title>
873 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis>
877 +This command is used for saving to an existing compressed folder.
878 +The <emphasis>command</emphasis> is the command that can be used for
879 +appending to the folders whose names match <emphasis>regexp</emphasis>.
880 +It has the same format as in the <link linkend="open-hook">open-hook</link>
881 +command. The temporary folder in this case contains the messages that
886 +The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis>
887 +remove the decompressed file. The <emphasis>command</emphasis> should
888 +return non-zero exit status if it fails, so mutt knows something's
896 +append-hook \\.gz$ "gzip -c %t >> %f"
901 +When <link linkend="append-hook">append-hook</link> is used, the folder
902 +is not opened, which saves time, but this means that we can not find
903 +out what the folder type is. Thus the default
904 +(<link linkend="mbox-type">$mbox_type</link>) type is
905 +always supposed (i.e. this is the format used for the temporary
910 +If the file does not exist when you save to it,
911 +<link linkend="close-hook">close-hook</link> is called, and not
912 +<link linkend="append-hook">append-hook</link>.
913 +<link linkend="append-hook">append-hook</link> is only for appending
914 +to existing folders.
918 +If the <emphasis>command</emphasis> is empty, this operation is
919 +disabled for this file type. In this case, the folder will be open and
920 +closed again (using <link linkend="open-hook">open-hook</link> and
921 +<link linkend="close-hook">close-hook</link> respectively) each time
928 +<title>Encrypted folders</title>
931 +The compressed folders support can also be used to handle encrypted
932 +folders. If you want to encrypt a folder with PGP, you may want to use
933 +the following hooks:
936 +open-hook \\.pgp$ "pgp -f < %f > %t"
937 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
942 +Please note, that PGP does not support appending to an encrypted
943 +folder, so there is no append-hook defined.
947 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
948 +decrypted in the /tmp directory, where it can be read by your system
949 +administrator. So think about the security aspects of this.
956 <chapter id="mimesupport">
957 <title>Mutt's MIME Support</title>
959 @@ -6056,6 +6322,12 @@ The following are the commands understoo
963 +<literal><link linkend="append-hook">append-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>command</emphasis>
969 <literal><link linkend="auto-view">auto_view</link></literal> <emphasis>mimetype</emphasis> [ <emphasis>mimetype</emphasis> ... ]
972 @@ -6086,6 +6358,12 @@ The following are the commands understoo
976 +<literal><link linkend="close-hook">close-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>command</emphasis>
982 <literal><link linkend="color">color</link></literal> <emphasis>object</emphasis> <emphasis>foreground</emphasis> <emphasis>background</emphasis> [ <emphasis>regexp</emphasis> ]
985 @@ -6218,6 +6496,12 @@ The following are the commands understoo
989 +<literal><link linkend="open-hook">open-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>command</emphasis>
995 <literal><link linkend="crypt-hook">crypt-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>key-id</emphasis>
998 diff -udprP mutt-1.5.16.orig/doc/muttrc.man.head mutt-1.5.16/doc/muttrc.man.head
999 --- mutt-1.5.16.orig/doc/muttrc.man.head 2007-04-02 00:58:55.000000000 +0300
1000 +++ mutt-1.5.16/doc/muttrc.man.head 2007-06-12 14:22:35.000000000 +0300
1001 @@ -345,6 +345,24 @@ specify the ID of the public key to be u
1002 to a certain recipient. The meaning of "key ID" is to be taken
1003 broadly: This can be a different e-mail address, a numerical key ID,
1004 or even just an arbitrary search string.
1007 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
1008 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
1009 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
1012 +These commands provide a way to handle compressed folders. The given
1013 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
1014 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
1015 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
1016 +compressed mail to a compressed folder (\fBappend-hook\fP). The
1017 +\fIcommand\fP string is the
1019 +like format string, and it should accept two parameters: \fB%f\fP,
1020 +which is replaced with the (compressed) folder name, and \fB%t\fP
1021 +which is replaced with the name of the temporary folder to which to
1024 \fBpush\fP \fIstring\fP
1025 This command adds the named \fIstring\fP to the keyboard buffer.
1026 diff -udprP mutt-1.5.16.orig/hook.c mutt-1.5.16/hook.c
1027 --- mutt-1.5.16.orig/hook.c 2007-04-08 02:36:55.000000000 +0300
1028 +++ mutt-1.5.16/hook.c 2007-06-12 14:22:35.000000000 +0300
1030 #include "mailbox.h"
1031 #include "mutt_crypt.h"
1033 +#ifdef USE_COMPRESSED
1034 +#include "compress.h"
1040 @@ -92,6 +96,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
1041 memset (&pattern, 0, sizeof (pattern));
1042 pattern.data = safe_strdup (path);
1044 +#ifdef USE_COMPRESSED
1045 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
1047 + if (mutt_test_compress_command (command.data))
1049 + strfcpy (err->data, _("bad formatted command string"), err->dsize);
1054 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
1055 && (!WithCrypto || !(data & M_CRYPTHOOK))
1057 diff -udprP mutt-1.5.16.orig/init.h mutt-1.5.16/init.h
1058 --- mutt-1.5.16.orig/init.h 2007-06-10 05:29:21.000000000 +0300
1059 +++ mutt-1.5.16/init.h 2007-06-12 14:22:35.000000000 +0300
1060 @@ -3129,6 +3129,11 @@ struct command_t Commands[] = {
1061 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
1062 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
1063 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
1064 +#ifdef USE_COMPRESSED
1065 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
1066 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
1067 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
1069 { "group", parse_group, 0 },
1070 { "ungroup", parse_ungroup, 0 },
1071 { "hdr_order", parse_list, UL &HeaderOrderList },
1072 diff -udprP mutt-1.5.16.orig/main.c mutt-1.5.16/main.c
1073 --- mutt-1.5.16.orig/main.c 2007-04-10 23:53:08.000000000 +0300
1074 +++ mutt-1.5.16/main.c 2007-06-12 14:22:35.000000000 +0300
1075 @@ -310,6 +310,12 @@ static void show_version (void)
1079 +#ifdef USE_COMPRESSED
1088 diff -udprP mutt-1.5.16.orig/mbox.c mutt-1.5.16/mbox.c
1089 --- mutt-1.5.16.orig/mbox.c 2007-04-02 00:58:56.000000000 +0300
1090 +++ mutt-1.5.16/mbox.c 2007-06-12 14:22:35.000000000 +0300
1093 #include "mutt_curses.h"
1095 +#ifdef USE_COMPRESSED
1096 +#include "compress.h"
1099 #include <sys/stat.h>
1102 @@ -1026,6 +1030,12 @@ bail: /* Come here in case of disaster
1103 int mbox_close_mailbox (CONTEXT *ctx)
1105 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
1107 +#ifdef USE_COMPRESSED
1108 + if (ctx->compressinfo)
1109 + mutt_slow_close_compressed (ctx);
1112 mutt_unblock_signals ();
1113 mx_fastclose_mailbox (ctx);
1115 diff -udprP mutt-1.5.16.orig/mutt.h mutt-1.5.16/mutt.h
1116 --- mutt-1.5.16.orig/mutt.h 2007-04-11 06:14:01.000000000 +0300
1117 +++ mutt-1.5.16/mutt.h 2007-06-12 14:22:35.000000000 +0300
1118 @@ -160,6 +160,11 @@ typedef enum
1119 #define M_ACCOUNTHOOK (1<<9)
1120 #define M_REPLYHOOK (1<<10)
1121 #define M_SEND2HOOK (1<<11)
1122 +#ifdef USE_COMPRESSED
1123 +#define M_OPENHOOK (1<<12)
1124 +#define M_APPENDHOOK (1<<13)
1125 +#define M_CLOSEHOOK (1<<14)
1128 /* tree characters for linearize_tree and print_enriched_string */
1129 #define M_TREE_LLCORNER 1
1130 @@ -889,6 +894,11 @@ typedef struct _context
1132 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
1134 +#ifdef USE_COMPRESSED
1135 + void *compressinfo; /* compressed mbox module private data */
1136 + char *realpath; /* path to compressed mailbox */
1137 +#endif /* USE_COMPRESSED */
1139 unsigned int locked : 1; /* is the mailbox locked? */
1140 unsigned int changed : 1; /* mailbox has been modified */
1141 unsigned int readonly : 1; /* don't allow changes to the mailbox */
1142 diff -udprP mutt-1.5.16.orig/mx.c mutt-1.5.16/mx.c
1143 --- mutt-1.5.16.orig/mx.c 2007-04-03 20:41:14.000000000 +0300
1144 +++ mutt-1.5.16/mx.c 2007-06-12 14:22:35.000000000 +0300
1149 +#ifdef USE_COMPRESSED
1150 +#include "compress.h"
1156 @@ -450,6 +454,11 @@ int mx_get_magic (const char *path)
1160 +#ifdef USE_COMPRESSED
1161 + if (magic == 0 && mutt_can_read_compressed (path))
1162 + return M_COMPRESSED;
1168 @@ -489,6 +498,13 @@ static int mx_open_mailbox_append (CONTE
1172 +#ifdef USE_COMPRESSED
1173 + /* special case for appending to compressed folders -
1174 + * even if we can not open them for reading */
1175 + if (mutt_can_append_compressed (ctx->path))
1176 + mutt_open_append_compressed (ctx);
1182 @@ -653,6 +669,11 @@ CONTEXT *mx_open_mailbox (const char *pa
1184 ctx->magic = mx_get_magic (path);
1186 +#ifdef USE_COMPRESSED
1187 + if (ctx->magic == M_COMPRESSED)
1188 + mutt_open_read_compressed (ctx);
1192 mutt_error (_("%s is not a mailbox."), path);
1194 @@ -753,6 +774,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
1195 mutt_free_header (&ctx->hdrs[i]);
1198 +#ifdef USE_COMPRESSED
1199 + if (ctx->compressinfo)
1200 + mutt_fast_close_compressed (ctx);
1203 FREE (&ctx->pattern);
1204 if (ctx->limit_pattern)
1205 @@ -805,6 +830,12 @@ static int sync_mailbox (CONTEXT *ctx, i
1207 if (tmp && tmp->new == 0)
1208 mutt_update_mailbox (tmp);
1210 +#ifdef USE_COMPRESSED
1211 + if (rc == 0 && ctx->compressinfo)
1212 + return mutt_sync_compressed (ctx);
1218 @@ -1006,6 +1037,11 @@ int mx_close_mailbox (CONTEXT *ctx, int
1219 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1220 mx_unlink_empty (ctx->path);
1222 +#ifdef USE_COMPRESSED
1223 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1227 mx_fastclose_mailbox (ctx);
1230 @@ -1315,6 +1351,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
1234 +#ifdef USE_COMPRESSED
1235 + if (ctx->compressinfo)
1236 + return mutt_check_mailbox_compressed (ctx);
1241 if (ctx->locked) lock = 0;
1242 diff -udprP mutt-1.5.16.orig/mx.h mutt-1.5.16/mx.h
1243 --- mutt-1.5.16.orig/mx.h 2007-04-02 00:58:56.000000000 +0300
1244 +++ mutt-1.5.16/mx.h 2007-06-12 14:22:35.000000000 +0300
1245 @@ -40,6 +40,9 @@ enum
1249 +#ifdef USE_COMPRESSED
1254 WHERE short DefaultMagic INITVAL (M_MBOX);
1255 diff -udprP mutt-1.5.16.orig/po/POTFILES.in mutt-1.5.16/po/POTFILES.in
1256 --- mutt-1.5.16.orig/po/POTFILES.in 2007-04-02 00:58:57.000000000 +0300
1257 +++ mutt-1.5.16/po/POTFILES.in 2007-06-12 14:22:35.000000000 +0300
1258 @@ -8,6 +8,7 @@ charset.c
1266 diff -udprP mutt-1.5.16.orig/status.c mutt-1.5.16/status.c
1267 --- mutt-1.5.16.orig/status.c 2007-04-16 02:56:26.000000000 +0300
1268 +++ mutt-1.5.16/status.c 2007-06-12 14:22:35.000000000 +0300
1269 @@ -99,6 +99,14 @@ status_format_str (char *buf, size_t buf
1272 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1273 +#ifdef USE_COMPRESSED
1274 + if (Context && Context->compressinfo && Context->realpath)
1276 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1277 + mutt_pretty_mailbox (tmp);
1281 if (Context && Context->path)
1283 strfcpy (tmp, Context->path, sizeof (tmp));