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);
306 + // remove the partial uncompressed file
308 + restore_path (ctx);
314 + if (mutt_check_mailbox_compressed (ctx))
317 + ctx->magic = mx_get_magic (ctx->path);
322 +void restore_path (CONTEXT* ctx)
325 + ctx->path = ctx->realpath;
328 +/* remove the temporary mailbox */
329 +void remove_file (CONTEXT* ctx)
331 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
332 + remove (ctx->path);
335 +int mutt_open_append_compressed (CONTEXT *ctx)
338 + COMPRESS_INFO *ci = set_compress_info (ctx);
340 + if (!get_append_command (ctx->path, ctx))
342 + if (ci->open && ci->close)
343 + return (mutt_open_read_compressed (ctx));
346 + FREE (&ctx->compressinfo);
352 + if (!is_new (ctx->realpath))
353 + if ((fh = fopen (ctx->path, "w")))
355 + /* No error checking - the parent function will catch it */
360 +/* close a compressed mailbox */
361 +void mutt_fast_close_compressed (CONTEXT *ctx)
363 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
366 + if (ctx->compressinfo)
371 + /* if the folder was removed, remove the gzipped folder too */
372 + if ((ctx->magic > 0)
373 + && (access (ctx->path, F_OK) != 0)
374 + && ! option (OPTSAVEEMPTY))
375 + remove (ctx->realpath);
379 + restore_path (ctx);
380 + FREE (&ctx->compressinfo);
384 +/* return 0 on success, -1 on failure */
385 +int mutt_sync_compressed (CONTEXT* ctx)
390 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
393 + mutt_message (_("Compressing %s..."), ctx->realpath);
395 + cmd = get_compression_cmd (ci->close, ctx);
399 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
401 + mutt_perror (ctx->realpath);
405 + mutt_block_signals ();
406 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
409 + mutt_unblock_signals ();
410 + mutt_error _("Unable to lock mailbox!");
416 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
420 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
421 + if (mutt_system (cmd))
423 + mutt_any_key_to_continue (NULL);
424 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
428 + mbox_unlock_compressed (ctx, fp);
429 + mutt_unblock_signals ();
439 +int mutt_slow_close_compressed (CONTEXT *ctx)
442 + const char *append;
444 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
446 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
450 + && ((append = get_append_command (ctx->realpath, ctx))
451 + || (append = ci->close))))
453 + /* if we can not or should not append, we only have to remove the */
454 + /* compressed info, because sync was already called */
455 + mutt_fast_close_compressed (ctx);
465 + if (append == ci->close)
466 + mutt_message (_("Compressing %s..."), ctx->realpath);
468 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
471 + cmd = get_compression_cmd (append, ctx);
475 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
477 + mutt_perror (ctx->realpath);
481 + mutt_block_signals ();
482 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
485 + mutt_unblock_signals ();
486 + mutt_error _("Unable to lock mailbox!");
491 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
496 + if (append == ci->close)
497 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
499 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
501 + if (mutt_system (cmd))
503 + mutt_any_key_to_continue (NULL);
504 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
507 + mbox_unlock_compressed (ctx, fp);
508 + mutt_unblock_signals ();
513 + mbox_unlock_compressed (ctx, fp);
514 + mutt_unblock_signals ();
517 + restore_path (ctx);
519 + FREE (&ctx->compressinfo);
524 +#endif /* USE_COMPRESSED */
529 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
531 + * This program is free software; you can redistribute it and/or modify
532 + * it under the terms of the GNU General Public License as published by
533 + * the Free Software Foundation; either version 2 of the License, or
534 + * (at your option) any later version.
536 + * This program is distributed in the hope that it will be useful,
537 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
538 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
539 + * GNU General Public License for more details.
541 + * You should have received a copy of the GNU General Public License
542 + * along with this program; if not, write to the Free Software
543 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
546 +int mutt_can_read_compressed (const char *);
547 +int mutt_can_append_compressed (const char *);
548 +int mutt_open_read_compressed (CONTEXT *);
549 +int mutt_open_append_compressed (CONTEXT *);
550 +int mutt_slow_close_compressed (CONTEXT *);
551 +int mutt_sync_compressed (CONTEXT *);
552 +int mutt_test_compress_command (const char *);
553 +int mutt_check_mailbox_compressed (CONTEXT *);
554 +void mutt_fast_close_compressed (CONTEXT *);
558 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
561 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
562 + [if test x$enableval = xyes; then
563 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
566 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
567 [if test $withval != yes; then
568 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
571 @@ -1153,6 +1153,11 @@
575 +#ifdef USE_COMPRESSED
576 + if (Context->compressinfo && Context->realpath)
577 + mutt_str_replace (&LastFolder, Context->realpath);
580 mutt_str_replace (&LastFolder, Context->path);
581 oldcount = Context ? Context->msgcount : 0;
583 --- a/doc/manual.xml.head
584 +++ b/doc/manual.xml.head
585 @@ -6116,6 +6116,205 @@
589 +<sect1 id="compressedfolders">
590 +<title>Compressed folders Support (OPTIONAL)</title>
593 +If Mutt was compiled with compressed folders support (by running the
594 +<emphasis>configure</emphasis> script with the
595 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
596 +stored in an arbitrary format, provided that the user has a script to
597 +convert from/to this format to one of the accepted.
599 +The most common use is to open compressed archived folders e.g. with
602 +In addition, the user can provide a script that gets a folder in an
603 +accepted format and appends its context to the folder in the
604 +user-defined format, which may be faster than converting the entire
605 +folder to the accepted format, appending to it and converting back to
606 +the user-defined format.
608 +There are three hooks defined (<link
609 +linkend="open-hook">open-hook</link>, <link
610 +linkend="close-hook">close-hook</link> and <link
611 +linkend="append-hook">append-hook</link>) which define commands to
612 +uncompress and compress a folder and to append messages to an existing
613 +compressed folder respectively.
618 +open-hook \\.gz$ "gzip -cd %f > %t"
619 +close-hook \\.gz$ "gzip -c %t > %f"
620 +append-hook \\.gz$ "gzip -c %t >> %f"
623 +You do not have to specify all of the commands. If you omit <link
624 +linkend="append-hook">append-hook</link>, the folder will be open and
625 +closed again each time you will add to it. If you omit <link
626 +linkend="close-hook">close-hook</link> (or give empty command) , the
627 +folder will be open in the mode. If you specify <link
628 +linkend="append-hook">append-hook</link> though you'll be able to
629 +append to the folder.
631 +Note that Mutt will only try to use hooks if the file is not in one of
632 +the accepted formats. In particular, if the file is empty, mutt
633 +supposes it is not compressed. This is important because it allows the
634 +use of programs that do not have well defined extensions. Just use
635 +"." as a regexp. But this may be surprising if your
636 +compressing script produces empty files. In this situation, unset
637 +<link linkend="save-empty">$save_empty</link>, so that
638 +the compressed file will be removed if you delete all of the messages.
641 +<sect2 id="open-hook">
642 +<title>Open a compressed mailbox for reading</title>
645 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
647 +The <emphasis>command</emphasis> is the command that can be used for
648 +opening the folders whose names match <emphasis>regexp</emphasis>.
650 +The <emphasis>command</emphasis> string is the printf-like format
651 +string, and it should accept two parameters: %f, which is
652 +replaced with the (compressed) folder name, and %t which is
653 +replaced with the name of the temporary folder to which to write.
655 +%f and %t can be repeated any number of times in the
656 +command string, and all of the entries are replaced with the
657 +appropriate folder name. In addition, %% is replaced by
658 +%, as in printf, and any other %anything is left as is.
660 +The <emphasis>command</emphasis> should <emphasis
661 +role="bold">not</emphasis> remove the original compressed file. The
662 +<emphasis>command</emphasis> should return non-zero exit status if it
663 +fails, so mutt knows something's wrong.
668 +open-hook \\.gz$ "gzip -cd %f > %t"
671 +If the <emphasis>command</emphasis> is empty, this operation is
672 +disabled for this file type.
676 +<sect2 id="close-hook">
677 +<title>Write a compressed mailbox</title>
680 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
682 +This is used to close the folder that was open with the <link
683 +linkend="open-hook">open-hook</link> command after some changes were
686 +The <emphasis>command</emphasis> string is the command that can be
687 +used for closing the folders whose names match
688 +<emphasis>regexp</emphasis>. It has the same format as in the <link
689 +linkend="open-hook">open-hook</link> command. Temporary folder in this
690 +case is the folder previously produced by the <link
691 +linkend="open-hook">open-hook</link> command.
693 +The <emphasis>command</emphasis> should <emphasis
694 +role="bold">not</emphasis> remove the decompressed file. The
695 +<emphasis>command</emphasis> should return non-zero exit status if it
696 +fails, so mutt knows something's wrong.
701 +close-hook \\.gz$ "gzip -c %t > %f"
704 +If the <emphasis>command</emphasis> is empty, this operation is
705 +disabled for this file type, and the file can only be open in the
708 +<link linkend="close-hook">close-hook</link> is not called when you
709 +exit from the folder if the folder was not changed.
713 +<sect2 id="append-hook">
714 +<title>Append a message to a compressed mailbox</title>
717 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
719 +This command is used for saving to an existing compressed folder. The
720 +<emphasis>command</emphasis> is the command that can be used for
721 +appending to the folders whose names match
722 +<emphasis>regexp</emphasis>. It has the same format as in the <link
723 +linkend="open-hook">open-hook</link> command. The temporary folder in
724 +this case contains the messages that are being appended.
726 +The <emphasis>command</emphasis> should <emphasis
727 +role="bold">not</emphasis> remove the decompressed file. The
728 +<emphasis>command</emphasis> should return non-zero exit status if it
729 +fails, so mutt knows something's wrong.
734 +append-hook \\.gz$ "gzip -c %t >> %f"
737 +When <link linkend="append-hook">append-hook</link> is used, the folder
738 +is not opened, which saves time, but this means that we can not find
739 +out what the folder type is. Thus the default (<link
740 +linkend="mbox-type">$mbox_type</link>) type is always
741 +supposed (i.e. this is the format used for the temporary folder).
743 +If the file does not exist when you save to it, <link
744 +linkend="close-hook">close-hook</link> is called, and not <link
745 +linkend="append-hook">append-hook</link>. <link
746 +linkend="append-hook">append-hook</link> is only for appending to
749 +If the <emphasis>command</emphasis> is empty, this operation is
750 +disabled for this file type. In this case, the folder will be open and
751 +closed again (using <link linkend="open-hook">open-hook</link> and
752 +<link linkend="close-hook">close-hook</link>respectively) each time you
758 +<title>Encrypted folders</title>
761 +The compressed folders support can also be used to handle encrypted
762 +folders. If you want to encrypt a folder with PGP, you may want to use
763 +the following hooks:
766 +open-hook \\.pgp$ "pgp -f < %f > %t"
767 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
770 +Please note, that PGP does not support appending to an encrypted
771 +folder, so there is no append-hook defined.
773 +If you are using GnuPG instead of PGP, you may use the following hooks
777 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
778 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
781 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
782 +decrypted in the /tmp directory, where it can be read by your system
783 +administrator. So think about the security aspects of this.
788 <chapter id="mimesupport">
789 <title>Mutt's MIME Support</title>
791 --- a/doc/muttrc.man.head
792 +++ b/doc/muttrc.man.head
794 to a certain recipient. The meaning of "key ID" is to be taken
795 broadly: This can be a different e-mail address, a numerical key ID,
796 or even just an arbitrary search string.
799 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
800 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
801 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
804 +These commands provide a way to handle compressed folders. The given
805 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
806 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
807 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
808 +compressed mail to a compressed folder (\fBappend-hook\fP). The
809 +\fIcommand\fP string is the
811 +like format string, and it should accept two parameters: \fB%f\fP,
812 +which is replaced with the (compressed) folder name, and \fB%t\fP
813 +which is replaced with the name of the temporary folder to which to
816 \fBpush\fP \fIstring\fP
817 This command adds the named \fIstring\fP to the keyboard buffer.
822 #include "mutt_crypt.h"
824 +#ifdef USE_COMPRESSED
825 +#include "compress.h"
832 memset (&pattern, 0, sizeof (pattern));
833 pattern.data = safe_strdup (path);
835 +#ifdef USE_COMPRESSED
836 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
838 + if (mutt_test_compress_command (command.data))
840 + strfcpy (err->data, _("badly formatted command string"), err->dsize);
845 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
846 && (!WithCrypto || !(data & M_CRYPTHOOK))
850 @@ -3530,6 +3530,11 @@
851 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
852 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
853 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
854 +#ifdef USE_COMPRESSED
855 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
856 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
857 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
859 { "group", parse_group, M_GROUP },
860 { "ungroup", parse_group, M_UNGROUP },
861 { "hdr_order", parse_list, UL &HeaderOrderList },
869 +#ifdef USE_COMPRESSED
880 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
882 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
883 - crypt.c cryptglue.c \
884 + crypt.c cryptglue.c compress.c \
885 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
886 edit.c enter.c flags.c init.c filter.c from.c \
887 getdomain.c group.c \
889 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
891 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
892 - configure account.h \
893 + configure account.h compress.h \
894 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
895 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
896 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
901 #include "mutt_curses.h"
903 +#ifdef USE_COMPRESSED
904 +#include "compress.h"
907 #include <sys/stat.h>
910 @@ -1070,6 +1074,12 @@
911 int mbox_close_mailbox (CONTEXT *ctx)
913 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
915 +#ifdef USE_COMPRESSED
916 + if (ctx->compressinfo)
917 + mutt_slow_close_compressed (ctx);
920 mutt_unblock_signals ();
921 mx_fastclose_mailbox (ctx);
926 #define M_ACCOUNTHOOK (1<<9)
927 #define M_REPLYHOOK (1<<10)
928 #define M_SEND2HOOK (1<<11)
929 +#ifdef USE_COMPRESSED
930 +#define M_OPENHOOK (1<<12)
931 +#define M_APPENDHOOK (1<<13)
932 +#define M_CLOSEHOOK (1<<14)
935 /* tree characters for linearize_tree and print_enriched_string */
936 #define M_TREE_LLCORNER 1
938 int flagged; /* how many flagged messages */
939 int msgnotreadyet; /* which msg "new" in pager, -1 if none */
941 +#ifdef USE_COMPRESSED
942 + void *compressinfo; /* compressed mbox module private data */
943 + char *realpath; /* path to compressed mailbox */
944 +#endif /* USE_COMPRESSED */
946 short magic; /* mailbox type */
948 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
955 +#ifdef USE_COMPRESSED
956 +#include "compress.h"
966 +#ifdef USE_COMPRESSED
967 + if (magic == 0 && mutt_can_read_compressed (path))
968 + return M_COMPRESSED;
977 +#ifdef USE_COMPRESSED
978 + /* special case for appending to compressed folders -
979 + * even if we can not open them for reading */
980 + if (mutt_can_append_compressed (ctx->path))
981 + mutt_open_append_compressed (ctx);
990 ctx->magic = mx_get_magic (path);
993 +#ifdef USE_COMPRESSED
994 + if (ctx->magic == M_COMPRESSED)
995 + mutt_open_read_compressed (ctx);
999 mutt_error (_("%s is not a mailbox."), path);
1001 @@ -721,6 +741,10 @@
1002 mutt_free_header (&ctx->hdrs[i]);
1005 +#ifdef USE_COMPRESSED
1006 + if (ctx->compressinfo)
1007 + mutt_fast_close_compressed (ctx);
1010 FREE (&ctx->pattern);
1011 if (ctx->limit_pattern)
1012 @@ -773,6 +797,12 @@
1014 if (tmp && tmp->new == 0)
1015 mutt_update_mailbox (tmp);
1017 +#ifdef USE_COMPRESSED
1018 + if (rc == 0 && ctx->compressinfo)
1019 + return mutt_sync_compressed (ctx);
1025 @@ -1043,6 +1073,11 @@
1026 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1027 mx_unlink_empty (ctx->path);
1029 +#ifdef USE_COMPRESSED
1030 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1034 mx_fastclose_mailbox (ctx);
1037 @@ -1361,6 +1396,11 @@
1041 +#ifdef USE_COMPRESSED
1042 + if (ctx->compressinfo)
1043 + return mutt_check_mailbox_compressed (ctx);
1048 if (ctx->locked) lock = 0;
1055 +#ifdef USE_COMPRESSED
1060 WHERE short DefaultMagic INITVAL (M_MBOX);
1061 --- a/po/POTFILES.in
1062 +++ b/po/POTFILES.in
1076 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1077 +#ifdef USE_COMPRESSED
1078 + if (Context && Context->compressinfo && Context->realpath)
1080 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1081 + mutt_pretty_mailbox (tmp, sizeof (tmp));
1085 if (Context && Context->path)
1087 strfcpy (tmp, Context->path, sizeof (tmp));
1090 @@ -5159,6 +5159,36 @@
1091 msgid "show S/MIME options"
1092 msgstr "Zeige S/MIME Optionen"
1095 +#: compress.c:228 compress.c:253
1097 +msgid "Decompressing %s...\n"
1098 +msgstr "Entpacke %s...\n"
1100 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1102 +msgid "Compressing %s...\n"
1103 +msgstr "Komprimiere %s...\n"
1108 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1111 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1112 +"entpackte gespeichert!\n"
1114 +#: compress.c:425 compress.c:456
1116 +msgid "Compressed-appending to %s...\n"
1117 +msgstr "Hänge komprimiert an %s... an\n"
1121 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1122 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1125 #~ msgstr "Klartext"