2 This is the compressed folders patch by Roland Rosenfeld
5 The home page for this patch is:
7 http://www.spinnaker.de/mutt/compressed/
9 * Patch last synced with upstream:
11 - File: http://www.spinnaker.de/mutt/compressed/patch-1.5.16.rr.compressed.1.gz
14 - 2007-06-14 myon: remove hunks for Muttrc*
17 Index: debian-mutt/compress.c
18 ===================================================================
19 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
20 +++ debian-mutt/compress.c 2007-06-14 10:57:02.000000000 +0200
23 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
25 + * This program is free software; you can redistribute it and/or modify
26 + * it under the terms of the GNU General Public License as published by
27 + * the Free Software Foundation; either version 2 of the License, or
28 + * (at your option) any later version.
30 + * This program is distributed in the hope that it will be useful,
31 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 + * GNU General Public License for more details.
35 + * You should have received a copy of the GNU General Public License
36 + * along with this program; if not, write to the Free Software
37 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
46 +#ifdef USE_COMPRESSED
50 +#include "mutt_curses.h"
55 +#include <sys/stat.h>
59 + const char *close; /* close-hook command */
60 + const char *open; /* open-hook command */
61 + const char *append; /* append-hook command */
62 + off_t size; /* size of real folder */
67 + * ctx - context to lock
68 + * excl - exclusive lock?
69 + * retry - should retry if unable to lock?
71 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
75 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
77 + else if (retry && !excl)
86 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
92 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
97 +static int is_new (const char *path)
99 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
102 +static const char* find_compress_hook (int type, const char *path)
104 + const char* c = mutt_find_hook (type, path);
105 + return (!c || !*c) ? NULL : c;
108 +int mutt_can_read_compressed (const char *path)
110 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
114 + * if the file is new, we really do not append, but create, and so use
115 + * close-hook, and not append-hook
117 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
119 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
120 + return (is_new (path)) ? ci->close : ci->append;
123 +int mutt_can_append_compressed (const char *path)
129 + char *dir_path = safe_strdup(path);
130 + char *aux = strrchr(dir_path, '/');
135 + if (access(dir_path, W_OK|X_OK))
138 + safe_free((void**)&dir_path);
139 + return dir_valid && (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
142 + magic = mx_get_magic (path);
144 + if (magic != 0 && magic != M_COMPRESSED)
147 + return (find_compress_hook (M_APPENDHOOK, path)
148 + || (find_compress_hook (M_OPENHOOK, path)
149 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
152 +/* open a compressed mailbox */
153 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
157 + /* Now lets uncompress this thing */
158 + ci = safe_malloc (sizeof (COMPRESS_INFO));
159 + ctx->compressinfo = (void*) ci;
160 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
161 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
162 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
166 +static void set_path (CONTEXT* ctx)
168 + char tmppath[_POSIX_PATH_MAX];
170 + /* Setup the right paths */
171 + ctx->realpath = ctx->path;
173 + /* Uncompress to /tmp */
174 + mutt_mktemp (tmppath);
175 + ctx->path = safe_malloc (strlen (tmppath) + 1);
176 + strcpy (ctx->path, tmppath);
179 +static int get_size (const char* path)
182 + if (stat (path, &sb) != 0)
184 + return (sb.st_size);
187 +static void store_size (CONTEXT* ctx)
189 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
190 + ci->size = get_size (ctx->realpath);
194 +compresshook_format_str (char *dest, size_t destlen, size_t col, char op,
195 + const char *src, const char *fmt,
196 + const char *ifstring, const char *elsestring,
197 + unsigned long data, format_flag flags)
199 + char tmp[SHORT_STRING];
201 + CONTEXT *ctx = (CONTEXT *) data;
205 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
206 + snprintf (dest, destlen, tmp, ctx->realpath);
209 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
210 + snprintf (dest, destlen, tmp, ctx->path);
217 + * check that the command has both %f and %t
218 + * 0 means OK, -1 means error
220 +int mutt_test_compress_command (const char* cmd)
222 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
225 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
227 + char expanded[_POSIX_PATH_MAX];
228 + mutt_FormatString (expanded, sizeof (expanded), 0, cmd,
229 + compresshook_format_str, (unsigned long) ctx, 0);
230 + return safe_strdup (expanded);
233 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
235 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
236 + if (ci->size != get_size (ctx->realpath))
238 + FREE (&ctx->compressinfo);
239 + FREE (&ctx->realpath);
240 + mutt_error _("Mailbox was corrupted!");
246 +int mutt_open_read_compressed (CONTEXT *ctx)
252 + COMPRESS_INFO *ci = set_compress_info (ctx);
255 + FREE (&ctx->compressinfo);
258 + if (!ci->close || access (ctx->path, W_OK) != 0)
265 + mutt_message (_("Decompressing %s..."), ctx->realpath);
267 + cmd = get_compression_cmd (ci->open, ctx);
270 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
272 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
274 + mutt_perror (ctx->realpath);
278 + mutt_block_signals ();
279 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
282 + mutt_unblock_signals ();
283 + mutt_error _("Unable to lock mailbox!");
290 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
291 + rc = mutt_system (cmd);
292 + mbox_unlock_compressed (ctx, fp);
293 + mutt_unblock_signals ();
298 + mutt_any_key_to_continue (NULL);
300 + FREE (&ctx->compressinfo);
301 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
307 + if (mutt_check_mailbox_compressed (ctx))
310 + ctx->magic = mx_get_magic (ctx->path);
315 +void restore_path (CONTEXT* ctx)
318 + ctx->path = ctx->realpath;
321 +/* remove the temporary mailbox */
322 +void remove_file (CONTEXT* ctx)
324 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
325 + remove (ctx->path);
328 +int mutt_open_append_compressed (CONTEXT *ctx)
331 + COMPRESS_INFO *ci = set_compress_info (ctx);
333 + if (!get_append_command (ctx->path, ctx))
335 + if (ci->open && ci->close)
336 + return (mutt_open_read_compressed (ctx));
339 + FREE (&ctx->compressinfo);
345 + ctx->magic = DefaultMagic;
347 + if (!is_new (ctx->realpath))
348 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
349 + if ((fh = fopen (ctx->path, "w")))
351 + /* No error checking - the parent function will catch it */
356 +/* close a compressed mailbox */
357 +void mutt_fast_close_compressed (CONTEXT *ctx)
359 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
362 + if (ctx->compressinfo)
367 + /* if the folder was removed, remove the gzipped folder too */
368 + if ((ctx->magic > 0)
369 + && (access (ctx->path, F_OK) != 0)
370 + && ! option (OPTSAVEEMPTY))
371 + remove (ctx->realpath);
375 + restore_path (ctx);
376 + FREE (&ctx->compressinfo);
380 +/* return 0 on success, -1 on failure */
381 +int mutt_sync_compressed (CONTEXT* ctx)
386 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
389 + mutt_message (_("Compressing %s..."), ctx->realpath);
391 + cmd = get_compression_cmd (ci->close, ctx);
395 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
397 + mutt_perror (ctx->realpath);
401 + mutt_block_signals ();
402 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
405 + mutt_unblock_signals ();
406 + mutt_error _("Unable to lock mailbox!");
412 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
416 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
417 + if (mutt_system (cmd))
419 + mutt_any_key_to_continue (NULL);
420 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
424 + mbox_unlock_compressed (ctx, fp);
425 + mutt_unblock_signals ();
435 +int mutt_slow_close_compressed (CONTEXT *ctx)
438 + const char *append;
440 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
442 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
446 + && ((append = get_append_command (ctx->realpath, ctx))
447 + || (append = ci->close))))
449 + /* if we can not or should not append, we only have to remove the */
450 + /* compressed info, because sync was already called */
451 + mutt_fast_close_compressed (ctx);
461 + if (append == ci->close)
462 + mutt_message (_("Compressing %s..."), ctx->realpath);
464 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
467 + cmd = get_compression_cmd (append, ctx);
471 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
473 + mutt_perror (ctx->realpath);
477 + mutt_block_signals ();
478 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
481 + mutt_unblock_signals ();
482 + mutt_error _("Unable to lock mailbox!");
487 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
492 + if (append == ci->close)
493 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
495 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
497 + if (mutt_system (cmd))
499 + mutt_any_key_to_continue (NULL);
500 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
503 + mbox_unlock_compressed (ctx, fp);
504 + mutt_unblock_signals ();
509 + mbox_unlock_compressed (ctx, fp);
510 + mutt_unblock_signals ();
513 + restore_path (ctx);
515 + FREE (&ctx->compressinfo);
520 +#endif /* USE_COMPRESSED */
521 Index: debian-mutt/compress.h
522 ===================================================================
523 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
524 +++ debian-mutt/compress.h 2007-06-14 10:57:02.000000000 +0200
527 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
529 + * This program is free software; you can redistribute it and/or modify
530 + * it under the terms of the GNU General Public License as published by
531 + * the Free Software Foundation; either version 2 of the License, or
532 + * (at your option) any later version.
534 + * This program is distributed in the hope that it will be useful,
535 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
536 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
537 + * GNU General Public License for more details.
539 + * You should have received a copy of the GNU General Public License
540 + * along with this program; if not, write to the Free Software
541 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
544 +int mutt_can_read_compressed (const char *);
545 +int mutt_can_append_compressed (const char *);
546 +int mutt_open_read_compressed (CONTEXT *);
547 +int mutt_open_append_compressed (CONTEXT *);
548 +int mutt_slow_close_compressed (CONTEXT *);
549 +int mutt_sync_compressed (CONTEXT *);
550 +int mutt_test_compress_command (const char *);
551 +int mutt_check_mailbox_compressed (CONTEXT *);
552 +void mutt_fast_close_compressed (CONTEXT *);
553 Index: debian-mutt/config.h.in
554 ===================================================================
555 --- debian-mutt.orig/config.h.in 2007-06-14 10:54:19.000000000 +0200
556 +++ debian-mutt/config.h.in 2007-06-14 10:57:02.000000000 +0200
558 /* Define to enable Sun mailtool attachments support. */
559 #undef SUN_ATTACHMENT
561 +/* Define to enable compressed mailboxes support */
562 +#undef USE_COMPRESSED
564 /* Define to use dotlocking for mailboxes. */
567 Index: debian-mutt/configure
568 ===================================================================
569 --- debian-mutt.orig/configure 2007-06-14 10:54:19.000000000 +0200
570 +++ debian-mutt/configure 2007-06-14 10:57:02.000000000 +0200
571 @@ -1371,6 +1371,7 @@ Optional Features:
572 --enable-hcache Enable header caching
573 --disable-iconv Disable iconv support
574 --disable-nls Do not use Native Language Support
575 + --enable-compressed Enable compressed folders support
578 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
579 @@ -15105,6 +15106,17 @@ _ACEOF
583 +# Check whether --enable-compressed or --disable-compressed was given.
584 +if test "${enable_compressed+set}" = set; then
585 + enableval="$enable_compressed"; if test x$enableval = xyes; then
587 +cat >>confdefs.h <<\_ACEOF
588 +#define USE_COMPRESSED 1
595 # Check whether --with-exec-shell was given.
596 if test "${with_exec_shell+set}" = set; then
597 Index: debian-mutt/configure.ac
598 ===================================================================
599 --- debian-mutt.orig/configure.ac 2007-06-14 10:54:19.000000000 +0200
600 +++ debian-mutt/configure.ac 2007-06-14 10:57:02.000000000 +0200
601 @@ -785,6 +785,11 @@ AC_ARG_ENABLE(locales-fix, AC_HELP_STRIN
602 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
605 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
606 + [if test x$enableval = xyes; then
607 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
610 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
611 [if test $withval != yes; then
612 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
613 Index: debian-mutt/curs_main.c
614 ===================================================================
615 --- debian-mutt.orig/curs_main.c 2007-06-14 10:54:19.000000000 +0200
616 +++ debian-mutt/curs_main.c 2007-06-14 10:57:02.000000000 +0200
617 @@ -1111,6 +1111,11 @@ int mutt_index_menu (void)
621 +#ifdef USE_COMPRESSED
622 + if (Context->compressinfo && Context->realpath)
623 + mutt_str_replace (&LastFolder, Context->realpath);
626 mutt_str_replace (&LastFolder, Context->path);
627 oldcount = Context ? Context->msgcount : 0;
629 Index: debian-mutt/doc/manual.xml.head
630 ===================================================================
631 --- debian-mutt.orig/doc/manual.xml.head 2007-06-14 10:54:19.000000000 +0200
632 +++ debian-mutt/doc/manual.xml.head 2007-06-14 10:57:02.000000000 +0200
633 @@ -4910,6 +4910,205 @@ becomes an issue as mutt will silently f
637 +<sect1 id="compressedfolders">
638 +<title>Compressed folders Support (OPTIONAL)</title>
641 +If Mutt was compiled with compressed folders support (by running the
642 +<emphasis>configure</emphasis> script with the
643 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
644 +stored in an arbitrary format, provided that the user has a script to
645 +convert from/to this format to one of the accepted.
647 +The most common use is to open compressed archived folders e.g. with
650 +In addition, the user can provide a script that gets a folder in an
651 +accepted format and appends its context to the folder in the
652 +user-defined format, which may be faster than converting the entire
653 +folder to the accepted format, appending to it and converting back to
654 +the user-defined format.
656 +There are three hooks defined (<link
657 +linkend="open-hook">open-hook</link>, <link
658 +linkend="close-hook">close-hook</link> and <link
659 +linkend="append-hook">append-hook</link>) which define commands to
660 +uncompress and compress a folder and to append messages to an existing
661 +compressed folder respectively.
666 +open-hook \\.gz$ "gzip -cd %f > %t"
667 +close-hook \\.gz$ "gzip -c %t > %f"
668 +append-hook \\.gz$ "gzip -c %t >> %f"
671 +You do not have to specify all of the commands. If you omit <link
672 +linkend="append-hook">append-hook</link>, the folder will be open and
673 +closed again each time you will add to it. If you omit <link
674 +linkend="close-hook">close-hook</link> (or give empty command) , the
675 +folder will be open in the mode. If you specify <link
676 +linkend="append-hook">append-hook</link> though you'll be able to
677 +append to the folder.
679 +Note that Mutt will only try to use hooks if the file is not in one of
680 +the accepted formats. In particular, if the file is empty, mutt
681 +supposes it is not compressed. This is important because it allows the
682 +use of programs that do not have well defined extensions. Just use
683 +"." as a regexp. But this may be surprising if your
684 +compressing script produces empty files. In this situation, unset
685 +<link linkend="save-empty">$save_empty</link>, so that
686 +the compressed file will be removed if you delete all of the messages.
689 +<sect2 id="open-hook">
690 +<title>Open a compressed mailbox for reading</title>
693 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
695 +The <emphasis>command</emphasis> is the command that can be used for
696 +opening the folders whose names match <emphasis>regexp</emphasis>.
698 +The <emphasis>command</emphasis> string is the printf-like format
699 +string, and it should accept two parameters: %f, which is
700 +replaced with the (compressed) folder name, and %t which is
701 +replaced with the name of the temporary folder to which to write.
703 +%f and %t can be repeated any number of times in the
704 +command string, and all of the entries are replaced with the
705 +appropriate folder name. In addition, %% is replaced by
706 +%, as in printf, and any other %anything is left as is.
708 +The <emphasis>command</emphasis> should <emphasis
709 +role="bold">not</emphasis> remove the original compressed file. The
710 +<emphasis>command</emphasis> should return non-zero exit status if it
711 +fails, so mutt knows something's wrong.
716 +open-hook \\.gz$ "gzip -cd %f > %t"
719 +If the <emphasis>command</emphasis> is empty, this operation is
720 +disabled for this file type.
724 +<sect2 id="close-hook">
725 +<title>Write a compressed mailbox</title>
728 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
730 +This is used to close the folder that was open with the <link
731 +linkend="open-hook">open-hook</link> command after some changes were
734 +The <emphasis>command</emphasis> string is the command that can be
735 +used for closing the folders whose names match
736 +<emphasis>regexp</emphasis>. It has the same format as in the <link
737 +linkend="open-hook">open-hook</link> command. Temporary folder in this
738 +case is the folder previously produced by the <link
739 +linkend="open-hook">open-hook</link> command.
741 +The <emphasis>command</emphasis> should <emphasis
742 +role="bold">not</emphasis> remove the decompressed file. The
743 +<emphasis>command</emphasis> should return non-zero exit status if it
744 +fails, so mutt knows something's wrong.
749 +close-hook \\.gz$ "gzip -c %t > %f"
752 +If the <emphasis>command</emphasis> is empty, this operation is
753 +disabled for this file type, and the file can only be open in the
756 +<link linkend="close-hook">close-hook</link> is not called when you
757 +exit from the folder if the folder was not changed.
761 +<sect2 id="append-hook">
762 +<title>Append a message to a compressed mailbox</title>
765 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
767 +This command is used for saving to an existing compressed folder. The
768 +<emphasis>command</emphasis> is the command that can be used for
769 +appending to the folders whose names match
770 +<emphasis>regexp</emphasis>. It has the same format as in the <link
771 +linkend="open-hook">open-hook</link> command. The temporary folder in
772 +this case contains the messages that are being appended.
774 +The <emphasis>command</emphasis> should <emphasis
775 +role="bold">not</emphasis> remove the decompressed file. The
776 +<emphasis>command</emphasis> should return non-zero exit status if it
777 +fails, so mutt knows something's wrong.
782 +append-hook \\.gz$ "gzip -c %t >> %f"
785 +When <link linkend="append-hook">append-hook</link> is used, the folder
786 +is not opened, which saves time, but this means that we can not find
787 +out what the folder type is. Thus the default (<link
788 +linkend="mbox-type">$mbox_type</link>) type is always
789 +supposed (i.e. this is the format used for the temporary folder).
791 +If the file does not exist when you save to it, <link
792 +linkend="close-hook">close-hook</link> is called, and not <link
793 +linkend="append-hook">append-hook</link>. <link
794 +linkend="append-hook">append-hook</link> is only for appending to
797 +If the <emphasis>command</emphasis> is empty, this operation is
798 +disabled for this file type. In this case, the folder will be open and
799 +closed again (using <link linkend="open-hook">open-hook</link> and
800 +<link linkend="close-hook">close-hook</link>respectively) each time you
806 +<title>Encrypted folders</title>
809 +The compressed folders support can also be used to handle encrypted
810 +folders. If you want to encrypt a folder with PGP, you may want to use
811 +the following hooks:
814 +open-hook \\.pgp$ "pgp -f < %f > %t"
815 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
818 +Please note, that PGP does not support appending to an encrypted
819 +folder, so there is no append-hook defined.
821 +If you are using GnuPG instead of PGP, you may use the following hooks
825 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
826 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
829 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
830 +decrypted in the /tmp directory, where it can be read by your system
831 +administrator. So think about the security aspects of this.
836 <chapter id="mimesupport">
837 <title>Mutt's MIME Support</title>
839 Index: debian-mutt/doc/muttrc.man.head
840 ===================================================================
841 --- debian-mutt.orig/doc/muttrc.man.head 2007-06-14 10:54:19.000000000 +0200
842 +++ debian-mutt/doc/muttrc.man.head 2007-06-14 10:57:02.000000000 +0200
843 @@ -345,6 +345,24 @@ specify the ID of the public key to be u
844 to a certain recipient. The meaning of "key ID" is to be taken
845 broadly: This can be a different e-mail address, a numerical key ID,
846 or even just an arbitrary search string.
849 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
850 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
851 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
854 +These commands provide a way to handle compressed folders. The given
855 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
856 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
857 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
858 +compressed mail to a compressed folder (\fBappend-hook\fP). The
859 +\fIcommand\fP string is the
861 +like format string, and it should accept two parameters: \fB%f\fP,
862 +which is replaced with the (compressed) folder name, and \fB%t\fP
863 +which is replaced with the name of the temporary folder to which to
866 \fBpush\fP \fIstring\fP
867 This command adds the named \fIstring\fP to the keyboard buffer.
868 Index: debian-mutt/hook.c
869 ===================================================================
870 --- debian-mutt.orig/hook.c 2007-06-14 10:54:19.000000000 +0200
871 +++ debian-mutt/hook.c 2007-06-14 10:57:02.000000000 +0200
874 #include "mutt_crypt.h"
876 +#ifdef USE_COMPRESSED
877 +#include "compress.h"
883 @@ -92,6 +96,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
884 memset (&pattern, 0, sizeof (pattern));
885 pattern.data = safe_strdup (path);
887 +#ifdef USE_COMPRESSED
888 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
890 + if (mutt_test_compress_command (command.data))
892 + strfcpy (err->data, _("badly formatted command string"), err->dsize);
897 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
898 && (!WithCrypto || !(data & M_CRYPTHOOK))
900 Index: debian-mutt/init.h
901 ===================================================================
902 --- debian-mutt.orig/init.h 2007-06-14 10:54:19.000000000 +0200
903 +++ debian-mutt/init.h 2007-06-14 10:57:02.000000000 +0200
904 @@ -3129,6 +3129,11 @@ struct command_t Commands[] = {
905 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
906 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
907 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
908 +#ifdef USE_COMPRESSED
909 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
910 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
911 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
913 { "group", parse_group, 0 },
914 { "ungroup", parse_ungroup, 0 },
915 { "hdr_order", parse_list, UL &HeaderOrderList },
916 Index: debian-mutt/main.c
917 ===================================================================
918 --- debian-mutt.orig/main.c 2007-06-14 10:54:19.000000000 +0200
919 +++ debian-mutt/main.c 2007-06-14 10:57:02.000000000 +0200
920 @@ -401,6 +401,12 @@ static void show_version (void)
925 +#ifdef USE_COMPRESSED
933 Index: debian-mutt/Makefile.am
934 ===================================================================
935 --- debian-mutt.orig/Makefile.am 2007-06-14 10:54:19.000000000 +0200
936 +++ debian-mutt/Makefile.am 2007-06-14 10:57:02.000000000 +0200
937 @@ -18,7 +18,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.
938 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
939 mutt_SOURCES = $(BUILT_SOURCES) \
940 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
941 - crypt.c cryptglue.c \
942 + crypt.c cryptglue.c compress.c \
943 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
944 edit.c enter.c flags.c init.c filter.c from.c \
945 getdomain.c group.c \
946 @@ -66,7 +66,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
949 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
950 - configure account.h \
951 + configure account.h compress.h \
952 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
953 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
954 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
955 Index: debian-mutt/Makefile.in
956 ===================================================================
957 --- debian-mutt.orig/Makefile.in 2007-06-14 10:54:19.000000000 +0200
958 +++ debian-mutt/Makefile.in 2007-06-14 10:57:02.000000000 +0200
959 @@ -74,7 +74,7 @@ am_mutt_OBJECTS = $(am__objects_1) addrb
960 attach.$(OBJEXT) base64.$(OBJEXT) browser.$(OBJEXT) \
961 buffy.$(OBJEXT) color.$(OBJEXT) crypt.$(OBJEXT) \
962 cryptglue.$(OBJEXT) commands.$(OBJEXT) complete.$(OBJEXT) \
963 - compose.$(OBJEXT) copy.$(OBJEXT) curs_lib.$(OBJEXT) \
964 + compose.$(OBJEXT) compress.$(OBJEXT) copy.$(OBJEXT) curs_lib.$(OBJEXT) \
965 curs_main.$(OBJEXT) date.$(OBJEXT) edit.$(OBJEXT) \
966 enter.$(OBJEXT) flags.$(OBJEXT) init.$(OBJEXT) \
967 filter.$(OBJEXT) from.$(OBJEXT) getdomain.$(OBJEXT) \
968 @@ -302,7 +302,7 @@ bin_SCRIPTS = muttbug flea @SMIMEAUX_TAR
969 BUILT_SOURCES = keymap_defs.h patchlist.c reldate.h hcversion.h
970 mutt_SOURCES = $(BUILT_SOURCES) \
971 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
972 - crypt.c cryptglue.c \
973 + crypt.c cryptglue.c compress.c \
974 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
975 edit.c enter.c flags.c init.c filter.c from.c \
976 getdomain.c group.c \
977 @@ -335,7 +335,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
980 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
981 - configure account.h \
982 + configure account.h compress.h \
983 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
984 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
985 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
986 @@ -507,6 +507,7 @@ distclean-compile:
987 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/commands.Po@am__quote@
988 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/complete.Po@am__quote@
989 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compose.Po@am__quote@
990 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compress.Po@am__quote@
991 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copy.Po@am__quote@
992 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypt-gpgme.Po@am__quote@
993 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypt-mod-pgp-classic.Po@am__quote@
994 Index: debian-mutt/mbox.c
995 ===================================================================
996 --- debian-mutt.orig/mbox.c 2007-06-14 10:54:19.000000000 +0200
997 +++ debian-mutt/mbox.c 2007-06-14 10:57:02.000000000 +0200
1000 #include "mutt_curses.h"
1002 +#ifdef USE_COMPRESSED
1003 +#include "compress.h"
1006 #include <sys/stat.h>
1009 @@ -1026,6 +1030,12 @@ bail: /* Come here in case of disaster
1010 int mbox_close_mailbox (CONTEXT *ctx)
1012 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
1014 +#ifdef USE_COMPRESSED
1015 + if (ctx->compressinfo)
1016 + mutt_slow_close_compressed (ctx);
1019 mutt_unblock_signals ();
1020 mx_fastclose_mailbox (ctx);
1022 Index: debian-mutt/mutt.h
1023 ===================================================================
1024 --- debian-mutt.orig/mutt.h 2007-06-14 10:54:19.000000000 +0200
1025 +++ debian-mutt/mutt.h 2007-06-14 10:57:02.000000000 +0200
1026 @@ -160,6 +160,11 @@ typedef enum
1027 #define M_ACCOUNTHOOK (1<<9)
1028 #define M_REPLYHOOK (1<<10)
1029 #define M_SEND2HOOK (1<<11)
1030 +#ifdef USE_COMPRESSED
1031 +#define M_OPENHOOK (1<<12)
1032 +#define M_APPENDHOOK (1<<13)
1033 +#define M_CLOSEHOOK (1<<14)
1036 /* tree characters for linearize_tree and print_enriched_string */
1037 #define M_TREE_LLCORNER 1
1038 @@ -885,6 +890,11 @@ typedef struct _context
1039 int flagged; /* how many flagged messages */
1040 int msgnotreadyet; /* which msg "new" in pager, -1 if none */
1042 +#ifdef USE_COMPRESSED
1043 + void *compressinfo; /* compressed mbox module private data */
1044 + char *realpath; /* path to compressed mailbox */
1045 +#endif /* USE_COMPRESSED */
1047 short magic; /* mailbox type */
1049 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
1050 Index: debian-mutt/mx.c
1051 ===================================================================
1052 --- debian-mutt.orig/mx.c 2007-06-14 10:54:19.000000000 +0200
1053 +++ debian-mutt/mx.c 2007-06-14 10:57:02.000000000 +0200
1058 +#ifdef USE_COMPRESSED
1059 +#include "compress.h"
1065 @@ -450,6 +454,10 @@ int mx_get_magic (const char *path)
1069 +#ifdef USE_COMPRESSED
1070 + if (magic == 0 && mutt_can_read_compressed (path))
1071 + return M_COMPRESSED;
1076 @@ -489,6 +497,13 @@ static int mx_open_mailbox_append (CONTE
1080 +#ifdef USE_COMPRESSED
1081 + /* special case for appending to compressed folders -
1082 + * even if we can not open them for reading */
1083 + if (mutt_can_append_compressed (ctx->path))
1084 + mutt_open_append_compressed (ctx);
1090 @@ -652,7 +667,12 @@ CONTEXT *mx_open_mailbox (const char *pa
1093 ctx->magic = mx_get_magic (path);
1096 +#ifdef USE_COMPRESSED
1097 + if (ctx->magic == M_COMPRESSED)
1098 + mutt_open_read_compressed (ctx);
1102 mutt_error (_("%s is not a mailbox."), path);
1104 @@ -753,6 +773,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
1105 mutt_free_header (&ctx->hdrs[i]);
1108 +#ifdef USE_COMPRESSED
1109 + if (ctx->compressinfo)
1110 + mutt_fast_close_compressed (ctx);
1113 FREE (&ctx->pattern);
1114 if (ctx->limit_pattern)
1115 @@ -805,6 +829,12 @@ static int sync_mailbox (CONTEXT *ctx, i
1117 if (tmp && tmp->new == 0)
1118 mutt_update_mailbox (tmp);
1120 +#ifdef USE_COMPRESSED
1121 + if (rc == 0 && ctx->compressinfo)
1122 + return mutt_sync_compressed (ctx);
1128 @@ -1006,6 +1036,11 @@ int mx_close_mailbox (CONTEXT *ctx, int
1129 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1130 mx_unlink_empty (ctx->path);
1132 +#ifdef USE_COMPRESSED
1133 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1137 mx_fastclose_mailbox (ctx);
1140 @@ -1315,6 +1350,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
1144 +#ifdef USE_COMPRESSED
1145 + if (ctx->compressinfo)
1146 + return mutt_check_mailbox_compressed (ctx);
1151 if (ctx->locked) lock = 0;
1152 Index: debian-mutt/mx.h
1153 ===================================================================
1154 --- debian-mutt.orig/mx.h 2007-06-14 10:54:19.000000000 +0200
1155 +++ debian-mutt/mx.h 2007-06-14 10:57:02.000000000 +0200
1156 @@ -40,6 +40,9 @@ enum
1160 +#ifdef USE_COMPRESSED
1165 WHERE short DefaultMagic INITVAL (M_MBOX);
1166 Index: debian-mutt/PATCHES
1167 ===================================================================
1168 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1169 +++ debian-mutt/PATCHES 2007-06-14 10:57:02.000000000 +0200
1171 +patch-1.5.16.rr.compressed.1
1172 Index: debian-mutt/po/de.po
1173 ===================================================================
1174 --- debian-mutt.orig/po/de.po 2007-06-14 10:54:19.000000000 +0200
1175 +++ debian-mutt/po/de.po 2007-06-14 10:57:02.000000000 +0200
1176 @@ -1279,6 +1279,48 @@ msgstr "Prüfung des Absenders fehlgeschl
1177 msgid "Failed to figure out sender"
1178 msgstr "Kann Absender nicht ermitteln"
1180 +#: compress.c:203 mbox.c:661
1181 +msgid "Mailbox was corrupted!"
1182 +msgstr "Mailbox wurde zerstört!"
1184 +#: compress.c:228 compress.c:253
1186 +msgid "Decompressing %s...\n"
1187 +msgstr "Entpacke %s...\n"
1189 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1190 +msgid "Unable to lock mailbox!"
1191 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1195 +msgid "Error executing: %s : unable to open the mailbox!\n"
1196 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1198 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1200 +msgid "Compressing %s...\n"
1201 +msgstr "Komprimiere %s...\n"
1206 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1209 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1210 +"entpackte gespeichert!\n"
1212 +#: compress.c:425 compress.c:456
1214 +msgid "Compressed-appending to %s...\n"
1215 +msgstr "Hänge komprimiert an %s... an\n"
1219 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1220 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1224 msgid " (current time: %c)"
1225 @@ -1948,6 +1990,10 @@ msgstr "Hilfe für %s"
1226 msgid "Bad history file format (line %d)"
1227 msgstr "Falsches Format der Datei früherer Eingaben (Zeile %d)"
1230 +msgid "badly formatted command string"
1231 +msgstr "Hook enthält nicht die Muster %f und %t"
1235 msgid "unhook: Can't do unhook * from within a hook."
1236 @@ -3452,18 +3498,10 @@ msgstr "Lese %s..."
1237 msgid "Mailbox is corrupt!"
1238 msgstr "Mailbox fehlerhaft!"
1241 -msgid "Mailbox was corrupted!"
1242 -msgstr "Mailbox wurde zerstört!"
1244 #: mbox.c:711 mbox.c:964
1245 msgid "Fatal error! Could not reopen mailbox!"
1246 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1249 -msgid "Unable to lock mailbox!"
1250 -msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1252 #. this means ctx->changed or ctx->deleted was set, but no
1253 #. * messages were found to be changed or deleted. This should
1254 #. * never happen, is we presume it is a bug in mutt.
1255 Index: debian-mutt/po/POTFILES.in
1256 ===================================================================
1257 --- debian-mutt.orig/po/POTFILES.in 2007-06-14 10:54:19.000000000 +0200
1258 +++ debian-mutt/po/POTFILES.in 2007-06-14 10:57:02.000000000 +0200
1259 @@ -8,6 +8,7 @@ charset.c
1267 Index: debian-mutt/status.c
1268 ===================================================================
1269 --- debian-mutt.orig/status.c 2007-06-14 10:54:19.000000000 +0200
1270 +++ debian-mutt/status.c 2007-06-14 10:57:02.000000000 +0200
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));