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)
18 - 2009-09-11 antonio: removed DefaultMagic, see 541360
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)
131 + char *dir_path = safe_strdup(path);
132 + char *aux = strrchr(dir_path, '/');
137 + if (access(dir_path, W_OK|X_OK))
140 + safe_free((void**)&dir_path);
141 + return dir_valid && (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
144 + magic = mx_get_magic (path);
146 + if (magic != 0 && magic != M_COMPRESSED)
149 + return (find_compress_hook (M_APPENDHOOK, path)
150 + || (find_compress_hook (M_OPENHOOK, path)
151 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
154 +/* open a compressed mailbox */
155 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
159 + /* Now lets uncompress this thing */
160 + ci = safe_malloc (sizeof (COMPRESS_INFO));
161 + ctx->compressinfo = (void*) ci;
162 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
163 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
164 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
168 +static void set_path (CONTEXT* ctx)
170 + char tmppath[_POSIX_PATH_MAX];
172 + /* Setup the right paths */
173 + ctx->realpath = ctx->path;
175 + /* Uncompress to /tmp */
176 + mutt_mktemp (tmppath);
177 + ctx->path = safe_malloc (strlen (tmppath) + 1);
178 + strcpy (ctx->path, tmppath);
181 +static int get_size (const char* path)
184 + if (stat (path, &sb) != 0)
186 + return (sb.st_size);
189 +static void store_size (CONTEXT* ctx)
191 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
192 + ci->size = get_size (ctx->realpath);
196 +compresshook_format_str (char *dest, size_t destlen, size_t col, char op,
197 + const char *src, const char *fmt,
198 + const char *ifstring, const char *elsestring,
199 + unsigned long data, format_flag flags)
201 + char tmp[SHORT_STRING];
203 + CONTEXT *ctx = (CONTEXT *) data;
207 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
208 + snprintf (dest, destlen, tmp, ctx->realpath);
211 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
212 + snprintf (dest, destlen, tmp, ctx->path);
219 + * check that the command has both %f and %t
220 + * 0 means OK, -1 means error
222 +int mutt_test_compress_command (const char* cmd)
224 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
227 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
229 + char expanded[_POSIX_PATH_MAX];
230 + mutt_FormatString (expanded, sizeof (expanded), 0, cmd,
231 + compresshook_format_str, (unsigned long) ctx, 0);
232 + return safe_strdup (expanded);
235 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
237 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
238 + if (ci->size != get_size (ctx->realpath))
240 + FREE (&ctx->compressinfo);
241 + FREE (&ctx->realpath);
242 + mutt_error _("Mailbox was corrupted!");
248 +int mutt_open_read_compressed (CONTEXT *ctx)
254 + COMPRESS_INFO *ci = set_compress_info (ctx);
257 + FREE (&ctx->compressinfo);
260 + if (!ci->close || access (ctx->path, W_OK) != 0)
267 + mutt_message (_("Decompressing %s..."), ctx->realpath);
269 + cmd = get_compression_cmd (ci->open, ctx);
272 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
274 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
276 + mutt_perror (ctx->realpath);
280 + mutt_block_signals ();
281 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
284 + mutt_unblock_signals ();
285 + mutt_error _("Unable to lock mailbox!");
292 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
293 + rc = mutt_system (cmd);
294 + mbox_unlock_compressed (ctx, fp);
295 + mutt_unblock_signals ();
300 + mutt_any_key_to_continue (NULL);
302 + FREE (&ctx->compressinfo);
303 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
309 + if (mutt_check_mailbox_compressed (ctx))
312 + ctx->magic = mx_get_magic (ctx->path);
317 +void restore_path (CONTEXT* ctx)
320 + ctx->path = ctx->realpath;
323 +/* remove the temporary mailbox */
324 +void remove_file (CONTEXT* ctx)
326 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
327 + remove (ctx->path);
330 +int mutt_open_append_compressed (CONTEXT *ctx)
333 + COMPRESS_INFO *ci = set_compress_info (ctx);
335 + if (!get_append_command (ctx->path, ctx))
337 + if (ci->open && ci->close)
338 + return (mutt_open_read_compressed (ctx));
341 + FREE (&ctx->compressinfo);
347 + if (!is_new (ctx->realpath))
348 + if ((fh = fopen (ctx->path, "w")))
350 + /* No error checking - the parent function will catch it */
355 +/* close a compressed mailbox */
356 +void mutt_fast_close_compressed (CONTEXT *ctx)
358 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
361 + if (ctx->compressinfo)
366 + /* if the folder was removed, remove the gzipped folder too */
367 + if ((ctx->magic > 0)
368 + && (access (ctx->path, F_OK) != 0)
369 + && ! option (OPTSAVEEMPTY))
370 + remove (ctx->realpath);
374 + restore_path (ctx);
375 + FREE (&ctx->compressinfo);
379 +/* return 0 on success, -1 on failure */
380 +int mutt_sync_compressed (CONTEXT* ctx)
385 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
388 + mutt_message (_("Compressing %s..."), ctx->realpath);
390 + cmd = get_compression_cmd (ci->close, ctx);
394 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
396 + mutt_perror (ctx->realpath);
400 + mutt_block_signals ();
401 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
404 + mutt_unblock_signals ();
405 + mutt_error _("Unable to lock mailbox!");
411 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
415 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
416 + if (mutt_system (cmd))
418 + mutt_any_key_to_continue (NULL);
419 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
423 + mbox_unlock_compressed (ctx, fp);
424 + mutt_unblock_signals ();
434 +int mutt_slow_close_compressed (CONTEXT *ctx)
437 + const char *append;
439 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
441 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
445 + && ((append = get_append_command (ctx->realpath, ctx))
446 + || (append = ci->close))))
448 + /* if we can not or should not append, we only have to remove the */
449 + /* compressed info, because sync was already called */
450 + mutt_fast_close_compressed (ctx);
460 + if (append == ci->close)
461 + mutt_message (_("Compressing %s..."), ctx->realpath);
463 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
466 + cmd = get_compression_cmd (append, ctx);
470 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
472 + mutt_perror (ctx->realpath);
476 + mutt_block_signals ();
477 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
480 + mutt_unblock_signals ();
481 + mutt_error _("Unable to lock mailbox!");
486 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
491 + if (append == ci->close)
492 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
494 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
496 + if (mutt_system (cmd))
498 + mutt_any_key_to_continue (NULL);
499 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
502 + mbox_unlock_compressed (ctx, fp);
503 + mutt_unblock_signals ();
508 + mbox_unlock_compressed (ctx, fp);
509 + mutt_unblock_signals ();
512 + restore_path (ctx);
514 + FREE (&ctx->compressinfo);
519 +#endif /* USE_COMPRESSED */
524 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
526 + * This program is free software; you can redistribute it and/or modify
527 + * it under the terms of the GNU General Public License as published by
528 + * the Free Software Foundation; either version 2 of the License, or
529 + * (at your option) any later version.
531 + * This program is distributed in the hope that it will be useful,
532 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
533 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
534 + * GNU General Public License for more details.
536 + * You should have received a copy of the GNU General Public License
537 + * along with this program; if not, write to the Free Software
538 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
541 +int mutt_can_read_compressed (const char *);
542 +int mutt_can_append_compressed (const char *);
543 +int mutt_open_read_compressed (CONTEXT *);
544 +int mutt_open_append_compressed (CONTEXT *);
545 +int mutt_slow_close_compressed (CONTEXT *);
546 +int mutt_sync_compressed (CONTEXT *);
547 +int mutt_test_compress_command (const char *);
548 +int mutt_check_mailbox_compressed (CONTEXT *);
549 +void mutt_fast_close_compressed (CONTEXT *);
553 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
556 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
557 + [if test x$enableval = xyes; then
558 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
561 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
562 [if test $withval != yes; then
563 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
566 @@ -1135,6 +1135,11 @@
570 +#ifdef USE_COMPRESSED
571 + if (Context->compressinfo && Context->realpath)
572 + mutt_str_replace (&LastFolder, Context->realpath);
575 mutt_str_replace (&LastFolder, Context->path);
576 oldcount = Context ? Context->msgcount : 0;
578 --- a/doc/manual.xml.head
579 +++ b/doc/manual.xml.head
580 @@ -5678,6 +5678,205 @@
584 +<sect1 id="compressedfolders">
585 +<title>Compressed folders Support (OPTIONAL)</title>
588 +If Mutt was compiled with compressed folders support (by running the
589 +<emphasis>configure</emphasis> script with the
590 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
591 +stored in an arbitrary format, provided that the user has a script to
592 +convert from/to this format to one of the accepted.
594 +The most common use is to open compressed archived folders e.g. with
597 +In addition, the user can provide a script that gets a folder in an
598 +accepted format and appends its context to the folder in the
599 +user-defined format, which may be faster than converting the entire
600 +folder to the accepted format, appending to it and converting back to
601 +the user-defined format.
603 +There are three hooks defined (<link
604 +linkend="open-hook">open-hook</link>, <link
605 +linkend="close-hook">close-hook</link> and <link
606 +linkend="append-hook">append-hook</link>) which define commands to
607 +uncompress and compress a folder and to append messages to an existing
608 +compressed folder respectively.
613 +open-hook \\.gz$ "gzip -cd %f > %t"
614 +close-hook \\.gz$ "gzip -c %t > %f"
615 +append-hook \\.gz$ "gzip -c %t >> %f"
618 +You do not have to specify all of the commands. If you omit <link
619 +linkend="append-hook">append-hook</link>, the folder will be open and
620 +closed again each time you will add to it. If you omit <link
621 +linkend="close-hook">close-hook</link> (or give empty command) , the
622 +folder will be open in the mode. If you specify <link
623 +linkend="append-hook">append-hook</link> though you'll be able to
624 +append to the folder.
626 +Note that Mutt will only try to use hooks if the file is not in one of
627 +the accepted formats. In particular, if the file is empty, mutt
628 +supposes it is not compressed. This is important because it allows the
629 +use of programs that do not have well defined extensions. Just use
630 +"." as a regexp. But this may be surprising if your
631 +compressing script produces empty files. In this situation, unset
632 +<link linkend="save-empty">$save_empty</link>, so that
633 +the compressed file will be removed if you delete all of the messages.
636 +<sect2 id="open-hook">
637 +<title>Open a compressed mailbox for reading</title>
640 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
642 +The <emphasis>command</emphasis> is the command that can be used for
643 +opening the folders whose names match <emphasis>regexp</emphasis>.
645 +The <emphasis>command</emphasis> string is the printf-like format
646 +string, and it should accept two parameters: %f, which is
647 +replaced with the (compressed) folder name, and %t which is
648 +replaced with the name of the temporary folder to which to write.
650 +%f and %t can be repeated any number of times in the
651 +command string, and all of the entries are replaced with the
652 +appropriate folder name. In addition, %% is replaced by
653 +%, as in printf, and any other %anything is left as is.
655 +The <emphasis>command</emphasis> should <emphasis
656 +role="bold">not</emphasis> remove the original compressed file. The
657 +<emphasis>command</emphasis> should return non-zero exit status if it
658 +fails, so mutt knows something's wrong.
663 +open-hook \\.gz$ "gzip -cd %f > %t"
666 +If the <emphasis>command</emphasis> is empty, this operation is
667 +disabled for this file type.
671 +<sect2 id="close-hook">
672 +<title>Write a compressed mailbox</title>
675 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
677 +This is used to close the folder that was open with the <link
678 +linkend="open-hook">open-hook</link> command after some changes were
681 +The <emphasis>command</emphasis> string is the command that can be
682 +used for closing the folders whose names match
683 +<emphasis>regexp</emphasis>. It has the same format as in the <link
684 +linkend="open-hook">open-hook</link> command. Temporary folder in this
685 +case is the folder previously produced by the <link
686 +linkend="open-hook">open-hook</link> command.
688 +The <emphasis>command</emphasis> should <emphasis
689 +role="bold">not</emphasis> remove the decompressed file. The
690 +<emphasis>command</emphasis> should return non-zero exit status if it
691 +fails, so mutt knows something's wrong.
696 +close-hook \\.gz$ "gzip -c %t > %f"
699 +If the <emphasis>command</emphasis> is empty, this operation is
700 +disabled for this file type, and the file can only be open in the
703 +<link linkend="close-hook">close-hook</link> is not called when you
704 +exit from the folder if the folder was not changed.
708 +<sect2 id="append-hook">
709 +<title>Append a message to a compressed mailbox</title>
712 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
714 +This command is used for saving to an existing compressed folder. The
715 +<emphasis>command</emphasis> is the command that can be used for
716 +appending to the folders whose names match
717 +<emphasis>regexp</emphasis>. It has the same format as in the <link
718 +linkend="open-hook">open-hook</link> command. The temporary folder in
719 +this case contains the messages that are being appended.
721 +The <emphasis>command</emphasis> should <emphasis
722 +role="bold">not</emphasis> remove the decompressed file. The
723 +<emphasis>command</emphasis> should return non-zero exit status if it
724 +fails, so mutt knows something's wrong.
729 +append-hook \\.gz$ "gzip -c %t >> %f"
732 +When <link linkend="append-hook">append-hook</link> is used, the folder
733 +is not opened, which saves time, but this means that we can not find
734 +out what the folder type is. Thus the default (<link
735 +linkend="mbox-type">$mbox_type</link>) type is always
736 +supposed (i.e. this is the format used for the temporary folder).
738 +If the file does not exist when you save to it, <link
739 +linkend="close-hook">close-hook</link> is called, and not <link
740 +linkend="append-hook">append-hook</link>. <link
741 +linkend="append-hook">append-hook</link> is only for appending to
744 +If the <emphasis>command</emphasis> is empty, this operation is
745 +disabled for this file type. In this case, the folder will be open and
746 +closed again (using <link linkend="open-hook">open-hook</link> and
747 +<link linkend="close-hook">close-hook</link>respectively) each time you
753 +<title>Encrypted folders</title>
756 +The compressed folders support can also be used to handle encrypted
757 +folders. If you want to encrypt a folder with PGP, you may want to use
758 +the following hooks:
761 +open-hook \\.pgp$ "pgp -f < %f > %t"
762 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
765 +Please note, that PGP does not support appending to an encrypted
766 +folder, so there is no append-hook defined.
768 +If you are using GnuPG instead of PGP, you may use the following hooks
772 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
773 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
776 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
777 +decrypted in the /tmp directory, where it can be read by your system
778 +administrator. So think about the security aspects of this.
783 <chapter id="mimesupport">
784 <title>Mutt's MIME Support</title>
786 --- a/doc/Muttrc.head
787 +++ b/doc/Muttrc.head
789 macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
792 +# Use folders which match on \\.gz$ as gzipped folders:
793 +# open-hook \\.gz$ "gzip -cd %f > %t"
794 +# close-hook \\.gz$ "gzip -c %t > %f"
795 +# append-hook \\.gz$ "gzip -c %t >> %f"
797 # If Mutt is unable to determine your site's domain name correctly, you can
798 # set the default here.
800 --- a/doc/muttrc.man.head
801 +++ b/doc/muttrc.man.head
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.
831 #include "mutt_crypt.h"
833 +#ifdef USE_COMPRESSED
834 +#include "compress.h"
841 memset (&pattern, 0, sizeof (pattern));
842 pattern.data = safe_strdup (path);
844 +#ifdef USE_COMPRESSED
845 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
847 + if (mutt_test_compress_command (command.data))
849 + strfcpy (err->data, _("badly formatted command string"), err->dsize);
854 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
855 && (!WithCrypto || !(data & M_CRYPTHOOK))
859 @@ -3504,6 +3504,11 @@
860 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
861 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
862 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
863 +#ifdef USE_COMPRESSED
864 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
865 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
866 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
868 { "group", parse_group, 0 },
869 { "ungroup", parse_ungroup, 0 },
870 { "hdr_order", parse_list, UL &HeaderOrderList },
878 +#ifdef USE_COMPRESSED
889 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
891 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
892 - crypt.c cryptglue.c \
893 + crypt.c cryptglue.c compress.c \
894 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
895 edit.c enter.c flags.c init.c filter.c from.c \
896 getdomain.c group.c \
898 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
900 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
901 - configure account.h \
902 + configure account.h compress.h \
903 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
904 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
905 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
910 #include "mutt_curses.h"
912 +#ifdef USE_COMPRESSED
913 +#include "compress.h"
916 #include <sys/stat.h>
919 @@ -1048,6 +1052,12 @@
920 int mbox_close_mailbox (CONTEXT *ctx)
922 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
924 +#ifdef USE_COMPRESSED
925 + if (ctx->compressinfo)
926 + mutt_slow_close_compressed (ctx);
929 mutt_unblock_signals ();
930 mx_fastclose_mailbox (ctx);
935 #define M_ACCOUNTHOOK (1<<9)
936 #define M_REPLYHOOK (1<<10)
937 #define M_SEND2HOOK (1<<11)
938 +#ifdef USE_COMPRESSED
939 +#define M_OPENHOOK (1<<12)
940 +#define M_APPENDHOOK (1<<13)
941 +#define M_CLOSEHOOK (1<<14)
944 /* tree characters for linearize_tree and print_enriched_string */
945 #define M_TREE_LLCORNER 1
947 int flagged; /* how many flagged messages */
948 int msgnotreadyet; /* which msg "new" in pager, -1 if none */
950 +#ifdef USE_COMPRESSED
951 + void *compressinfo; /* compressed mbox module private data */
952 + char *realpath; /* path to compressed mailbox */
953 +#endif /* USE_COMPRESSED */
955 short magic; /* mailbox type */
957 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
964 +#ifdef USE_COMPRESSED
965 +#include "compress.h"
975 +#ifdef USE_COMPRESSED
976 + if (magic == 0 && mutt_can_read_compressed (path))
977 + return M_COMPRESSED;
986 +#ifdef USE_COMPRESSED
987 + /* special case for appending to compressed folders -
988 + * even if we can not open them for reading */
989 + if (mutt_can_append_compressed (ctx->path))
990 + mutt_open_append_compressed (ctx);
999 ctx->magic = mx_get_magic (path);
1002 +#ifdef USE_COMPRESSED
1003 + if (ctx->magic == M_COMPRESSED)
1004 + mutt_open_read_compressed (ctx);
1008 mutt_error (_("%s is not a mailbox."), path);
1010 @@ -718,6 +738,10 @@
1011 mutt_free_header (&ctx->hdrs[i]);
1014 +#ifdef USE_COMPRESSED
1015 + if (ctx->compressinfo)
1016 + mutt_fast_close_compressed (ctx);
1019 FREE (&ctx->pattern);
1020 if (ctx->limit_pattern)
1021 @@ -770,6 +794,12 @@
1023 if (tmp && tmp->new == 0)
1024 mutt_update_mailbox (tmp);
1026 +#ifdef USE_COMPRESSED
1027 + if (rc == 0 && ctx->compressinfo)
1028 + return mutt_sync_compressed (ctx);
1034 @@ -1033,6 +1063,11 @@
1035 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1036 mx_unlink_empty (ctx->path);
1038 +#ifdef USE_COMPRESSED
1039 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1043 mx_fastclose_mailbox (ctx);
1046 @@ -1355,6 +1390,11 @@
1050 +#ifdef USE_COMPRESSED
1051 + if (ctx->compressinfo)
1052 + return mutt_check_mailbox_compressed (ctx);
1057 if (ctx->locked) lock = 0;
1064 +#ifdef USE_COMPRESSED
1069 WHERE short DefaultMagic INITVAL (M_MBOX);
1072 @@ -2005,6 +2005,10 @@
1073 msgid "Bad history file format (line %d)"
1074 msgstr "Falsches Format der Datei früherer Eingaben (Zeile %d)"
1077 +msgid "badly formatted command string"
1078 +msgstr "Hook enthält nicht die Muster %f und %t"
1082 msgid "unhook: Can't do unhook * from within a hook."
1083 @@ -2766,7 +2770,7 @@
1084 msgid "Mailbox is corrupt!"
1085 msgstr "Mailbox fehlerhaft!"
1088 +#: mbox.c:678 compress.c:203 mbox.c:661
1089 msgid "Mailbox was corrupted!"
1090 msgstr "Mailbox wurde zerstört!"
1092 @@ -2774,10 +2778,11 @@
1093 msgid "Fatal error! Could not reopen mailbox!"
1094 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1097 +#: mbox.c:746 compress.c:264 compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1098 msgid "Unable to lock mailbox!"
1099 msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1102 #. this means ctx->changed or ctx->deleted was set, but no
1103 #. * messages were found to be changed or deleted. This should
1104 #. * never happen, is we presume it is a bug in mutt.
1105 @@ -5378,3 +5383,32 @@
1107 #~ msgid "Authentication method is unknown."
1108 #~ msgstr "Authentifizierungsmethode unbekannt."
1110 +#: compress.c:228 compress.c:253
1112 +msgid "Decompressing %s...\n"
1113 +msgstr "Entpacke %s...\n"
1115 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1117 +msgid "Compressing %s...\n"
1118 +msgstr "Komprimiere %s...\n"
1123 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1126 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1127 +"entpackte gespeichert!\n"
1129 +#: compress.c:425 compress.c:456
1131 +msgid "Compressed-appending to %s...\n"
1132 +msgstr "Hänge komprimiert an %s... an\n"
1136 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1137 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1138 --- a/po/POTFILES.in
1139 +++ b/po/POTFILES.in
1153 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1154 +#ifdef USE_COMPRESSED
1155 + if (Context && Context->compressinfo && Context->realpath)
1157 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1158 + mutt_pretty_mailbox (tmp, sizeof (tmp));
1162 if (Context && Context->path)
1164 strfcpy (tmp, Context->path, sizeof (tmp));