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)
17 - adjust the init.h hunk to the presence of group & ungroup
20 diff -urN mutt-1.5.11/compress.c mutt-1.5.11-ro/compress.c
21 --- mutt-1.5.11/compress.c 1970-01-01 01:00:00.000000000 +0100
22 +++ mutt-1.5.11-ro/compress.c 2005-09-27 13:26:58.000000000 +0200
25 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
27 + * This program is free software; you can redistribute it and/or modify
28 + * it under the terms of the GNU General Public License as published by
29 + * the Free Software Foundation; either version 2 of the License, or
30 + * (at your option) any later version.
32 + * This program is distributed in the hope that it will be useful,
33 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 + * GNU General Public License for more details.
37 + * You should have received a copy of the GNU General Public License
38 + * along with this program; if not, write to the Free Software
39 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
48 +#ifdef USE_COMPRESSED
52 +#include "mutt_curses.h"
57 +#include <sys/stat.h>
61 + const char *close; /* close-hook command */
62 + const char *open; /* open-hook command */
63 + const char *append; /* append-hook command */
64 + off_t size; /* size of real folder */
69 + * ctx - context to lock
70 + * excl - exclusive lock?
71 + * retry - should retry if unable to lock?
73 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
77 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
79 + else if (retry && !excl)
88 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
94 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
99 +static int is_new (const char *path)
101 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
104 +static const char* find_compress_hook (int type, const char *path)
106 + const char* c = mutt_find_hook (type, path);
107 + return (!c || !*c) ? NULL : c;
110 +int mutt_can_read_compressed (const char *path)
112 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
116 + * if the file is new, we really do not append, but create, and so use
117 + * close-hook, and not append-hook
119 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
121 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
122 + return (is_new (path)) ? ci->close : ci->append;
125 +int mutt_can_append_compressed (const char *path)
130 + return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
132 + magic = mx_get_magic (path);
134 + if (magic != 0 && magic != M_COMPRESSED)
137 + return (find_compress_hook (M_APPENDHOOK, path)
138 + || (find_compress_hook (M_OPENHOOK, path)
139 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
142 +/* open a compressed mailbox */
143 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
147 + /* Now lets uncompress this thing */
148 + ci = safe_malloc (sizeof (COMPRESS_INFO));
149 + ctx->compressinfo = (void*) ci;
150 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
151 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
152 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
156 +static void set_path (CONTEXT* ctx)
158 + char tmppath[_POSIX_PATH_MAX];
160 + /* Setup the right paths */
161 + ctx->realpath = ctx->path;
163 + /* Uncompress to /tmp */
164 + mutt_mktemp (tmppath);
165 + ctx->path = safe_malloc (strlen (tmppath) + 1);
166 + strcpy (ctx->path, tmppath);
169 +static int get_size (const char* path)
172 + if (stat (path, &sb) != 0)
174 + return (sb.st_size);
177 +static void store_size (CONTEXT* ctx)
179 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
180 + ci->size = get_size (ctx->realpath);
184 +compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
185 + const char *fmt, const char *ifstring,
186 + const char *elsestring, unsigned long data,
189 + char tmp[SHORT_STRING];
191 + CONTEXT *ctx = (CONTEXT *) data;
195 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
196 + snprintf (dest, destlen, tmp, ctx->realpath);
199 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
200 + snprintf (dest, destlen, tmp, ctx->path);
207 + * check that the command has both %f and %t
208 + * 0 means OK, -1 means error
210 +int mutt_test_compress_command (const char* cmd)
212 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
215 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
217 + char expanded[_POSIX_PATH_MAX];
218 + mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str,
219 + (unsigned long) ctx, 0);
220 + return safe_strdup (expanded);
223 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
225 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
226 + if (ci->size != get_size (ctx->realpath))
228 + FREE (&ctx->compressinfo);
229 + FREE (&ctx->realpath);
230 + mutt_error _("Mailbox was corrupted!");
236 +int mutt_open_read_compressed (CONTEXT *ctx)
242 + COMPRESS_INFO *ci = set_compress_info (ctx);
245 + FREE (ctx->compressinfo);
248 + if (!ci->close || access (ctx->path, W_OK) != 0)
255 + mutt_message (_("Decompressing %s..."), ctx->realpath);
257 + cmd = get_compression_cmd (ci->open, ctx);
260 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
262 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
264 + mutt_perror (ctx->realpath);
268 + mutt_block_signals ();
269 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
272 + mutt_unblock_signals ();
273 + mutt_error _("Unable to lock mailbox!");
280 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
281 + rc = mutt_system (cmd);
282 + mbox_unlock_compressed (ctx, fp);
283 + mutt_unblock_signals ();
288 + mutt_any_key_to_continue (NULL);
290 + FREE (ctx->compressinfo);
291 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
297 + if (mutt_check_mailbox_compressed (ctx))
300 + ctx->magic = mx_get_magic (ctx->path);
305 +void restore_path (CONTEXT* ctx)
308 + ctx->path = ctx->realpath;
311 +/* remove the temporary mailbox */
312 +void remove_file (CONTEXT* ctx)
314 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
315 + remove (ctx->path);
318 +int mutt_open_append_compressed (CONTEXT *ctx)
321 + COMPRESS_INFO *ci = set_compress_info (ctx);
323 + if (!get_append_command (ctx->path, ctx))
325 + if (ci->open && ci->close)
326 + return (mutt_open_read_compressed (ctx));
329 + FREE (&ctx->compressinfo);
335 + ctx->magic = DefaultMagic;
337 + if (!is_new (ctx->realpath))
338 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
339 + if ((fh = fopen (ctx->path, "w")))
341 + /* No error checking - the parent function will catch it */
346 +/* close a compressed mailbox */
347 +void mutt_fast_close_compressed (CONTEXT *ctx)
349 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
352 + if (ctx->compressinfo)
357 + /* if the folder was removed, remove the gzipped folder too */
358 + if ((ctx->magic > 0)
359 + && (access (ctx->path, F_OK) != 0)
360 + && ! option (OPTSAVEEMPTY))
361 + remove (ctx->realpath);
365 + restore_path (ctx);
366 + FREE (&ctx->compressinfo);
370 +/* return 0 on success, -1 on failure */
371 +int mutt_sync_compressed (CONTEXT* ctx)
376 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
379 + mutt_message (_("Compressing %s..."), ctx->realpath);
381 + cmd = get_compression_cmd (ci->close, ctx);
385 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
387 + mutt_perror (ctx->realpath);
391 + mutt_block_signals ();
392 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
395 + mutt_unblock_signals ();
396 + mutt_error _("Unable to lock mailbox!");
402 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
406 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
407 + if (mutt_system (cmd))
409 + mutt_any_key_to_continue (NULL);
410 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
414 + mbox_unlock_compressed (ctx, fp);
415 + mutt_unblock_signals ();
425 +int mutt_slow_close_compressed (CONTEXT *ctx)
428 + const char *append;
430 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
432 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
436 + && ((append = get_append_command (ctx->realpath, ctx))
437 + || (append = ci->close))))
439 + /* if we can not or should not append, we only have to remove the */
440 + /* compressed info, because sync was already called */
441 + mutt_fast_close_compressed (ctx);
451 + if (append == ci->close)
452 + mutt_message (_("Compressing %s..."), ctx->realpath);
454 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
457 + cmd = get_compression_cmd (append, ctx);
461 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
463 + mutt_perror (ctx->realpath);
467 + mutt_block_signals ();
468 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
471 + mutt_unblock_signals ();
472 + mutt_error _("Unable to lock mailbox!");
477 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
482 + if (append == ci->close)
483 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
485 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
487 + if (mutt_system (cmd))
489 + mutt_any_key_to_continue (NULL);
490 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
493 + mbox_unlock_compressed (ctx, fp);
494 + mutt_unblock_signals ();
499 + mbox_unlock_compressed (ctx, fp);
500 + mutt_unblock_signals ();
503 + restore_path (ctx);
505 + FREE (&ctx->compressinfo);
510 +#endif /* USE_COMPRESSED */
511 diff -urN mutt-1.5.11/compress.h mutt-1.5.11-ro/compress.h
512 --- mutt-1.5.11/compress.h 1970-01-01 01:00:00.000000000 +0100
513 +++ mutt-1.5.11-ro/compress.h 2005-09-27 13:26:58.000000000 +0200
516 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
518 + * This program is free software; you can redistribute it and/or modify
519 + * it under the terms of the GNU General Public License as published by
520 + * the Free Software Foundation; either version 2 of the License, or
521 + * (at your option) any later version.
523 + * This program is distributed in the hope that it will be useful,
524 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
525 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
526 + * GNU General Public License for more details.
528 + * You should have received a copy of the GNU General Public License
529 + * along with this program; if not, write to the Free Software
530 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
533 +int mutt_can_read_compressed (const char *);
534 +int mutt_can_append_compressed (const char *);
535 +int mutt_open_read_compressed (CONTEXT *);
536 +int mutt_open_append_compressed (CONTEXT *);
537 +int mutt_slow_close_compressed (CONTEXT *);
538 +int mutt_sync_compressed (CONTEXT *);
539 +int mutt_test_compress_command (const char *);
540 +int mutt_check_mailbox_compressed (CONTEXT *);
541 +void mutt_fast_close_compressed (CONTEXT *);
542 diff -urN mutt-1.5.11/config.h.in mutt-1.5.11-ro/config.h.in
543 diff -urN mutt-1.5.11/configure mutt-1.5.11-ro/configure
544 diff -urN mutt-1.5.11/configure.in mutt-1.5.11-ro/configure.in
545 --- mutt-1.5.11/configure.in 2005-09-15 16:21:24.000000000 +0200
546 +++ mutt-1.5.11-ro/configure.in 2005-09-27 13:26:58.000000000 +0200
548 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
551 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
552 + [if test x$enableval = xyes; then
553 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
556 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
557 [if test $withval != yes; then
558 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
559 diff -urN mutt-1.5.11/curs_main.c mutt-1.5.11-ro/curs_main.c
560 --- mutt-1.5.11/curs_main.c 2005-09-07 10:19:43.000000000 +0200
561 +++ mutt-1.5.11-ro/curs_main.c 2005-09-27 13:26:58.000000000 +0200
562 @@ -1091,6 +1091,11 @@
566 +#ifdef USE_COMPRESSED
567 + if (Context->compressinfo && Context->realpath)
568 + mutt_str_replace (&LastFolder, Context->realpath);
571 mutt_str_replace (&LastFolder, Context->path);
572 oldcount = Context ? Context->msgcount : 0;
574 diff -urN mutt-1.5.11/doc/manual.xml.head mutt-1.5.11-ro/doc/manual.xml.head
575 --- mutt-1.5.11/doc/manual.xml.head 2005-09-06 18:46:44.000000000 +0200
576 +++ mutt-1.5.11-ro/doc/manual.xml.head 2005-09-27 13:29:11.000000000 +0200
577 @@ -4404,6 +4404,205 @@
581 +<sect2 id="compressedfolders">
582 +<title>Compressed folders Support (OPTIONAL)</title>
585 +If Mutt was compiled with compressed folders support (by running the
586 +<emphasis>configure</emphasis> script with the
587 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
588 +stored in an arbitrary format, provided that the user has a script to
589 +convert from/to this format to one of the accepted.
591 +The most common use is to open compressed archived folders e.g. with
594 +In addition, the user can provide a script that gets a folder in an
595 +accepted format and appends its context to the folder in the
596 +user-defined format, which may be faster than converting the entire
597 +folder to the accepted format, appending to it and converting back to
598 +the user-defined format.
600 +There are three hooks defined (<link
601 +linkend="open-hook">open-hook</link>, <link
602 +linkend="close-hook">close-hook</link> and <link
603 +linkend="append-hook">append-hook</link>) which define commands to
604 +uncompress and compress a folder and to append messages to an existing
605 +compressed folder respectively.
610 +open-hook \\.gz$ "gzip -cd %f > %t"
611 +close-hook \\.gz$ "gzip -c %t > %f"
612 +append-hook \\.gz$ "gzip -c %t >> %f"
615 +You do not have to specify all of the commands. If you omit <link
616 +linkend="append-hook">append-hook</link>, the folder will be open and
617 +closed again each time you will add to it. If you omit <link
618 +linkend="close-hook">close-hook</link> (or give empty command) , the
619 +folder will be open in the mode. If you specify <link
620 +linkend="append-hook">append-hook</link> though you'll be able to
621 +append to the folder.
623 +Note that Mutt will only try to use hooks if the file is not in one of
624 +the accepted formats. In particular, if the file is empty, mutt
625 +supposes it is not compressed. This is important because it allows the
626 +use of programs that do not have well defined extensions. Just use
627 +"." as a regexp. But this may be surprising if your
628 +compressing script produces empty files. In this situation, unset
629 +<link linkend="save-empty">$save_empty</link>, so that
630 +the compressed file will be removed if you delete all of the messages.
633 +<sect3 id="open-hook">
634 +<title>Open a compressed mailbox for reading</title>
637 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
639 +The <emphasis>command</emphasis> is the command that can be used for
640 +opening the folders whose names match <emphasis>regexp</emphasis>.
642 +The <emphasis>command</emphasis> string is the printf-like format
643 +string, and it should accept two parameters: %f, which is
644 +replaced with the (compressed) folder name, and %t which is
645 +replaced with the name of the temporary folder to which to write.
647 +%f and %t can be repeated any number of times in the
648 +command string, and all of the entries are replaced with the
649 +appropriate folder name. In addition, %% is replaced by
650 +%, as in printf, and any other %anything is left as is.
652 +The <emphasis>command</emphasis> should <emphasis
653 +role="bold">not</emphasis> remove the original compressed file. The
654 +<emphasis>command</emphasis> should return non-zero exit status if it
655 +fails, so mutt knows something's wrong.
660 +open-hook \\.gz$ "gzip -cd %f > %t"
663 +If the <emphasis>command</emphasis> is empty, this operation is
664 +disabled for this file type.
668 +<sect3 id="close-hook">
669 +<title>Write a compressed mailbox</title>
672 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
674 +This is used to close the folder that was open with the <link
675 +linkend="open-hook">open-hook</link> command after some changes were
678 +The <emphasis>command</emphasis> string is the command that can be
679 +used for closing the folders whose names match
680 +<emphasis>regexp</emphasis>. It has the same format as in the <link
681 +linkend="open-hook">open-hook</link> command. Temporary folder in this
682 +case is the folder previously produced by the <link
683 +linkend="open-hook">open-hook</link> command.
685 +The <emphasis>command</emphasis> should <emphasis
686 +role="bold">not</emphasis> remove the decompressed file. The
687 +<emphasis>command</emphasis> should return non-zero exit status if it
688 +fails, so mutt knows something's wrong.
693 +close-hook \\.gz$ "gzip -c %t > %f"
696 +If the <emphasis>command</emphasis> is empty, this operation is
697 +disabled for this file type, and the file can only be open in the
700 +<link linkend="close-hook">close-hook</link> is not called when you
701 +exit from the folder if the folder was not changed.
705 +<sect3 id="append-hook">
706 +<title>Append a message to a compressed mailbox</title>
709 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
711 +This command is used for saving to an existing compressed folder. The
712 +<emphasis>command</emphasis> is the command that can be used for
713 +appending to the folders whose names match
714 +<emphasis>regexp</emphasis>. It has the same format as in the <link
715 +linkend="open-hook">open-hook</link> command. The temporary folder in
716 +this case contains the messages that are being appended.
718 +The <emphasis>command</emphasis> should <emphasis
719 +role="bold">not</emphasis> remove the decompressed file. The
720 +<emphasis>command</emphasis> should return non-zero exit status if it
721 +fails, so mutt knows something's wrong.
726 +append-hook \\.gz$ "gzip -c %t >> %f"
729 +When <link linkend="append-hook">append-hook</link> is used, the folder
730 +is not opened, which saves time, but this means that we can not find
731 +out what the folder type is. Thus the default (<link
732 +linkend="mbox-type">$mbox_type</link>) type is always
733 +supposed (i.e. this is the format used for the temporary folder).
735 +If the file does not exist when you save to it, <link
736 +linkend="close-hook">close-hook</link> is called, and not <link
737 +linkend="append-hook">append-hook</link>. <link
738 +linkend="append-hook">append-hook</link> is only for appending to
741 +If the <emphasis>command</emphasis> is empty, this operation is
742 +disabled for this file type. In this case, the folder will be open and
743 +closed again (using <link linkend="open-hook">open-hook</link> and
744 +<link linkend="close-hook">close-hook</link>respectively) each time you
750 +<title>Encrypted folders</title>
753 +The compressed folders support can also be used to handle encrypted
754 +folders. If you want to encrypt a folder with PGP, you may want to use
755 +the following hooks:
758 +open-hook \\.pgp$ "pgp -f < %f > %t"
759 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
762 +Please note, that PGP does not support appending to an encrypted
763 +folder, so there is no append-hook defined.
765 +If you are using GnuPG instead of PGP, you may use the following hooks
769 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
770 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
773 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
774 +decrypted in the /tmp directory, where it can be read by your system
775 +administrator. So think about the security aspects of this.
780 <sect1 id="mimesupport">
781 <title>Mutt's MIME Support</title>
783 diff -urN mutt-1.5.11/doc/muttrc.man.head mutt-1.5.11-ro/doc/muttrc.man.head
784 --- mutt-1.5.11/doc/muttrc.man.head 2005-09-07 10:19:44.000000000 +0200
785 +++ mutt-1.5.11-ro/doc/muttrc.man.head 2005-09-27 13:29:53.000000000 +0200
787 to a certain recipient. The meaning of "key ID" is to be taken
788 broadly: This can be a different e-mail address, a numerical key ID,
789 or even just an arbitrary search string.
792 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
793 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
794 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
797 +These commands provide a way to handle compressed folders. The given
798 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
799 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
800 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
801 +compressed mail to a compressed folder (\fBappend-hook\fP). The
802 +\fIcommand\fP string is the
804 +like format string, and it should accept two parameters: \fB%f\fP,
805 +which is replaced with the (compressed) folder name, and \fB%t\fP
806 +which is replaced with the name of the temporary folder to which to
809 \fBpush\fP \fIstring\fP
810 This command adds the named \fIstring\fP to the keyboard buffer.
811 diff -urN mutt-1.5.11/hook.c mutt-1.5.11-ro/hook.c
812 --- mutt-1.5.11/hook.c 2005-02-03 19:47:52.000000000 +0100
813 +++ mutt-1.5.11-ro/hook.c 2005-09-27 13:27:02.000000000 +0200
816 #include "mutt_crypt.h"
818 +#ifdef USE_COMPRESSED
819 +#include "compress.h"
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, _("bad formatted command string"), err->dsize);
839 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ACCOUNTHOOK))
840 && (!WithCrypto || !(data & M_CRYPTHOOK))
842 diff -urN mutt-1.5.11/init.h mutt-1.5.11-ro/init.h
843 --- mutt-1.5.11/init.h 2005-09-15 16:19:54.000000000 +0200
844 +++ mutt-1.5.11-ro/init.h 2005-09-27 13:27:02.000000000 +0200
845 @@ -3100,6 +3100,11 @@
846 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
847 { "group", parse_group, 0 },
848 { "ungroup", parse_ungroup, 0 },
849 +#ifdef USE_COMPRESSED
850 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
851 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
852 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
854 { "hdr_order", parse_list, UL &HeaderOrderList },
856 { "iconv-hook", mutt_parse_hook, M_ICONVHOOK },
857 diff -urN mutt-1.5.11/main.c mutt-1.5.11-ro/main.c
858 --- mutt-1.5.11/main.c 2005-09-07 10:19:43.000000000 +0200
859 +++ mutt-1.5.11-ro/main.c 2005-09-27 13:27:02.000000000 +0200
865 +#ifdef USE_COMPRESSED
873 diff -urN mutt-1.5.11/Makefile.am mutt-1.5.11-ro/Makefile.am
874 --- mutt-1.5.11/Makefile.am 2005-08-11 23:27:28.000000000 +0200
875 +++ mutt-1.5.11-ro/Makefile.am 2005-09-27 13:27:02.000000000 +0200
877 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
878 mutt_SOURCES = $(BUILT_SOURCES) \
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 getdomain.c \
884 handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c \
886 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c
888 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \
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 \
894 diff -urN mutt-1.5.11/Makefile.in mutt-1.5.11-ro/Makefile.in
895 diff -urN mutt-1.5.11/mbox.c mutt-1.5.11-ro/mbox.c
896 --- mutt-1.5.11/mbox.c 2005-08-02 09:08:00.000000000 +0200
897 +++ mutt-1.5.11-ro/mbox.c 2005-09-27 13:27:02.000000000 +0200
902 +#ifdef USE_COMPRESSED
903 +#include "compress.h"
906 #include <sys/stat.h>
909 @@ -1014,6 +1018,12 @@
910 int mbox_close_mailbox (CONTEXT *ctx)
912 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
914 +#ifdef USE_COMPRESSED
915 + if (ctx->compressinfo)
916 + mutt_slow_close_compressed (ctx);
919 mutt_unblock_signals ();
920 mx_fastclose_mailbox (ctx);
922 diff -urN mutt-1.5.11/mutt.h mutt-1.5.11-ro/mutt.h
923 --- mutt-1.5.11/mutt.h 2005-09-07 10:19:43.000000000 +0200
924 +++ mutt-1.5.11-ro/mutt.h 2005-09-27 13:27:02.000000000 +0200
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 void *data; /* driver specific data */
939 #endif /* USE_IMAP */
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 int locked : 1; /* is the mailbox locked? */
949 diff -urN mutt-1.5.11/Muttrc mutt-1.5.11-ro/Muttrc
950 diff -urN mutt-1.5.11/Muttrc.head mutt-1.5.11-ro/Muttrc.head
951 diff -urN mutt-1.5.11/Muttrc.head.in mutt-1.5.11-ro/Muttrc.head.in
952 diff -urN mutt-1.5.11/mx.c mutt-1.5.11-ro/mx.c
953 --- mutt-1.5.11/mx.c 2005-09-07 10:19:43.000000000 +0200
954 +++ mutt-1.5.11-ro/mx.c 2005-09-27 13:27:02.000000000 +0200
959 +#ifdef USE_COMPRESSED
960 +#include "compress.h"
970 +#ifdef USE_COMPRESSED
971 + if (magic == 0 && mutt_can_read_compressed (path))
972 + return M_COMPRESSED;
981 +#ifdef USE_COMPRESSED
982 + /* special case for appending to compressed folders -
983 + * even if we can not open them for reading */
984 + if (mutt_can_append_compressed (ctx->path))
985 + mutt_open_append_compressed (ctx);
994 ctx->magic = mx_get_magic (path);
997 +#ifdef USE_COMPRESSED
998 + if (ctx->magic == M_COMPRESSED)
999 + mutt_open_read_compressed (ctx);
1003 mutt_error (_("%s is not a mailbox."), path);
1005 @@ -759,6 +779,10 @@
1006 mutt_free_header (&ctx->hdrs[i]);
1009 +#ifdef USE_COMPRESSED
1010 + if (ctx->compressinfo)
1011 + mutt_fast_close_compressed (ctx);
1014 FREE (&ctx->pattern);
1015 if (ctx->limit_pattern)
1016 @@ -816,6 +840,12 @@
1017 if (tmp && tmp->new == 0)
1018 mutt_update_mailbox (tmp);
1021 +#ifdef USE_COMPRESSED
1022 + if (rc == 0 && ctx->compressinfo)
1023 + return mutt_sync_compressed (ctx);
1029 @@ -1021,6 +1051,11 @@
1030 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1031 mx_unlink_empty (ctx->path);
1033 +#ifdef USE_COMPRESSED
1034 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1038 mx_fastclose_mailbox (ctx);
1041 @@ -1330,6 +1365,11 @@
1045 +#ifdef USE_COMPRESSED
1046 + if (ctx->compressinfo)
1047 + return mutt_check_mailbox_compressed (ctx);
1052 if (ctx->locked) lock = 0;
1053 diff -urN mutt-1.5.11/mx.h mutt-1.5.11-ro/mx.h
1054 --- mutt-1.5.11/mx.h 2003-08-05 15:58:16.000000000 +0200
1055 +++ mutt-1.5.11-ro/mx.h 2005-09-27 13:27:02.000000000 +0200
1060 +#ifdef USE_COMPRESSED
1065 WHERE short DefaultMagic INITVAL (M_MBOX);
1066 diff -urN mutt-1.5.11/PATCHES mutt-1.5.11-ro/PATCHES
1067 --- mutt-1.5.11/PATCHES 2005-08-15 10:16:00.000000000 +0200
1068 +++ mutt-1.5.11-ro/PATCHES 2005-09-27 13:30:25.000000000 +0200
1070 +patch-1.5.11.rr.compressed.1
1071 diff -urN mutt-1.5.11/po/de.po mutt-1.5.11-ro/po/de.po
1072 --- mutt-1.5.11/po/de.po 2005-09-15 16:23:50.000000000 +0200
1073 +++ mutt-1.5.11-ro/po/de.po 2005-09-27 13:27:02.000000000 +0200
1074 @@ -1262,6 +1262,48 @@
1075 msgid "Failed to figure out sender"
1076 msgstr "Kann Absender nicht ermitteln"
1078 +#: compress.c:203 mbox.c:661
1079 +msgid "Mailbox was corrupted!"
1080 +msgstr "Mailbox wurde zerstört!"
1082 +#: compress.c:228 compress.c:253
1084 +msgid "Decompressing %s...\n"
1085 +msgstr "Entpacke %s...\n"
1087 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1088 +msgid "Unable to lock mailbox!"
1089 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1093 +msgid "Error executing: %s : unable to open the mailbox!\n"
1094 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1096 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1098 +msgid "Compressing %s...\n"
1099 +msgstr "Komprimiere %s...\n"
1104 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1107 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1108 +"entpackte gespeichert!\n"
1110 +#: compress.c:425 compress.c:456
1112 +msgid "Compressed-appending to %s...\n"
1113 +msgstr "Hänge komprimiert an %s... an\n"
1117 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1118 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1122 msgid " (current time: %c)"
1123 @@ -1882,6 +1924,10 @@
1125 msgstr "Hilfe für %s"
1128 +msgid "bad formatted command string"
1129 +msgstr "Hook enthält nicht die Muster %f und %t"
1133 msgid "unhook: Can't do unhook * from within a hook."
1134 @@ -3336,18 +3382,10 @@
1135 msgid "Mailbox is corrupt!"
1136 msgstr "Mailbox fehlerhaft!"
1139 -msgid "Mailbox was corrupted!"
1140 -msgstr "Mailbox wurde zerstört!"
1142 #: mbox.c:701 mbox.c:952
1143 msgid "Fatal error! Could not reopen mailbox!"
1144 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1147 -msgid "Unable to lock mailbox!"
1148 -msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1150 #. this means ctx->changed or ctx->deleted was set, but no
1151 #. * messages were found to be changed or deleted. This should
1152 #. * never happen, is we presume it is a bug in mutt.
1153 diff -urN mutt-1.5.11/po/POTFILES.in mutt-1.5.11-ro/po/POTFILES.in
1154 --- mutt-1.5.11/po/POTFILES.in 2005-08-03 11:17:47.000000000 +0200
1155 +++ mutt-1.5.11-ro/po/POTFILES.in 2005-09-27 13:27:02.000000000 +0200
1164 diff -urN mutt-1.5.11/status.c mutt-1.5.11-ro/status.c
1165 --- mutt-1.5.11/status.c 2005-02-03 19:47:53.000000000 +0100
1166 +++ mutt-1.5.11-ro/status.c 2005-09-27 13:27:02.000000000 +0200
1170 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1171 +#ifdef USE_COMPRESSED
1172 + if (Context && Context->compressinfo && Context->realpath)
1174 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1175 + mutt_pretty_mailbox (tmp);
1179 if (Context && Context->path)
1181 strfcpy (tmp, Context->path, sizeof (tmp));