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.11.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 - adjust the init.h hunk to the presence of group & ungroup
18 - 2006-07-15: adjust Makefile.am and doc/manual.xml.head to mutt-1.5.12
25 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
27 + * This program is free software; you can redistribute it and/or modify
28 + * it under the terms of the GNU General Public License as published by
29 + * the Free Software Foundation; either version 2 of the License, or
30 + * (at your option) any later version.
32 + * This program is distributed in the hope that it will be useful,
33 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 + * GNU General Public License for more details.
37 + * You should have received a copy of the GNU General Public License
38 + * along with this program; if not, write to the Free Software
39 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
48 +#ifdef USE_COMPRESSED
52 +#include "mutt_curses.h"
57 +#include <sys/stat.h>
61 + const char *close; /* close-hook command */
62 + const char *open; /* open-hook command */
63 + const char *append; /* append-hook command */
64 + off_t size; /* size of real folder */
69 + * ctx - context to lock
70 + * excl - exclusive lock?
71 + * retry - should retry if unable to lock?
73 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
77 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
79 + else if (retry && !excl)
88 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
94 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
99 +static int is_new (const char *path)
101 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
104 +static const char* find_compress_hook (int type, const char *path)
106 + const char* c = mutt_find_hook (type, path);
107 + return (!c || !*c) ? NULL : c;
110 +int mutt_can_read_compressed (const char *path)
112 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
116 + * if the file is new, we really do not append, but create, and so use
117 + * close-hook, and not append-hook
119 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
121 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
122 + return (is_new (path)) ? ci->close : ci->append;
125 +int mutt_can_append_compressed (const char *path)
130 + return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
132 + magic = mx_get_magic (path);
134 + if (magic != 0 && magic != M_COMPRESSED)
137 + return (find_compress_hook (M_APPENDHOOK, path)
138 + || (find_compress_hook (M_OPENHOOK, path)
139 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
142 +/* open a compressed mailbox */
143 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
147 + /* Now lets uncompress this thing */
148 + ci = safe_malloc (sizeof (COMPRESS_INFO));
149 + ctx->compressinfo = (void*) ci;
150 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
151 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
152 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
156 +static void set_path (CONTEXT* ctx)
158 + char tmppath[_POSIX_PATH_MAX];
160 + /* Setup the right paths */
161 + ctx->realpath = ctx->path;
163 + /* Uncompress to /tmp */
164 + mutt_mktemp (tmppath);
165 + ctx->path = safe_malloc (strlen (tmppath) + 1);
166 + strcpy (ctx->path, tmppath);
169 +static int get_size (const char* path)
172 + if (stat (path, &sb) != 0)
174 + return (sb.st_size);
177 +static void store_size (CONTEXT* ctx)
179 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
180 + ci->size = get_size (ctx->realpath);
184 +compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
185 + const char *fmt, const char *ifstring,
186 + const char *elsestring, unsigned long data,
189 + char tmp[SHORT_STRING];
191 + CONTEXT *ctx = (CONTEXT *) data;
195 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
196 + snprintf (dest, destlen, tmp, ctx->realpath);
199 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
200 + snprintf (dest, destlen, tmp, ctx->path);
207 + * check that the command has both %f and %t
208 + * 0 means OK, -1 means error
210 +int mutt_test_compress_command (const char* cmd)
212 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
215 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
217 + char expanded[_POSIX_PATH_MAX];
218 + mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str,
219 + (unsigned long) ctx, 0);
220 + return safe_strdup (expanded);
223 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
225 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
226 + if (ci->size != get_size (ctx->realpath))
228 + FREE (&ctx->compressinfo);
229 + FREE (&ctx->realpath);
230 + mutt_error _("Mailbox was corrupted!");
236 +int mutt_open_read_compressed (CONTEXT *ctx)
242 + COMPRESS_INFO *ci = set_compress_info (ctx);
245 + FREE (ctx->compressinfo);
248 + if (!ci->close || access (ctx->path, W_OK) != 0)
255 + mutt_message (_("Decompressing %s..."), ctx->realpath);
257 + cmd = get_compression_cmd (ci->open, ctx);
260 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
262 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
264 + mutt_perror (ctx->realpath);
268 + mutt_block_signals ();
269 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
272 + mutt_unblock_signals ();
273 + mutt_error _("Unable to lock mailbox!");
280 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
281 + rc = mutt_system (cmd);
282 + mbox_unlock_compressed (ctx, fp);
283 + mutt_unblock_signals ();
288 + mutt_any_key_to_continue (NULL);
290 + FREE (ctx->compressinfo);
291 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
297 + if (mutt_check_mailbox_compressed (ctx))
300 + ctx->magic = mx_get_magic (ctx->path);
305 +void restore_path (CONTEXT* ctx)
308 + ctx->path = ctx->realpath;
311 +/* remove the temporary mailbox */
312 +void remove_file (CONTEXT* ctx)
314 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
315 + remove (ctx->path);
318 +int mutt_open_append_compressed (CONTEXT *ctx)
321 + COMPRESS_INFO *ci = set_compress_info (ctx);
323 + if (!get_append_command (ctx->path, ctx))
325 + if (ci->open && ci->close)
326 + return (mutt_open_read_compressed (ctx));
329 + FREE (&ctx->compressinfo);
335 + ctx->magic = DefaultMagic;
337 + if (!is_new (ctx->realpath))
338 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
339 + if ((fh = fopen (ctx->path, "w")))
341 + /* No error checking - the parent function will catch it */
346 +/* close a compressed mailbox */
347 +void mutt_fast_close_compressed (CONTEXT *ctx)
349 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
352 + if (ctx->compressinfo)
357 + /* if the folder was removed, remove the gzipped folder too */
358 + if ((ctx->magic > 0)
359 + && (access (ctx->path, F_OK) != 0)
360 + && ! option (OPTSAVEEMPTY))
361 + remove (ctx->realpath);
365 + restore_path (ctx);
366 + FREE (&ctx->compressinfo);
370 +/* return 0 on success, -1 on failure */
371 +int mutt_sync_compressed (CONTEXT* ctx)
376 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
379 + mutt_message (_("Compressing %s..."), ctx->realpath);
381 + cmd = get_compression_cmd (ci->close, ctx);
385 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
387 + mutt_perror (ctx->realpath);
391 + mutt_block_signals ();
392 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
395 + mutt_unblock_signals ();
396 + mutt_error _("Unable to lock mailbox!");
402 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
406 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
407 + if (mutt_system (cmd))
409 + mutt_any_key_to_continue (NULL);
410 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
414 + mbox_unlock_compressed (ctx, fp);
415 + mutt_unblock_signals ();
425 +int mutt_slow_close_compressed (CONTEXT *ctx)
428 + const char *append;
430 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
432 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
436 + && ((append = get_append_command (ctx->realpath, ctx))
437 + || (append = ci->close))))
439 + /* if we can not or should not append, we only have to remove the */
440 + /* compressed info, because sync was already called */
441 + mutt_fast_close_compressed (ctx);
451 + if (append == ci->close)
452 + mutt_message (_("Compressing %s..."), ctx->realpath);
454 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
457 + cmd = get_compression_cmd (append, ctx);
461 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
463 + mutt_perror (ctx->realpath);
467 + mutt_block_signals ();
468 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
471 + mutt_unblock_signals ();
472 + mutt_error _("Unable to lock mailbox!");
477 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
482 + if (append == ci->close)
483 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
485 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
487 + if (mutt_system (cmd))
489 + mutt_any_key_to_continue (NULL);
490 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
493 + mbox_unlock_compressed (ctx, fp);
494 + mutt_unblock_signals ();
499 + mbox_unlock_compressed (ctx, fp);
500 + mutt_unblock_signals ();
503 + restore_path (ctx);
505 + FREE (&ctx->compressinfo);
510 +#endif /* USE_COMPRESSED */
515 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
517 + * This program is free software; you can redistribute it and/or modify
518 + * it under the terms of the GNU General Public License as published by
519 + * the Free Software Foundation; either version 2 of the License, or
520 + * (at your option) any later version.
522 + * This program is distributed in the hope that it will be useful,
523 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
524 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
525 + * GNU General Public License for more details.
527 + * You should have received a copy of the GNU General Public License
528 + * along with this program; if not, write to the Free Software
529 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
532 +int mutt_can_read_compressed (const char *);
533 +int mutt_can_append_compressed (const char *);
534 +int mutt_open_read_compressed (CONTEXT *);
535 +int mutt_open_append_compressed (CONTEXT *);
536 +int mutt_slow_close_compressed (CONTEXT *);
537 +int mutt_sync_compressed (CONTEXT *);
538 +int mutt_test_compress_command (const char *);
539 +int mutt_check_mailbox_compressed (CONTEXT *);
540 +void mutt_fast_close_compressed (CONTEXT *);
541 --- configure.in.orig
544 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
547 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
548 + [if test x$enableval = xyes; then
549 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
552 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
553 [if test $withval != yes; then
554 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
557 @@ -1096,6 +1096,11 @@
561 +#ifdef USE_COMPRESSED
562 + if (Context->compressinfo && Context->realpath)
563 + mutt_str_replace (&LastFolder, Context->realpath);
566 mutt_str_replace (&LastFolder, Context->path);
567 oldcount = Context ? Context->msgcount : 0;
569 --- doc/manual.xml.head.orig
570 +++ doc/manual.xml.head
571 @@ -4745,6 +4745,205 @@
575 +<sect1 id="compressedfolders">
576 +<title>Compressed folders Support (OPTIONAL)</title>
579 +If Mutt was compiled with compressed folders support (by running the
580 +<emphasis>configure</emphasis> script with the
581 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
582 +stored in an arbitrary format, provided that the user has a script to
583 +convert from/to this format to one of the accepted.
585 +The most common use is to open compressed archived folders e.g. with
588 +In addition, the user can provide a script that gets a folder in an
589 +accepted format and appends its context to the folder in the
590 +user-defined format, which may be faster than converting the entire
591 +folder to the accepted format, appending to it and converting back to
592 +the user-defined format.
594 +There are three hooks defined (<link
595 +linkend="open-hook">open-hook</link>, <link
596 +linkend="close-hook">close-hook</link> and <link
597 +linkend="append-hook">append-hook</link>) which define commands to
598 +uncompress and compress a folder and to append messages to an existing
599 +compressed folder respectively.
604 +open-hook \\.gz$ "gzip -cd %f > %t"
605 +close-hook \\.gz$ "gzip -c %t > %f"
606 +append-hook \\.gz$ "gzip -c %t >> %f"
609 +You do not have to specify all of the commands. If you omit <link
610 +linkend="append-hook">append-hook</link>, the folder will be open and
611 +closed again each time you will add to it. If you omit <link
612 +linkend="close-hook">close-hook</link> (or give empty command) , the
613 +folder will be open in the mode. If you specify <link
614 +linkend="append-hook">append-hook</link> though you'll be able to
615 +append to the folder.
617 +Note that Mutt will only try to use hooks if the file is not in one of
618 +the accepted formats. In particular, if the file is empty, mutt
619 +supposes it is not compressed. This is important because it allows the
620 +use of programs that do not have well defined extensions. Just use
621 +"." as a regexp. But this may be surprising if your
622 +compressing script produces empty files. In this situation, unset
623 +<link linkend="save-empty">$save_empty</link>, so that
624 +the compressed file will be removed if you delete all of the messages.
627 +<sect2 id="open-hook">
628 +<title>Open a compressed mailbox for reading</title>
631 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
633 +The <emphasis>command</emphasis> is the command that can be used for
634 +opening the folders whose names match <emphasis>regexp</emphasis>.
636 +The <emphasis>command</emphasis> string is the printf-like format
637 +string, and it should accept two parameters: %f, which is
638 +replaced with the (compressed) folder name, and %t which is
639 +replaced with the name of the temporary folder to which to write.
641 +%f and %t can be repeated any number of times in the
642 +command string, and all of the entries are replaced with the
643 +appropriate folder name. In addition, %% is replaced by
644 +%, as in printf, and any other %anything is left as is.
646 +The <emphasis>command</emphasis> should <emphasis
647 +role="bold">not</emphasis> remove the original compressed file. The
648 +<emphasis>command</emphasis> should return non-zero exit status if it
649 +fails, so mutt knows something's wrong.
654 +open-hook \\.gz$ "gzip -cd %f > %t"
657 +If the <emphasis>command</emphasis> is empty, this operation is
658 +disabled for this file type.
662 +<sect2 id="close-hook">
663 +<title>Write a compressed mailbox</title>
666 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
668 +This is used to close the folder that was open with the <link
669 +linkend="open-hook">open-hook</link> command after some changes were
672 +The <emphasis>command</emphasis> string is the command that can be
673 +used for closing the folders whose names match
674 +<emphasis>regexp</emphasis>. It has the same format as in the <link
675 +linkend="open-hook">open-hook</link> command. Temporary folder in this
676 +case is the folder previously produced by the <link
677 +linkend="open-hook">open-hook</link> command.
679 +The <emphasis>command</emphasis> should <emphasis
680 +role="bold">not</emphasis> remove the decompressed file. The
681 +<emphasis>command</emphasis> should return non-zero exit status if it
682 +fails, so mutt knows something's wrong.
687 +close-hook \\.gz$ "gzip -c %t > %f"
690 +If the <emphasis>command</emphasis> is empty, this operation is
691 +disabled for this file type, and the file can only be open in the
694 +<link linkend="close-hook">close-hook</link> is not called when you
695 +exit from the folder if the folder was not changed.
699 +<sect2 id="append-hook">
700 +<title>Append a message to a compressed mailbox</title>
703 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
705 +This command is used for saving to an existing compressed folder. The
706 +<emphasis>command</emphasis> is the command that can be used for
707 +appending to the folders whose names match
708 +<emphasis>regexp</emphasis>. It has the same format as in the <link
709 +linkend="open-hook">open-hook</link> command. The temporary folder in
710 +this case contains the messages that are being appended.
712 +The <emphasis>command</emphasis> should <emphasis
713 +role="bold">not</emphasis> remove the decompressed file. The
714 +<emphasis>command</emphasis> should return non-zero exit status if it
715 +fails, so mutt knows something's wrong.
720 +append-hook \\.gz$ "gzip -c %t >> %f"
723 +When <link linkend="append-hook">append-hook</link> is used, the folder
724 +is not opened, which saves time, but this means that we can not find
725 +out what the folder type is. Thus the default (<link
726 +linkend="mbox-type">$mbox_type</link>) type is always
727 +supposed (i.e. this is the format used for the temporary folder).
729 +If the file does not exist when you save to it, <link
730 +linkend="close-hook">close-hook</link> is called, and not <link
731 +linkend="append-hook">append-hook</link>. <link
732 +linkend="append-hook">append-hook</link> is only for appending to
735 +If the <emphasis>command</emphasis> is empty, this operation is
736 +disabled for this file type. In this case, the folder will be open and
737 +closed again (using <link linkend="open-hook">open-hook</link> and
738 +<link linkend="close-hook">close-hook</link>respectively) each time you
744 +<title>Encrypted folders</title>
747 +The compressed folders support can also be used to handle encrypted
748 +folders. If you want to encrypt a folder with PGP, you may want to use
749 +the following hooks:
752 +open-hook \\.pgp$ "pgp -f < %f > %t"
753 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
756 +Please note, that PGP does not support appending to an encrypted
757 +folder, so there is no append-hook defined.
759 +If you are using GnuPG instead of PGP, you may use the following hooks
763 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
764 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
767 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
768 +decrypted in the /tmp directory, where it can be read by your system
769 +administrator. So think about the security aspects of this.
776 <chapter id="mimesupport">
777 --- doc/muttrc.man.head.orig
778 +++ doc/muttrc.man.head
780 to a certain recipient. The meaning of "key ID" is to be taken
781 broadly: This can be a different e-mail address, a numerical key ID,
782 or even just an arbitrary search string.
785 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
786 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
787 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
790 +These commands provide a way to handle compressed folders. The given
791 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
792 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
793 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
794 +compressed mail to a compressed folder (\fBappend-hook\fP). The
795 +\fIcommand\fP string is the
797 +like format string, and it should accept two parameters: \fB%f\fP,
798 +which is replaced with the (compressed) folder name, and \fB%t\fP
799 +which is replaced with the name of the temporary folder to which to
802 \fBpush\fP \fIstring\fP
803 This command adds the named \fIstring\fP to the keyboard buffer.
808 #include "mutt_crypt.h"
810 +#ifdef USE_COMPRESSED
811 +#include "compress.h"
818 memset (&pattern, 0, sizeof (pattern));
819 pattern.data = safe_strdup (path);
821 +#ifdef USE_COMPRESSED
822 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
824 + if (mutt_test_compress_command (command.data))
826 + strfcpy (err->data, _("bad formatted command string"), err->dsize);
831 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ACCOUNTHOOK))
832 && (!WithCrypto || !(data & M_CRYPTHOOK))
836 @@ -3108,6 +3108,11 @@
837 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
838 { "group", parse_group, 0 },
839 { "ungroup", parse_ungroup, 0 },
840 +#ifdef USE_COMPRESSED
841 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
842 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
843 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
845 { "hdr_order", parse_list, UL &HeaderOrderList },
847 { "iconv-hook", mutt_parse_hook, M_ICONVHOOK },
855 +#ifdef USE_COMPRESSED
866 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
867 mutt_SOURCES = $(BUILT_SOURCES) \
868 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
869 - crypt.c cryptglue.c \
870 + crypt.c cryptglue.c compress.c \
871 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
872 edit.c enter.c flags.c init.c filter.c from.c \
873 getdomain.c group.c \
875 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c
877 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
878 - configure account.h \
879 + configure account.h compress.h \
880 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
881 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
882 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
889 +#ifdef USE_COMPRESSED
890 +#include "compress.h"
893 #include <sys/stat.h>
896 @@ -1014,6 +1018,12 @@
897 int mbox_close_mailbox (CONTEXT *ctx)
899 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
901 +#ifdef USE_COMPRESSED
902 + if (ctx->compressinfo)
903 + mutt_slow_close_compressed (ctx);
906 mutt_unblock_signals ();
907 mx_fastclose_mailbox (ctx);
912 #define M_ACCOUNTHOOK (1<<9)
913 #define M_REPLYHOOK (1<<10)
914 #define M_SEND2HOOK (1<<11)
915 +#ifdef USE_COMPRESSED
916 +#define M_OPENHOOK (1<<12)
917 +#define M_APPENDHOOK (1<<13)
918 +#define M_CLOSEHOOK (1<<14)
921 /* tree characters for linearize_tree and print_enriched_string */
922 #define M_TREE_LLCORNER 1
924 void *data; /* driver specific data */
925 #endif /* USE_IMAP */
927 +#ifdef USE_COMPRESSED
928 + void *compressinfo; /* compressed mbox module private data */
929 + char *realpath; /* path to compressed mailbox */
930 +#endif /* USE_COMPRESSED */
932 short magic; /* mailbox type */
934 unsigned int locked : 1; /* is the mailbox locked? */
941 +#ifdef USE_COMPRESSED
942 +#include "compress.h"
952 +#ifdef USE_COMPRESSED
953 + if (magic == 0 && mutt_can_read_compressed (path))
954 + return M_COMPRESSED;
963 +#ifdef USE_COMPRESSED
964 + /* special case for appending to compressed folders -
965 + * even if we can not open them for reading */
966 + if (mutt_can_append_compressed (ctx->path))
967 + mutt_open_append_compressed (ctx);
976 ctx->magic = mx_get_magic (path);
979 +#ifdef USE_COMPRESSED
980 + if (ctx->magic == M_COMPRESSED)
981 + mutt_open_read_compressed (ctx);
985 mutt_error (_("%s is not a mailbox."), path);
988 mutt_free_header (&ctx->hdrs[i]);
991 +#ifdef USE_COMPRESSED
992 + if (ctx->compressinfo)
993 + mutt_fast_close_compressed (ctx);
996 FREE (&ctx->pattern);
997 if (ctx->limit_pattern)
999 if (tmp && tmp->new == 0)
1000 mutt_update_mailbox (tmp);
1003 +#ifdef USE_COMPRESSED
1004 + if (rc == 0 && ctx->compressinfo)
1005 + return mutt_sync_compressed (ctx);
1011 @@ -1017,6 +1047,11 @@
1012 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1013 mx_unlink_empty (ctx->path);
1015 +#ifdef USE_COMPRESSED
1016 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1020 mx_fastclose_mailbox (ctx);
1023 @@ -1326,6 +1361,11 @@
1027 +#ifdef USE_COMPRESSED
1028 + if (ctx->compressinfo)
1029 + return mutt_check_mailbox_compressed (ctx);
1034 if (ctx->locked) lock = 0;
1041 +#ifdef USE_COMPRESSED
1046 WHERE short DefaultMagic INITVAL (M_MBOX);
1050 +patch-1.5.11.rr.compressed.1
1051 patch-1.5.6.tt.assumed_charset.1
1052 patch-1.5.6.dw.maildir-mtime.1
1055 @@ -1262,6 +1262,48 @@
1056 msgid "Failed to figure out sender"
1057 msgstr "Kann Absender nicht ermitteln"
1059 +#: compress.c:203 mbox.c:661
1060 +msgid "Mailbox was corrupted!"
1061 +msgstr "Mailbox wurde zerstört!"
1063 +#: compress.c:228 compress.c:253
1065 +msgid "Decompressing %s...\n"
1066 +msgstr "Entpacke %s...\n"
1068 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1069 +msgid "Unable to lock mailbox!"
1070 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1074 +msgid "Error executing: %s : unable to open the mailbox!\n"
1075 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1077 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1079 +msgid "Compressing %s...\n"
1080 +msgstr "Komprimiere %s...\n"
1085 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1088 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1089 +"entpackte gespeichert!\n"
1091 +#: compress.c:425 compress.c:456
1093 +msgid "Compressed-appending to %s...\n"
1094 +msgstr "Hänge komprimiert an %s... an\n"
1098 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1099 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1103 msgid " (current time: %c)"
1104 @@ -1910,6 +1952,10 @@
1106 msgstr "Hilfe für %s"
1109 +msgid "bad formatted command string"
1110 +msgstr "Hook enthält nicht die Muster %f und %t"
1114 msgid "unhook: Can't do unhook * from within a hook."
1115 @@ -3424,18 +3470,10 @@
1116 msgid "Mailbox is corrupt!"
1117 msgstr "Mailbox fehlerhaft!"
1120 -msgid "Mailbox was corrupted!"
1121 -msgstr "Mailbox wurde zerstört!"
1123 #: mbox.c:701 mbox.c:952
1124 msgid "Fatal error! Could not reopen mailbox!"
1125 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1128 -msgid "Unable to lock mailbox!"
1129 -msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1131 #. this means ctx->changed or ctx->deleted was set, but no
1132 #. * messages were found to be changed or deleted. This should
1133 #. * never happen, is we presume it is a bug in mutt.
1134 --- po/POTFILES.in.orig
1149 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1150 +#ifdef USE_COMPRESSED
1151 + if (Context && Context->compressinfo && Context->realpath)
1153 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1154 + mutt_pretty_mailbox (tmp);
1158 if (Context && Context->path)
1160 strfcpy (tmp, Context->path, sizeof (tmp));