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
19 - 2010-05-31 myon: remove commented paragraph "Use folders..." in
20 doc/Muttrc.head, see #578096
27 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
29 + * This program is free software; you can redistribute it and/or modify
30 + * it under the terms of the GNU General Public License as published by
31 + * the Free Software Foundation; either version 2 of the License, or
32 + * (at your option) any later version.
34 + * This program is distributed in the hope that it will be useful,
35 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
36 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 + * GNU General Public License for more details.
39 + * You should have received a copy of the GNU General Public License
40 + * along with this program; if not, write to the Free Software
41 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
50 +#ifdef USE_COMPRESSED
54 +#include "mutt_curses.h"
59 +#include <sys/stat.h>
63 + const char *close; /* close-hook command */
64 + const char *open; /* open-hook command */
65 + const char *append; /* append-hook command */
66 + off_t size; /* size of real folder */
71 + * ctx - context to lock
72 + * excl - exclusive lock?
73 + * retry - should retry if unable to lock?
75 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
79 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
81 + else if (retry && !excl)
90 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
96 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
101 +static int is_new (const char *path)
103 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
106 +static const char* find_compress_hook (int type, const char *path)
108 + const char* c = mutt_find_hook (type, path);
109 + return (!c || !*c) ? NULL : c;
112 +int mutt_can_read_compressed (const char *path)
114 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
118 + * if the file is new, we really do not append, but create, and so use
119 + * close-hook, and not append-hook
121 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
123 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
124 + return (is_new (path)) ? ci->close : ci->append;
127 +int mutt_can_append_compressed (const char *path)
133 + char *dir_path = safe_strdup(path);
134 + char *aux = strrchr(dir_path, '/');
139 + if (access(dir_path, W_OK|X_OK))
142 + safe_free((void**)&dir_path);
143 + return dir_valid && (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
146 + magic = mx_get_magic (path);
148 + if (magic != 0 && magic != M_COMPRESSED)
151 + return (find_compress_hook (M_APPENDHOOK, path)
152 + || (find_compress_hook (M_OPENHOOK, path)
153 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
156 +/* open a compressed mailbox */
157 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
161 + /* Now lets uncompress this thing */
162 + ci = safe_malloc (sizeof (COMPRESS_INFO));
163 + ctx->compressinfo = (void*) ci;
164 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
165 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
166 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
170 +static void set_path (CONTEXT* ctx)
172 + char tmppath[_POSIX_PATH_MAX];
174 + /* Setup the right paths */
175 + ctx->realpath = ctx->path;
177 + /* Uncompress to /tmp */
178 + mutt_mktemp (tmppath, sizeof(tmppath));
179 + ctx->path = safe_malloc (strlen (tmppath) + 1);
180 + strcpy (ctx->path, tmppath);
183 +static int get_size (const char* path)
186 + if (stat (path, &sb) != 0)
188 + return (sb.st_size);
191 +static void store_size (CONTEXT* ctx)
193 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
194 + ci->size = get_size (ctx->realpath);
198 +compresshook_format_str (char *dest, size_t destlen, size_t col, char op,
199 + const char *src, const char *fmt,
200 + const char *ifstring, const char *elsestring,
201 + unsigned long data, format_flag flags)
203 + char tmp[SHORT_STRING];
205 + CONTEXT *ctx = (CONTEXT *) data;
209 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
210 + snprintf (dest, destlen, tmp, ctx->realpath);
213 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
214 + snprintf (dest, destlen, tmp, ctx->path);
221 + * check that the command has both %f and %t
222 + * 0 means OK, -1 means error
224 +int mutt_test_compress_command (const char* cmd)
226 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
229 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
231 + char expanded[_POSIX_PATH_MAX];
232 + mutt_FormatString (expanded, sizeof (expanded), 0, cmd,
233 + compresshook_format_str, (unsigned long) ctx, 0);
234 + return safe_strdup (expanded);
237 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
239 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
240 + if (ci->size != get_size (ctx->realpath))
242 + FREE (&ctx->compressinfo);
243 + FREE (&ctx->realpath);
244 + mutt_error _("Mailbox was corrupted!");
250 +int mutt_open_read_compressed (CONTEXT *ctx)
256 + COMPRESS_INFO *ci = set_compress_info (ctx);
259 + FREE (&ctx->compressinfo);
262 + if (!ci->close || access (ctx->path, W_OK) != 0)
269 + mutt_message (_("Decompressing %s..."), ctx->realpath);
271 + cmd = get_compression_cmd (ci->open, ctx);
274 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
276 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
278 + mutt_perror (ctx->realpath);
282 + mutt_block_signals ();
283 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
286 + mutt_unblock_signals ();
287 + mutt_error _("Unable to lock mailbox!");
294 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
295 + rc = mutt_system (cmd);
296 + mbox_unlock_compressed (ctx, fp);
297 + mutt_unblock_signals ();
302 + mutt_any_key_to_continue (NULL);
304 + FREE (&ctx->compressinfo);
305 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
311 + if (mutt_check_mailbox_compressed (ctx))
314 + ctx->magic = mx_get_magic (ctx->path);
319 +void restore_path (CONTEXT* ctx)
322 + ctx->path = ctx->realpath;
325 +/* remove the temporary mailbox */
326 +void remove_file (CONTEXT* ctx)
328 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
329 + remove (ctx->path);
332 +int mutt_open_append_compressed (CONTEXT *ctx)
335 + COMPRESS_INFO *ci = set_compress_info (ctx);
337 + if (!get_append_command (ctx->path, ctx))
339 + if (ci->open && ci->close)
340 + return (mutt_open_read_compressed (ctx));
343 + FREE (&ctx->compressinfo);
349 + if (!is_new (ctx->realpath))
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 *);
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 @@ -1153,6 +1153,11 @@
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 @@ -6116,6 +6116,205 @@
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.man.head
789 +++ b/doc/muttrc.man.head
791 to a certain recipient. The meaning of "key ID" is to be taken
792 broadly: This can be a different e-mail address, a numerical key ID,
793 or even just an arbitrary search string.
796 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
797 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
798 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
801 +These commands provide a way to handle compressed folders. The given
802 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
803 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
804 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
805 +compressed mail to a compressed folder (\fBappend-hook\fP). The
806 +\fIcommand\fP string is the
808 +like format string, and it should accept two parameters: \fB%f\fP,
809 +which is replaced with the (compressed) folder name, and \fB%t\fP
810 +which is replaced with the name of the temporary folder to which to
813 \fBpush\fP \fIstring\fP
814 This command adds the named \fIstring\fP to the keyboard buffer.
819 #include "mutt_crypt.h"
821 +#ifdef USE_COMPRESSED
822 +#include "compress.h"
829 memset (&pattern, 0, sizeof (pattern));
830 pattern.data = safe_strdup (path);
832 +#ifdef USE_COMPRESSED
833 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
835 + if (mutt_test_compress_command (command.data))
837 + strfcpy (err->data, _("badly formatted command string"), err->dsize);
842 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
843 && (!WithCrypto || !(data & M_CRYPTHOOK))
847 @@ -3530,6 +3530,11 @@
848 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
849 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
850 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
851 +#ifdef USE_COMPRESSED
852 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
853 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
854 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
856 { "group", parse_group, M_GROUP },
857 { "ungroup", parse_group, M_UNGROUP },
858 { "hdr_order", parse_list, UL &HeaderOrderList },
866 +#ifdef USE_COMPRESSED
877 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
879 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
880 - crypt.c cryptglue.c \
881 + crypt.c cryptglue.c compress.c \
882 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
883 edit.c enter.c flags.c init.c filter.c from.c \
884 getdomain.c group.c \
886 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
888 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
889 - configure account.h \
890 + configure account.h compress.h \
891 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
892 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
893 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
898 #include "mutt_curses.h"
900 +#ifdef USE_COMPRESSED
901 +#include "compress.h"
904 #include <sys/stat.h>
907 @@ -1070,6 +1074,12 @@
908 int mbox_close_mailbox (CONTEXT *ctx)
910 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
912 +#ifdef USE_COMPRESSED
913 + if (ctx->compressinfo)
914 + mutt_slow_close_compressed (ctx);
917 mutt_unblock_signals ();
918 mx_fastclose_mailbox (ctx);
923 #define M_ACCOUNTHOOK (1<<9)
924 #define M_REPLYHOOK (1<<10)
925 #define M_SEND2HOOK (1<<11)
926 +#ifdef USE_COMPRESSED
927 +#define M_OPENHOOK (1<<12)
928 +#define M_APPENDHOOK (1<<13)
929 +#define M_CLOSEHOOK (1<<14)
932 /* tree characters for linearize_tree and print_enriched_string */
933 #define M_TREE_LLCORNER 1
935 int flagged; /* how many flagged messages */
936 int msgnotreadyet; /* which msg "new" in pager, -1 if none */
938 +#ifdef USE_COMPRESSED
939 + void *compressinfo; /* compressed mbox module private data */
940 + char *realpath; /* path to compressed mailbox */
941 +#endif /* USE_COMPRESSED */
943 short magic; /* mailbox type */
945 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
952 +#ifdef USE_COMPRESSED
953 +#include "compress.h"
963 +#ifdef USE_COMPRESSED
964 + if (magic == 0 && mutt_can_read_compressed (path))
965 + return M_COMPRESSED;
974 +#ifdef USE_COMPRESSED
975 + /* special case for appending to compressed folders -
976 + * even if we can not open them for reading */
977 + if (mutt_can_append_compressed (ctx->path))
978 + mutt_open_append_compressed (ctx);
987 ctx->magic = mx_get_magic (path);
990 +#ifdef USE_COMPRESSED
991 + if (ctx->magic == M_COMPRESSED)
992 + mutt_open_read_compressed (ctx);
996 mutt_error (_("%s is not a mailbox."), path);
999 mutt_free_header (&ctx->hdrs[i]);
1002 +#ifdef USE_COMPRESSED
1003 + if (ctx->compressinfo)
1004 + mutt_fast_close_compressed (ctx);
1007 FREE (&ctx->pattern);
1008 if (ctx->limit_pattern)
1009 @@ -773,6 +797,12 @@
1011 if (tmp && tmp->new == 0)
1012 mutt_update_mailbox (tmp);
1014 +#ifdef USE_COMPRESSED
1015 + if (rc == 0 && ctx->compressinfo)
1016 + return mutt_sync_compressed (ctx);
1022 @@ -1043,6 +1073,11 @@
1023 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1024 mx_unlink_empty (ctx->path);
1026 +#ifdef USE_COMPRESSED
1027 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1031 mx_fastclose_mailbox (ctx);
1034 @@ -1361,6 +1396,11 @@
1038 +#ifdef USE_COMPRESSED
1039 + if (ctx->compressinfo)
1040 + return mutt_check_mailbox_compressed (ctx);
1045 if (ctx->locked) lock = 0;
1052 +#ifdef USE_COMPRESSED
1057 WHERE short DefaultMagic INITVAL (M_MBOX);
1058 --- a/po/POTFILES.in
1059 +++ b/po/POTFILES.in
1073 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1074 +#ifdef USE_COMPRESSED
1075 + if (Context && Context->compressinfo && Context->realpath)
1077 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1078 + mutt_pretty_mailbox (tmp, sizeof (tmp));
1082 if (Context && Context->path)
1084 strfcpy (tmp, Context->path, sizeof (tmp));
1087 @@ -5159,6 +5159,36 @@
1088 msgid "show S/MIME options"
1089 msgstr "Zeige S/MIME Optionen"
1092 +#: compress.c:228 compress.c:253
1094 +msgid "Decompressing %s...\n"
1095 +msgstr "Entpacke %s...\n"
1097 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1099 +msgid "Compressing %s...\n"
1100 +msgstr "Komprimiere %s...\n"
1105 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1108 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1109 +"entpackte gespeichert!\n"
1111 +#: compress.c:425 compress.c:456
1113 +msgid "Compressed-appending to %s...\n"
1114 +msgstr "Hänge komprimiert an %s... an\n"
1118 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1119 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1122 #~ msgstr "Klartext"