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.18.rr.compressed.1.gz
14 - 2008-05-20 myon: refreshed to remove hunks in auto* files
15 - 2009-09-15 myon: refreshed for mutt-1.5.19
16 status.c:103: add sizeof (tmp) to mutt_pretty_mailbox
17 - 2009-09-15 scotton: removed doc/Muttrc for mutt-1.5.19 (only patch doc/Muttrc.head)
24 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
26 + * This program is free software; you can redistribute it and/or modify
27 + * it under the terms of the GNU General Public License as published by
28 + * the Free Software Foundation; either version 2 of the License, or
29 + * (at your option) any later version.
31 + * This program is distributed in the hope that it will be useful,
32 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 + * GNU General Public License for more details.
36 + * You should have received a copy of the GNU General Public License
37 + * along with this program; if not, write to the Free Software
38 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
47 +#ifdef USE_COMPRESSED
51 +#include "mutt_curses.h"
56 +#include <sys/stat.h>
60 + const char *close; /* close-hook command */
61 + const char *open; /* open-hook command */
62 + const char *append; /* append-hook command */
63 + off_t size; /* size of real folder */
68 + * ctx - context to lock
69 + * excl - exclusive lock?
70 + * retry - should retry if unable to lock?
72 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
76 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
78 + else if (retry && !excl)
87 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
93 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
98 +static int is_new (const char *path)
100 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
103 +static const char* find_compress_hook (int type, const char *path)
105 + const char* c = mutt_find_hook (type, path);
106 + return (!c || !*c) ? NULL : c;
109 +int mutt_can_read_compressed (const char *path)
111 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
115 + * if the file is new, we really do not append, but create, and so use
116 + * close-hook, and not append-hook
118 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
120 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
121 + return (is_new (path)) ? ci->close : ci->append;
124 +int mutt_can_append_compressed (const char *path)
130 + char *dir_path = safe_strdup(path);
131 + char *aux = strrchr(dir_path, '/');
136 + if (access(dir_path, W_OK|X_OK))
139 + safe_free((void**)&dir_path);
140 + return dir_valid && (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
143 + magic = mx_get_magic (path);
145 + if (magic != 0 && magic != M_COMPRESSED)
148 + return (find_compress_hook (M_APPENDHOOK, path)
149 + || (find_compress_hook (M_OPENHOOK, path)
150 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
153 +/* open a compressed mailbox */
154 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
158 + /* Now lets uncompress this thing */
159 + ci = safe_malloc (sizeof (COMPRESS_INFO));
160 + ctx->compressinfo = (void*) ci;
161 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
162 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
163 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
167 +static void set_path (CONTEXT* ctx)
169 + char tmppath[_POSIX_PATH_MAX];
171 + /* Setup the right paths */
172 + ctx->realpath = ctx->path;
174 + /* Uncompress to /tmp */
175 + mutt_mktemp (tmppath);
176 + ctx->path = safe_malloc (strlen (tmppath) + 1);
177 + strcpy (ctx->path, tmppath);
180 +static int get_size (const char* path)
183 + if (stat (path, &sb) != 0)
185 + return (sb.st_size);
188 +static void store_size (CONTEXT* ctx)
190 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
191 + ci->size = get_size (ctx->realpath);
195 +compresshook_format_str (char *dest, size_t destlen, size_t col, char op,
196 + const char *src, const char *fmt,
197 + const char *ifstring, const char *elsestring,
198 + unsigned long data, format_flag flags)
200 + char tmp[SHORT_STRING];
202 + CONTEXT *ctx = (CONTEXT *) data;
206 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
207 + snprintf (dest, destlen, tmp, ctx->realpath);
210 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
211 + snprintf (dest, destlen, tmp, ctx->path);
218 + * check that the command has both %f and %t
219 + * 0 means OK, -1 means error
221 +int mutt_test_compress_command (const char* cmd)
223 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
226 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
228 + char expanded[_POSIX_PATH_MAX];
229 + mutt_FormatString (expanded, sizeof (expanded), 0, cmd,
230 + compresshook_format_str, (unsigned long) ctx, 0);
231 + return safe_strdup (expanded);
234 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
236 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
237 + if (ci->size != get_size (ctx->realpath))
239 + FREE (&ctx->compressinfo);
240 + FREE (&ctx->realpath);
241 + mutt_error _("Mailbox was corrupted!");
247 +int mutt_open_read_compressed (CONTEXT *ctx)
253 + COMPRESS_INFO *ci = set_compress_info (ctx);
256 + FREE (&ctx->compressinfo);
259 + if (!ci->close || access (ctx->path, W_OK) != 0)
266 + mutt_message (_("Decompressing %s..."), ctx->realpath);
268 + cmd = get_compression_cmd (ci->open, ctx);
271 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
273 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
275 + mutt_perror (ctx->realpath);
279 + mutt_block_signals ();
280 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
283 + mutt_unblock_signals ();
284 + mutt_error _("Unable to lock mailbox!");
291 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
292 + rc = mutt_system (cmd);
293 + mbox_unlock_compressed (ctx, fp);
294 + mutt_unblock_signals ();
299 + mutt_any_key_to_continue (NULL);
301 + FREE (&ctx->compressinfo);
302 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
308 + if (mutt_check_mailbox_compressed (ctx))
311 + ctx->magic = mx_get_magic (ctx->path);
316 +void restore_path (CONTEXT* ctx)
319 + ctx->path = ctx->realpath;
322 +/* remove the temporary mailbox */
323 +void remove_file (CONTEXT* ctx)
325 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
326 + remove (ctx->path);
329 +int mutt_open_append_compressed (CONTEXT *ctx)
332 + COMPRESS_INFO *ci = set_compress_info (ctx);
334 + if (!get_append_command (ctx->path, ctx))
336 + if (ci->open && ci->close)
337 + return (mutt_open_read_compressed (ctx));
340 + FREE (&ctx->compressinfo);
346 + ctx->magic = DefaultMagic;
348 + if (!is_new (ctx->realpath))
349 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
350 + if ((fh = fopen (ctx->path, "w")))
352 + /* No error checking - the parent function will catch it */
357 +/* close a compressed mailbox */
358 +void mutt_fast_close_compressed (CONTEXT *ctx)
360 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
363 + if (ctx->compressinfo)
368 + /* if the folder was removed, remove the gzipped folder too */
369 + if ((ctx->magic > 0)
370 + && (access (ctx->path, F_OK) != 0)
371 + && ! option (OPTSAVEEMPTY))
372 + remove (ctx->realpath);
376 + restore_path (ctx);
377 + FREE (&ctx->compressinfo);
381 +/* return 0 on success, -1 on failure */
382 +int mutt_sync_compressed (CONTEXT* ctx)
387 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
390 + mutt_message (_("Compressing %s..."), ctx->realpath);
392 + cmd = get_compression_cmd (ci->close, ctx);
396 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
398 + mutt_perror (ctx->realpath);
402 + mutt_block_signals ();
403 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
406 + mutt_unblock_signals ();
407 + mutt_error _("Unable to lock mailbox!");
413 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
417 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
418 + if (mutt_system (cmd))
420 + mutt_any_key_to_continue (NULL);
421 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
425 + mbox_unlock_compressed (ctx, fp);
426 + mutt_unblock_signals ();
436 +int mutt_slow_close_compressed (CONTEXT *ctx)
439 + const char *append;
441 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
443 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
447 + && ((append = get_append_command (ctx->realpath, ctx))
448 + || (append = ci->close))))
450 + /* if we can not or should not append, we only have to remove the */
451 + /* compressed info, because sync was already called */
452 + mutt_fast_close_compressed (ctx);
462 + if (append == ci->close)
463 + mutt_message (_("Compressing %s..."), ctx->realpath);
465 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
468 + cmd = get_compression_cmd (append, ctx);
472 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
474 + mutt_perror (ctx->realpath);
478 + mutt_block_signals ();
479 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
482 + mutt_unblock_signals ();
483 + mutt_error _("Unable to lock mailbox!");
488 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
493 + if (append == ci->close)
494 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
496 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
498 + if (mutt_system (cmd))
500 + mutt_any_key_to_continue (NULL);
501 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
504 + mbox_unlock_compressed (ctx, fp);
505 + mutt_unblock_signals ();
510 + mbox_unlock_compressed (ctx, fp);
511 + mutt_unblock_signals ();
514 + restore_path (ctx);
516 + FREE (&ctx->compressinfo);
521 +#endif /* USE_COMPRESSED */
526 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
528 + * This program is free software; you can redistribute it and/or modify
529 + * it under the terms of the GNU General Public License as published by
530 + * the Free Software Foundation; either version 2 of the License, or
531 + * (at your option) any later version.
533 + * This program is distributed in the hope that it will be useful,
534 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
535 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
536 + * GNU General Public License for more details.
538 + * You should have received a copy of the GNU General Public License
539 + * along with this program; if not, write to the Free Software
540 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
543 +int mutt_can_read_compressed (const char *);
544 +int mutt_can_append_compressed (const char *);
545 +int mutt_open_read_compressed (CONTEXT *);
546 +int mutt_open_append_compressed (CONTEXT *);
547 +int mutt_slow_close_compressed (CONTEXT *);
548 +int mutt_sync_compressed (CONTEXT *);
549 +int mutt_test_compress_command (const char *);
550 +int mutt_check_mailbox_compressed (CONTEXT *);
551 +void mutt_fast_close_compressed (CONTEXT *);
554 @@ -795,6 +795,11 @@ AC_ARG_ENABLE(locales-fix, AC_HELP_STRIN
555 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
558 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
559 + [if test x$enableval = xyes; then
560 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
563 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
564 [if test $withval != yes; then
565 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
568 @@ -1128,6 +1128,11 @@ int mutt_index_menu (void)
572 +#ifdef USE_COMPRESSED
573 + if (Context->compressinfo && Context->realpath)
574 + mutt_str_replace (&LastFolder, Context->realpath);
577 mutt_str_replace (&LastFolder, Context->path);
578 oldcount = Context ? Context->msgcount : 0;
580 --- a/doc/manual.xml.head
581 +++ b/doc/manual.xml.head
582 @@ -5160,6 +5160,205 @@ macro pager \cb |urlview\n
586 +<sect1 id="compressedfolders">
587 +<title>Compressed folders Support (OPTIONAL)</title>
590 +If Mutt was compiled with compressed folders support (by running the
591 +<emphasis>configure</emphasis> script with the
592 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
593 +stored in an arbitrary format, provided that the user has a script to
594 +convert from/to this format to one of the accepted.
596 +The most common use is to open compressed archived folders e.g. with
599 +In addition, the user can provide a script that gets a folder in an
600 +accepted format and appends its context to the folder in the
601 +user-defined format, which may be faster than converting the entire
602 +folder to the accepted format, appending to it and converting back to
603 +the user-defined format.
605 +There are three hooks defined (<link
606 +linkend="open-hook">open-hook</link>, <link
607 +linkend="close-hook">close-hook</link> and <link
608 +linkend="append-hook">append-hook</link>) which define commands to
609 +uncompress and compress a folder and to append messages to an existing
610 +compressed folder respectively.
615 +open-hook \\.gz$ "gzip -cd %f > %t"
616 +close-hook \\.gz$ "gzip -c %t > %f"
617 +append-hook \\.gz$ "gzip -c %t >> %f"
620 +You do not have to specify all of the commands. If you omit <link
621 +linkend="append-hook">append-hook</link>, the folder will be open and
622 +closed again each time you will add to it. If you omit <link
623 +linkend="close-hook">close-hook</link> (or give empty command) , the
624 +folder will be open in the mode. If you specify <link
625 +linkend="append-hook">append-hook</link> though you'll be able to
626 +append to the folder.
628 +Note that Mutt will only try to use hooks if the file is not in one of
629 +the accepted formats. In particular, if the file is empty, mutt
630 +supposes it is not compressed. This is important because it allows the
631 +use of programs that do not have well defined extensions. Just use
632 +"." as a regexp. But this may be surprising if your
633 +compressing script produces empty files. In this situation, unset
634 +<link linkend="save-empty">$save_empty</link>, so that
635 +the compressed file will be removed if you delete all of the messages.
638 +<sect2 id="open-hook">
639 +<title>Open a compressed mailbox for reading</title>
642 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
644 +The <emphasis>command</emphasis> is the command that can be used for
645 +opening the folders whose names match <emphasis>regexp</emphasis>.
647 +The <emphasis>command</emphasis> string is the printf-like format
648 +string, and it should accept two parameters: %f, which is
649 +replaced with the (compressed) folder name, and %t which is
650 +replaced with the name of the temporary folder to which to write.
652 +%f and %t can be repeated any number of times in the
653 +command string, and all of the entries are replaced with the
654 +appropriate folder name. In addition, %% is replaced by
655 +%, as in printf, and any other %anything is left as is.
657 +The <emphasis>command</emphasis> should <emphasis
658 +role="bold">not</emphasis> remove the original compressed file. The
659 +<emphasis>command</emphasis> should return non-zero exit status if it
660 +fails, so mutt knows something's wrong.
665 +open-hook \\.gz$ "gzip -cd %f > %t"
668 +If the <emphasis>command</emphasis> is empty, this operation is
669 +disabled for this file type.
673 +<sect2 id="close-hook">
674 +<title>Write a compressed mailbox</title>
677 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
679 +This is used to close the folder that was open with the <link
680 +linkend="open-hook">open-hook</link> command after some changes were
683 +The <emphasis>command</emphasis> string is the command that can be
684 +used for closing the folders whose names match
685 +<emphasis>regexp</emphasis>. It has the same format as in the <link
686 +linkend="open-hook">open-hook</link> command. Temporary folder in this
687 +case is the folder previously produced by the <link
688 +linkend="open-hook">open-hook</link> command.
690 +The <emphasis>command</emphasis> should <emphasis
691 +role="bold">not</emphasis> remove the decompressed file. The
692 +<emphasis>command</emphasis> should return non-zero exit status if it
693 +fails, so mutt knows something's wrong.
698 +close-hook \\.gz$ "gzip -c %t > %f"
701 +If the <emphasis>command</emphasis> is empty, this operation is
702 +disabled for this file type, and the file can only be open in the
705 +<link linkend="close-hook">close-hook</link> is not called when you
706 +exit from the folder if the folder was not changed.
710 +<sect2 id="append-hook">
711 +<title>Append a message to a compressed mailbox</title>
714 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
716 +This command is used for saving to an existing compressed folder. The
717 +<emphasis>command</emphasis> is the command that can be used for
718 +appending to the folders whose names match
719 +<emphasis>regexp</emphasis>. It has the same format as in the <link
720 +linkend="open-hook">open-hook</link> command. The temporary folder in
721 +this case contains the messages that are being appended.
723 +The <emphasis>command</emphasis> should <emphasis
724 +role="bold">not</emphasis> remove the decompressed file. The
725 +<emphasis>command</emphasis> should return non-zero exit status if it
726 +fails, so mutt knows something's wrong.
731 +append-hook \\.gz$ "gzip -c %t >> %f"
734 +When <link linkend="append-hook">append-hook</link> is used, the folder
735 +is not opened, which saves time, but this means that we can not find
736 +out what the folder type is. Thus the default (<link
737 +linkend="mbox-type">$mbox_type</link>) type is always
738 +supposed (i.e. this is the format used for the temporary folder).
740 +If the file does not exist when you save to it, <link
741 +linkend="close-hook">close-hook</link> is called, and not <link
742 +linkend="append-hook">append-hook</link>. <link
743 +linkend="append-hook">append-hook</link> is only for appending to
746 +If the <emphasis>command</emphasis> is empty, this operation is
747 +disabled for this file type. In this case, the folder will be open and
748 +closed again (using <link linkend="open-hook">open-hook</link> and
749 +<link linkend="close-hook">close-hook</link>respectively) each time you
755 +<title>Encrypted folders</title>
758 +The compressed folders support can also be used to handle encrypted
759 +folders. If you want to encrypt a folder with PGP, you may want to use
760 +the following hooks:
763 +open-hook \\.pgp$ "pgp -f < %f > %t"
764 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
767 +Please note, that PGP does not support appending to an encrypted
768 +folder, so there is no append-hook defined.
770 +If you are using GnuPG instead of PGP, you may use the following hooks
774 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
775 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
778 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
779 +decrypted in the /tmp directory, where it can be read by your system
780 +administrator. So think about the security aspects of this.
785 <chapter id="mimesupport">
786 <title>Mutt's MIME Support</title>
788 --- a/doc/Muttrc.head
789 +++ b/doc/Muttrc.head
790 @@ -29,6 +29,11 @@ macro generic,pager <F1> "<shell-escape>
791 macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
794 +# Use folders which match on \\.gz$ as gzipped folders:
795 +# open-hook \\.gz$ "gzip -cd %f > %t"
796 +# close-hook \\.gz$ "gzip -c %t > %f"
797 +# append-hook \\.gz$ "gzip -c %t >> %f"
799 # If Mutt is unable to determine your site's domain name correctly, you can
800 # set the default here.
802 --- a/doc/muttrc.man.head
803 +++ b/doc/muttrc.man.head
804 @@ -345,6 +345,24 @@ specify the ID of the public key to be u
805 to a certain recipient. The meaning of "key ID" is to be taken
806 broadly: This can be a different e-mail address, a numerical key ID,
807 or even just an arbitrary search string.
810 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
811 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
812 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
815 +These commands provide a way to handle compressed folders. The given
816 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
817 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
818 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
819 +compressed mail to a compressed folder (\fBappend-hook\fP). The
820 +\fIcommand\fP string is the
822 +like format string, and it should accept two parameters: \fB%f\fP,
823 +which is replaced with the (compressed) folder name, and \fB%t\fP
824 +which is replaced with the name of the temporary folder to which to
827 \fBpush\fP \fIstring\fP
828 This command adds the named \fIstring\fP to the keyboard buffer.
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, _("badly formatted command string"), err->dsize);
856 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
857 && (!WithCrypto || !(data & M_CRYPTHOOK))
861 @@ -3452,6 +3452,11 @@ struct command_t Commands[] = {
862 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
863 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
864 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
865 +#ifdef USE_COMPRESSED
866 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
867 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
868 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
870 { "group", parse_group, 0 },
871 { "ungroup", parse_ungroup, 0 },
872 { "hdr_order", parse_list, UL &HeaderOrderList },
875 @@ -402,6 +402,12 @@ static void show_version (void)
880 +#ifdef USE_COMPRESSED
890 @@ -18,7 +18,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.
891 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
893 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
894 - crypt.c cryptglue.c \
895 + crypt.c cryptglue.c compress.c \
896 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
897 edit.c enter.c flags.c init.c filter.c from.c \
898 getdomain.c group.c \
899 @@ -57,7 +57,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c
900 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
902 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
903 - configure account.h \
904 + configure account.h compress.h \
905 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
906 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
907 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
912 #include "mutt_curses.h"
914 +#ifdef USE_COMPRESSED
915 +#include "compress.h"
918 #include <sys/stat.h>
921 @@ -1038,6 +1042,12 @@ bail: /* Come here in case of disaster
922 int mbox_close_mailbox (CONTEXT *ctx)
924 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
926 +#ifdef USE_COMPRESSED
927 + if (ctx->compressinfo)
928 + mutt_slow_close_compressed (ctx);
931 mutt_unblock_signals ();
932 mx_fastclose_mailbox (ctx);
936 @@ -140,6 +140,11 @@ typedef enum
937 #define M_ACCOUNTHOOK (1<<9)
938 #define M_REPLYHOOK (1<<10)
939 #define M_SEND2HOOK (1<<11)
940 +#ifdef USE_COMPRESSED
941 +#define M_OPENHOOK (1<<12)
942 +#define M_APPENDHOOK (1<<13)
943 +#define M_CLOSEHOOK (1<<14)
946 /* tree characters for linearize_tree and print_enriched_string */
947 #define M_TREE_LLCORNER 1
948 @@ -872,6 +877,11 @@ typedef struct _context
949 int flagged; /* how many flagged messages */
950 int msgnotreadyet; /* which msg "new" in pager, -1 if none */
952 +#ifdef USE_COMPRESSED
953 + void *compressinfo; /* compressed mbox module private data */
954 + char *realpath; /* path to compressed mailbox */
955 +#endif /* USE_COMPRESSED */
957 short magic; /* mailbox type */
959 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
966 +#ifdef USE_COMPRESSED
967 +#include "compress.h"
973 @@ -445,6 +449,10 @@ int mx_get_magic (const char *path)
977 +#ifdef USE_COMPRESSED
978 + if (magic == 0 && mutt_can_read_compressed (path))
979 + return M_COMPRESSED;
984 @@ -484,6 +492,13 @@ static int mx_open_mailbox_append (CONTE
988 +#ifdef USE_COMPRESSED
989 + /* special case for appending to compressed folders -
990 + * even if we can not open them for reading */
991 + if (mutt_can_append_compressed (ctx->path))
992 + mutt_open_append_compressed (ctx);
998 @@ -647,7 +662,12 @@ CONTEXT *mx_open_mailbox (const char *pa
1001 ctx->magic = mx_get_magic (path);
1004 +#ifdef USE_COMPRESSED
1005 + if (ctx->magic == M_COMPRESSED)
1006 + mutt_open_read_compressed (ctx);
1010 mutt_error (_("%s is not a mailbox."), path);
1012 @@ -748,6 +768,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
1013 mutt_free_header (&ctx->hdrs[i]);
1016 +#ifdef USE_COMPRESSED
1017 + if (ctx->compressinfo)
1018 + mutt_fast_close_compressed (ctx);
1021 FREE (&ctx->pattern);
1022 if (ctx->limit_pattern)
1023 @@ -800,6 +824,12 @@ static int sync_mailbox (CONTEXT *ctx, i
1025 if (tmp && tmp->new == 0)
1026 mutt_update_mailbox (tmp);
1028 +#ifdef USE_COMPRESSED
1029 + if (rc == 0 && ctx->compressinfo)
1030 + return mutt_sync_compressed (ctx);
1036 @@ -1058,6 +1088,11 @@ int mx_close_mailbox (CONTEXT *ctx, int
1037 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1038 mx_unlink_empty (ctx->path);
1040 +#ifdef USE_COMPRESSED
1041 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1045 mx_fastclose_mailbox (ctx);
1048 @@ -1373,6 +1408,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
1052 +#ifdef USE_COMPRESSED
1053 + if (ctx->compressinfo)
1054 + return mutt_check_mailbox_compressed (ctx);
1059 if (ctx->locked) lock = 0;
1062 @@ -40,6 +40,9 @@ enum
1066 +#ifdef USE_COMPRESSED
1071 WHERE short DefaultMagic INITVAL (M_MBOX);
1074 @@ -3,7 +3,7 @@ msgstr ""
1075 "Project-Id-Version: 1.5.18\n"
1076 "Report-Msgid-Bugs-To: \n"
1077 "POT-Creation-Date: 2009-01-05 16:36-0800\n"
1078 -"PO-Revision-Date: 2008-05-18 10:28+0200\n"
1079 +"PO-Revision-Date: 2009-01-15 23:09+0100\n"
1080 "Last-Translator: Roland Rosenfeld <roland@spinnaker.de>\n"
1081 "Language-Team: German <mutt-po@mutt.org>\n"
1082 "MIME-Version: 1.0\n"
1083 @@ -1975,6 +1975,10 @@ msgstr "Hilfe für %s"
1084 msgid "Bad history file format (line %d)"
1085 msgstr "Falsches Format der Datei früherer Eingaben (Zeile %d)"
1088 +msgid "badly formatted command string"
1089 +msgstr "Hook enthält nicht die Muster %f und %t"
1093 msgid "unhook: Can't do unhook * from within a hook."
1094 @@ -2718,18 +2722,10 @@ msgstr "Lese %s..."
1095 msgid "Mailbox is corrupt!"
1096 msgstr "Mailbox fehlerhaft!"
1099 -msgid "Mailbox was corrupted!"
1100 -msgstr "Mailbox wurde zerstört!"
1102 #: mbox.c:719 mbox.c:976
1103 msgid "Fatal error! Could not reopen mailbox!"
1104 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1107 -msgid "Unable to lock mailbox!"
1108 -msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1110 #. this means ctx->changed or ctx->deleted was set, but no
1111 #. * messages were found to be changed or deleted. This should
1112 #. * never happen, is we presume it is a bug in mutt.
1113 @@ -5298,3 +5294,45 @@ msgstr "Zeige S/MIME Optionen"
1115 #~ msgid "Authentication method is unknown."
1116 #~ msgstr "Authentifizierungsmethode unbekannt."
1118 +#: compress.c:203 mbox.c:661
1119 +msgid "Mailbox was corrupted!"
1120 +msgstr "Mailbox wurde zerstört!"
1122 +#: compress.c:228 compress.c:253
1124 +msgid "Decompressing %s...\n"
1125 +msgstr "Entpacke %s...\n"
1127 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1128 +msgid "Unable to lock mailbox!"
1129 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1133 +msgid "Error executing: %s : unable to open the mailbox!\n"
1134 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1136 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1138 +msgid "Compressing %s...\n"
1139 +msgstr "Komprimiere %s...\n"
1144 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1147 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1148 +"entpackte gespeichert!\n"
1150 +#: compress.c:425 compress.c:456
1152 +msgid "Compressed-appending to %s...\n"
1153 +msgstr "Hänge komprimiert an %s... an\n"
1157 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1158 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1159 --- a/po/POTFILES.in
1160 +++ b/po/POTFILES.in
1161 @@ -8,6 +8,7 @@ charset.c
1171 @@ -96,6 +96,14 @@ status_format_str (char *buf, size_t buf
1174 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1175 +#ifdef USE_COMPRESSED
1176 + if (Context && Context->compressinfo && Context->realpath)
1178 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1179 + mutt_pretty_mailbox (tmp, sizeof (tmp));
1183 if (Context && Context->path)
1185 strfcpy (tmp, Context->path, sizeof (tmp));
1189 +patch-1.5.18.rr.compressed.1