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,8 @@ EXTRA_DIST = dotlock.man \
657 HTML_DOCFILES = manual.html index.html intro.html gettingstarted.html \
658 configuration.html mimesupport.html advancedusage.html \
659 - optionalfeatures.html tuning.html reference.html miscellany.html
660 + optionalfeatures.html tuning.html reference.html miscellany.html \
661 + compressed-folders.html
663 BUILT_DISTFILES = stamp-doc-xml stamp-doc-chunked manual.txt $(HTML_DOCFILES)
665 diff -udprP mutt-1.5.16.orig/doc/Makefile.in mutt-1.5.16/doc/Makefile.in
666 --- mutt-1.5.16.orig/doc/Makefile.in 2007-06-10 05:43:25.000000000 +0300
667 +++ mutt-1.5.16/doc/Makefile.in 2007-06-12 14:22:35.000000000 +0300
670 HTML_DOCFILES = manual.html index.html intro.html gettingstarted.html \
671 configuration.html mimesupport.html advancedusage.html \
672 - optionalfeatures.html tuning.html reference.html miscellany.html
673 + optionalfeatures.html tuning.html reference.html miscellany.html \
674 + compressed-folders.html
676 BUILT_DISTFILES = stamp-doc-xml stamp-doc-chunked manual.txt $(HTML_DOCFILES)
677 srcdir_DOCFILES = PGP-Notes.txt applying-patches.txt \
678 diff -udprP mutt-1.5.16.orig/doc/manual.xml.head mutt-1.5.16/doc/manual.xml.head
679 --- mutt-1.5.16.orig/doc/manual.xml.head 2007-04-04 08:37:13.000000000 +0300
680 +++ mutt-1.5.16/doc/manual.xml.head 2007-06-12 14:22:35.000000000 +0300
681 @@ -4083,6 +4083,24 @@ configuration option/command. See
682 <link linkend="fcc-save-hook">fcc-save-hook</link>
688 +<link linkend="open-hook">open-hook</link>
694 +<link linkend="close-hook">close-hook</link>
700 +<link linkend="append-hook">append-hook</link>
706 @@ -4910,6 +4928,254 @@ becomes an issue as mutt will silently f
710 +<chapter id="compressed-folders">
711 +<title>Compressed folders Support (OPTIONAL)</title>
714 +If Mutt was compiled with compressed folders support (by running the
715 +<emphasis>configure</emphasis> script with the
716 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
717 +stored in an arbitrary format, provided that the user has a script to
718 +convert from/to this format to one of the accepted.
722 +The most common use is to open compressed archived folders e.g. with
727 +In addition, the user can provide a script that gets a folder in an
728 +accepted format and appends its context to the folder in the
729 +user-defined format, which may be faster than converting the entire
730 +folder to the accepted format, appending to it and converting back to
731 +the user-defined format.
735 +There are three hooks defined
736 +(<link linkend="open-hook">open-hook</link>,
737 +<link linkend="close-hook">close-hook</link> and
738 +<link linkend="append-hook">append-hook</link>) which define commands
739 +to uncompress and compress a folder and to append messages to an
740 +existing compressed folder respectively.
747 +open-hook \\.gz$ "gzip -cd %f > %t"
748 +close-hook \\.gz$ "gzip -c %t > %f"
749 +append-hook \\.gz$ "gzip -c %t >> %f"
754 +You do not have to specify all of the commands. If you omit
755 +<link linkend="append-hook">append-hook</link>, the folder will be open
756 +and closed again each time you will add to it. If you omit
757 +<link linkend="close-hook">close-hook</link> (or give empty command),
758 +the folder will be open in the mode. If you specify
759 +<link linkend="append-hook">append-hook</link> though you'll be able to
760 +append to the folder.
764 +Note that Mutt will only try to use hooks if the file is not in one of
765 +the accepted formats. In particular, if the file is empty, mutt
766 +supposes it is not compressed. This is important because it allows the
767 +use of programs that do not have well defined extensions. Just use
768 +``.'' as a regexp. But this may be surprising if your compressing
769 +script produces empty files. In this situation, unset
770 +<link linkend="save-empty">$save_empty</link>, so that
771 +the compressed file will be removed if you delete all of the messages.
774 +<sect1 id="open-hook">
775 +<title>Open a compressed mailbox for reading</title>
778 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis>
782 +The <emphasis>command</emphasis> is the command that can be used for
783 +opening the folders whose names match <emphasis>regexp</emphasis>.
787 +The <emphasis>command</emphasis> string is the printf-like format
788 +string, and it should accept two parameters: %f, which is
789 +replaced with the (compressed) folder name, and %t which is
790 +replaced with the name of the temporary folder to which to write.
794 +%f and %t can be repeated any number of times in the
795 +command string, and all of the entries are replaced with the
796 +appropriate folder name. In addition, %% is replaced by
797 +%, as in printf, and any other %anything is left as is.
801 +The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis>
802 +remove the original compressed file. The <emphasis>command</emphasis>
803 +should return non-zero exit status if it fails, so mutt knows
811 +open-hook \\.gz$ "gzip -cd %f > %t"
816 +If the <emphasis>command</emphasis> is empty, this operation is
817 +disabled for this file type.
822 +<sect1 id="close-hook">
823 +<title>Write a compressed mailbox</title>
826 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis>
830 +This is used to close the folder that was open with the
831 +<link linkend="open-hook">open-hook</link> command after some changes
836 +The <emphasis>command</emphasis> string is the command that can be
837 +used for closing the folders whose names match <emphasis>regexp</emphasis>.
838 +It has the same format as in the <link linkend="open-hook">open-hook</link>
839 +command. Temporary folder in this case is the folder previously
840 +produced by the <link linkend="open-hook">open-hook</link> command.
844 +The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis>
845 +remove the decompressed file. The <emphasis>command</emphasis> should
846 +return non-zero exit status if it fails, so mutt knows something's
854 +close-hook \\.gz$ "gzip -c %t > %f"
859 +If the <emphasis>command</emphasis> is empty, this operation is
860 +disabled for this file type, and the file can only be open in the
865 +<link linkend="close-hook">close-hook</link> is not called when you
866 +exit from the folder if the folder was not changed.
871 +<sect1 id="append-hook">
872 +<title>Append a message to a compressed mailbox</title>
875 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis>
879 +This command is used for saving to an existing compressed folder.
880 +The <emphasis>command</emphasis> is the command that can be used for
881 +appending to the folders whose names match <emphasis>regexp</emphasis>.
882 +It has the same format as in the <link linkend="open-hook">open-hook</link>
883 +command. The temporary folder in this case contains the messages that
888 +The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis>
889 +remove the decompressed file. The <emphasis>command</emphasis> should
890 +return non-zero exit status if it fails, so mutt knows something's
898 +append-hook \\.gz$ "gzip -c %t >> %f"
903 +When <link linkend="append-hook">append-hook</link> is used, the folder
904 +is not opened, which saves time, but this means that we can not find
905 +out what the folder type is. Thus the default
906 +(<link linkend="mbox-type">$mbox_type</link>) type is
907 +always supposed (i.e. this is the format used for the temporary
912 +If the file does not exist when you save to it,
913 +<link linkend="close-hook">close-hook</link> is called, and not
914 +<link linkend="append-hook">append-hook</link>.
915 +<link linkend="append-hook">append-hook</link> is only for appending
916 +to existing folders.
920 +If the <emphasis>command</emphasis> is empty, this operation is
921 +disabled for this file type. In this case, the folder will be open and
922 +closed again (using <link linkend="open-hook">open-hook</link> and
923 +<link linkend="close-hook">close-hook</link> respectively) each time
930 +<title>Encrypted folders</title>
933 +The compressed folders support can also be used to handle encrypted
934 +folders. If you want to encrypt a folder with PGP, you may want to use
935 +the following hooks:
938 +open-hook \\.pgp$ "pgp -f < %f > %t"
939 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
944 +Please note, that PGP does not support appending to an encrypted
945 +folder, so there is no append-hook defined.
949 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
950 +decrypted in the /tmp directory, where it can be read by your system
951 +administrator. So think about the security aspects of this.
958 <chapter id="mimesupport">
959 <title>Mutt's MIME Support</title>
961 @@ -6056,6 +6322,12 @@ The following are the commands understoo
965 +<literal><link linkend="append-hook">append-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>command</emphasis>
971 <literal><link linkend="auto-view">auto_view</link></literal> <emphasis>mimetype</emphasis> [ <emphasis>mimetype</emphasis> ... ]
974 @@ -6086,6 +6358,12 @@ The following are the commands understoo
978 +<literal><link linkend="close-hook">close-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>command</emphasis>
984 <literal><link linkend="color">color</link></literal> <emphasis>object</emphasis> <emphasis>foreground</emphasis> <emphasis>background</emphasis> [ <emphasis>regexp</emphasis> ]
987 @@ -6218,6 +6496,12 @@ The following are the commands understoo
991 +<literal><link linkend="open-hook">open-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>command</emphasis>
997 <literal><link linkend="crypt-hook">crypt-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>key-id</emphasis>
1000 diff -udprP mutt-1.5.16.orig/doc/muttrc.man.head mutt-1.5.16/doc/muttrc.man.head
1001 --- mutt-1.5.16.orig/doc/muttrc.man.head 2007-04-02 00:58:55.000000000 +0300
1002 +++ mutt-1.5.16/doc/muttrc.man.head 2007-06-12 14:22:35.000000000 +0300
1003 @@ -345,6 +345,24 @@ specify the ID of the public key to be u
1004 to a certain recipient. The meaning of "key ID" is to be taken
1005 broadly: This can be a different e-mail address, a numerical key ID,
1006 or even just an arbitrary search string.
1009 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
1010 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
1011 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
1014 +These commands provide a way to handle compressed folders. The given
1015 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
1016 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
1017 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
1018 +compressed mail to a compressed folder (\fBappend-hook\fP). The
1019 +\fIcommand\fP string is the
1021 +like format string, and it should accept two parameters: \fB%f\fP,
1022 +which is replaced with the (compressed) folder name, and \fB%t\fP
1023 +which is replaced with the name of the temporary folder to which to
1026 \fBpush\fP \fIstring\fP
1027 This command adds the named \fIstring\fP to the keyboard buffer.
1028 diff -udprP mutt-1.5.16.orig/hook.c mutt-1.5.16/hook.c
1029 --- mutt-1.5.16.orig/hook.c 2007-04-08 02:36:55.000000000 +0300
1030 +++ mutt-1.5.16/hook.c 2007-06-12 14:22:35.000000000 +0300
1032 #include "mailbox.h"
1033 #include "mutt_crypt.h"
1035 +#ifdef USE_COMPRESSED
1036 +#include "compress.h"
1042 @@ -92,6 +96,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
1043 memset (&pattern, 0, sizeof (pattern));
1044 pattern.data = safe_strdup (path);
1046 +#ifdef USE_COMPRESSED
1047 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
1049 + if (mutt_test_compress_command (command.data))
1051 + strfcpy (err->data, _("bad formatted command string"), err->dsize);
1056 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
1057 && (!WithCrypto || !(data & M_CRYPTHOOK))
1059 diff -udprP mutt-1.5.16.orig/init.h mutt-1.5.16/init.h
1060 --- mutt-1.5.16.orig/init.h 2007-06-10 05:29:21.000000000 +0300
1061 +++ mutt-1.5.16/init.h 2007-06-12 14:22:35.000000000 +0300
1062 @@ -3129,6 +3129,11 @@ struct command_t Commands[] = {
1063 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
1064 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
1065 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
1066 +#ifdef USE_COMPRESSED
1067 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
1068 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
1069 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
1071 { "group", parse_group, 0 },
1072 { "ungroup", parse_ungroup, 0 },
1073 { "hdr_order", parse_list, UL &HeaderOrderList },
1074 diff -udprP mutt-1.5.16.orig/main.c mutt-1.5.16/main.c
1075 --- mutt-1.5.16.orig/main.c 2007-04-10 23:53:08.000000000 +0300
1076 +++ mutt-1.5.16/main.c 2007-06-12 14:22:35.000000000 +0300
1077 @@ -310,6 +310,12 @@ static void show_version (void)
1081 +#ifdef USE_COMPRESSED
1090 diff -udprP mutt-1.5.16.orig/mbox.c mutt-1.5.16/mbox.c
1091 --- mutt-1.5.16.orig/mbox.c 2007-04-02 00:58:56.000000000 +0300
1092 +++ mutt-1.5.16/mbox.c 2007-06-12 14:22:35.000000000 +0300
1095 #include "mutt_curses.h"
1097 +#ifdef USE_COMPRESSED
1098 +#include "compress.h"
1101 #include <sys/stat.h>
1104 @@ -1026,6 +1030,12 @@ bail: /* Come here in case of disaster
1105 int mbox_close_mailbox (CONTEXT *ctx)
1107 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
1109 +#ifdef USE_COMPRESSED
1110 + if (ctx->compressinfo)
1111 + mutt_slow_close_compressed (ctx);
1114 mutt_unblock_signals ();
1115 mx_fastclose_mailbox (ctx);
1117 diff -udprP mutt-1.5.16.orig/mutt.h mutt-1.5.16/mutt.h
1118 --- mutt-1.5.16.orig/mutt.h 2007-04-11 06:14:01.000000000 +0300
1119 +++ mutt-1.5.16/mutt.h 2007-06-12 14:22:35.000000000 +0300
1120 @@ -160,6 +160,11 @@ typedef enum
1121 #define M_ACCOUNTHOOK (1<<9)
1122 #define M_REPLYHOOK (1<<10)
1123 #define M_SEND2HOOK (1<<11)
1124 +#ifdef USE_COMPRESSED
1125 +#define M_OPENHOOK (1<<12)
1126 +#define M_APPENDHOOK (1<<13)
1127 +#define M_CLOSEHOOK (1<<14)
1130 /* tree characters for linearize_tree and print_enriched_string */
1131 #define M_TREE_LLCORNER 1
1132 @@ -889,6 +894,11 @@ typedef struct _context
1134 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
1136 +#ifdef USE_COMPRESSED
1137 + void *compressinfo; /* compressed mbox module private data */
1138 + char *realpath; /* path to compressed mailbox */
1139 +#endif /* USE_COMPRESSED */
1141 unsigned int locked : 1; /* is the mailbox locked? */
1142 unsigned int changed : 1; /* mailbox has been modified */
1143 unsigned int readonly : 1; /* don't allow changes to the mailbox */
1144 diff -udprP mutt-1.5.16.orig/mx.c mutt-1.5.16/mx.c
1145 --- mutt-1.5.16.orig/mx.c 2007-04-03 20:41:14.000000000 +0300
1146 +++ mutt-1.5.16/mx.c 2007-06-12 14:22:35.000000000 +0300
1151 +#ifdef USE_COMPRESSED
1152 +#include "compress.h"
1158 @@ -450,6 +454,11 @@ int mx_get_magic (const char *path)
1162 +#ifdef USE_COMPRESSED
1163 + if (magic == 0 && mutt_can_read_compressed (path))
1164 + return M_COMPRESSED;
1170 @@ -489,6 +498,13 @@ static int mx_open_mailbox_append (CONTE
1174 +#ifdef USE_COMPRESSED
1175 + /* special case for appending to compressed folders -
1176 + * even if we can not open them for reading */
1177 + if (mutt_can_append_compressed (ctx->path))
1178 + mutt_open_append_compressed (ctx);
1184 @@ -653,6 +669,11 @@ CONTEXT *mx_open_mailbox (const char *pa
1186 ctx->magic = mx_get_magic (path);
1188 +#ifdef USE_COMPRESSED
1189 + if (ctx->magic == M_COMPRESSED)
1190 + mutt_open_read_compressed (ctx);
1194 mutt_error (_("%s is not a mailbox."), path);
1196 @@ -753,6 +774,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
1197 mutt_free_header (&ctx->hdrs[i]);
1200 +#ifdef USE_COMPRESSED
1201 + if (ctx->compressinfo)
1202 + mutt_fast_close_compressed (ctx);
1205 FREE (&ctx->pattern);
1206 if (ctx->limit_pattern)
1207 @@ -805,6 +830,12 @@ static int sync_mailbox (CONTEXT *ctx, i
1209 if (tmp && tmp->new == 0)
1210 mutt_update_mailbox (tmp);
1212 +#ifdef USE_COMPRESSED
1213 + if (rc == 0 && ctx->compressinfo)
1214 + return mutt_sync_compressed (ctx);
1220 @@ -1006,6 +1037,11 @@ int mx_close_mailbox (CONTEXT *ctx, int
1221 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1222 mx_unlink_empty (ctx->path);
1224 +#ifdef USE_COMPRESSED
1225 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1229 mx_fastclose_mailbox (ctx);
1232 @@ -1315,6 +1351,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
1236 +#ifdef USE_COMPRESSED
1237 + if (ctx->compressinfo)
1238 + return mutt_check_mailbox_compressed (ctx);
1243 if (ctx->locked) lock = 0;
1244 diff -udprP mutt-1.5.16.orig/mx.h mutt-1.5.16/mx.h
1245 --- mutt-1.5.16.orig/mx.h 2007-04-02 00:58:56.000000000 +0300
1246 +++ mutt-1.5.16/mx.h 2007-06-12 14:22:35.000000000 +0300
1247 @@ -40,6 +40,9 @@ enum
1251 +#ifdef USE_COMPRESSED
1256 WHERE short DefaultMagic INITVAL (M_MBOX);
1257 diff -udprP mutt-1.5.16.orig/po/POTFILES.in mutt-1.5.16/po/POTFILES.in
1258 --- mutt-1.5.16.orig/po/POTFILES.in 2007-04-02 00:58:57.000000000 +0300
1259 +++ mutt-1.5.16/po/POTFILES.in 2007-06-12 14:22:35.000000000 +0300
1260 @@ -8,6 +8,7 @@ charset.c
1268 diff -udprP mutt-1.5.16.orig/status.c mutt-1.5.16/status.c
1269 --- mutt-1.5.16.orig/status.c 2007-04-16 02:56:26.000000000 +0300
1270 +++ mutt-1.5.16/status.c 2007-06-12 14:22:35.000000000 +0300
1271 @@ -99,6 +99,14 @@ status_format_str (char *buf, size_t buf
1274 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1275 +#ifdef USE_COMPRESSED
1276 + if (Context && Context->compressinfo && Context->realpath)
1278 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1279 + mutt_pretty_mailbox (tmp);
1283 if (Context && Context->path)
1285 strfcpy (tmp, Context->path, sizeof (tmp));