2 This is the compressed folders patch by Roland Rosenfeld
5 The home page for this patch is:
7 http://www.spinnaker.de/mutt/compressed/
9 * Patch last synced with upstream:
11 - File: http://www.spinnaker.de/mutt/compressed/patch-1.5.11.rr.compressed.1.gz
15 $(for f in Makefile.in config.h.in configure 'Muttrc*' doc/manual.txt \
16 doc/manual.sgml 'doc/manual*.html' doc/muttrc.man; do echo "-x $f"; done)
19 diff -urN mutt-1.5.11/compress.c mutt-1.5.11-ro/compress.c
20 --- mutt-1.5.11/compress.c 1970-01-01 01:00:00.000000000 +0100
21 +++ mutt-1.5.11-ro/compress.c 2005-09-27 13:26:58.000000000 +0200
24 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
26 + * This program is free software; you can redistribute it and/or modify
27 + * it under the terms of the GNU General Public License as published by
28 + * the Free Software Foundation; either version 2 of the License, or
29 + * (at your option) any later version.
31 + * This program is distributed in the hope that it will be useful,
32 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 + * GNU General Public License for more details.
36 + * You should have received a copy of the GNU General Public License
37 + * along with this program; if not, write to the Free Software
38 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
47 +#ifdef USE_COMPRESSED
51 +#include "mutt_curses.h"
56 +#include <sys/stat.h>
60 + const char *close; /* close-hook command */
61 + const char *open; /* open-hook command */
62 + const char *append; /* append-hook command */
63 + off_t size; /* size of real folder */
68 + * ctx - context to lock
69 + * excl - exclusive lock?
70 + * retry - should retry if unable to lock?
72 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
76 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
78 + else if (retry && !excl)
87 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
93 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
98 +static int is_new (const char *path)
100 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
103 +static const char* find_compress_hook (int type, const char *path)
105 + const char* c = mutt_find_hook (type, path);
106 + return (!c || !*c) ? NULL : c;
109 +int mutt_can_read_compressed (const char *path)
111 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
115 + * if the file is new, we really do not append, but create, and so use
116 + * close-hook, and not append-hook
118 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
120 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
121 + return (is_new (path)) ? ci->close : ci->append;
124 +int mutt_can_append_compressed (const char *path)
129 + return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
131 + magic = mx_get_magic (path);
133 + if (magic != 0 && magic != M_COMPRESSED)
136 + return (find_compress_hook (M_APPENDHOOK, path)
137 + || (find_compress_hook (M_OPENHOOK, path)
138 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
141 +/* open a compressed mailbox */
142 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
146 + /* Now lets uncompress this thing */
147 + ci = safe_malloc (sizeof (COMPRESS_INFO));
148 + ctx->compressinfo = (void*) ci;
149 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
150 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
151 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
155 +static void set_path (CONTEXT* ctx)
157 + char tmppath[_POSIX_PATH_MAX];
159 + /* Setup the right paths */
160 + ctx->realpath = ctx->path;
162 + /* Uncompress to /tmp */
163 + mutt_mktemp (tmppath);
164 + ctx->path = safe_malloc (strlen (tmppath) + 1);
165 + strcpy (ctx->path, tmppath);
168 +static int get_size (const char* path)
171 + if (stat (path, &sb) != 0)
173 + return (sb.st_size);
176 +static void store_size (CONTEXT* ctx)
178 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
179 + ci->size = get_size (ctx->realpath);
183 +compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
184 + const char *fmt, const char *ifstring,
185 + const char *elsestring, unsigned long data,
188 + char tmp[SHORT_STRING];
190 + CONTEXT *ctx = (CONTEXT *) data;
194 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
195 + snprintf (dest, destlen, tmp, ctx->realpath);
198 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
199 + snprintf (dest, destlen, tmp, ctx->path);
206 + * check that the command has both %f and %t
207 + * 0 means OK, -1 means error
209 +int mutt_test_compress_command (const char* cmd)
211 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
214 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
216 + char expanded[_POSIX_PATH_MAX];
217 + mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str,
218 + (unsigned long) ctx, 0);
219 + return safe_strdup (expanded);
222 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
224 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
225 + if (ci->size != get_size (ctx->realpath))
227 + FREE (&ctx->compressinfo);
228 + FREE (&ctx->realpath);
229 + mutt_error _("Mailbox was corrupted!");
235 +int mutt_open_read_compressed (CONTEXT *ctx)
241 + COMPRESS_INFO *ci = set_compress_info (ctx);
244 + FREE (ctx->compressinfo);
247 + if (!ci->close || access (ctx->path, W_OK) != 0)
254 + mutt_message (_("Decompressing %s..."), ctx->realpath);
256 + cmd = get_compression_cmd (ci->open, ctx);
259 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
261 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
263 + mutt_perror (ctx->realpath);
267 + mutt_block_signals ();
268 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
271 + mutt_unblock_signals ();
272 + mutt_error _("Unable to lock mailbox!");
279 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
280 + rc = mutt_system (cmd);
281 + mbox_unlock_compressed (ctx, fp);
282 + mutt_unblock_signals ();
287 + mutt_any_key_to_continue (NULL);
289 + FREE (ctx->compressinfo);
290 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
296 + if (mutt_check_mailbox_compressed (ctx))
299 + ctx->magic = mx_get_magic (ctx->path);
304 +void restore_path (CONTEXT* ctx)
307 + ctx->path = ctx->realpath;
310 +/* remove the temporary mailbox */
311 +void remove_file (CONTEXT* ctx)
313 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
314 + remove (ctx->path);
317 +int mutt_open_append_compressed (CONTEXT *ctx)
320 + COMPRESS_INFO *ci = set_compress_info (ctx);
322 + if (!get_append_command (ctx->path, ctx))
324 + if (ci->open && ci->close)
325 + return (mutt_open_read_compressed (ctx));
328 + FREE (&ctx->compressinfo);
334 + ctx->magic = DefaultMagic;
336 + if (!is_new (ctx->realpath))
337 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
338 + if ((fh = fopen (ctx->path, "w")))
340 + /* No error checking - the parent function will catch it */
345 +/* close a compressed mailbox */
346 +void mutt_fast_close_compressed (CONTEXT *ctx)
348 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
351 + if (ctx->compressinfo)
356 + /* if the folder was removed, remove the gzipped folder too */
357 + if ((ctx->magic > 0)
358 + && (access (ctx->path, F_OK) != 0)
359 + && ! option (OPTSAVEEMPTY))
360 + remove (ctx->realpath);
364 + restore_path (ctx);
365 + FREE (&ctx->compressinfo);
369 +/* return 0 on success, -1 on failure */
370 +int mutt_sync_compressed (CONTEXT* ctx)
375 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
378 + mutt_message (_("Compressing %s..."), ctx->realpath);
380 + cmd = get_compression_cmd (ci->close, ctx);
384 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
386 + mutt_perror (ctx->realpath);
390 + mutt_block_signals ();
391 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
394 + mutt_unblock_signals ();
395 + mutt_error _("Unable to lock mailbox!");
401 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
405 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
406 + if (mutt_system (cmd))
408 + mutt_any_key_to_continue (NULL);
409 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
413 + mbox_unlock_compressed (ctx, fp);
414 + mutt_unblock_signals ();
424 +int mutt_slow_close_compressed (CONTEXT *ctx)
427 + const char *append;
429 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
431 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
435 + && ((append = get_append_command (ctx->realpath, ctx))
436 + || (append = ci->close))))
438 + /* if we can not or should not append, we only have to remove the */
439 + /* compressed info, because sync was already called */
440 + mutt_fast_close_compressed (ctx);
450 + if (append == ci->close)
451 + mutt_message (_("Compressing %s..."), ctx->realpath);
453 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
456 + cmd = get_compression_cmd (append, ctx);
460 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
462 + mutt_perror (ctx->realpath);
466 + mutt_block_signals ();
467 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
470 + mutt_unblock_signals ();
471 + mutt_error _("Unable to lock mailbox!");
476 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
481 + if (append == ci->close)
482 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
484 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
486 + if (mutt_system (cmd))
488 + mutt_any_key_to_continue (NULL);
489 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
492 + mbox_unlock_compressed (ctx, fp);
493 + mutt_unblock_signals ();
498 + mbox_unlock_compressed (ctx, fp);
499 + mutt_unblock_signals ();
502 + restore_path (ctx);
504 + FREE (&ctx->compressinfo);
509 +#endif /* USE_COMPRESSED */
510 diff -urN mutt-1.5.11/compress.h mutt-1.5.11-ro/compress.h
511 --- mutt-1.5.11/compress.h 1970-01-01 01:00:00.000000000 +0100
512 +++ mutt-1.5.11-ro/compress.h 2005-09-27 13:26:58.000000000 +0200
515 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
517 + * This program is free software; you can redistribute it and/or modify
518 + * it under the terms of the GNU General Public License as published by
519 + * the Free Software Foundation; either version 2 of the License, or
520 + * (at your option) any later version.
522 + * This program is distributed in the hope that it will be useful,
523 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
524 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
525 + * GNU General Public License for more details.
527 + * You should have received a copy of the GNU General Public License
528 + * along with this program; if not, write to the Free Software
529 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
532 +int mutt_can_read_compressed (const char *);
533 +int mutt_can_append_compressed (const char *);
534 +int mutt_open_read_compressed (CONTEXT *);
535 +int mutt_open_append_compressed (CONTEXT *);
536 +int mutt_slow_close_compressed (CONTEXT *);
537 +int mutt_sync_compressed (CONTEXT *);
538 +int mutt_test_compress_command (const char *);
539 +int mutt_check_mailbox_compressed (CONTEXT *);
540 +void mutt_fast_close_compressed (CONTEXT *);
541 diff -urN mutt-1.5.11/config.h.in mutt-1.5.11-ro/config.h.in
542 diff -urN mutt-1.5.11/configure mutt-1.5.11-ro/configure
543 diff -urN mutt-1.5.11/configure.in mutt-1.5.11-ro/configure.in
544 --- mutt-1.5.11/configure.in 2005-09-15 16:21:24.000000000 +0200
545 +++ mutt-1.5.11-ro/configure.in 2005-09-27 13:26:58.000000000 +0200
547 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
550 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
551 + [if test x$enableval = xyes; then
552 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
555 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
556 [if test $withval != yes; then
557 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
558 diff -urN mutt-1.5.11/curs_main.c mutt-1.5.11-ro/curs_main.c
559 --- mutt-1.5.11/curs_main.c 2005-09-07 10:19:43.000000000 +0200
560 +++ mutt-1.5.11-ro/curs_main.c 2005-09-27 13:26:58.000000000 +0200
561 @@ -1091,6 +1091,11 @@
565 +#ifdef USE_COMPRESSED
566 + if (Context->compressinfo && Context->realpath)
567 + mutt_str_replace (&LastFolder, Context->realpath);
570 mutt_str_replace (&LastFolder, Context->path);
571 oldcount = Context ? Context->msgcount : 0;
573 diff -urN mutt-1.5.11/doc/manual.xml.head mutt-1.5.11-ro/doc/manual.xml.head
574 --- mutt-1.5.11/doc/manual.xml.head 2005-09-06 18:46:44.000000000 +0200
575 +++ mutt-1.5.11-ro/doc/manual.xml.head 2005-09-27 13:29:11.000000000 +0200
576 @@ -4404,6 +4404,205 @@
580 +<sect2 id="compressedfolders">
581 +<title>Compressed folders Support (OPTIONAL)</title>
584 +If Mutt was compiled with compressed folders support (by running the
585 +<emphasis>configure</emphasis> script with the
586 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
587 +stored in an arbitrary format, provided that the user has a script to
588 +convert from/to this format to one of the accepted.
590 +The most common use is to open compressed archived folders e.g. with
593 +In addition, the user can provide a script that gets a folder in an
594 +accepted format and appends its context to the folder in the
595 +user-defined format, which may be faster than converting the entire
596 +folder to the accepted format, appending to it and converting back to
597 +the user-defined format.
599 +There are three hooks defined (<link
600 +linkend="open-hook">open-hook</link>, <link
601 +linkend="close-hook">close-hook</link> and <link
602 +linkend="append-hook">append-hook</link>) which define commands to
603 +uncompress and compress a folder and to append messages to an existing
604 +compressed folder respectively.
609 +open-hook \\.gz$ "gzip -cd %f > %t"
610 +close-hook \\.gz$ "gzip -c %t > %f"
611 +append-hook \\.gz$ "gzip -c %t >> %f"
614 +You do not have to specify all of the commands. If you omit <link
615 +linkend="append-hook">append-hook</link>, the folder will be open and
616 +closed again each time you will add to it. If you omit <link
617 +linkend="close-hook">close-hook</link> (or give empty command) , the
618 +folder will be open in the mode. If you specify <link
619 +linkend="append-hook">append-hook</link> though you'll be able to
620 +append to the folder.
622 +Note that Mutt will only try to use hooks if the file is not in one of
623 +the accepted formats. In particular, if the file is empty, mutt
624 +supposes it is not compressed. This is important because it allows the
625 +use of programs that do not have well defined extensions. Just use
626 +"." as a regexp. But this may be surprising if your
627 +compressing script produces empty files. In this situation, unset
628 +<link linkend="save-empty">$save_empty</link>, so that
629 +the compressed file will be removed if you delete all of the messages.
632 +<sect3 id="open-hook">
633 +<title>Open a compressed mailbox for reading</title>
636 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
638 +The <emphasis>command</emphasis> is the command that can be used for
639 +opening the folders whose names match <emphasis>regexp</emphasis>.
641 +The <emphasis>command</emphasis> string is the printf-like format
642 +string, and it should accept two parameters: %f, which is
643 +replaced with the (compressed) folder name, and %t which is
644 +replaced with the name of the temporary folder to which to write.
646 +%f and %t can be repeated any number of times in the
647 +command string, and all of the entries are replaced with the
648 +appropriate folder name. In addition, %% is replaced by
649 +%, as in printf, and any other %anything is left as is.
651 +The <emphasis>command</emphasis> should <emphasis
652 +role="bold">not</emphasis> remove the original compressed file. The
653 +<emphasis>command</emphasis> should return non-zero exit status if it
654 +fails, so mutt knows something's wrong.
659 +open-hook \\.gz$ "gzip -cd %f > %t"
662 +If the <emphasis>command</emphasis> is empty, this operation is
663 +disabled for this file type.
667 +<sect3 id="close-hook">
668 +<title>Write a compressed mailbox</title>
671 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
673 +This is used to close the folder that was open with the <link
674 +linkend="open-hook">open-hook</link> command after some changes were
677 +The <emphasis>command</emphasis> string is the command that can be
678 +used for closing the folders whose names match
679 +<emphasis>regexp</emphasis>. It has the same format as in the <link
680 +linkend="open-hook">open-hook</link> command. Temporary folder in this
681 +case is the folder previously produced by the <link
682 +linkend="open-hook">open-hook</link> command.
684 +The <emphasis>command</emphasis> should <emphasis
685 +role="bold">not</emphasis> remove the decompressed file. The
686 +<emphasis>command</emphasis> should return non-zero exit status if it
687 +fails, so mutt knows something's wrong.
692 +close-hook \\.gz$ "gzip -c %t > %f"
695 +If the <emphasis>command</emphasis> is empty, this operation is
696 +disabled for this file type, and the file can only be open in the
699 +<link linkend="close-hook">close-hook</link> is not called when you
700 +exit from the folder if the folder was not changed.
704 +<sect3 id="append-hook">
705 +<title>Append a message to a compressed mailbox</title>
708 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
710 +This command is used for saving to an existing compressed folder. The
711 +<emphasis>command</emphasis> is the command that can be used for
712 +appending to the folders whose names match
713 +<emphasis>regexp</emphasis>. It has the same format as in the <link
714 +linkend="open-hook">open-hook</link> command. The temporary folder in
715 +this case contains the messages that are being appended.
717 +The <emphasis>command</emphasis> should <emphasis
718 +role="bold">not</emphasis> remove the decompressed file. The
719 +<emphasis>command</emphasis> should return non-zero exit status if it
720 +fails, so mutt knows something's wrong.
725 +append-hook \\.gz$ "gzip -c %t >> %f"
728 +When <link linkend="append-hook">append-hook</link> is used, the folder
729 +is not opened, which saves time, but this means that we can not find
730 +out what the folder type is. Thus the default (<link
731 +linkend="mbox-type">$mbox_type</link>) type is always
732 +supposed (i.e. this is the format used for the temporary folder).
734 +If the file does not exist when you save to it, <link
735 +linkend="close-hook">close-hook</link> is called, and not <link
736 +linkend="append-hook">append-hook</link>. <link
737 +linkend="append-hook">append-hook</link> is only for appending to
740 +If the <emphasis>command</emphasis> is empty, this operation is
741 +disabled for this file type. In this case, the folder will be open and
742 +closed again (using <link linkend="open-hook">open-hook</link> and
743 +<link linkend="close-hook">close-hook</link>respectively) each time you
749 +<title>Encrypted folders</title>
752 +The compressed folders support can also be used to handle encrypted
753 +folders. If you want to encrypt a folder with PGP, you may want to use
754 +the following hooks:
757 +open-hook \\.pgp$ "pgp -f < %f > %t"
758 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
761 +Please note, that PGP does not support appending to an encrypted
762 +folder, so there is no append-hook defined.
764 +If you are using GnuPG instead of PGP, you may use the following hooks
768 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
769 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
772 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
773 +decrypted in the /tmp directory, where it can be read by your system
774 +administrator. So think about the security aspects of this.
779 <sect1 id="mimesupport">
780 <title>Mutt's MIME Support</title>
782 diff -urN mutt-1.5.11/doc/muttrc.man.head mutt-1.5.11-ro/doc/muttrc.man.head
783 --- mutt-1.5.11/doc/muttrc.man.head 2005-09-07 10:19:44.000000000 +0200
784 +++ mutt-1.5.11-ro/doc/muttrc.man.head 2005-09-27 13:29:53.000000000 +0200
786 to a certain recipient. The meaning of "key ID" is to be taken
787 broadly: This can be a different e-mail address, a numerical key ID,
788 or even just an arbitrary search string.
791 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
792 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
793 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
796 +These commands provide a way to handle compressed folders. The given
797 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
798 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
799 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
800 +compressed mail to a compressed folder (\fBappend-hook\fP). The
801 +\fIcommand\fP string is the
803 +like format string, and it should accept two parameters: \fB%f\fP,
804 +which is replaced with the (compressed) folder name, and \fB%t\fP
805 +which is replaced with the name of the temporary folder to which to
808 \fBpush\fP \fIstring\fP
809 This command adds the named \fIstring\fP to the keyboard buffer.
810 diff -urN mutt-1.5.11/hook.c mutt-1.5.11-ro/hook.c
811 --- mutt-1.5.11/hook.c 2005-02-03 19:47:52.000000000 +0100
812 +++ mutt-1.5.11-ro/hook.c 2005-09-27 13:27:02.000000000 +0200
815 #include "mutt_crypt.h"
817 +#ifdef USE_COMPRESSED
818 +#include "compress.h"
825 memset (&pattern, 0, sizeof (pattern));
826 pattern.data = safe_strdup (path);
828 +#ifdef USE_COMPRESSED
829 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
831 + if (mutt_test_compress_command (command.data))
833 + strfcpy (err->data, _("bad formatted command string"), err->dsize);
838 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ACCOUNTHOOK))
839 && (!WithCrypto || !(data & M_CRYPTHOOK))
841 diff -urN mutt-1.5.11/init.h mutt-1.5.11-ro/init.h
842 --- mutt-1.5.11/init.h 2005-09-15 16:19:54.000000000 +0200
843 +++ mutt-1.5.11-ro/init.h 2005-09-27 13:27:02.000000000 +0200
844 @@ -3002,6 +3002,11 @@
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 { "hdr_order", parse_list, UL &HeaderOrderList },
855 { "iconv-hook", mutt_parse_hook, M_ICONVHOOK },
856 diff -urN mutt-1.5.11/main.c mutt-1.5.11-ro/main.c
857 --- mutt-1.5.11/main.c 2005-09-07 10:19:43.000000000 +0200
858 +++ mutt-1.5.11-ro/main.c 2005-09-27 13:27:02.000000000 +0200
864 +#ifdef USE_COMPRESSED
872 diff -urN mutt-1.5.11/Makefile.am mutt-1.5.11-ro/Makefile.am
873 --- mutt-1.5.11/Makefile.am 2005-08-11 23:27:28.000000000 +0200
874 +++ mutt-1.5.11-ro/Makefile.am 2005-09-27 13:27:02.000000000 +0200
876 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
877 mutt_SOURCES = $(BUILT_SOURCES) \
878 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
879 - crypt.c cryptglue.c \
880 + crypt.c cryptglue.c compress.c \
881 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
882 edit.c enter.c flags.c init.c filter.c from.c getdomain.c \
883 handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c \
885 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c
887 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \
888 - configure account.h \
889 + configure account.h compress.h \
890 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
891 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
892 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
893 diff -urN mutt-1.5.11/Makefile.in mutt-1.5.11-ro/Makefile.in
894 diff -urN mutt-1.5.11/mbox.c mutt-1.5.11-ro/mbox.c
895 --- mutt-1.5.11/mbox.c 2005-08-02 09:08:00.000000000 +0200
896 +++ mutt-1.5.11-ro/mbox.c 2005-09-27 13:27:02.000000000 +0200
901 +#ifdef USE_COMPRESSED
902 +#include "compress.h"
905 #include <sys/stat.h>
908 @@ -1014,6 +1018,12 @@
909 int mbox_close_mailbox (CONTEXT *ctx)
911 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
913 +#ifdef USE_COMPRESSED
914 + if (ctx->compressinfo)
915 + mutt_slow_close_compressed (ctx);
918 mutt_unblock_signals ();
919 mx_fastclose_mailbox (ctx);
921 diff -urN mutt-1.5.11/mutt.h mutt-1.5.11-ro/mutt.h
922 --- mutt-1.5.11/mutt.h 2005-09-07 10:19:43.000000000 +0200
923 +++ mutt-1.5.11-ro/mutt.h 2005-09-27 13:27:02.000000000 +0200
925 #define M_ACCOUNTHOOK (1<<9)
926 #define M_REPLYHOOK (1<<10)
927 #define M_SEND2HOOK (1<<11)
928 +#ifdef USE_COMPRESSED
929 +#define M_OPENHOOK (1<<12)
930 +#define M_APPENDHOOK (1<<13)
931 +#define M_CLOSEHOOK (1<<14)
934 /* tree characters for linearize_tree and print_enriched_string */
935 #define M_TREE_LLCORNER 1
937 void *data; /* driver specific data */
938 #endif /* USE_IMAP */
940 +#ifdef USE_COMPRESSED
941 + void *compressinfo; /* compressed mbox module private data */
942 + char *realpath; /* path to compressed mailbox */
943 +#endif /* USE_COMPRESSED */
945 short magic; /* mailbox type */
947 unsigned int locked : 1; /* is the mailbox locked? */
948 diff -urN mutt-1.5.11/Muttrc mutt-1.5.11-ro/Muttrc
949 diff -urN mutt-1.5.11/Muttrc.head mutt-1.5.11-ro/Muttrc.head
950 diff -urN mutt-1.5.11/Muttrc.head.in mutt-1.5.11-ro/Muttrc.head.in
951 diff -urN mutt-1.5.11/mx.c mutt-1.5.11-ro/mx.c
952 --- mutt-1.5.11/mx.c 2005-09-07 10:19:43.000000000 +0200
953 +++ mutt-1.5.11-ro/mx.c 2005-09-27 13:27:02.000000000 +0200
958 +#ifdef USE_COMPRESSED
959 +#include "compress.h"
969 +#ifdef USE_COMPRESSED
970 + if (magic == 0 && mutt_can_read_compressed (path))
971 + return M_COMPRESSED;
980 +#ifdef USE_COMPRESSED
981 + /* special case for appending to compressed folders -
982 + * even if we can not open them for reading */
983 + if (mutt_can_append_compressed (ctx->path))
984 + mutt_open_append_compressed (ctx);
993 ctx->magic = mx_get_magic (path);
996 +#ifdef USE_COMPRESSED
997 + if (ctx->magic == M_COMPRESSED)
998 + mutt_open_read_compressed (ctx);
1002 mutt_error (_("%s is not a mailbox."), path);
1004 @@ -759,6 +779,10 @@
1005 mutt_free_header (&ctx->hdrs[i]);
1008 +#ifdef USE_COMPRESSED
1009 + if (ctx->compressinfo)
1010 + mutt_fast_close_compressed (ctx);
1013 FREE (&ctx->pattern);
1014 if (ctx->limit_pattern)
1015 @@ -816,6 +840,12 @@
1016 if (tmp && tmp->new == 0)
1017 mutt_update_mailbox (tmp);
1020 +#ifdef USE_COMPRESSED
1021 + if (rc == 0 && ctx->compressinfo)
1022 + return mutt_sync_compressed (ctx);
1028 @@ -1021,6 +1051,11 @@
1029 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1030 mx_unlink_empty (ctx->path);
1032 +#ifdef USE_COMPRESSED
1033 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1037 mx_fastclose_mailbox (ctx);
1040 @@ -1330,6 +1365,11 @@
1044 +#ifdef USE_COMPRESSED
1045 + if (ctx->compressinfo)
1046 + return mutt_check_mailbox_compressed (ctx);
1051 if (ctx->locked) lock = 0;
1052 diff -urN mutt-1.5.11/mx.h mutt-1.5.11-ro/mx.h
1053 --- mutt-1.5.11/mx.h 2003-08-05 15:58:16.000000000 +0200
1054 +++ mutt-1.5.11-ro/mx.h 2005-09-27 13:27:02.000000000 +0200
1059 +#ifdef USE_COMPRESSED
1064 WHERE short DefaultMagic INITVAL (M_MBOX);
1065 diff -urN mutt-1.5.11/PATCHES mutt-1.5.11-ro/PATCHES
1066 --- mutt-1.5.11/PATCHES 2005-08-15 10:16:00.000000000 +0200
1067 +++ mutt-1.5.11-ro/PATCHES 2005-09-27 13:30:25.000000000 +0200
1069 +patch-1.5.11.rr.compressed.1
1070 diff -urN mutt-1.5.11/po/de.po mutt-1.5.11-ro/po/de.po
1071 --- mutt-1.5.11/po/de.po 2005-09-15 16:23:50.000000000 +0200
1072 +++ mutt-1.5.11-ro/po/de.po 2005-09-27 13:27:02.000000000 +0200
1073 @@ -1262,6 +1262,48 @@
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 @@ -1882,6 +1924,10 @@
1124 msgstr "Hilfe für %s"
1127 +msgid "bad 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 @@ -3336,18 +3382,10 @@
1134 msgid "Mailbox is corrupt!"
1135 msgstr "Mailbox fehlerhaft!"
1138 -msgid "Mailbox was corrupted!"
1139 -msgstr "Mailbox wurde zerstört!"
1141 #: mbox.c:701 mbox.c:952
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 diff -urN mutt-1.5.11/po/POTFILES.in mutt-1.5.11-ro/po/POTFILES.in
1153 --- mutt-1.5.11/po/POTFILES.in 2005-08-03 11:17:47.000000000 +0200
1154 +++ mutt-1.5.11-ro/po/POTFILES.in 2005-09-27 13:27:02.000000000 +0200
1163 diff -urN mutt-1.5.11/status.c mutt-1.5.11-ro/status.c
1164 --- mutt-1.5.11/status.c 2005-02-03 19:47:53.000000000 +0100
1165 +++ mutt-1.5.11-ro/status.c 2005-09-27 13:27:02.000000000 +0200
1169 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1170 +#ifdef USE_COMPRESSED
1171 + if (Context && Context->compressinfo && Context->realpath)
1173 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1174 + mutt_pretty_mailbox (tmp);
1178 if (Context && Context->path)
1180 strfcpy (tmp, Context->path, sizeof (tmp));