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
18 - 2006-07-15: adjust Makefile.am and doc/manual.xml.head to mutt-1.5.12
19 - 2006-08-16: adjust Makefile.am mutt-1.5.13
23 ===================================================================
24 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
25 +++ compress.c 2007-02-16 01:59:20.562597888 +0100
28 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
30 + * This program is free software; you can redistribute it and/or modify
31 + * it under the terms of the GNU General Public License as published by
32 + * the Free Software Foundation; either version 2 of the License, or
33 + * (at your option) any later version.
35 + * This program is distributed in the hope that it will be useful,
36 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
37 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 + * GNU General Public License for more details.
40 + * You should have received a copy of the GNU General Public License
41 + * along with this program; if not, write to the Free Software
42 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
51 +#ifdef USE_COMPRESSED
55 +#include "mutt_curses.h"
60 +#include <sys/stat.h>
64 + const char *close; /* close-hook command */
65 + const char *open; /* open-hook command */
66 + const char *append; /* append-hook command */
67 + off_t size; /* size of real folder */
72 + * ctx - context to lock
73 + * excl - exclusive lock?
74 + * retry - should retry if unable to lock?
76 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
80 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
82 + else if (retry && !excl)
91 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
97 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
102 +static int is_new (const char *path)
104 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
107 +static const char* find_compress_hook (int type, const char *path)
109 + const char* c = mutt_find_hook (type, path);
110 + return (!c || !*c) ? NULL : c;
113 +int mutt_can_read_compressed (const char *path)
115 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
119 + * if the file is new, we really do not append, but create, and so use
120 + * close-hook, and not append-hook
122 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
124 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
125 + return (is_new (path)) ? ci->close : ci->append;
128 +int mutt_can_append_compressed (const char *path)
133 + return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
135 + magic = mx_get_magic (path);
137 + if (magic != 0 && magic != M_COMPRESSED)
140 + return (find_compress_hook (M_APPENDHOOK, path)
141 + || (find_compress_hook (M_OPENHOOK, path)
142 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
145 +/* open a compressed mailbox */
146 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
150 + /* Now lets uncompress this thing */
151 + ci = safe_malloc (sizeof (COMPRESS_INFO));
152 + ctx->compressinfo = (void*) ci;
153 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
154 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
155 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
159 +static void set_path (CONTEXT* ctx)
161 + char tmppath[_POSIX_PATH_MAX];
163 + /* Setup the right paths */
164 + ctx->realpath = ctx->path;
166 + /* Uncompress to /tmp */
167 + mutt_mktemp (tmppath);
168 + ctx->path = safe_malloc (strlen (tmppath) + 1);
169 + strcpy (ctx->path, tmppath);
172 +static int get_size (const char* path)
175 + if (stat (path, &sb) != 0)
177 + return (sb.st_size);
180 +static void store_size (CONTEXT* ctx)
182 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
183 + ci->size = get_size (ctx->realpath);
187 +compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
188 + const char *fmt, const char *ifstring,
189 + const char *elsestring, unsigned long data,
192 + char tmp[SHORT_STRING];
194 + CONTEXT *ctx = (CONTEXT *) data;
198 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
199 + snprintf (dest, destlen, tmp, ctx->realpath);
202 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
203 + snprintf (dest, destlen, tmp, ctx->path);
210 + * check that the command has both %f and %t
211 + * 0 means OK, -1 means error
213 +int mutt_test_compress_command (const char* cmd)
215 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
218 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
220 + char expanded[_POSIX_PATH_MAX];
221 + mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str,
222 + (unsigned long) ctx, 0);
223 + return safe_strdup (expanded);
226 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
228 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
229 + if (ci->size != get_size (ctx->realpath))
231 + FREE (&ctx->compressinfo);
232 + FREE (&ctx->realpath);
233 + mutt_error _("Mailbox was corrupted!");
239 +int mutt_open_read_compressed (CONTEXT *ctx)
245 + COMPRESS_INFO *ci = set_compress_info (ctx);
248 + FREE (ctx->compressinfo);
251 + if (!ci->close || access (ctx->path, W_OK) != 0)
258 + mutt_message (_("Decompressing %s..."), ctx->realpath);
260 + cmd = get_compression_cmd (ci->open, ctx);
263 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
265 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
267 + mutt_perror (ctx->realpath);
271 + mutt_block_signals ();
272 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
275 + mutt_unblock_signals ();
276 + mutt_error _("Unable to lock mailbox!");
283 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
284 + rc = mutt_system (cmd);
285 + mbox_unlock_compressed (ctx, fp);
286 + mutt_unblock_signals ();
291 + mutt_any_key_to_continue (NULL);
293 + FREE (ctx->compressinfo);
294 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
300 + if (mutt_check_mailbox_compressed (ctx))
303 + ctx->magic = mx_get_magic (ctx->path);
308 +void restore_path (CONTEXT* ctx)
311 + ctx->path = ctx->realpath;
314 +/* remove the temporary mailbox */
315 +void remove_file (CONTEXT* ctx)
317 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
318 + remove (ctx->path);
321 +int mutt_open_append_compressed (CONTEXT *ctx)
324 + COMPRESS_INFO *ci = set_compress_info (ctx);
326 + if (!get_append_command (ctx->path, ctx))
328 + if (ci->open && ci->close)
329 + return (mutt_open_read_compressed (ctx));
332 + FREE (&ctx->compressinfo);
338 + ctx->magic = DefaultMagic;
340 + if (!is_new (ctx->realpath))
341 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
342 + if ((fh = fopen (ctx->path, "w")))
344 + /* No error checking - the parent function will catch it */
349 +/* close a compressed mailbox */
350 +void mutt_fast_close_compressed (CONTEXT *ctx)
352 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
355 + if (ctx->compressinfo)
360 + /* if the folder was removed, remove the gzipped folder too */
361 + if ((ctx->magic > 0)
362 + && (access (ctx->path, F_OK) != 0)
363 + && ! option (OPTSAVEEMPTY))
364 + remove (ctx->realpath);
368 + restore_path (ctx);
369 + FREE (&ctx->compressinfo);
373 +/* return 0 on success, -1 on failure */
374 +int mutt_sync_compressed (CONTEXT* ctx)
379 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
382 + mutt_message (_("Compressing %s..."), ctx->realpath);
384 + cmd = get_compression_cmd (ci->close, ctx);
388 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
390 + mutt_perror (ctx->realpath);
394 + mutt_block_signals ();
395 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
398 + mutt_unblock_signals ();
399 + mutt_error _("Unable to lock mailbox!");
405 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
409 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
410 + if (mutt_system (cmd))
412 + mutt_any_key_to_continue (NULL);
413 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
417 + mbox_unlock_compressed (ctx, fp);
418 + mutt_unblock_signals ();
428 +int mutt_slow_close_compressed (CONTEXT *ctx)
431 + const char *append;
433 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
435 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
439 + && ((append = get_append_command (ctx->realpath, ctx))
440 + || (append = ci->close))))
442 + /* if we can not or should not append, we only have to remove the */
443 + /* compressed info, because sync was already called */
444 + mutt_fast_close_compressed (ctx);
454 + if (append == ci->close)
455 + mutt_message (_("Compressing %s..."), ctx->realpath);
457 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
460 + cmd = get_compression_cmd (append, ctx);
464 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
466 + mutt_perror (ctx->realpath);
470 + mutt_block_signals ();
471 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
474 + mutt_unblock_signals ();
475 + mutt_error _("Unable to lock mailbox!");
480 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
485 + if (append == ci->close)
486 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
488 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
490 + if (mutt_system (cmd))
492 + mutt_any_key_to_continue (NULL);
493 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
496 + mbox_unlock_compressed (ctx, fp);
497 + mutt_unblock_signals ();
502 + mbox_unlock_compressed (ctx, fp);
503 + mutt_unblock_signals ();
506 + restore_path (ctx);
508 + FREE (&ctx->compressinfo);
513 +#endif /* USE_COMPRESSED */
515 ===================================================================
516 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
517 +++ compress.h 2007-02-16 01:59:20.562597888 +0100
520 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
522 + * This program is free software; you can redistribute it and/or modify
523 + * it under the terms of the GNU General Public License as published by
524 + * the Free Software Foundation; either version 2 of the License, or
525 + * (at your option) any later version.
527 + * This program is distributed in the hope that it will be useful,
528 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
529 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
530 + * GNU General Public License for more details.
532 + * You should have received a copy of the GNU General Public License
533 + * along with this program; if not, write to the Free Software
534 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
537 +int mutt_can_read_compressed (const char *);
538 +int mutt_can_append_compressed (const char *);
539 +int mutt_open_read_compressed (CONTEXT *);
540 +int mutt_open_append_compressed (CONTEXT *);
541 +int mutt_slow_close_compressed (CONTEXT *);
542 +int mutt_sync_compressed (CONTEXT *);
543 +int mutt_test_compress_command (const char *);
544 +int mutt_check_mailbox_compressed (CONTEXT *);
545 +void mutt_fast_close_compressed (CONTEXT *);
547 ===================================================================
548 --- configure.in.orig 2007-02-16 01:59:04.810992496 +0100
549 +++ configure.in 2007-02-16 01:59:20.563597736 +0100
550 @@ -801,6 +801,11 @@ AC_ARG_ENABLE(locales-fix, AC_HELP_STRIN
551 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
554 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
555 + [if test x$enableval = xyes; then
556 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
559 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
560 [if test $withval != yes; then
561 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
563 ===================================================================
564 --- curs_main.c.orig 2007-02-16 01:59:04.853985960 +0100
565 +++ curs_main.c 2007-02-16 01:59:20.563597736 +0100
566 @@ -1090,6 +1090,11 @@ int mutt_index_menu (void)
570 +#ifdef USE_COMPRESSED
571 + if (Context->compressinfo && Context->realpath)
572 + mutt_str_replace (&LastFolder, Context->realpath);
575 mutt_str_replace (&LastFolder, Context->path);
576 oldcount = Context ? Context->msgcount : 0;
578 Index: doc/manual.xml.head
579 ===================================================================
580 --- doc/manual.xml.head.orig 2007-02-16 01:59:04.898979120 +0100
581 +++ doc/manual.xml.head 2007-02-16 01:59:20.566597280 +0100
582 @@ -4749,6 +4749,205 @@ becomes an issue as mutt will silently f
586 +<sect1 id="compressedfolders">
587 +<title>Compressed folders Support (OPTIONAL)</title>
590 +If Mutt was compiled with compressed folders support (by running the
591 +<emphasis>configure</emphasis> script with the
592 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
593 +stored in an arbitrary format, provided that the user has a script to
594 +convert from/to this format to one of the accepted.
596 +The most common use is to open compressed archived folders e.g. with
599 +In addition, the user can provide a script that gets a folder in an
600 +accepted format and appends its context to the folder in the
601 +user-defined format, which may be faster than converting the entire
602 +folder to the accepted format, appending to it and converting back to
603 +the user-defined format.
605 +There are three hooks defined (<link
606 +linkend="open-hook">open-hook</link>, <link
607 +linkend="close-hook">close-hook</link> and <link
608 +linkend="append-hook">append-hook</link>) which define commands to
609 +uncompress and compress a folder and to append messages to an existing
610 +compressed folder respectively.
615 +open-hook \\.gz$ "gzip -cd %f > %t"
616 +close-hook \\.gz$ "gzip -c %t > %f"
617 +append-hook \\.gz$ "gzip -c %t >> %f"
620 +You do not have to specify all of the commands. If you omit <link
621 +linkend="append-hook">append-hook</link>, the folder will be open and
622 +closed again each time you will add to it. If you omit <link
623 +linkend="close-hook">close-hook</link> (or give empty command) , the
624 +folder will be open in the mode. If you specify <link
625 +linkend="append-hook">append-hook</link> though you'll be able to
626 +append to the folder.
628 +Note that Mutt will only try to use hooks if the file is not in one of
629 +the accepted formats. In particular, if the file is empty, mutt
630 +supposes it is not compressed. This is important because it allows the
631 +use of programs that do not have well defined extensions. Just use
632 +"." as a regexp. But this may be surprising if your
633 +compressing script produces empty files. In this situation, unset
634 +<link linkend="save-empty">$save_empty</link>, so that
635 +the compressed file will be removed if you delete all of the messages.
638 +<sect2 id="open-hook">
639 +<title>Open a compressed mailbox for reading</title>
642 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
644 +The <emphasis>command</emphasis> is the command that can be used for
645 +opening the folders whose names match <emphasis>regexp</emphasis>.
647 +The <emphasis>command</emphasis> string is the printf-like format
648 +string, and it should accept two parameters: %f, which is
649 +replaced with the (compressed) folder name, and %t which is
650 +replaced with the name of the temporary folder to which to write.
652 +%f and %t can be repeated any number of times in the
653 +command string, and all of the entries are replaced with the
654 +appropriate folder name. In addition, %% is replaced by
655 +%, as in printf, and any other %anything is left as is.
657 +The <emphasis>command</emphasis> should <emphasis
658 +role="bold">not</emphasis> remove the original compressed file. The
659 +<emphasis>command</emphasis> should return non-zero exit status if it
660 +fails, so mutt knows something's wrong.
665 +open-hook \\.gz$ "gzip -cd %f > %t"
668 +If the <emphasis>command</emphasis> is empty, this operation is
669 +disabled for this file type.
673 +<sect2 id="close-hook">
674 +<title>Write a compressed mailbox</title>
677 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
679 +This is used to close the folder that was open with the <link
680 +linkend="open-hook">open-hook</link> command after some changes were
683 +The <emphasis>command</emphasis> string is the command that can be
684 +used for closing the folders whose names match
685 +<emphasis>regexp</emphasis>. It has the same format as in the <link
686 +linkend="open-hook">open-hook</link> command. Temporary folder in this
687 +case is the folder previously produced by the <link
688 +linkend="open-hook">open-hook</link> command.
690 +The <emphasis>command</emphasis> should <emphasis
691 +role="bold">not</emphasis> remove the decompressed file. The
692 +<emphasis>command</emphasis> should return non-zero exit status if it
693 +fails, so mutt knows something's wrong.
698 +close-hook \\.gz$ "gzip -c %t > %f"
701 +If the <emphasis>command</emphasis> is empty, this operation is
702 +disabled for this file type, and the file can only be open in the
705 +<link linkend="close-hook">close-hook</link> is not called when you
706 +exit from the folder if the folder was not changed.
710 +<sect2 id="append-hook">
711 +<title>Append a message to a compressed mailbox</title>
714 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
716 +This command is used for saving to an existing compressed folder. The
717 +<emphasis>command</emphasis> is the command that can be used for
718 +appending to the folders whose names match
719 +<emphasis>regexp</emphasis>. It has the same format as in the <link
720 +linkend="open-hook">open-hook</link> command. The temporary folder in
721 +this case contains the messages that are being appended.
723 +The <emphasis>command</emphasis> should <emphasis
724 +role="bold">not</emphasis> remove the decompressed file. The
725 +<emphasis>command</emphasis> should return non-zero exit status if it
726 +fails, so mutt knows something's wrong.
731 +append-hook \\.gz$ "gzip -c %t >> %f"
734 +When <link linkend="append-hook">append-hook</link> is used, the folder
735 +is not opened, which saves time, but this means that we can not find
736 +out what the folder type is. Thus the default (<link
737 +linkend="mbox-type">$mbox_type</link>) type is always
738 +supposed (i.e. this is the format used for the temporary folder).
740 +If the file does not exist when you save to it, <link
741 +linkend="close-hook">close-hook</link> is called, and not <link
742 +linkend="append-hook">append-hook</link>. <link
743 +linkend="append-hook">append-hook</link> is only for appending to
746 +If the <emphasis>command</emphasis> is empty, this operation is
747 +disabled for this file type. In this case, the folder will be open and
748 +closed again (using <link linkend="open-hook">open-hook</link> and
749 +<link linkend="close-hook">close-hook</link>respectively) each time you
755 +<title>Encrypted folders</title>
758 +The compressed folders support can also be used to handle encrypted
759 +folders. If you want to encrypt a folder with PGP, you may want to use
760 +the following hooks:
763 +open-hook \\.pgp$ "pgp -f < %f > %t"
764 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
767 +Please note, that PGP does not support appending to an encrypted
768 +folder, so there is no append-hook defined.
770 +If you are using GnuPG instead of PGP, you may use the following hooks
774 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
775 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
778 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
779 +decrypted in the /tmp directory, where it can be read by your system
780 +administrator. So think about the security aspects of this.
787 <chapter id="mimesupport">
788 Index: doc/muttrc.man.head
789 ===================================================================
790 --- doc/muttrc.man.head.orig 2007-02-16 01:59:04.942972432 +0100
791 +++ doc/muttrc.man.head 2007-02-16 01:59:20.567597128 +0100
792 @@ -316,6 +316,24 @@ specify the ID of the public key to be u
793 to a certain recipient. The meaning of "key ID" is to be taken
794 broadly: This can be a different e-mail address, a numerical key ID,
795 or even just an arbitrary search string.
798 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
799 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
800 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
803 +These commands provide a way to handle compressed folders. The given
804 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
805 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
806 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
807 +compressed mail to a compressed folder (\fBappend-hook\fP). The
808 +\fIcommand\fP string is the
810 +like format string, and it should accept two parameters: \fB%f\fP,
811 +which is replaced with the (compressed) folder name, and \fB%t\fP
812 +which is replaced with the name of the temporary folder to which to
815 \fBpush\fP \fIstring\fP
816 This command adds the named \fIstring\fP to the keyboard buffer.
818 ===================================================================
819 --- hook.c.orig 2007-02-16 01:59:04.986965744 +0100
820 +++ hook.c 2007-02-16 01:59:20.567597128 +0100
823 #include "mutt_crypt.h"
825 +#ifdef USE_COMPRESSED
826 +#include "compress.h"
832 @@ -92,6 +96,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
833 memset (&pattern, 0, sizeof (pattern));
834 pattern.data = safe_strdup (path);
836 +#ifdef USE_COMPRESSED
837 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
839 + if (mutt_test_compress_command (command.data))
841 + strfcpy (err->data, _("bad formatted command string"), err->dsize);
846 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ACCOUNTHOOK))
847 && (!WithCrypto || !(data & M_CRYPTHOOK))
850 ===================================================================
851 --- init.h.orig 2007-02-16 01:59:05.029959208 +0100
852 +++ init.h 2007-02-16 01:59:20.568596976 +0100
853 @@ -3067,6 +3067,11 @@ struct command_t Commands[] = {
854 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
855 { "group", parse_group, 0 },
856 { "ungroup", parse_ungroup, 0 },
857 +#ifdef USE_COMPRESSED
858 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
859 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
860 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
862 { "hdr_order", parse_list, UL &HeaderOrderList },
864 { "iconv-hook", mutt_parse_hook, M_ICONVHOOK },
866 ===================================================================
867 --- main.c.orig 2007-02-16 01:59:05.073952520 +0100
868 +++ main.c 2007-02-16 01:59:20.569596824 +0100
869 @@ -398,6 +398,12 @@ static void show_version (void)
874 +#ifdef USE_COMPRESSED
883 ===================================================================
884 --- Makefile.am.orig 2007-02-16 01:59:05.117945832 +0100
885 +++ Makefile.am 2007-02-16 01:59:20.569596824 +0100
886 @@ -18,7 +18,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.
887 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
888 mutt_SOURCES = $(BUILT_SOURCES) \
889 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
890 - crypt.c cryptglue.c \
891 + crypt.c cryptglue.c compress.c \
892 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
893 edit.c enter.c flags.c init.c filter.c from.c \
894 getdomain.c group.c \
895 @@ -67,7 +67,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
898 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
899 - configure account.h \
900 + configure account.h compress.h \
901 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
902 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
903 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
905 ===================================================================
906 --- mbox.c.orig 2007-02-16 01:59:05.160939296 +0100
907 +++ mbox.c 2007-02-16 01:59:20.569596824 +0100
910 #include "mutt_curses.h"
912 +#ifdef USE_COMPRESSED
913 +#include "compress.h"
916 #include <sys/stat.h>
919 @@ -1026,6 +1030,12 @@ bail: /* Come here in case of disaster
920 int mbox_close_mailbox (CONTEXT *ctx)
922 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
924 +#ifdef USE_COMPRESSED
925 + if (ctx->compressinfo)
926 + mutt_slow_close_compressed (ctx);
929 mutt_unblock_signals ();
930 mx_fastclose_mailbox (ctx);
933 ===================================================================
934 --- mutt.h.orig 2007-02-16 01:59:05.203932760 +0100
935 +++ mutt.h 2007-02-16 01:59:20.570596672 +0100
936 @@ -159,6 +159,11 @@ typedef enum
937 #define M_ACCOUNTHOOK (1<<9)
938 #define M_REPLYHOOK (1<<10)
939 #define M_SEND2HOOK (1<<11)
940 +#ifdef USE_COMPRESSED
941 +#define M_OPENHOOK (1<<12)
942 +#define M_APPENDHOOK (1<<13)
943 +#define M_CLOSEHOOK (1<<14)
946 /* tree characters for linearize_tree and print_enriched_string */
947 #define M_TREE_LLCORNER 1
948 @@ -879,6 +884,11 @@ typedef struct
949 void *data; /* driver specific data */
950 #endif /* USE_IMAP */
952 +#ifdef USE_COMPRESSED
953 + void *compressinfo; /* compressed mbox module private data */
954 + char *realpath; /* path to compressed mailbox */
955 +#endif /* USE_COMPRESSED */
957 short magic; /* mailbox type */
959 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
961 ===================================================================
962 --- mx.c.orig 2007-02-16 01:59:05.247926072 +0100
963 +++ mx.c 2007-02-16 01:59:20.571596520 +0100
968 +#ifdef USE_COMPRESSED
969 +#include "compress.h"
975 @@ -454,6 +458,10 @@ int mx_get_magic (const char *path)
979 +#ifdef USE_COMPRESSED
980 + if (magic == 0 && mutt_can_read_compressed (path))
981 + return M_COMPRESSED;
986 @@ -493,6 +501,13 @@ static int mx_open_mailbox_append (CONTE
990 +#ifdef USE_COMPRESSED
991 + /* special case for appending to compressed folders -
992 + * even if we can not open them for reading */
993 + if (mutt_can_append_compressed (ctx->path))
994 + mutt_open_append_compressed (ctx);
1000 @@ -656,7 +671,12 @@ CONTEXT *mx_open_mailbox (const char *pa
1003 ctx->magic = mx_get_magic (path);
1006 +#ifdef USE_COMPRESSED
1007 + if (ctx->magic == M_COMPRESSED)
1008 + mutt_open_read_compressed (ctx);
1012 mutt_error (_("%s is not a mailbox."), path);
1014 @@ -762,6 +782,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
1015 mutt_free_header (&ctx->hdrs[i]);
1018 +#ifdef USE_COMPRESSED
1019 + if (ctx->compressinfo)
1020 + mutt_fast_close_compressed (ctx);
1023 FREE (&ctx->pattern);
1024 if (ctx->limit_pattern)
1025 @@ -819,6 +843,12 @@ static int sync_mailbox (CONTEXT *ctx, i
1026 if (tmp && tmp->new == 0)
1027 mutt_update_mailbox (tmp);
1030 +#ifdef USE_COMPRESSED
1031 + if (rc == 0 && ctx->compressinfo)
1032 + return mutt_sync_compressed (ctx);
1038 @@ -1020,6 +1050,11 @@ int mx_close_mailbox (CONTEXT *ctx, int
1039 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1040 mx_unlink_empty (ctx->path);
1042 +#ifdef USE_COMPRESSED
1043 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1047 mx_fastclose_mailbox (ctx);
1050 @@ -1329,6 +1364,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
1054 +#ifdef USE_COMPRESSED
1055 + if (ctx->compressinfo)
1056 + return mutt_check_mailbox_compressed (ctx);
1061 if (ctx->locked) lock = 0;
1063 ===================================================================
1064 --- mx.h.orig 2007-02-16 01:59:05.289919688 +0100
1065 +++ mx.h 2007-02-16 01:59:20.571596520 +0100
1066 @@ -40,6 +40,9 @@ enum
1070 +#ifdef USE_COMPRESSED
1075 WHERE short DefaultMagic INITVAL (M_MBOX);
1077 ===================================================================
1078 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1079 +++ PATCHES 2007-02-16 01:59:50.727012200 +0100
1081 +patch-1.5.11.rr.compressed.1
1083 ===================================================================
1084 --- po/de.po.orig 2007-02-16 01:59:05.375906616 +0100
1085 +++ po/de.po 2007-02-16 01:59:20.572596368 +0100
1086 @@ -1266,6 +1266,48 @@ msgstr "Prüfung des Absenders fehlgeschl
1087 msgid "Failed to figure out sender"
1088 msgstr "Kann Absender nicht ermitteln"
1090 +#: compress.c:203 mbox.c:661
1091 +msgid "Mailbox was corrupted!"
1092 +msgstr "Mailbox wurde zerstört!"
1094 +#: compress.c:228 compress.c:253
1096 +msgid "Decompressing %s...\n"
1097 +msgstr "Entpacke %s...\n"
1099 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1100 +msgid "Unable to lock mailbox!"
1101 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1105 +msgid "Error executing: %s : unable to open the mailbox!\n"
1106 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1108 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1110 +msgid "Compressing %s...\n"
1111 +msgstr "Komprimiere %s...\n"
1116 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1119 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1120 +"entpackte gespeichert!\n"
1122 +#: compress.c:425 compress.c:456
1124 +msgid "Compressed-appending to %s...\n"
1125 +msgstr "Hänge komprimiert an %s... an\n"
1129 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1130 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1134 msgid " (current time: %c)"
1135 @@ -1892,6 +1934,10 @@ msgstr ""
1137 msgstr "Hilfe für %s"
1140 +msgid "bad formatted command string"
1141 +msgstr "Hook enthält nicht die Muster %f und %t"
1145 msgid "unhook: Can't do unhook * from within a hook."
1146 @@ -3392,18 +3438,10 @@ msgstr "Lese %s... %d (%d%%)"
1147 msgid "Mailbox is corrupt!"
1148 msgstr "Mailbox fehlerhaft!"
1151 -msgid "Mailbox was corrupted!"
1152 -msgstr "Mailbox wurde zerstört!"
1154 #: mbox.c:701 mbox.c:952
1155 msgid "Fatal error! Could not reopen mailbox!"
1156 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1159 -msgid "Unable to lock mailbox!"
1160 -msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1162 #. this means ctx->changed or ctx->deleted was set, but no
1163 #. * messages were found to be changed or deleted. This should
1164 #. * never happen, is we presume it is a bug in mutt.
1165 Index: po/POTFILES.in
1166 ===================================================================
1167 --- po/POTFILES.in.orig 2007-02-16 01:59:05.419899928 +0100
1168 +++ po/POTFILES.in 2007-02-16 01:59:20.573596216 +0100
1169 @@ -8,6 +8,7 @@ charset.c
1178 ===================================================================
1179 --- status.c.orig 2007-02-16 01:59:05.465892936 +0100
1180 +++ status.c 2007-02-16 01:59:20.573596216 +0100
1181 @@ -97,6 +97,14 @@ status_format_str (char *buf, size_t buf
1184 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1185 +#ifdef USE_COMPRESSED
1186 + if (Context && Context->compressinfo && Context->realpath)
1188 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1189 + mutt_pretty_mailbox (tmp);
1193 if (Context && Context->path)
1195 strfcpy (tmp, Context->path, sizeof (tmp));