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.14.rr.compressed.1.gz
15 $(for f in Makefile.in config.h.in configure 'Muttrc*' doc/manual.txt \
16 doc/manual.sgml 'doc/manual*.html' doc/muttrc.man; do echo "-x $f"; done)
17 - 2007-03-13 myon: update for 1.5.14+tip (conflict in hook.c)
20 Index: mutt/compress.c
21 ===================================================================
22 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
23 +++ mutt/compress.c 2007-03-13 20:59:30.000000000 +0100
26 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
28 + * This program is free software; you can redistribute it and/or modify
29 + * it under the terms of the GNU General Public License as published by
30 + * the Free Software Foundation; either version 2 of the License, or
31 + * (at your option) any later version.
33 + * This program is distributed in the hope that it will be useful,
34 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
35 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 + * GNU General Public License for more details.
38 + * You should have received a copy of the GNU General Public License
39 + * along with this program; if not, write to the Free Software
40 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
49 +#ifdef USE_COMPRESSED
53 +#include "mutt_curses.h"
58 +#include <sys/stat.h>
62 + const char *close; /* close-hook command */
63 + const char *open; /* open-hook command */
64 + const char *append; /* append-hook command */
65 + off_t size; /* size of real folder */
70 + * ctx - context to lock
71 + * excl - exclusive lock?
72 + * retry - should retry if unable to lock?
74 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
78 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
80 + else if (retry && !excl)
89 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
95 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
100 +static int is_new (const char *path)
102 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
105 +static const char* find_compress_hook (int type, const char *path)
107 + const char* c = mutt_find_hook (type, path);
108 + return (!c || !*c) ? NULL : c;
111 +int mutt_can_read_compressed (const char *path)
113 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
117 + * if the file is new, we really do not append, but create, and so use
118 + * close-hook, and not append-hook
120 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
122 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
123 + return (is_new (path)) ? ci->close : ci->append;
126 +int mutt_can_append_compressed (const char *path)
132 + char *dir_path = safe_strdup(path);
133 + char *aux = strrchr(dir_path, '/');
138 + if (access(dir_path, W_OK|X_OK))
141 + safe_free((void**)&dir_path);
142 + return dir_valid && (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
145 + magic = mx_get_magic (path);
147 + if (magic != 0 && magic != M_COMPRESSED)
150 + return (find_compress_hook (M_APPENDHOOK, path)
151 + || (find_compress_hook (M_OPENHOOK, path)
152 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
155 +/* open a compressed mailbox */
156 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
160 + /* Now lets uncompress this thing */
161 + ci = safe_malloc (sizeof (COMPRESS_INFO));
162 + ctx->compressinfo = (void*) ci;
163 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
164 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
165 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
169 +static void set_path (CONTEXT* ctx)
171 + char tmppath[_POSIX_PATH_MAX];
173 + /* Setup the right paths */
174 + ctx->realpath = ctx->path;
176 + /* Uncompress to /tmp */
177 + mutt_mktemp (tmppath);
178 + ctx->path = safe_malloc (strlen (tmppath) + 1);
179 + strcpy (ctx->path, tmppath);
182 +static int get_size (const char* path)
185 + if (stat (path, &sb) != 0)
187 + return (sb.st_size);
190 +static void store_size (CONTEXT* ctx)
192 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
193 + ci->size = get_size (ctx->realpath);
197 +compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
198 + const char *fmt, const char *ifstring,
199 + const char *elsestring, unsigned long data,
202 + char tmp[SHORT_STRING];
204 + CONTEXT *ctx = (CONTEXT *) data;
208 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
209 + snprintf (dest, destlen, tmp, ctx->realpath);
212 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
213 + snprintf (dest, destlen, tmp, ctx->path);
220 + * check that the command has both %f and %t
221 + * 0 means OK, -1 means error
223 +int mutt_test_compress_command (const char* cmd)
225 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
228 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
230 + char expanded[_POSIX_PATH_MAX];
231 + mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str,
232 + (unsigned long) ctx, 0);
233 + return safe_strdup (expanded);
236 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
238 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
239 + if (ci->size != get_size (ctx->realpath))
241 + FREE (&ctx->compressinfo);
242 + FREE (&ctx->realpath);
243 + mutt_error _("Mailbox was corrupted!");
249 +int mutt_open_read_compressed (CONTEXT *ctx)
255 + COMPRESS_INFO *ci = set_compress_info (ctx);
258 + FREE (ctx->compressinfo);
261 + if (!ci->close || access (ctx->path, W_OK) != 0)
268 + mutt_message (_("Decompressing %s..."), ctx->realpath);
270 + cmd = get_compression_cmd (ci->open, ctx);
273 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
275 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
277 + mutt_perror (ctx->realpath);
281 + mutt_block_signals ();
282 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
285 + mutt_unblock_signals ();
286 + mutt_error _("Unable to lock mailbox!");
293 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
294 + rc = mutt_system (cmd);
295 + mbox_unlock_compressed (ctx, fp);
296 + mutt_unblock_signals ();
301 + mutt_any_key_to_continue (NULL);
303 + FREE (ctx->compressinfo);
304 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
310 + if (mutt_check_mailbox_compressed (ctx))
313 + ctx->magic = mx_get_magic (ctx->path);
318 +void restore_path (CONTEXT* ctx)
321 + ctx->path = ctx->realpath;
324 +/* remove the temporary mailbox */
325 +void remove_file (CONTEXT* ctx)
327 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
328 + remove (ctx->path);
331 +int mutt_open_append_compressed (CONTEXT *ctx)
334 + COMPRESS_INFO *ci = set_compress_info (ctx);
336 + if (!get_append_command (ctx->path, ctx))
338 + if (ci->open && ci->close)
339 + return (mutt_open_read_compressed (ctx));
342 + FREE (&ctx->compressinfo);
348 + ctx->magic = DefaultMagic;
350 + if (!is_new (ctx->realpath))
351 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
352 + if ((fh = fopen (ctx->path, "w")))
354 + /* No error checking - the parent function will catch it */
359 +/* close a compressed mailbox */
360 +void mutt_fast_close_compressed (CONTEXT *ctx)
362 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
365 + if (ctx->compressinfo)
370 + /* if the folder was removed, remove the gzipped folder too */
371 + if ((ctx->magic > 0)
372 + && (access (ctx->path, F_OK) != 0)
373 + && ! option (OPTSAVEEMPTY))
374 + remove (ctx->realpath);
378 + restore_path (ctx);
379 + FREE (&ctx->compressinfo);
383 +/* return 0 on success, -1 on failure */
384 +int mutt_sync_compressed (CONTEXT* ctx)
389 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
392 + mutt_message (_("Compressing %s..."), ctx->realpath);
394 + cmd = get_compression_cmd (ci->close, ctx);
398 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
400 + mutt_perror (ctx->realpath);
404 + mutt_block_signals ();
405 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
408 + mutt_unblock_signals ();
409 + mutt_error _("Unable to lock mailbox!");
415 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
419 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
420 + if (mutt_system (cmd))
422 + mutt_any_key_to_continue (NULL);
423 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
427 + mbox_unlock_compressed (ctx, fp);
428 + mutt_unblock_signals ();
438 +int mutt_slow_close_compressed (CONTEXT *ctx)
441 + const char *append;
443 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
445 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
449 + && ((append = get_append_command (ctx->realpath, ctx))
450 + || (append = ci->close))))
452 + /* if we can not or should not append, we only have to remove the */
453 + /* compressed info, because sync was already called */
454 + mutt_fast_close_compressed (ctx);
464 + if (append == ci->close)
465 + mutt_message (_("Compressing %s..."), ctx->realpath);
467 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
470 + cmd = get_compression_cmd (append, ctx);
474 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
476 + mutt_perror (ctx->realpath);
480 + mutt_block_signals ();
481 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
484 + mutt_unblock_signals ();
485 + mutt_error _("Unable to lock mailbox!");
490 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
495 + if (append == ci->close)
496 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
498 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
500 + if (mutt_system (cmd))
502 + mutt_any_key_to_continue (NULL);
503 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
506 + mbox_unlock_compressed (ctx, fp);
507 + mutt_unblock_signals ();
512 + mbox_unlock_compressed (ctx, fp);
513 + mutt_unblock_signals ();
516 + restore_path (ctx);
518 + FREE (&ctx->compressinfo);
523 +#endif /* USE_COMPRESSED */
524 Index: mutt/compress.h
525 ===================================================================
526 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
527 +++ mutt/compress.h 2007-03-13 20:59:30.000000000 +0100
530 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
532 + * This program is free software; you can redistribute it and/or modify
533 + * it under the terms of the GNU General Public License as published by
534 + * the Free Software Foundation; either version 2 of the License, or
535 + * (at your option) any later version.
537 + * This program is distributed in the hope that it will be useful,
538 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
539 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
540 + * GNU General Public License for more details.
542 + * You should have received a copy of the GNU General Public License
543 + * along with this program; if not, write to the Free Software
544 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
547 +int mutt_can_read_compressed (const char *);
548 +int mutt_can_append_compressed (const char *);
549 +int mutt_open_read_compressed (CONTEXT *);
550 +int mutt_open_append_compressed (CONTEXT *);
551 +int mutt_slow_close_compressed (CONTEXT *);
552 +int mutt_sync_compressed (CONTEXT *);
553 +int mutt_test_compress_command (const char *);
554 +int mutt_check_mailbox_compressed (CONTEXT *);
555 +void mutt_fast_close_compressed (CONTEXT *);
556 Index: mutt/configure.in
557 ===================================================================
558 --- mutt.orig/configure.in 2007-03-13 20:53:07.000000000 +0100
559 +++ mutt/configure.in 2007-03-13 20:59:30.000000000 +0100
560 @@ -807,6 +807,11 @@ AC_ARG_ENABLE(locales-fix, AC_HELP_STRIN
561 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
564 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
565 + [if test x$enableval = xyes; then
566 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
569 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
570 [if test $withval != yes; then
571 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
572 Index: mutt/curs_main.c
573 ===================================================================
574 --- mutt.orig/curs_main.c 2007-03-13 20:53:07.000000000 +0100
575 +++ mutt/curs_main.c 2007-03-13 20:59:30.000000000 +0100
576 @@ -1090,6 +1090,11 @@ int mutt_index_menu (void)
580 +#ifdef USE_COMPRESSED
581 + if (Context->compressinfo && Context->realpath)
582 + mutt_str_replace (&LastFolder, Context->realpath);
585 mutt_str_replace (&LastFolder, Context->path);
586 oldcount = Context ? Context->msgcount : 0;
588 Index: mutt/doc/manual.xml.head
589 ===================================================================
590 --- mutt.orig/doc/manual.xml.head 2007-03-13 20:53:07.000000000 +0100
591 +++ mutt/doc/manual.xml.head 2007-03-13 20:59:30.000000000 +0100
592 @@ -4843,6 +4843,205 @@ becomes an issue as mutt will silently f
596 +<sect1 id="compressedfolders">
597 +<title>Compressed folders Support (OPTIONAL)</title>
600 +If Mutt was compiled with compressed folders support (by running the
601 +<emphasis>configure</emphasis> script with the
602 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
603 +stored in an arbitrary format, provided that the user has a script to
604 +convert from/to this format to one of the accepted.
606 +The most common use is to open compressed archived folders e.g. with
609 +In addition, the user can provide a script that gets a folder in an
610 +accepted format and appends its context to the folder in the
611 +user-defined format, which may be faster than converting the entire
612 +folder to the accepted format, appending to it and converting back to
613 +the user-defined format.
615 +There are three hooks defined (<link
616 +linkend="open-hook">open-hook</link>, <link
617 +linkend="close-hook">close-hook</link> and <link
618 +linkend="append-hook">append-hook</link>) which define commands to
619 +uncompress and compress a folder and to append messages to an existing
620 +compressed folder respectively.
625 +open-hook \\.gz$ "gzip -cd %f > %t"
626 +close-hook \\.gz$ "gzip -c %t > %f"
627 +append-hook \\.gz$ "gzip -c %t >> %f"
630 +You do not have to specify all of the commands. If you omit <link
631 +linkend="append-hook">append-hook</link>, the folder will be open and
632 +closed again each time you will add to it. If you omit <link
633 +linkend="close-hook">close-hook</link> (or give empty command) , the
634 +folder will be open in the mode. If you specify <link
635 +linkend="append-hook">append-hook</link> though you'll be able to
636 +append to the folder.
638 +Note that Mutt will only try to use hooks if the file is not in one of
639 +the accepted formats. In particular, if the file is empty, mutt
640 +supposes it is not compressed. This is important because it allows the
641 +use of programs that do not have well defined extensions. Just use
642 +"." as a regexp. But this may be surprising if your
643 +compressing script produces empty files. In this situation, unset
644 +<link linkend="save-empty">$save_empty</link>, so that
645 +the compressed file will be removed if you delete all of the messages.
648 +<sect2 id="open-hook">
649 +<title>Open a compressed mailbox for reading</title>
652 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
654 +The <emphasis>command</emphasis> is the command that can be used for
655 +opening the folders whose names match <emphasis>regexp</emphasis>.
657 +The <emphasis>command</emphasis> string is the printf-like format
658 +string, and it should accept two parameters: %f, which is
659 +replaced with the (compressed) folder name, and %t which is
660 +replaced with the name of the temporary folder to which to write.
662 +%f and %t can be repeated any number of times in the
663 +command string, and all of the entries are replaced with the
664 +appropriate folder name. In addition, %% is replaced by
665 +%, as in printf, and any other %anything is left as is.
667 +The <emphasis>command</emphasis> should <emphasis
668 +role="bold">not</emphasis> remove the original compressed file. The
669 +<emphasis>command</emphasis> should return non-zero exit status if it
670 +fails, so mutt knows something's wrong.
675 +open-hook \\.gz$ "gzip -cd %f > %t"
678 +If the <emphasis>command</emphasis> is empty, this operation is
679 +disabled for this file type.
683 +<sect2 id="close-hook">
684 +<title>Write a compressed mailbox</title>
687 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
689 +This is used to close the folder that was open with the <link
690 +linkend="open-hook">open-hook</link> command after some changes were
693 +The <emphasis>command</emphasis> string is the command that can be
694 +used for closing the folders whose names match
695 +<emphasis>regexp</emphasis>. It has the same format as in the <link
696 +linkend="open-hook">open-hook</link> command. Temporary folder in this
697 +case is the folder previously produced by the <link
698 +linkend="open-hook">open-hook</link> command.
700 +The <emphasis>command</emphasis> should <emphasis
701 +role="bold">not</emphasis> remove the decompressed file. The
702 +<emphasis>command</emphasis> should return non-zero exit status if it
703 +fails, so mutt knows something's wrong.
708 +close-hook \\.gz$ "gzip -c %t > %f"
711 +If the <emphasis>command</emphasis> is empty, this operation is
712 +disabled for this file type, and the file can only be open in the
715 +<link linkend="close-hook">close-hook</link> is not called when you
716 +exit from the folder if the folder was not changed.
720 +<sect2 id="append-hook">
721 +<title>Append a message to a compressed mailbox</title>
724 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
726 +This command is used for saving to an existing compressed folder. The
727 +<emphasis>command</emphasis> is the command that can be used for
728 +appending to the folders whose names match
729 +<emphasis>regexp</emphasis>. It has the same format as in the <link
730 +linkend="open-hook">open-hook</link> command. The temporary folder in
731 +this case contains the messages that are being appended.
733 +The <emphasis>command</emphasis> should <emphasis
734 +role="bold">not</emphasis> remove the decompressed file. The
735 +<emphasis>command</emphasis> should return non-zero exit status if it
736 +fails, so mutt knows something's wrong.
741 +append-hook \\.gz$ "gzip -c %t >> %f"
744 +When <link linkend="append-hook">append-hook</link> is used, the folder
745 +is not opened, which saves time, but this means that we can not find
746 +out what the folder type is. Thus the default (<link
747 +linkend="mbox-type">$mbox_type</link>) type is always
748 +supposed (i.e. this is the format used for the temporary folder).
750 +If the file does not exist when you save to it, <link
751 +linkend="close-hook">close-hook</link> is called, and not <link
752 +linkend="append-hook">append-hook</link>. <link
753 +linkend="append-hook">append-hook</link> is only for appending to
756 +If the <emphasis>command</emphasis> is empty, this operation is
757 +disabled for this file type. In this case, the folder will be open and
758 +closed again (using <link linkend="open-hook">open-hook</link> and
759 +<link linkend="close-hook">close-hook</link>respectively) each time you
765 +<title>Encrypted folders</title>
768 +The compressed folders support can also be used to handle encrypted
769 +folders. If you want to encrypt a folder with PGP, you may want to use
770 +the following hooks:
773 +open-hook \\.pgp$ "pgp -f < %f > %t"
774 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
777 +Please note, that PGP does not support appending to an encrypted
778 +folder, so there is no append-hook defined.
780 +If you are using GnuPG instead of PGP, you may use the following hooks
784 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
785 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
788 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
789 +decrypted in the /tmp directory, where it can be read by your system
790 +administrator. So think about the security aspects of this.
795 <chapter id="mimesupport">
796 <title>Mutt's MIME Support</title>
798 Index: mutt/doc/muttrc.man.head
799 ===================================================================
800 --- mutt.orig/doc/muttrc.man.head 2007-03-13 20:53:07.000000000 +0100
801 +++ mutt/doc/muttrc.man.head 2007-03-13 20:59:30.000000000 +0100
802 @@ -316,6 +316,24 @@ specify the ID of the public key to be u
803 to a certain recipient. The meaning of "key ID" is to be taken
804 broadly: This can be a different e-mail address, a numerical key ID,
805 or even just an arbitrary search string.
808 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
809 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
810 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
813 +These commands provide a way to handle compressed folders. The given
814 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
815 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
816 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
817 +compressed mail to a compressed folder (\fBappend-hook\fP). The
818 +\fIcommand\fP string is the
820 +like format string, and it should accept two parameters: \fB%f\fP,
821 +which is replaced with the (compressed) folder name, and \fB%t\fP
822 +which is replaced with the name of the temporary folder to which to
825 \fBpush\fP \fIstring\fP
826 This command adds the named \fIstring\fP to the keyboard buffer.
828 ===================================================================
829 --- mutt.orig/hook.c 2007-03-13 20:53:07.000000000 +0100
830 +++ mutt/hook.c 2007-03-13 21:00:40.000000000 +0100
833 #include "mutt_crypt.h"
835 +#ifdef USE_COMPRESSED
836 +#include "compress.h"
842 @@ -92,6 +96,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
843 memset (&pattern, 0, sizeof (pattern));
844 pattern.data = safe_strdup (path);
846 +#ifdef USE_COMPRESSED
847 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
849 + if (mutt_test_compress_command (command.data))
851 + strfcpy (err->data, _("bad formatted command string"), err->dsize);
856 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
857 && (!WithCrypto || !(data & M_CRYPTHOOK))
860 ===================================================================
861 --- mutt.orig/init.h 2007-03-13 20:53:07.000000000 +0100
862 +++ mutt/init.h 2007-03-13 20:59:30.000000000 +0100
863 @@ -3167,6 +3167,11 @@ struct command_t Commands[] = {
864 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
865 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
866 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
867 +#ifdef USE_COMPRESSED
868 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
869 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
870 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
872 { "group", parse_group, 0 },
873 { "ungroup", parse_ungroup, 0 },
874 { "hdr_order", parse_list, UL &HeaderOrderList },
876 ===================================================================
877 --- mutt.orig/main.c 2007-03-13 20:53:07.000000000 +0100
878 +++ mutt/main.c 2007-03-13 20:59:30.000000000 +0100
879 @@ -404,6 +404,12 @@ static void show_version (void)
884 +#ifdef USE_COMPRESSED
892 Index: mutt/Makefile.am
893 ===================================================================
894 --- mutt.orig/Makefile.am 2007-03-13 20:53:07.000000000 +0100
895 +++ mutt/Makefile.am 2007-03-13 20:59:30.000000000 +0100
896 @@ -18,7 +18,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.
897 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
898 mutt_SOURCES = $(BUILT_SOURCES) \
899 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
900 - crypt.c cryptglue.c \
901 + crypt.c cryptglue.c compress.c \
902 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
903 edit.c enter.c flags.c init.c filter.c from.c \
904 getdomain.c group.c \
905 @@ -66,7 +66,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
908 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
909 - configure account.h \
910 + configure account.h compress.h \
911 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
912 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
913 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
915 ===================================================================
916 --- mutt.orig/mbox.c 2007-03-13 20:53:07.000000000 +0100
917 +++ mutt/mbox.c 2007-03-13 20:59:30.000000000 +0100
920 #include "mutt_curses.h"
922 +#ifdef USE_COMPRESSED
923 +#include "compress.h"
926 #include <sys/stat.h>
929 @@ -1026,6 +1030,12 @@ bail: /* Come here in case of disaster
930 int mbox_close_mailbox (CONTEXT *ctx)
932 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
934 +#ifdef USE_COMPRESSED
935 + if (ctx->compressinfo)
936 + mutt_slow_close_compressed (ctx);
939 mutt_unblock_signals ();
940 mx_fastclose_mailbox (ctx);
943 ===================================================================
944 --- mutt.orig/mutt.h 2007-03-13 20:53:07.000000000 +0100
945 +++ mutt/mutt.h 2007-03-13 20:59:30.000000000 +0100
946 @@ -159,6 +159,11 @@ typedef enum
947 #define M_ACCOUNTHOOK (1<<9)
948 #define M_REPLYHOOK (1<<10)
949 #define M_SEND2HOOK (1<<11)
950 +#ifdef USE_COMPRESSED
951 +#define M_OPENHOOK (1<<12)
952 +#define M_APPENDHOOK (1<<13)
953 +#define M_CLOSEHOOK (1<<14)
956 /* tree characters for linearize_tree and print_enriched_string */
957 #define M_TREE_LLCORNER 1
958 @@ -882,6 +887,11 @@ typedef struct
959 void *data; /* driver specific data */
960 #endif /* USE_IMAP */
962 +#ifdef USE_COMPRESSED
963 + void *compressinfo; /* compressed mbox module private data */
964 + char *realpath; /* path to compressed mailbox */
965 +#endif /* USE_COMPRESSED */
967 short magic; /* mailbox type */
969 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
971 ===================================================================
972 --- mutt.orig/mx.c 2007-03-13 20:53:07.000000000 +0100
973 +++ mutt/mx.c 2007-03-13 20:59:30.000000000 +0100
978 +#ifdef USE_COMPRESSED
979 +#include "compress.h"
985 @@ -454,6 +458,10 @@ int mx_get_magic (const char *path)
989 +#ifdef USE_COMPRESSED
990 + if (magic == 0 && mutt_can_read_compressed (path))
991 + return M_COMPRESSED;
996 @@ -494,6 +502,13 @@ static int mx_open_mailbox_append (CONTE
1000 +#ifdef USE_COMPRESSED
1001 + /* special case for appending to compressed folders -
1002 + * even if we can not open them for reading */
1003 + if (mutt_can_append_compressed (ctx->path))
1004 + mutt_open_append_compressed (ctx);
1010 @@ -664,7 +679,12 @@ CONTEXT *mx_open_mailbox (const char *pa
1013 ctx->magic = mx_get_magic (path);
1016 +#ifdef USE_COMPRESSED
1017 + if (ctx->magic == M_COMPRESSED)
1018 + mutt_open_read_compressed (ctx);
1022 mutt_error (_("%s is not a mailbox."), path);
1024 @@ -770,6 +790,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
1025 mutt_free_header (&ctx->hdrs[i]);
1028 +#ifdef USE_COMPRESSED
1029 + if (ctx->compressinfo)
1030 + mutt_fast_close_compressed (ctx);
1033 FREE (&ctx->pattern);
1034 if (ctx->limit_pattern)
1035 @@ -827,6 +851,12 @@ static int sync_mailbox (CONTEXT *ctx, i
1036 if (tmp && tmp->new == 0)
1037 mutt_update_mailbox (tmp);
1040 +#ifdef USE_COMPRESSED
1041 + if (rc == 0 && ctx->compressinfo)
1042 + return mutt_sync_compressed (ctx);
1048 @@ -1028,6 +1058,11 @@ int mx_close_mailbox (CONTEXT *ctx, int
1049 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1050 mx_unlink_empty (ctx->path);
1052 +#ifdef USE_COMPRESSED
1053 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1057 mx_fastclose_mailbox (ctx);
1060 @@ -1342,6 +1377,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
1064 +#ifdef USE_COMPRESSED
1065 + if (ctx->compressinfo)
1066 + return mutt_check_mailbox_compressed (ctx);
1071 if (ctx->locked) lock = 0;
1073 ===================================================================
1074 --- mutt.orig/mx.h 2007-03-13 20:53:07.000000000 +0100
1075 +++ mutt/mx.h 2007-03-13 20:59:30.000000000 +0100
1076 @@ -40,6 +40,9 @@ enum
1080 +#ifdef USE_COMPRESSED
1085 WHERE short DefaultMagic INITVAL (M_MBOX);
1087 ===================================================================
1088 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1089 +++ mutt/PATCHES 2007-03-13 20:59:30.000000000 +0100
1091 +patch-1.5.14.rr.compressed.1
1092 Index: mutt/po/de.po
1093 ===================================================================
1094 --- mutt.orig/po/de.po 2007-03-13 20:53:07.000000000 +0100
1095 +++ mutt/po/de.po 2007-03-13 20:59:30.000000000 +0100
1096 @@ -1266,6 +1266,48 @@ msgstr "Prüfung des Absenders fehlgeschl
1097 msgid "Failed to figure out sender"
1098 msgstr "Kann Absender nicht ermitteln"
1100 +#: compress.c:203 mbox.c:661
1101 +msgid "Mailbox was corrupted!"
1102 +msgstr "Mailbox wurde zerstört!"
1104 +#: compress.c:228 compress.c:253
1106 +msgid "Decompressing %s...\n"
1107 +msgstr "Entpacke %s...\n"
1109 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1110 +msgid "Unable to lock mailbox!"
1111 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1115 +msgid "Error executing: %s : unable to open the mailbox!\n"
1116 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1118 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1120 +msgid "Compressing %s...\n"
1121 +msgstr "Komprimiere %s...\n"
1126 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1129 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1130 +"entpackte gespeichert!\n"
1132 +#: compress.c:425 compress.c:456
1134 +msgid "Compressed-appending to %s...\n"
1135 +msgstr "Hänge komprimiert an %s... an\n"
1139 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1140 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1144 msgid " (current time: %c)"
1145 @@ -1926,6 +1968,10 @@ msgstr ""
1147 msgstr "Hilfe für %s"
1150 +msgid "bad formatted command string"
1151 +msgstr "Hook enthält nicht die Muster %f und %t"
1155 msgid "unhook: Can't do unhook * from within a hook."
1156 @@ -3428,18 +3474,10 @@ msgstr "Lese %s..."
1157 msgid "Mailbox is corrupt!"
1158 msgstr "Mailbox fehlerhaft!"
1161 -msgid "Mailbox was corrupted!"
1162 -msgstr "Mailbox wurde zerstört!"
1164 #: mbox.c:711 mbox.c:964
1165 msgid "Fatal error! Could not reopen mailbox!"
1166 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1169 -msgid "Unable to lock mailbox!"
1170 -msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1172 #. this means ctx->changed or ctx->deleted was set, but no
1173 #. * messages were found to be changed or deleted. This should
1174 #. * never happen, is we presume it is a bug in mutt.
1175 Index: mutt/po/POTFILES.in
1176 ===================================================================
1177 --- mutt.orig/po/POTFILES.in 2007-03-13 20:53:07.000000000 +0100
1178 +++ mutt/po/POTFILES.in 2007-03-13 20:59:30.000000000 +0100
1179 @@ -8,6 +8,7 @@ charset.c
1187 Index: mutt/status.c
1188 ===================================================================
1189 --- mutt.orig/status.c 2007-03-13 20:53:07.000000000 +0100
1190 +++ mutt/status.c 2007-03-13 20:59:30.000000000 +0100
1191 @@ -97,6 +97,14 @@ status_format_str (char *buf, size_t buf
1194 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1195 +#ifdef USE_COMPRESSED
1196 + if (Context && Context->compressinfo && Context->realpath)
1198 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1199 + mutt_pretty_mailbox (tmp);
1203 if (Context && Context->path)
1205 strfcpy (tmp, Context->path, sizeof (tmp));