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.16.rr.compressed.1.gz
14 - 2007-06-14 myon: remove hunks for Muttrc*
21 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
23 + * This program is free software; you can redistribute it and/or modify
24 + * it under the terms of the GNU General Public License as published by
25 + * the Free Software Foundation; either version 2 of the License, or
26 + * (at your option) any later version.
28 + * This program is distributed in the hope that it will be useful,
29 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 + * GNU General Public License for more details.
33 + * You should have received a copy of the GNU General Public License
34 + * along with this program; if not, write to the Free Software
35 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
44 +#ifdef USE_COMPRESSED
48 +#include "mutt_curses.h"
53 +#include <sys/stat.h>
57 + const char *close; /* close-hook command */
58 + const char *open; /* open-hook command */
59 + const char *append; /* append-hook command */
60 + off_t size; /* size of real folder */
65 + * ctx - context to lock
66 + * excl - exclusive lock?
67 + * retry - should retry if unable to lock?
69 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
73 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
75 + else if (retry && !excl)
84 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
90 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
95 +static int is_new (const char *path)
97 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
100 +static const char* find_compress_hook (int type, const char *path)
102 + const char* c = mutt_find_hook (type, path);
103 + return (!c || !*c) ? NULL : c;
106 +int mutt_can_read_compressed (const char *path)
108 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
112 + * if the file is new, we really do not append, but create, and so use
113 + * close-hook, and not append-hook
115 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
117 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
118 + return (is_new (path)) ? ci->close : ci->append;
121 +int mutt_can_append_compressed (const char *path)
127 + char *dir_path = safe_strdup(path);
128 + char *aux = strrchr(dir_path, '/');
133 + if (access(dir_path, W_OK|X_OK))
136 + safe_free((void**)&dir_path);
137 + return dir_valid && (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
140 + magic = mx_get_magic (path);
142 + if (magic != 0 && magic != M_COMPRESSED)
145 + return (find_compress_hook (M_APPENDHOOK, path)
146 + || (find_compress_hook (M_OPENHOOK, path)
147 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
150 +/* open a compressed mailbox */
151 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
155 + /* Now lets uncompress this thing */
156 + ci = safe_malloc (sizeof (COMPRESS_INFO));
157 + ctx->compressinfo = (void*) ci;
158 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
159 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
160 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
164 +static void set_path (CONTEXT* ctx)
166 + char tmppath[_POSIX_PATH_MAX];
168 + /* Setup the right paths */
169 + ctx->realpath = ctx->path;
171 + /* Uncompress to /tmp */
172 + mutt_mktemp (tmppath);
173 + ctx->path = safe_malloc (strlen (tmppath) + 1);
174 + strcpy (ctx->path, tmppath);
177 +static int get_size (const char* path)
180 + if (stat (path, &sb) != 0)
182 + return (sb.st_size);
185 +static void store_size (CONTEXT* ctx)
187 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
188 + ci->size = get_size (ctx->realpath);
192 +compresshook_format_str (char *dest, size_t destlen, size_t col, char op,
193 + const char *src, const char *fmt,
194 + const char *ifstring, const char *elsestring,
195 + unsigned long data, format_flag flags)
197 + char tmp[SHORT_STRING];
199 + CONTEXT *ctx = (CONTEXT *) data;
203 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
204 + snprintf (dest, destlen, tmp, ctx->realpath);
207 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
208 + snprintf (dest, destlen, tmp, ctx->path);
215 + * check that the command has both %f and %t
216 + * 0 means OK, -1 means error
218 +int mutt_test_compress_command (const char* cmd)
220 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
223 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
225 + char expanded[_POSIX_PATH_MAX];
226 + mutt_FormatString (expanded, sizeof (expanded), 0, cmd,
227 + compresshook_format_str, (unsigned long) ctx, 0);
228 + return safe_strdup (expanded);
231 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
233 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
234 + if (ci->size != get_size (ctx->realpath))
236 + FREE (&ctx->compressinfo);
237 + FREE (&ctx->realpath);
238 + mutt_error _("Mailbox was corrupted!");
244 +int mutt_open_read_compressed (CONTEXT *ctx)
250 + COMPRESS_INFO *ci = set_compress_info (ctx);
253 + FREE (&ctx->compressinfo);
256 + if (!ci->close || access (ctx->path, W_OK) != 0)
263 + mutt_message (_("Decompressing %s..."), ctx->realpath);
265 + cmd = get_compression_cmd (ci->open, ctx);
268 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
270 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
272 + mutt_perror (ctx->realpath);
276 + mutt_block_signals ();
277 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
280 + mutt_unblock_signals ();
281 + mutt_error _("Unable to lock mailbox!");
288 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
289 + rc = mutt_system (cmd);
290 + mbox_unlock_compressed (ctx, fp);
291 + mutt_unblock_signals ();
296 + mutt_any_key_to_continue (NULL);
298 + FREE (&ctx->compressinfo);
299 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
305 + if (mutt_check_mailbox_compressed (ctx))
308 + ctx->magic = mx_get_magic (ctx->path);
313 +void restore_path (CONTEXT* ctx)
316 + ctx->path = ctx->realpath;
319 +/* remove the temporary mailbox */
320 +void remove_file (CONTEXT* ctx)
322 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
323 + remove (ctx->path);
326 +int mutt_open_append_compressed (CONTEXT *ctx)
329 + COMPRESS_INFO *ci = set_compress_info (ctx);
331 + if (!get_append_command (ctx->path, ctx))
333 + if (ci->open && ci->close)
334 + return (mutt_open_read_compressed (ctx));
337 + FREE (&ctx->compressinfo);
343 + ctx->magic = DefaultMagic;
345 + if (!is_new (ctx->realpath))
346 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
347 + if ((fh = fopen (ctx->path, "w")))
349 + /* No error checking - the parent function will catch it */
354 +/* close a compressed mailbox */
355 +void mutt_fast_close_compressed (CONTEXT *ctx)
357 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
360 + if (ctx->compressinfo)
365 + /* if the folder was removed, remove the gzipped folder too */
366 + if ((ctx->magic > 0)
367 + && (access (ctx->path, F_OK) != 0)
368 + && ! option (OPTSAVEEMPTY))
369 + remove (ctx->realpath);
373 + restore_path (ctx);
374 + FREE (&ctx->compressinfo);
378 +/* return 0 on success, -1 on failure */
379 +int mutt_sync_compressed (CONTEXT* ctx)
384 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
387 + mutt_message (_("Compressing %s..."), ctx->realpath);
389 + cmd = get_compression_cmd (ci->close, ctx);
393 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
395 + mutt_perror (ctx->realpath);
399 + mutt_block_signals ();
400 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
403 + mutt_unblock_signals ();
404 + mutt_error _("Unable to lock mailbox!");
410 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
414 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
415 + if (mutt_system (cmd))
417 + mutt_any_key_to_continue (NULL);
418 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
422 + mbox_unlock_compressed (ctx, fp);
423 + mutt_unblock_signals ();
433 +int mutt_slow_close_compressed (CONTEXT *ctx)
436 + const char *append;
438 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
440 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
444 + && ((append = get_append_command (ctx->realpath, ctx))
445 + || (append = ci->close))))
447 + /* if we can not or should not append, we only have to remove the */
448 + /* compressed info, because sync was already called */
449 + mutt_fast_close_compressed (ctx);
459 + if (append == ci->close)
460 + mutt_message (_("Compressing %s..."), ctx->realpath);
462 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
465 + cmd = get_compression_cmd (append, ctx);
469 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
471 + mutt_perror (ctx->realpath);
475 + mutt_block_signals ();
476 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
479 + mutt_unblock_signals ();
480 + mutt_error _("Unable to lock mailbox!");
485 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
490 + if (append == ci->close)
491 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
493 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
495 + if (mutt_system (cmd))
497 + mutt_any_key_to_continue (NULL);
498 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
501 + mbox_unlock_compressed (ctx, fp);
502 + mutt_unblock_signals ();
507 + mbox_unlock_compressed (ctx, fp);
508 + mutt_unblock_signals ();
511 + restore_path (ctx);
513 + FREE (&ctx->compressinfo);
518 +#endif /* USE_COMPRESSED */
523 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
525 + * This program is free software; you can redistribute it and/or modify
526 + * it under the terms of the GNU General Public License as published by
527 + * the Free Software Foundation; either version 2 of the License, or
528 + * (at your option) any later version.
530 + * This program is distributed in the hope that it will be useful,
531 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
532 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
533 + * GNU General Public License for more details.
535 + * You should have received a copy of the GNU General Public License
536 + * along with this program; if not, write to the Free Software
537 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
540 +int mutt_can_read_compressed (const char *);
541 +int mutt_can_append_compressed (const char *);
542 +int mutt_open_read_compressed (CONTEXT *);
543 +int mutt_open_append_compressed (CONTEXT *);
544 +int mutt_slow_close_compressed (CONTEXT *);
545 +int mutt_sync_compressed (CONTEXT *);
546 +int mutt_test_compress_command (const char *);
547 +int mutt_check_mailbox_compressed (CONTEXT *);
548 +void mutt_fast_close_compressed (CONTEXT *);
551 @@ -804,6 +804,11 @@ AC_ARG_ENABLE(locales-fix, AC_HELP_STRIN
552 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
555 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
556 + [if test x$enableval = xyes; then
557 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
560 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
561 [if test $withval != yes; then
562 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
565 @@ -1116,6 +1116,11 @@ int mutt_index_menu (void)
569 +#ifdef USE_COMPRESSED
570 + if (Context->compressinfo && Context->realpath)
571 + mutt_str_replace (&LastFolder, Context->realpath);
574 mutt_str_replace (&LastFolder, Context->path);
575 oldcount = Context ? Context->msgcount : 0;
577 --- a/doc/manual.xml.head
578 +++ b/doc/manual.xml.head
579 @@ -4932,6 +4932,205 @@ becomes an issue as mutt will silently f
583 +<sect1 id="compressedfolders">
584 +<title>Compressed folders Support (OPTIONAL)</title>
587 +If Mutt was compiled with compressed folders support (by running the
588 +<emphasis>configure</emphasis> script with the
589 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
590 +stored in an arbitrary format, provided that the user has a script to
591 +convert from/to this format to one of the accepted.
593 +The most common use is to open compressed archived folders e.g. with
596 +In addition, the user can provide a script that gets a folder in an
597 +accepted format and appends its context to the folder in the
598 +user-defined format, which may be faster than converting the entire
599 +folder to the accepted format, appending to it and converting back to
600 +the user-defined format.
602 +There are three hooks defined (<link
603 +linkend="open-hook">open-hook</link>, <link
604 +linkend="close-hook">close-hook</link> and <link
605 +linkend="append-hook">append-hook</link>) which define commands to
606 +uncompress and compress a folder and to append messages to an existing
607 +compressed folder respectively.
612 +open-hook \\.gz$ "gzip -cd %f > %t"
613 +close-hook \\.gz$ "gzip -c %t > %f"
614 +append-hook \\.gz$ "gzip -c %t >> %f"
617 +You do not have to specify all of the commands. If you omit <link
618 +linkend="append-hook">append-hook</link>, the folder will be open and
619 +closed again each time you will add to it. If you omit <link
620 +linkend="close-hook">close-hook</link> (or give empty command) , the
621 +folder will be open in the mode. If you specify <link
622 +linkend="append-hook">append-hook</link> though you'll be able to
623 +append to the folder.
625 +Note that Mutt will only try to use hooks if the file is not in one of
626 +the accepted formats. In particular, if the file is empty, mutt
627 +supposes it is not compressed. This is important because it allows the
628 +use of programs that do not have well defined extensions. Just use
629 +"." as a regexp. But this may be surprising if your
630 +compressing script produces empty files. In this situation, unset
631 +<link linkend="save-empty">$save_empty</link>, so that
632 +the compressed file will be removed if you delete all of the messages.
635 +<sect2 id="open-hook">
636 +<title>Open a compressed mailbox for reading</title>
639 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
641 +The <emphasis>command</emphasis> is the command that can be used for
642 +opening the folders whose names match <emphasis>regexp</emphasis>.
644 +The <emphasis>command</emphasis> string is the printf-like format
645 +string, and it should accept two parameters: %f, which is
646 +replaced with the (compressed) folder name, and %t which is
647 +replaced with the name of the temporary folder to which to write.
649 +%f and %t can be repeated any number of times in the
650 +command string, and all of the entries are replaced with the
651 +appropriate folder name. In addition, %% is replaced by
652 +%, as in printf, and any other %anything is left as is.
654 +The <emphasis>command</emphasis> should <emphasis
655 +role="bold">not</emphasis> remove the original compressed file. The
656 +<emphasis>command</emphasis> should return non-zero exit status if it
657 +fails, so mutt knows something's wrong.
662 +open-hook \\.gz$ "gzip -cd %f > %t"
665 +If the <emphasis>command</emphasis> is empty, this operation is
666 +disabled for this file type.
670 +<sect2 id="close-hook">
671 +<title>Write a compressed mailbox</title>
674 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
676 +This is used to close the folder that was open with the <link
677 +linkend="open-hook">open-hook</link> command after some changes were
680 +The <emphasis>command</emphasis> string is the command that can be
681 +used for closing the folders whose names match
682 +<emphasis>regexp</emphasis>. It has the same format as in the <link
683 +linkend="open-hook">open-hook</link> command. Temporary folder in this
684 +case is the folder previously produced by the <link
685 +linkend="open-hook">open-hook</link> command.
687 +The <emphasis>command</emphasis> should <emphasis
688 +role="bold">not</emphasis> remove the decompressed file. The
689 +<emphasis>command</emphasis> should return non-zero exit status if it
690 +fails, so mutt knows something's wrong.
695 +close-hook \\.gz$ "gzip -c %t > %f"
698 +If the <emphasis>command</emphasis> is empty, this operation is
699 +disabled for this file type, and the file can only be open in the
702 +<link linkend="close-hook">close-hook</link> is not called when you
703 +exit from the folder if the folder was not changed.
707 +<sect2 id="append-hook">
708 +<title>Append a message to a compressed mailbox</title>
711 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
713 +This command is used for saving to an existing compressed folder. The
714 +<emphasis>command</emphasis> is the command that can be used for
715 +appending to the folders whose names match
716 +<emphasis>regexp</emphasis>. It has the same format as in the <link
717 +linkend="open-hook">open-hook</link> command. The temporary folder in
718 +this case contains the messages that are being appended.
720 +The <emphasis>command</emphasis> should <emphasis
721 +role="bold">not</emphasis> remove the decompressed file. The
722 +<emphasis>command</emphasis> should return non-zero exit status if it
723 +fails, so mutt knows something's wrong.
728 +append-hook \\.gz$ "gzip -c %t >> %f"
731 +When <link linkend="append-hook">append-hook</link> is used, the folder
732 +is not opened, which saves time, but this means that we can not find
733 +out what the folder type is. Thus the default (<link
734 +linkend="mbox-type">$mbox_type</link>) type is always
735 +supposed (i.e. this is the format used for the temporary folder).
737 +If the file does not exist when you save to it, <link
738 +linkend="close-hook">close-hook</link> is called, and not <link
739 +linkend="append-hook">append-hook</link>. <link
740 +linkend="append-hook">append-hook</link> is only for appending to
743 +If the <emphasis>command</emphasis> is empty, this operation is
744 +disabled for this file type. In this case, the folder will be open and
745 +closed again (using <link linkend="open-hook">open-hook</link> and
746 +<link linkend="close-hook">close-hook</link>respectively) each time you
752 +<title>Encrypted folders</title>
755 +The compressed folders support can also be used to handle encrypted
756 +folders. If you want to encrypt a folder with PGP, you may want to use
757 +the following hooks:
760 +open-hook \\.pgp$ "pgp -f < %f > %t"
761 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
764 +Please note, that PGP does not support appending to an encrypted
765 +folder, so there is no append-hook defined.
767 +If you are using GnuPG instead of PGP, you may use the following hooks
771 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
772 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
775 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
776 +decrypted in the /tmp directory, where it can be read by your system
777 +administrator. So think about the security aspects of this.
782 <chapter id="mimesupport">
783 <title>Mutt's MIME Support</title>
785 --- a/doc/muttrc.man.head
786 +++ b/doc/muttrc.man.head
787 @@ -345,6 +345,24 @@ specify the ID of the public key to be u
788 to a certain recipient. The meaning of "key ID" is to be taken
789 broadly: This can be a different e-mail address, a numerical key ID,
790 or even just an arbitrary search string.
793 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
794 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
795 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
798 +These commands provide a way to handle compressed folders. The given
799 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
800 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
801 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
802 +compressed mail to a compressed folder (\fBappend-hook\fP). The
803 +\fIcommand\fP string is the
805 +like format string, and it should accept two parameters: \fB%f\fP,
806 +which is replaced with the (compressed) folder name, and \fB%t\fP
807 +which is replaced with the name of the temporary folder to which to
810 \fBpush\fP \fIstring\fP
811 This command adds the named \fIstring\fP to the keyboard buffer.
816 #include "mutt_crypt.h"
818 +#ifdef USE_COMPRESSED
819 +#include "compress.h"
825 @@ -92,6 +96,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
826 memset (&pattern, 0, sizeof (pattern));
827 pattern.data = safe_strdup (path);
829 +#ifdef USE_COMPRESSED
830 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
832 + if (mutt_test_compress_command (command.data))
834 + strfcpy (err->data, _("badly formatted command string"), err->dsize);
839 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
840 && (!WithCrypto || !(data & M_CRYPTHOOK))
844 @@ -3172,6 +3172,11 @@ struct command_t Commands[] = {
845 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
846 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
847 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
848 +#ifdef USE_COMPRESSED
849 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
850 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
851 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
853 { "group", parse_group, 0 },
854 { "ungroup", parse_ungroup, 0 },
855 { "hdr_order", parse_list, UL &HeaderOrderList },
858 @@ -400,6 +400,12 @@ static void show_version (void)
863 +#ifdef USE_COMPRESSED
873 @@ -18,7 +18,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.
874 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
875 mutt_SOURCES = $(BUILT_SOURCES) \
876 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
877 - crypt.c cryptglue.c \
878 + crypt.c cryptglue.c compress.c \
879 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
880 edit.c enter.c flags.c init.c filter.c from.c \
881 getdomain.c group.c \
882 @@ -66,7 +66,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
885 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
886 - configure account.h \
887 + configure account.h compress.h \
888 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
889 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
890 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
895 #include "mutt_curses.h"
897 +#ifdef USE_COMPRESSED
898 +#include "compress.h"
901 #include <sys/stat.h>
904 @@ -1026,6 +1030,12 @@ bail: /* Come here in case of disaster
905 int mbox_close_mailbox (CONTEXT *ctx)
907 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
909 +#ifdef USE_COMPRESSED
910 + if (ctx->compressinfo)
911 + mutt_slow_close_compressed (ctx);
914 mutt_unblock_signals ();
915 mx_fastclose_mailbox (ctx);
919 @@ -160,6 +160,11 @@ typedef enum
920 #define M_ACCOUNTHOOK (1<<9)
921 #define M_REPLYHOOK (1<<10)
922 #define M_SEND2HOOK (1<<11)
923 +#ifdef USE_COMPRESSED
924 +#define M_OPENHOOK (1<<12)
925 +#define M_APPENDHOOK (1<<13)
926 +#define M_CLOSEHOOK (1<<14)
929 /* tree characters for linearize_tree and print_enriched_string */
930 #define M_TREE_LLCORNER 1
931 @@ -889,6 +894,11 @@ typedef struct _context
932 int flagged; /* how many flagged messages */
933 int msgnotreadyet; /* which msg "new" in pager, -1 if none */
935 +#ifdef USE_COMPRESSED
936 + void *compressinfo; /* compressed mbox module private data */
937 + char *realpath; /* path to compressed mailbox */
938 +#endif /* USE_COMPRESSED */
940 short magic; /* mailbox type */
942 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
949 +#ifdef USE_COMPRESSED
950 +#include "compress.h"
956 @@ -450,6 +454,10 @@ int mx_get_magic (const char *path)
960 +#ifdef USE_COMPRESSED
961 + if (magic == 0 && mutt_can_read_compressed (path))
962 + return M_COMPRESSED;
967 @@ -489,6 +497,13 @@ static int mx_open_mailbox_append (CONTE
971 +#ifdef USE_COMPRESSED
972 + /* special case for appending to compressed folders -
973 + * even if we can not open them for reading */
974 + if (mutt_can_append_compressed (ctx->path))
975 + mutt_open_append_compressed (ctx);
981 @@ -652,7 +667,12 @@ CONTEXT *mx_open_mailbox (const char *pa
984 ctx->magic = mx_get_magic (path);
987 +#ifdef USE_COMPRESSED
988 + if (ctx->magic == M_COMPRESSED)
989 + mutt_open_read_compressed (ctx);
993 mutt_error (_("%s is not a mailbox."), path);
995 @@ -753,6 +773,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
996 mutt_free_header (&ctx->hdrs[i]);
999 +#ifdef USE_COMPRESSED
1000 + if (ctx->compressinfo)
1001 + mutt_fast_close_compressed (ctx);
1004 FREE (&ctx->pattern);
1005 if (ctx->limit_pattern)
1006 @@ -805,6 +829,12 @@ static int sync_mailbox (CONTEXT *ctx, i
1008 if (tmp && tmp->new == 0)
1009 mutt_update_mailbox (tmp);
1011 +#ifdef USE_COMPRESSED
1012 + if (rc == 0 && ctx->compressinfo)
1013 + return mutt_sync_compressed (ctx);
1019 @@ -1063,6 +1093,11 @@ int mx_close_mailbox (CONTEXT *ctx, int
1020 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1021 mx_unlink_empty (ctx->path);
1023 +#ifdef USE_COMPRESSED
1024 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1028 mx_fastclose_mailbox (ctx);
1031 @@ -1378,6 +1413,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
1035 +#ifdef USE_COMPRESSED
1036 + if (ctx->compressinfo)
1037 + return mutt_check_mailbox_compressed (ctx);
1042 if (ctx->locked) lock = 0;
1045 @@ -40,6 +40,9 @@ enum
1049 +#ifdef USE_COMPRESSED
1054 WHERE short DefaultMagic INITVAL (M_MBOX);
1057 @@ -5,3 +5,4 @@ patch-1.5.13.nt+ab.xtitles.4
1058 patch-1.5.6.dw.maildir-mtime.1
1059 patch-1.5.13.cd.ifdef.2
1060 patch-1.5.8.hr.sensible_browser_position.3
1061 +patch-1.5.16.rr.compressed.1
1064 @@ -3,7 +3,7 @@ msgstr ""
1065 "Project-Id-Version: 1.5.14\n"
1066 "Report-Msgid-Bugs-To: \n"
1067 "POT-Creation-Date: 2007-02-23 09:18-0800\n"
1068 -"PO-Revision-Date: 2007-02-25 12:33+0100\n"
1069 +"PO-Revision-Date: 2007-09-08 20:55+0200\n"
1070 "Last-Translator: Roland Rosenfeld <roland@spinnaker.de>\n"
1071 "Language-Team: German <mutt-po@mutt.org>\n"
1072 "MIME-Version: 1.0\n"
1073 @@ -1266,6 +1266,48 @@ msgstr "Prüfung des Absenders fehlgeschl
1074 msgid "Failed to figure out sender"
1075 msgstr "Kann Absender nicht ermitteln"
1077 +#: compress.c:203 mbox.c:661
1078 +msgid "Mailbox was corrupted!"
1079 +msgstr "Mailbox wurde zerstört!"
1081 +#: compress.c:228 compress.c:253
1083 +msgid "Decompressing %s...\n"
1084 +msgstr "Entpacke %s...\n"
1086 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1087 +msgid "Unable to lock mailbox!"
1088 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1092 +msgid "Error executing: %s : unable to open the mailbox!\n"
1093 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1095 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1097 +msgid "Compressing %s...\n"
1098 +msgstr "Komprimiere %s...\n"
1103 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1106 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1107 +"entpackte gespeichert!\n"
1109 +#: compress.c:425 compress.c:456
1111 +msgid "Compressed-appending to %s...\n"
1112 +msgstr "Hänge komprimiert an %s... an\n"
1116 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1117 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1121 msgid " (current time: %c)"
1122 @@ -1926,6 +1968,10 @@ msgstr ""
1124 msgstr "Hilfe für %s"
1127 +msgid "badly formatted command string"
1128 +msgstr "Hook enthält nicht die Muster %f und %t"
1132 msgid "unhook: Can't do unhook * from within a hook."
1133 @@ -3428,18 +3474,10 @@ msgstr "Lese %s..."
1134 msgid "Mailbox is corrupt!"
1135 msgstr "Mailbox fehlerhaft!"
1138 -msgid "Mailbox was corrupted!"
1139 -msgstr "Mailbox wurde zerstört!"
1141 #: mbox.c:711 mbox.c:964
1142 msgid "Fatal error! Could not reopen mailbox!"
1143 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1146 -msgid "Unable to lock mailbox!"
1147 -msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1149 #. this means ctx->changed or ctx->deleted was set, but no
1150 #. * messages were found to be changed or deleted. This should
1151 #. * never happen, is we presume it is a bug in mutt.
1152 --- a/po/POTFILES.in
1153 +++ b/po/POTFILES.in
1154 @@ -8,6 +8,7 @@ charset.c
1164 @@ -97,6 +97,14 @@ status_format_str (char *buf, size_t buf
1167 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1168 +#ifdef USE_COMPRESSED
1169 + if (Context && Context->compressinfo && Context->realpath)
1171 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1172 + mutt_pretty_mailbox (tmp);
1176 if (Context && Context->path)
1178 strfcpy (tmp, Context->path, sizeof (tmp));