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
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 */
525 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
527 + * This program is free software; you can redistribute it and/or modify
528 + * it under the terms of the GNU General Public License as published by
529 + * the Free Software Foundation; either version 2 of the License, or
530 + * (at your option) any later version.
532 + * This program is distributed in the hope that it will be useful,
533 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
534 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
535 + * GNU General Public License for more details.
537 + * You should have received a copy of the GNU General Public License
538 + * along with this program; if not, write to the Free Software
539 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
542 +int mutt_can_read_compressed (const char *);
543 +int mutt_can_append_compressed (const char *);
544 +int mutt_open_read_compressed (CONTEXT *);
545 +int mutt_open_append_compressed (CONTEXT *);
546 +int mutt_slow_close_compressed (CONTEXT *);
547 +int mutt_sync_compressed (CONTEXT *);
548 +int mutt_test_compress_command (const char *);
549 +int mutt_check_mailbox_compressed (CONTEXT *);
550 +void mutt_fast_close_compressed (CONTEXT *);
553 @@ -795,6 +795,11 @@ AC_ARG_ENABLE(locales-fix, AC_HELP_STRIN
554 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
557 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
558 + [if test x$enableval = xyes; then
559 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
562 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
563 [if test $withval != yes; then
564 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
567 @@ -1128,6 +1128,11 @@ int mutt_index_menu (void)
571 +#ifdef USE_COMPRESSED
572 + if (Context->compressinfo && Context->realpath)
573 + mutt_str_replace (&LastFolder, Context->realpath);
576 mutt_str_replace (&LastFolder, Context->path);
577 oldcount = Context ? Context->msgcount : 0;
579 --- a/doc/manual.xml.head
580 +++ b/doc/manual.xml.head
581 @@ -5160,6 +5160,205 @@ macro pager \cb |urlview\n
585 +<sect1 id="compressedfolders">
586 +<title>Compressed folders Support (OPTIONAL)</title>
589 +If Mutt was compiled with compressed folders support (by running the
590 +<emphasis>configure</emphasis> script with the
591 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
592 +stored in an arbitrary format, provided that the user has a script to
593 +convert from/to this format to one of the accepted.
595 +The most common use is to open compressed archived folders e.g. with
598 +In addition, the user can provide a script that gets a folder in an
599 +accepted format and appends its context to the folder in the
600 +user-defined format, which may be faster than converting the entire
601 +folder to the accepted format, appending to it and converting back to
602 +the user-defined format.
604 +There are three hooks defined (<link
605 +linkend="open-hook">open-hook</link>, <link
606 +linkend="close-hook">close-hook</link> and <link
607 +linkend="append-hook">append-hook</link>) which define commands to
608 +uncompress and compress a folder and to append messages to an existing
609 +compressed folder respectively.
614 +open-hook \\.gz$ "gzip -cd %f > %t"
615 +close-hook \\.gz$ "gzip -c %t > %f"
616 +append-hook \\.gz$ "gzip -c %t >> %f"
619 +You do not have to specify all of the commands. If you omit <link
620 +linkend="append-hook">append-hook</link>, the folder will be open and
621 +closed again each time you will add to it. If you omit <link
622 +linkend="close-hook">close-hook</link> (or give empty command) , the
623 +folder will be open in the mode. If you specify <link
624 +linkend="append-hook">append-hook</link> though you'll be able to
625 +append to the folder.
627 +Note that Mutt will only try to use hooks if the file is not in one of
628 +the accepted formats. In particular, if the file is empty, mutt
629 +supposes it is not compressed. This is important because it allows the
630 +use of programs that do not have well defined extensions. Just use
631 +"." as a regexp. But this may be surprising if your
632 +compressing script produces empty files. In this situation, unset
633 +<link linkend="save-empty">$save_empty</link>, so that
634 +the compressed file will be removed if you delete all of the messages.
637 +<sect2 id="open-hook">
638 +<title>Open a compressed mailbox for reading</title>
641 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
643 +The <emphasis>command</emphasis> is the command that can be used for
644 +opening the folders whose names match <emphasis>regexp</emphasis>.
646 +The <emphasis>command</emphasis> string is the printf-like format
647 +string, and it should accept two parameters: %f, which is
648 +replaced with the (compressed) folder name, and %t which is
649 +replaced with the name of the temporary folder to which to write.
651 +%f and %t can be repeated any number of times in the
652 +command string, and all of the entries are replaced with the
653 +appropriate folder name. In addition, %% is replaced by
654 +%, as in printf, and any other %anything is left as is.
656 +The <emphasis>command</emphasis> should <emphasis
657 +role="bold">not</emphasis> remove the original compressed file. The
658 +<emphasis>command</emphasis> should return non-zero exit status if it
659 +fails, so mutt knows something's wrong.
664 +open-hook \\.gz$ "gzip -cd %f > %t"
667 +If the <emphasis>command</emphasis> is empty, this operation is
668 +disabled for this file type.
672 +<sect2 id="close-hook">
673 +<title>Write a compressed mailbox</title>
676 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
678 +This is used to close the folder that was open with the <link
679 +linkend="open-hook">open-hook</link> command after some changes were
682 +The <emphasis>command</emphasis> string is the command that can be
683 +used for closing the folders whose names match
684 +<emphasis>regexp</emphasis>. It has the same format as in the <link
685 +linkend="open-hook">open-hook</link> command. Temporary folder in this
686 +case is the folder previously produced by the <link
687 +linkend="open-hook">open-hook</link> command.
689 +The <emphasis>command</emphasis> should <emphasis
690 +role="bold">not</emphasis> remove the decompressed file. The
691 +<emphasis>command</emphasis> should return non-zero exit status if it
692 +fails, so mutt knows something's wrong.
697 +close-hook \\.gz$ "gzip -c %t > %f"
700 +If the <emphasis>command</emphasis> is empty, this operation is
701 +disabled for this file type, and the file can only be open in the
704 +<link linkend="close-hook">close-hook</link> is not called when you
705 +exit from the folder if the folder was not changed.
709 +<sect2 id="append-hook">
710 +<title>Append a message to a compressed mailbox</title>
713 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
715 +This command is used for saving to an existing compressed folder. The
716 +<emphasis>command</emphasis> is the command that can be used for
717 +appending to the folders whose names match
718 +<emphasis>regexp</emphasis>. It has the same format as in the <link
719 +linkend="open-hook">open-hook</link> command. The temporary folder in
720 +this case contains the messages that are being appended.
722 +The <emphasis>command</emphasis> should <emphasis
723 +role="bold">not</emphasis> remove the decompressed file. The
724 +<emphasis>command</emphasis> should return non-zero exit status if it
725 +fails, so mutt knows something's wrong.
730 +append-hook \\.gz$ "gzip -c %t >> %f"
733 +When <link linkend="append-hook">append-hook</link> is used, the folder
734 +is not opened, which saves time, but this means that we can not find
735 +out what the folder type is. Thus the default (<link
736 +linkend="mbox-type">$mbox_type</link>) type is always
737 +supposed (i.e. this is the format used for the temporary folder).
739 +If the file does not exist when you save to it, <link
740 +linkend="close-hook">close-hook</link> is called, and not <link
741 +linkend="append-hook">append-hook</link>. <link
742 +linkend="append-hook">append-hook</link> is only for appending to
745 +If the <emphasis>command</emphasis> is empty, this operation is
746 +disabled for this file type. In this case, the folder will be open and
747 +closed again (using <link linkend="open-hook">open-hook</link> and
748 +<link linkend="close-hook">close-hook</link>respectively) each time you
754 +<title>Encrypted folders</title>
757 +The compressed folders support can also be used to handle encrypted
758 +folders. If you want to encrypt a folder with PGP, you may want to use
759 +the following hooks:
762 +open-hook \\.pgp$ "pgp -f < %f > %t"
763 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
766 +Please note, that PGP does not support appending to an encrypted
767 +folder, so there is no append-hook defined.
769 +If you are using GnuPG instead of PGP, you may use the following hooks
773 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
774 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
777 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
778 +decrypted in the /tmp directory, where it can be read by your system
779 +administrator. So think about the security aspects of this.
784 <chapter id="mimesupport">
785 <title>Mutt's MIME Support</title>
789 @@ -29,6 +29,11 @@ macro generic,pager <F1> "<shell-escape>
790 macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
793 +# Use folders which match on \\.gz$ as gzipped folders:
794 +# open-hook \\.gz$ "gzip -cd %f > %t"
795 +# close-hook \\.gz$ "gzip -c %t > %f"
796 +# append-hook \\.gz$ "gzip -c %t >> %f"
798 # If Mutt is unable to determine your site's domain name correctly, you can
799 # set the default here.
801 --- a/doc/Muttrc.head
802 +++ b/doc/Muttrc.head
803 @@ -29,6 +29,11 @@ macro generic,pager <F1> "<shell-escape>
804 macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
807 +# Use folders which match on \\.gz$ as gzipped folders:
808 +# open-hook \\.gz$ "gzip -cd %f > %t"
809 +# close-hook \\.gz$ "gzip -c %t > %f"
810 +# append-hook \\.gz$ "gzip -c %t >> %f"
812 # If Mutt is unable to determine your site's domain name correctly, you can
813 # set the default here.
815 --- a/doc/muttrc.man.head
816 +++ b/doc/muttrc.man.head
817 @@ -345,6 +345,24 @@ specify the ID of the public key to be u
818 to a certain recipient. The meaning of "key ID" is to be taken
819 broadly: This can be a different e-mail address, a numerical key ID,
820 or even just an arbitrary search string.
823 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
824 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
825 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
828 +These commands provide a way to handle compressed folders. The given
829 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
830 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
831 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
832 +compressed mail to a compressed folder (\fBappend-hook\fP). The
833 +\fIcommand\fP string is the
835 +like format string, and it should accept two parameters: \fB%f\fP,
836 +which is replaced with the (compressed) folder name, and \fB%t\fP
837 +which is replaced with the name of the temporary folder to which to
840 \fBpush\fP \fIstring\fP
841 This command adds the named \fIstring\fP to the keyboard buffer.
846 #include "mutt_crypt.h"
848 +#ifdef USE_COMPRESSED
849 +#include "compress.h"
855 @@ -92,6 +96,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
856 memset (&pattern, 0, sizeof (pattern));
857 pattern.data = safe_strdup (path);
859 +#ifdef USE_COMPRESSED
860 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
862 + if (mutt_test_compress_command (command.data))
864 + strfcpy (err->data, _("badly formatted command string"), err->dsize);
869 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
870 && (!WithCrypto || !(data & M_CRYPTHOOK))
874 @@ -3452,6 +3452,11 @@ struct command_t Commands[] = {
875 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
876 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
877 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
878 +#ifdef USE_COMPRESSED
879 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
880 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
881 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
883 { "group", parse_group, 0 },
884 { "ungroup", parse_ungroup, 0 },
885 { "hdr_order", parse_list, UL &HeaderOrderList },
888 @@ -402,6 +402,12 @@ static void show_version (void)
893 +#ifdef USE_COMPRESSED
903 @@ -18,7 +18,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.
904 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
906 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
907 - crypt.c cryptglue.c \
908 + crypt.c cryptglue.c compress.c \
909 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
910 edit.c enter.c flags.c init.c filter.c from.c \
911 getdomain.c group.c \
912 @@ -57,7 +57,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c
913 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
915 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
916 - configure account.h \
917 + configure account.h compress.h \
918 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
919 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
920 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
925 #include "mutt_curses.h"
927 +#ifdef USE_COMPRESSED
928 +#include "compress.h"
931 #include <sys/stat.h>
934 @@ -1038,6 +1042,12 @@ bail: /* Come here in case of disaster
935 int mbox_close_mailbox (CONTEXT *ctx)
937 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
939 +#ifdef USE_COMPRESSED
940 + if (ctx->compressinfo)
941 + mutt_slow_close_compressed (ctx);
944 mutt_unblock_signals ();
945 mx_fastclose_mailbox (ctx);
949 @@ -140,6 +140,11 @@ typedef enum
950 #define M_ACCOUNTHOOK (1<<9)
951 #define M_REPLYHOOK (1<<10)
952 #define M_SEND2HOOK (1<<11)
953 +#ifdef USE_COMPRESSED
954 +#define M_OPENHOOK (1<<12)
955 +#define M_APPENDHOOK (1<<13)
956 +#define M_CLOSEHOOK (1<<14)
959 /* tree characters for linearize_tree and print_enriched_string */
960 #define M_TREE_LLCORNER 1
961 @@ -872,6 +877,11 @@ typedef struct _context
962 int flagged; /* how many flagged messages */
963 int msgnotreadyet; /* which msg "new" in pager, -1 if none */
965 +#ifdef USE_COMPRESSED
966 + void *compressinfo; /* compressed mbox module private data */
967 + char *realpath; /* path to compressed mailbox */
968 +#endif /* USE_COMPRESSED */
970 short magic; /* mailbox type */
972 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
979 +#ifdef USE_COMPRESSED
980 +#include "compress.h"
986 @@ -445,6 +449,10 @@ int mx_get_magic (const char *path)
990 +#ifdef USE_COMPRESSED
991 + if (magic == 0 && mutt_can_read_compressed (path))
992 + return M_COMPRESSED;
997 @@ -484,6 +492,13 @@ static int mx_open_mailbox_append (CONTE
1001 +#ifdef USE_COMPRESSED
1002 + /* special case for appending to compressed folders -
1003 + * even if we can not open them for reading */
1004 + if (mutt_can_append_compressed (ctx->path))
1005 + mutt_open_append_compressed (ctx);
1011 @@ -647,7 +662,12 @@ CONTEXT *mx_open_mailbox (const char *pa
1014 ctx->magic = mx_get_magic (path);
1017 +#ifdef USE_COMPRESSED
1018 + if (ctx->magic == M_COMPRESSED)
1019 + mutt_open_read_compressed (ctx);
1023 mutt_error (_("%s is not a mailbox."), path);
1025 @@ -748,6 +768,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
1026 mutt_free_header (&ctx->hdrs[i]);
1029 +#ifdef USE_COMPRESSED
1030 + if (ctx->compressinfo)
1031 + mutt_fast_close_compressed (ctx);
1034 FREE (&ctx->pattern);
1035 if (ctx->limit_pattern)
1036 @@ -800,6 +824,12 @@ static int sync_mailbox (CONTEXT *ctx, i
1038 if (tmp && tmp->new == 0)
1039 mutt_update_mailbox (tmp);
1041 +#ifdef USE_COMPRESSED
1042 + if (rc == 0 && ctx->compressinfo)
1043 + return mutt_sync_compressed (ctx);
1049 @@ -1058,6 +1088,11 @@ int mx_close_mailbox (CONTEXT *ctx, int
1050 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1051 mx_unlink_empty (ctx->path);
1053 +#ifdef USE_COMPRESSED
1054 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1058 mx_fastclose_mailbox (ctx);
1061 @@ -1373,6 +1408,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
1065 +#ifdef USE_COMPRESSED
1066 + if (ctx->compressinfo)
1067 + return mutt_check_mailbox_compressed (ctx);
1072 if (ctx->locked) lock = 0;
1075 @@ -40,6 +40,9 @@ enum
1079 +#ifdef USE_COMPRESSED
1084 WHERE short DefaultMagic INITVAL (M_MBOX);
1087 @@ -3,7 +3,7 @@ msgstr ""
1088 "Project-Id-Version: 1.5.18\n"
1089 "Report-Msgid-Bugs-To: \n"
1090 "POT-Creation-Date: 2009-01-05 16:36-0800\n"
1091 -"PO-Revision-Date: 2008-05-18 10:28+0200\n"
1092 +"PO-Revision-Date: 2009-01-15 23:09+0100\n"
1093 "Last-Translator: Roland Rosenfeld <roland@spinnaker.de>\n"
1094 "Language-Team: German <mutt-po@mutt.org>\n"
1095 "MIME-Version: 1.0\n"
1096 @@ -1975,6 +1975,10 @@ msgstr "Hilfe für %s"
1097 msgid "Bad history file format (line %d)"
1098 msgstr "Falsches Format der Datei früherer Eingaben (Zeile %d)"
1101 +msgid "badly formatted command string"
1102 +msgstr "Hook enthält nicht die Muster %f und %t"
1106 msgid "unhook: Can't do unhook * from within a hook."
1107 @@ -2718,18 +2722,10 @@ msgstr "Lese %s..."
1108 msgid "Mailbox is corrupt!"
1109 msgstr "Mailbox fehlerhaft!"
1112 -msgid "Mailbox was corrupted!"
1113 -msgstr "Mailbox wurde zerstört!"
1115 #: mbox.c:719 mbox.c:976
1116 msgid "Fatal error! Could not reopen mailbox!"
1117 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1120 -msgid "Unable to lock mailbox!"
1121 -msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1123 #. this means ctx->changed or ctx->deleted was set, but no
1124 #. * messages were found to be changed or deleted. This should
1125 #. * never happen, is we presume it is a bug in mutt.
1126 @@ -5298,3 +5294,45 @@ msgstr "Zeige S/MIME Optionen"
1128 #~ msgid "Authentication method is unknown."
1129 #~ msgstr "Authentifizierungsmethode unbekannt."
1131 +#: compress.c:203 mbox.c:661
1132 +msgid "Mailbox was corrupted!"
1133 +msgstr "Mailbox wurde zerstört!"
1135 +#: compress.c:228 compress.c:253
1137 +msgid "Decompressing %s...\n"
1138 +msgstr "Entpacke %s...\n"
1140 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1141 +msgid "Unable to lock mailbox!"
1142 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1146 +msgid "Error executing: %s : unable to open the mailbox!\n"
1147 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1149 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1151 +msgid "Compressing %s...\n"
1152 +msgstr "Komprimiere %s...\n"
1157 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1160 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1161 +"entpackte gespeichert!\n"
1163 +#: compress.c:425 compress.c:456
1165 +msgid "Compressed-appending to %s...\n"
1166 +msgstr "Hänge komprimiert an %s... an\n"
1170 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1171 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1172 --- a/po/POTFILES.in
1173 +++ b/po/POTFILES.in
1174 @@ -8,6 +8,7 @@ charset.c
1184 @@ -96,6 +96,14 @@ status_format_str (char *buf, size_t buf
1187 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1188 +#ifdef USE_COMPRESSED
1189 + if (Context && Context->compressinfo && Context->realpath)
1191 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1192 + mutt_pretty_mailbox (tmp, sizeof (tmp));
1196 if (Context && Context->path)
1198 strfcpy (tmp, Context->path, sizeof (tmp));
1202 +patch-1.5.18.rr.compressed.1