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 --- mutt-1.5.18.orig/doc/Muttrc.head 2007-06-06 19:02:56.000000000 +0300
35 +++ mutt-1.5.18/doc/Muttrc.head 2007-06-12 14:22:35.000000000 +0300
36 @@ -24,6 +24,11 @@ macro generic,pager <F1> "<shell-escape>
37 macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
40 +# Use folders which match on \\.gz$ as gzipped folders:
41 +# open-hook \\.gz$ "gzip -cd %f > %t"
42 +# close-hook \\.gz$ "gzip -c %t > %f"
43 +# append-hook \\.gz$ "gzip -c %t >> %f"
45 # If Mutt is unable to determine your site's domain name correctly, you can
46 # set the default here.
48 diff -udprP mutt-1.5.16.orig/PATCHES mutt-1.5.16/PATCHES
49 --- mutt-1.5.16.orig/PATCHES 2007-04-30 05:07:48.000000000 +0300
50 +++ mutt-1.5.16/PATCHES 2007-06-12 14:22:35.000000000 +0300
53 diff -udprP mutt-1.5.16.orig/compress.c mutt-1.5.16/compress.c
54 --- mutt-1.5.16.orig/compress.c 1970-01-01 03:00:00.000000000 +0300
55 +++ mutt-1.5.16/compress.c 2007-06-12 14:22:35.000000000 +0300
58 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
60 + * This program is free software; you can redistribute it and/or modify
61 + * it under the terms of the GNU General Public License as published by
62 + * the Free Software Foundation; either version 2 of the License, or
63 + * (at your option) any later version.
65 + * This program is distributed in the hope that it will be useful,
66 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
67 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
68 + * GNU General Public License for more details.
70 + * You should have received a copy of the GNU General Public License
71 + * along with this program; if not, write to the Free Software
72 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
81 +#ifdef USE_COMPRESSED
85 +#include "mutt_curses.h"
90 +#include <sys/stat.h>
94 + const char *close; /* close-hook command */
95 + const char *open; /* open-hook command */
96 + const char *append; /* append-hook command */
97 + off_t size; /* size of real folder */
100 +char echo_cmd[HUGE_STRING];
103 + * ctx - context to lock
104 + * excl - exclusive lock?
105 + * retry - should retry if unable to lock?
107 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
111 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
113 + else if (retry && !excl)
122 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
128 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
133 +static int is_new (const char *path)
135 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
138 +static const char* find_compress_hook (int type, const char *path)
140 + const char* c = mutt_find_hook (type, path);
141 + return (!c || !*c) ? NULL : c;
144 +int mutt_can_read_compressed (const char *path)
146 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
149 +/* if the file is new, we really do not append, but create, and so use
150 + * close-hook, and not append-hook
152 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
154 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
155 + return (is_new (path)) ? ci->close : ci->append;
158 +int mutt_can_append_compressed (const char *path)
163 + return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
165 + magic = mx_get_magic (path);
167 + if (magic != 0 && magic != M_COMPRESSED)
170 + return (find_compress_hook (M_APPENDHOOK, path)
171 + || (find_compress_hook (M_OPENHOOK, path)
172 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
175 +/* open a compressed mailbox */
176 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
180 + /* Now lets uncompress this thing */
181 + ci = safe_malloc (sizeof (COMPRESS_INFO));
182 + ctx->compressinfo = (void*) ci;
183 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
184 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
185 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
189 +static void set_path (CONTEXT* ctx)
191 + char tmppath[_POSIX_PATH_MAX];
193 + /* Setup the right paths */
194 + ctx->realpath = ctx->path;
196 + /* Uncompress to /tmp */
197 + mutt_mktemp (tmppath);
198 + ctx->path = safe_malloc (strlen (tmppath) + 1);
199 + strcpy (ctx->path, tmppath);
202 +static int get_size (const char* path)
205 + if (stat (path, &sb) != 0)
207 + return (sb.st_size);
210 +static void store_size (CONTEXT* ctx)
212 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
213 + ci->size = get_size (ctx->realpath);
217 +compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
218 + const char *fmt, const char *ifstring,
219 + const char *elsestring, unsigned long data,
222 + char tmp[SHORT_STRING];
224 + CONTEXT *ctx = (CONTEXT *) data;
228 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
229 + snprintf (dest, destlen, tmp, ctx->realpath);
232 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
233 + snprintf (dest, destlen, tmp, ctx->path);
239 +/* check that the command has both %f and %t
240 + * 0 means OK, -1 means error
242 +int mutt_test_compress_command (const char* cmd)
244 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
247 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
249 + char expanded[_POSIX_PATH_MAX];
250 + mutt_FormatString (expanded, sizeof (expanded), 0, cmd, compresshook_format_str,
251 + (unsigned long) ctx, 0);
252 + return safe_strdup (expanded);
255 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
257 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
258 + if (ci->size != get_size (ctx->realpath))
260 + FREE (&ctx->compressinfo);
261 + FREE (&ctx->realpath);
262 + mutt_error _("Mailbox was corrupted!");
268 +int mutt_open_read_compressed (CONTEXT *ctx)
274 + COMPRESS_INFO *ci = set_compress_info (ctx);
277 + FREE (ctx->compressinfo);
280 + if (!ci->close || access (ctx->path, W_OK) != 0)
287 + mutt_message (_("Decompressing %s..."), ctx->realpath);
289 + cmd = get_compression_cmd (ci->open, ctx);
292 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
294 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
296 + mutt_perror (ctx->realpath);
300 + mutt_block_signals ();
301 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
304 + mutt_unblock_signals ();
305 + mutt_error _("Unable to lock mailbox!");
312 + sprintf(echo_cmd,_("echo Decompressing %s..."),ctx->realpath);
313 + mutt_system(echo_cmd);
314 + rc = mutt_system (cmd);
315 + mbox_unlock_compressed (ctx, fp);
316 + mutt_unblock_signals ();
321 + mutt_any_key_to_continue (NULL);
323 + FREE (ctx->compressinfo);
324 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
330 + if (mutt_check_mailbox_compressed (ctx))
333 + ctx->magic = mx_get_magic (ctx->path);
338 +void restore_path (CONTEXT* ctx)
341 + ctx->path = ctx->realpath;
344 +/* remove the temporary mailbox */
345 +void remove_file (CONTEXT* ctx)
347 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
348 + remove (ctx->path);
351 +int mutt_open_append_compressed (CONTEXT *ctx)
354 + COMPRESS_INFO *ci = set_compress_info (ctx);
356 + if (!get_append_command (ctx->path, ctx))
358 + if (ci->open && ci->close)
359 + return (mutt_open_read_compressed (ctx));
362 + FREE (&ctx->compressinfo);
368 + ctx->magic = DefaultMagic;
370 + if (!is_new (ctx->realpath))
371 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
372 + if ((fh = fopen (ctx->path, "w")))
374 + /* No error checking - the parent function will catch it */
379 +/* close a compressed mailbox */
380 +void mutt_fast_close_compressed (CONTEXT *ctx)
382 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
385 + if (ctx->compressinfo)
390 + /* if the folder was removed, remove the gzipped folder too */
391 + if (access (ctx->path, F_OK) != 0 && ! option (OPTSAVEEMPTY))
392 + remove (ctx->realpath);
396 + restore_path (ctx);
397 + FREE (&ctx->compressinfo);
401 +/* return 0 on success, -1 on failure */
402 +int mutt_sync_compressed (CONTEXT* ctx)
407 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
410 + mutt_message (_("Compressing %s..."), ctx->realpath);
412 + cmd = get_compression_cmd (ci->close, ctx);
416 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
418 + mutt_perror (ctx->realpath);
422 + mutt_block_signals ();
423 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
426 + mutt_unblock_signals ();
427 + mutt_error _("Unable to lock mailbox!");
435 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
439 + sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath);
440 + mutt_system(echo_cmd);
441 + if (mutt_system (cmd))
443 + mutt_any_key_to_continue (NULL);
444 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
448 + mbox_unlock_compressed (ctx, fp);
449 + mutt_unblock_signals ();
459 +int mutt_slow_close_compressed (CONTEXT *ctx)
462 + const char *append;
464 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
466 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
470 + && ((append = get_append_command (ctx->realpath, ctx))
471 + || (append = ci->close))))
472 + { /* if we can not or should not append,
473 + * we only have to remove the compressed info, because sync was already
476 + mutt_fast_close_compressed (ctx);
486 + if (append == ci->close)
487 + mutt_message (_("Compressing %s..."), ctx->realpath);
489 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
492 + cmd = get_compression_cmd (append, ctx);
496 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
498 + mutt_perror (ctx->realpath);
502 + mutt_block_signals ();
503 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
506 + mutt_unblock_signals ();
507 + mutt_error _("Unable to lock mailbox!");
512 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
517 + if (append == ci->close)
518 + sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath);
520 + sprintf(echo_cmd,_("echo Compressed-appending to %s..."), ctx->realpath);
521 + mutt_system(echo_cmd);
523 + if (mutt_system (cmd))
525 + mutt_any_key_to_continue (NULL);
526 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
529 + mbox_unlock_compressed (ctx, fp);
530 + mutt_unblock_signals ();
535 + mbox_unlock_compressed (ctx, fp);
536 + mutt_unblock_signals ();
539 + restore_path (ctx);
541 + FREE (&ctx->compressinfo);
546 +#endif /* USE_COMPRESSED */
547 diff -udprP mutt-1.5.16.orig/compress.h mutt-1.5.16/compress.h
548 --- mutt-1.5.16.orig/compress.h 1970-01-01 03:00:00.000000000 +0300
549 +++ mutt-1.5.16/compress.h 2007-06-12 14:22:35.000000000 +0300
552 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
554 + * This program is free software; you can redistribute it and/or modify
555 + * it under the terms of the GNU General Public License as published by
556 + * the Free Software Foundation; either version 2 of the License, or
557 + * (at your option) any later version.
559 + * This program is distributed in the hope that it will be useful,
560 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
561 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
562 + * GNU General Public License for more details.
564 + * You should have received a copy of the GNU General Public License
565 + * along with this program; if not, write to the Free Software
566 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
569 +int mutt_can_read_compressed (const char *);
570 +int mutt_can_append_compressed (const char *);
571 +int mutt_open_read_compressed (CONTEXT *);
572 +int mutt_open_append_compressed (CONTEXT *);
573 +int mutt_slow_close_compressed (CONTEXT *);
574 +int mutt_sync_compressed (CONTEXT *);
575 +int mutt_test_compress_command (const char *);
576 +int mutt_check_mailbox_compressed (CONTEXT *);
577 +void mutt_fast_close_compressed (CONTEXT *);
578 diff -udprP mutt-1.5.16.orig/config.h.in mutt-1.5.16/config.h.in
579 --- mutt-1.5.16.orig/config.h.in 2007-06-10 05:44:57.000000000 +0300
580 +++ mutt-1.5.16/config.h.in 2007-06-12 14:22:35.000000000 +0300
583 /* Define to enable Sun mailtool attachments support. */
584 #undef SUN_ATTACHMENT
586 +/* The compressed mailboxes support */
587 +#undef USE_COMPRESSED
589 /* Define to use dotlocking for mailboxes. */
591 diff -udprP mutt-1.5.16.orig/configure mutt-1.5.16/configure
592 --- mutt-1.5.16.orig/configure 2007-06-10 05:43:29.000000000 +0300
593 +++ mutt-1.5.16/configure 2007-06-12 14:22:35.000000000 +0300
594 @@ -1350,6 +1350,7 @@ Optional Features:
595 --disable-warnings Turn off compiler warnings (not recommended)
596 --enable-nfs-fix Work around an NFS with broken attributes caching
597 --enable-mailtool Enable Sun mailtool attachments support
598 + --enable-compressed Enable compressed folders support
599 --enable-locales-fix The result of isprint() is unreliable
600 --enable-exact-address Enable regeneration of email addresses
601 --enable-hcache Enable header caching
602 @@ -14414,6 +14415,18 @@ echo "${ECHO_T}$mutt_cv_regex_broken" >&
607 +# Check whether --enable-compressed or --disable-compressed was given.
608 +if test "${enable_compressed+set}" = set; then
609 + enableval="$enable_compressed"
610 + if test x$enableval = xyes; then
611 + cat >> confdefs.h <<\EOF
612 +#define USE_COMPRESSED 1
618 if test $mutt_cv_regex = yes; then
620 cat >>confdefs.h <<\_ACEOF
621 diff -udprP mutt-1.5.16.orig/configure.ac mutt-1.5.16/configure.ac
622 --- mutt-1.5.16.orig/configure.ac 2007-06-04 07:20:01.000000000 +0300
623 +++ mutt-1.5.16/configure.ac 2007-06-12 14:22:35.000000000 +0300
624 @@ -780,6 +780,11 @@ AC_ARG_ENABLE(mailtool, AC_HELP_STRING([
625 AC_DEFINE(SUN_ATTACHMENT,1,[ Define to enable Sun mailtool attachments support. ])
628 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
629 + [if test x$enableval = xyes; then
630 + AC_DEFINE(USE_COMPRESSED,1,[ Define to enable compressed folders support. ])
633 AC_ARG_ENABLE(locales-fix, AC_HELP_STRING([--enable-locales-fix], [The result of isprint() is unreliable]),
634 [if test x$enableval = xyes; then
635 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
636 diff -udprP mutt-1.5.16.orig/curs_main.c mutt-1.5.16/curs_main.c
637 --- mutt-1.5.16.orig/curs_main.c 2007-05-20 10:30:00.000000000 +0300
638 +++ mutt-1.5.16/curs_main.c 2007-06-12 14:22:35.000000000 +0300
639 @@ -1111,6 +1111,11 @@ int mutt_index_menu (void)
643 +#ifdef USE_COMPRESSED
644 + if (Context->compressinfo && Context->realpath)
645 + mutt_str_replace (&LastFolder, Context->realpath);
648 mutt_str_replace (&LastFolder, Context->path);
649 oldcount = Context ? Context->msgcount : 0;
651 diff -udprP mutt-1.5.16.orig/doc/Makefile.am mutt-1.5.16/doc/Makefile.am
652 --- mutt-1.5.16.orig/doc/Makefile.am 2007-04-13 19:43:45.000000000 +0300
653 +++ mutt-1.5.16/doc/Makefile.am 2007-06-12 14:22:35.000000000 +0300
654 @@ -27,7 +27,8 @@ EXTRA_DIST = dotlock.man \
656 HTML_DOCFILES = manual.html index.html intro.html gettingstarted.html \
657 configuration.html mimesupport.html advancedusage.html \
658 - optionalfeatures.html tuning.html reference.html miscellany.html
659 + optionalfeatures.html tuning.html reference.html miscellany.html \
660 + 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
669 HTML_DOCFILES = manual.html index.html intro.html gettingstarted.html \
670 configuration.html mimesupport.html advancedusage.html \
671 - optionalfeatures.html tuning.html reference.html miscellany.html
672 + optionalfeatures.html tuning.html reference.html miscellany.html \
673 + compressed-folders.html
675 BUILT_DISTFILES = stamp-doc-xml stamp-doc-chunked manual.txt $(HTML_DOCFILES)
676 srcdir_DOCFILES = PGP-Notes.txt applying-patches.txt \
677 diff -udprP mutt-1.5.16.orig/doc/manual.xml.head mutt-1.5.16/doc/manual.xml.head
678 --- mutt-1.5.16.orig/doc/manual.xml.head 2007-04-04 08:37:13.000000000 +0300
679 +++ mutt-1.5.16/doc/manual.xml.head 2007-06-12 14:22:35.000000000 +0300
680 @@ -4083,6 +4083,24 @@ configuration option/command. See
681 <link linkend="fcc-save-hook">fcc-save-hook</link>
687 +<link linkend="open-hook">open-hook</link>
693 +<link linkend="close-hook">close-hook</link>
699 +<link linkend="append-hook">append-hook</link>
705 @@ -4910,6 +4928,254 @@ becomes an issue as mutt will silently f
709 +<chapter id="compressed-folders">
710 +<title>Compressed folders Support (OPTIONAL)</title>
713 +If Mutt was compiled with compressed folders support (by running the
714 +<emphasis>configure</emphasis> script with the
715 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
716 +stored in an arbitrary format, provided that the user has a script to
717 +convert from/to this format to one of the accepted.
721 +The most common use is to open compressed archived folders e.g. with
726 +In addition, the user can provide a script that gets a folder in an
727 +accepted format and appends its context to the folder in the
728 +user-defined format, which may be faster than converting the entire
729 +folder to the accepted format, appending to it and converting back to
730 +the user-defined format.
734 +There are three hooks defined
735 +(<link linkend="open-hook">open-hook</link>,
736 +<link linkend="close-hook">close-hook</link> and
737 +<link linkend="append-hook">append-hook</link>) which define commands
738 +to uncompress and compress a folder and to append messages to an
739 +existing compressed folder respectively.
746 +open-hook \\.gz$ "gzip -cd %f > %t"
747 +close-hook \\.gz$ "gzip -c %t > %f"
748 +append-hook \\.gz$ "gzip -c %t >> %f"
753 +You do not have to specify all of the commands. If you omit
754 +<link linkend="append-hook">append-hook</link>, the folder will be open
755 +and closed again each time you will add to it. If you omit
756 +<link linkend="close-hook">close-hook</link> (or give empty command),
757 +the folder will be open in the mode. If you specify
758 +<link linkend="append-hook">append-hook</link> though you'll be able to
759 +append to the folder.
763 +Note that Mutt will only try to use hooks if the file is not in one of
764 +the accepted formats. In particular, if the file is empty, mutt
765 +supposes it is not compressed. This is important because it allows the
766 +use of programs that do not have well defined extensions. Just use
767 +``.'' as a regexp. But this may be surprising if your compressing
768 +script produces empty files. In this situation, unset
769 +<link linkend="save-empty">$save_empty</link>, so that
770 +the compressed file will be removed if you delete all of the messages.
773 +<sect1 id="open-hook">
774 +<title>Open a compressed mailbox for reading</title>
777 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis>
781 +The <emphasis>command</emphasis> is the command that can be used for
782 +opening the folders whose names match <emphasis>regexp</emphasis>.
786 +The <emphasis>command</emphasis> string is the printf-like format
787 +string, and it should accept two parameters: %f, which is
788 +replaced with the (compressed) folder name, and %t which is
789 +replaced with the name of the temporary folder to which to write.
793 +%f and %t can be repeated any number of times in the
794 +command string, and all of the entries are replaced with the
795 +appropriate folder name. In addition, %% is replaced by
796 +%, as in printf, and any other %anything is left as is.
800 +The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis>
801 +remove the original compressed file. The <emphasis>command</emphasis>
802 +should return non-zero exit status if it fails, so mutt knows
810 +open-hook \\.gz$ "gzip -cd %f > %t"
815 +If the <emphasis>command</emphasis> is empty, this operation is
816 +disabled for this file type.
821 +<sect1 id="close-hook">
822 +<title>Write a compressed mailbox</title>
825 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis>
829 +This is used to close the folder that was open with the
830 +<link linkend="open-hook">open-hook</link> command after some changes
835 +The <emphasis>command</emphasis> string is the command that can be
836 +used for closing the folders whose names match <emphasis>regexp</emphasis>.
837 +It has the same format as in the <link linkend="open-hook">open-hook</link>
838 +command. Temporary folder in this case is the folder previously
839 +produced by the <link linkend="open-hook">open-hook</link> command.
843 +The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis>
844 +remove the decompressed file. The <emphasis>command</emphasis> should
845 +return non-zero exit status if it fails, so mutt knows something's
853 +close-hook \\.gz$ "gzip -c %t > %f"
858 +If the <emphasis>command</emphasis> is empty, this operation is
859 +disabled for this file type, and the file can only be open in the
864 +<link linkend="close-hook">close-hook</link> is not called when you
865 +exit from the folder if the folder was not changed.
870 +<sect1 id="append-hook">
871 +<title>Append a message to a compressed mailbox</title>
874 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis>
878 +This command is used for saving to an existing compressed folder.
879 +The <emphasis>command</emphasis> is the command that can be used for
880 +appending to the folders whose names match <emphasis>regexp</emphasis>.
881 +It has the same format as in the <link linkend="open-hook">open-hook</link>
882 +command. The temporary folder in this case contains the messages that
887 +The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis>
888 +remove the decompressed file. The <emphasis>command</emphasis> should
889 +return non-zero exit status if it fails, so mutt knows something's
897 +append-hook \\.gz$ "gzip -c %t >> %f"
902 +When <link linkend="append-hook">append-hook</link> is used, the folder
903 +is not opened, which saves time, but this means that we can not find
904 +out what the folder type is. Thus the default
905 +(<link linkend="mbox-type">$mbox_type</link>) type is
906 +always supposed (i.e. this is the format used for the temporary
911 +If the file does not exist when you save to it,
912 +<link linkend="close-hook">close-hook</link> is called, and not
913 +<link linkend="append-hook">append-hook</link>.
914 +<link linkend="append-hook">append-hook</link> is only for appending
915 +to existing folders.
919 +If the <emphasis>command</emphasis> is empty, this operation is
920 +disabled for this file type. In this case, the folder will be open and
921 +closed again (using <link linkend="open-hook">open-hook</link> and
922 +<link linkend="close-hook">close-hook</link> respectively) each time
929 +<title>Encrypted folders</title>
932 +The compressed folders support can also be used to handle encrypted
933 +folders. If you want to encrypt a folder with PGP, you may want to use
934 +the following hooks:
937 +open-hook \\.pgp$ "pgp -f < %f > %t"
938 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
943 +Please note, that PGP does not support appending to an encrypted
944 +folder, so there is no append-hook defined.
948 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
949 +decrypted in the /tmp directory, where it can be read by your system
950 +administrator. So think about the security aspects of this.
957 <chapter id="mimesupport">
958 <title>Mutt's MIME Support</title>
960 @@ -6056,6 +6322,12 @@ The following are the commands understoo
964 +<literal><link linkend="append-hook">append-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>command</emphasis>
970 <literal><link linkend="auto-view">auto_view</link></literal> <emphasis>mimetype</emphasis> [ <emphasis>mimetype</emphasis> ... ]
973 @@ -6086,6 +6358,12 @@ The following are the commands understoo
977 +<literal><link linkend="close-hook">close-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>command</emphasis>
983 <literal><link linkend="color">color</link></literal> <emphasis>object</emphasis> <emphasis>foreground</emphasis> <emphasis>background</emphasis> [ <emphasis>regexp</emphasis> ]
986 @@ -6218,6 +6496,12 @@ The following are the commands understoo
990 +<literal><link linkend="open-hook">open-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>command</emphasis>
996 <literal><link linkend="crypt-hook">crypt-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>key-id</emphasis>
999 diff -udprP mutt-1.5.16.orig/doc/muttrc.man.head mutt-1.5.16/doc/muttrc.man.head
1000 --- mutt-1.5.16.orig/doc/muttrc.man.head 2007-04-02 00:58:55.000000000 +0300
1001 +++ mutt-1.5.16/doc/muttrc.man.head 2007-06-12 14:22:35.000000000 +0300
1002 @@ -345,6 +345,24 @@ specify the ID of the public key to be u
1003 to a certain recipient. The meaning of "key ID" is to be taken
1004 broadly: This can be a different e-mail address, a numerical key ID,
1005 or even just an arbitrary search string.
1008 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
1009 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
1010 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
1013 +These commands provide a way to handle compressed folders. The given
1014 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
1015 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
1016 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
1017 +compressed mail to a compressed folder (\fBappend-hook\fP). The
1018 +\fIcommand\fP string is the
1020 +like format string, and it should accept two parameters: \fB%f\fP,
1021 +which is replaced with the (compressed) folder name, and \fB%t\fP
1022 +which is replaced with the name of the temporary folder to which to
1025 \fBpush\fP \fIstring\fP
1026 This command adds the named \fIstring\fP to the keyboard buffer.
1027 diff -udprP mutt-1.5.16.orig/hook.c mutt-1.5.16/hook.c
1028 --- mutt-1.5.16.orig/hook.c 2007-04-08 02:36:55.000000000 +0300
1029 +++ mutt-1.5.16/hook.c 2007-06-12 14:22:35.000000000 +0300
1031 #include "mailbox.h"
1032 #include "mutt_crypt.h"
1034 +#ifdef USE_COMPRESSED
1035 +#include "compress.h"
1041 @@ -92,6 +96,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
1042 memset (&pattern, 0, sizeof (pattern));
1043 pattern.data = safe_strdup (path);
1045 +#ifdef USE_COMPRESSED
1046 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
1048 + if (mutt_test_compress_command (command.data))
1050 + strfcpy (err->data, _("bad formatted command string"), err->dsize);
1055 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
1056 && (!WithCrypto || !(data & M_CRYPTHOOK))
1058 diff -udprP mutt-1.5.16.orig/init.h mutt-1.5.16/init.h
1059 --- mutt-1.5.16.orig/init.h 2007-06-10 05:29:21.000000000 +0300
1060 +++ mutt-1.5.16/init.h 2007-06-12 14:22:35.000000000 +0300
1061 @@ -3129,6 +3129,11 @@ struct command_t Commands[] = {
1062 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
1063 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
1064 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
1065 +#ifdef USE_COMPRESSED
1066 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
1067 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
1068 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
1070 { "group", parse_group, 0 },
1071 { "ungroup", parse_ungroup, 0 },
1072 { "hdr_order", parse_list, UL &HeaderOrderList },
1073 diff -udprP mutt-1.5.16.orig/main.c mutt-1.5.16/main.c
1074 --- mutt-1.5.16.orig/main.c 2007-04-10 23:53:08.000000000 +0300
1075 +++ mutt-1.5.16/main.c 2007-06-12 14:22:35.000000000 +0300
1076 @@ -310,6 +310,12 @@ static void show_version (void)
1080 +#ifdef USE_COMPRESSED
1089 diff -udprP mutt-1.5.16.orig/mbox.c mutt-1.5.16/mbox.c
1090 --- mutt-1.5.16.orig/mbox.c 2007-04-02 00:58:56.000000000 +0300
1091 +++ mutt-1.5.16/mbox.c 2007-06-12 14:22:35.000000000 +0300
1094 #include "mutt_curses.h"
1096 +#ifdef USE_COMPRESSED
1097 +#include "compress.h"
1100 #include <sys/stat.h>
1103 @@ -1026,6 +1030,12 @@ bail: /* Come here in case of disaster
1104 int mbox_close_mailbox (CONTEXT *ctx)
1106 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
1108 +#ifdef USE_COMPRESSED
1109 + if (ctx->compressinfo)
1110 + mutt_slow_close_compressed (ctx);
1113 mutt_unblock_signals ();
1114 mx_fastclose_mailbox (ctx);
1116 diff -udprP mutt-1.5.16.orig/mutt.h mutt-1.5.16/mutt.h
1117 --- mutt-1.5.16.orig/mutt.h 2007-04-11 06:14:01.000000000 +0300
1118 +++ mutt-1.5.16/mutt.h 2007-06-12 14:22:35.000000000 +0300
1119 @@ -160,6 +160,11 @@ typedef enum
1120 #define M_ACCOUNTHOOK (1<<9)
1121 #define M_REPLYHOOK (1<<10)
1122 #define M_SEND2HOOK (1<<11)
1123 +#ifdef USE_COMPRESSED
1124 +#define M_OPENHOOK (1<<12)
1125 +#define M_APPENDHOOK (1<<13)
1126 +#define M_CLOSEHOOK (1<<14)
1129 /* tree characters for linearize_tree and print_enriched_string */
1130 #define M_TREE_LLCORNER 1
1131 @@ -889,6 +894,11 @@ typedef struct _context
1133 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
1135 +#ifdef USE_COMPRESSED
1136 + void *compressinfo; /* compressed mbox module private data */
1137 + char *realpath; /* path to compressed mailbox */
1138 +#endif /* USE_COMPRESSED */
1140 unsigned int locked : 1; /* is the mailbox locked? */
1141 unsigned int changed : 1; /* mailbox has been modified */
1142 unsigned int readonly : 1; /* don't allow changes to the mailbox */
1143 diff -udprP mutt-1.5.16.orig/mx.c mutt-1.5.16/mx.c
1144 --- mutt-1.5.16.orig/mx.c 2007-04-03 20:41:14.000000000 +0300
1145 +++ mutt-1.5.16/mx.c 2007-06-12 14:22:35.000000000 +0300
1150 +#ifdef USE_COMPRESSED
1151 +#include "compress.h"
1157 @@ -450,6 +454,11 @@ int mx_get_magic (const char *path)
1161 +#ifdef USE_COMPRESSED
1162 + if (magic == 0 && mutt_can_read_compressed (path))
1163 + return M_COMPRESSED;
1169 @@ -489,6 +498,13 @@ static int mx_open_mailbox_append (CONTE
1173 +#ifdef USE_COMPRESSED
1174 + /* special case for appending to compressed folders -
1175 + * even if we can not open them for reading */
1176 + if (mutt_can_append_compressed (ctx->path))
1177 + mutt_open_append_compressed (ctx);
1183 @@ -653,6 +669,11 @@ CONTEXT *mx_open_mailbox (const char *pa
1185 ctx->magic = mx_get_magic (path);
1187 +#ifdef USE_COMPRESSED
1188 + if (ctx->magic == M_COMPRESSED)
1189 + mutt_open_read_compressed (ctx);
1193 mutt_error (_("%s is not a mailbox."), path);
1195 @@ -753,6 +774,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
1196 mutt_free_header (&ctx->hdrs[i]);
1199 +#ifdef USE_COMPRESSED
1200 + if (ctx->compressinfo)
1201 + mutt_fast_close_compressed (ctx);
1204 FREE (&ctx->pattern);
1205 if (ctx->limit_pattern)
1206 @@ -805,6 +830,12 @@ static int sync_mailbox (CONTEXT *ctx, i
1208 if (tmp && tmp->new == 0)
1209 mutt_update_mailbox (tmp);
1211 +#ifdef USE_COMPRESSED
1212 + if (rc == 0 && ctx->compressinfo)
1213 + return mutt_sync_compressed (ctx);
1219 @@ -1006,6 +1037,11 @@ int mx_close_mailbox (CONTEXT *ctx, int
1220 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1221 mx_unlink_empty (ctx->path);
1223 +#ifdef USE_COMPRESSED
1224 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1228 mx_fastclose_mailbox (ctx);
1231 @@ -1315,6 +1351,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
1235 +#ifdef USE_COMPRESSED
1236 + if (ctx->compressinfo)
1237 + return mutt_check_mailbox_compressed (ctx);
1242 if (ctx->locked) lock = 0;
1243 diff -udprP mutt-1.5.16.orig/mx.h mutt-1.5.16/mx.h
1244 --- mutt-1.5.16.orig/mx.h 2007-04-02 00:58:56.000000000 +0300
1245 +++ mutt-1.5.16/mx.h 2007-06-12 14:22:35.000000000 +0300
1246 @@ -40,6 +40,9 @@ enum
1250 +#ifdef USE_COMPRESSED
1255 WHERE short DefaultMagic INITVAL (M_MBOX);
1256 diff -udprP mutt-1.5.16.orig/po/POTFILES.in mutt-1.5.16/po/POTFILES.in
1257 --- mutt-1.5.16.orig/po/POTFILES.in 2007-04-02 00:58:57.000000000 +0300
1258 +++ mutt-1.5.16/po/POTFILES.in 2007-06-12 14:22:35.000000000 +0300
1259 @@ -8,6 +8,7 @@ charset.c
1267 diff -udprP mutt-1.5.16.orig/status.c mutt-1.5.16/status.c
1268 --- mutt-1.5.16.orig/status.c 2007-04-16 02:56:26.000000000 +0300
1269 +++ mutt-1.5.16/status.c 2007-06-12 14:22:35.000000000 +0300
1270 @@ -99,6 +99,14 @@ status_format_str (char *buf, size_t buf
1273 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1274 +#ifdef USE_COMPRESSED
1275 + if (Context && Context->compressinfo && Context->realpath)
1277 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1278 + mutt_pretty_mailbox (tmp);
1282 if (Context && Context->path)
1284 strfcpy (tmp, Context->path, sizeof (tmp));