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.14.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 - 2007-03-13 myon: update for 1.5.14+tip (conflict in hook.c)
18 - 2007-03-20 myon: conflict in mx.c resolved (BUFFY_SIZE is gone)
19 - 2007-05-16 myon: conflict in flags.c resolved, adjusted mutt_FormatString
20 call and compresshook_format_str in compress.c
23 Index: debian-mutt/compress.c
24 ===================================================================
25 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
26 +++ debian-mutt/compress.c 2007-05-17 00:11:39.000000000 +0200
29 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
31 + * This program is free software; you can redistribute it and/or modify
32 + * it under the terms of the GNU General Public License as published by
33 + * the Free Software Foundation; either version 2 of the License, or
34 + * (at your option) any later version.
36 + * This program is distributed in the hope that it will be useful,
37 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
38 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39 + * GNU General Public License for more details.
41 + * You should have received a copy of the GNU General Public License
42 + * along with this program; if not, write to the Free Software
43 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
52 +#ifdef USE_COMPRESSED
56 +#include "mutt_curses.h"
61 +#include <sys/stat.h>
65 + const char *close; /* close-hook command */
66 + const char *open; /* open-hook command */
67 + const char *append; /* append-hook command */
68 + off_t size; /* size of real folder */
73 + * ctx - context to lock
74 + * excl - exclusive lock?
75 + * retry - should retry if unable to lock?
77 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
81 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
83 + else if (retry && !excl)
92 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
98 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
103 +static int is_new (const char *path)
105 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
108 +static const char* find_compress_hook (int type, const char *path)
110 + const char* c = mutt_find_hook (type, path);
111 + return (!c || !*c) ? NULL : c;
114 +int mutt_can_read_compressed (const char *path)
116 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
120 + * if the file is new, we really do not append, but create, and so use
121 + * close-hook, and not append-hook
123 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
125 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
126 + return (is_new (path)) ? ci->close : ci->append;
129 +int mutt_can_append_compressed (const char *path)
135 + char *dir_path = safe_strdup(path);
136 + char *aux = strrchr(dir_path, '/');
141 + if (access(dir_path, W_OK|X_OK))
144 + safe_free((void**)&dir_path);
145 + return dir_valid && (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
148 + magic = mx_get_magic (path);
150 + if (magic != 0 && magic != M_COMPRESSED)
153 + return (find_compress_hook (M_APPENDHOOK, path)
154 + || (find_compress_hook (M_OPENHOOK, path)
155 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
158 +/* open a compressed mailbox */
159 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
163 + /* Now lets uncompress this thing */
164 + ci = safe_malloc (sizeof (COMPRESS_INFO));
165 + ctx->compressinfo = (void*) ci;
166 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
167 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
168 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
172 +static void set_path (CONTEXT* ctx)
174 + char tmppath[_POSIX_PATH_MAX];
176 + /* Setup the right paths */
177 + ctx->realpath = ctx->path;
179 + /* Uncompress to /tmp */
180 + mutt_mktemp (tmppath);
181 + ctx->path = safe_malloc (strlen (tmppath) + 1);
182 + strcpy (ctx->path, tmppath);
185 +static int get_size (const char* path)
188 + if (stat (path, &sb) != 0)
190 + return (sb.st_size);
193 +static void store_size (CONTEXT* ctx)
195 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
196 + ci->size = get_size (ctx->realpath);
200 +compresshook_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
201 + const char *fmt, const char *ifstring,
202 + const char *elsestring, unsigned long data,
205 + char tmp[SHORT_STRING];
207 + CONTEXT *ctx = (CONTEXT *) data;
211 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
212 + snprintf (dest, destlen, tmp, ctx->realpath);
215 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
216 + snprintf (dest, destlen, tmp, ctx->path);
223 + * check that the command has both %f and %t
224 + * 0 means OK, -1 means error
226 +int mutt_test_compress_command (const char* cmd)
228 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
231 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
233 + char expanded[_POSIX_PATH_MAX];
234 + mutt_FormatString (expanded, sizeof (expanded), 0, cmd, compresshook_format_str,
235 + (unsigned long) ctx, 0);
236 + return safe_strdup (expanded);
239 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
241 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
242 + if (ci->size != get_size (ctx->realpath))
244 + FREE (&ctx->compressinfo);
245 + FREE (&ctx->realpath);
246 + mutt_error _("Mailbox was corrupted!");
252 +int mutt_open_read_compressed (CONTEXT *ctx)
258 + COMPRESS_INFO *ci = set_compress_info (ctx);
261 + FREE (ctx->compressinfo);
264 + if (!ci->close || access (ctx->path, W_OK) != 0)
271 + mutt_message (_("Decompressing %s..."), ctx->realpath);
273 + cmd = get_compression_cmd (ci->open, ctx);
276 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
278 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
280 + mutt_perror (ctx->realpath);
284 + mutt_block_signals ();
285 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
288 + mutt_unblock_signals ();
289 + mutt_error _("Unable to lock mailbox!");
296 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
297 + rc = mutt_system (cmd);
298 + mbox_unlock_compressed (ctx, fp);
299 + mutt_unblock_signals ();
304 + mutt_any_key_to_continue (NULL);
306 + FREE (ctx->compressinfo);
307 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
313 + if (mutt_check_mailbox_compressed (ctx))
316 + ctx->magic = mx_get_magic (ctx->path);
321 +void restore_path (CONTEXT* ctx)
324 + ctx->path = ctx->realpath;
327 +/* remove the temporary mailbox */
328 +void remove_file (CONTEXT* ctx)
330 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
331 + remove (ctx->path);
334 +int mutt_open_append_compressed (CONTEXT *ctx)
337 + COMPRESS_INFO *ci = set_compress_info (ctx);
339 + if (!get_append_command (ctx->path, ctx))
341 + if (ci->open && ci->close)
342 + return (mutt_open_read_compressed (ctx));
345 + FREE (&ctx->compressinfo);
351 + ctx->magic = DefaultMagic;
353 + if (!is_new (ctx->realpath))
354 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
355 + if ((fh = fopen (ctx->path, "w")))
357 + /* No error checking - the parent function will catch it */
362 +/* close a compressed mailbox */
363 +void mutt_fast_close_compressed (CONTEXT *ctx)
365 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
368 + if (ctx->compressinfo)
373 + /* if the folder was removed, remove the gzipped folder too */
374 + if ((ctx->magic > 0)
375 + && (access (ctx->path, F_OK) != 0)
376 + && ! option (OPTSAVEEMPTY))
377 + remove (ctx->realpath);
381 + restore_path (ctx);
382 + FREE (&ctx->compressinfo);
386 +/* return 0 on success, -1 on failure */
387 +int mutt_sync_compressed (CONTEXT* ctx)
392 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
395 + mutt_message (_("Compressing %s..."), ctx->realpath);
397 + cmd = get_compression_cmd (ci->close, ctx);
401 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
403 + mutt_perror (ctx->realpath);
407 + mutt_block_signals ();
408 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
411 + mutt_unblock_signals ();
412 + mutt_error _("Unable to lock mailbox!");
418 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
422 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
423 + if (mutt_system (cmd))
425 + mutt_any_key_to_continue (NULL);
426 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
430 + mbox_unlock_compressed (ctx, fp);
431 + mutt_unblock_signals ();
441 +int mutt_slow_close_compressed (CONTEXT *ctx)
444 + const char *append;
446 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
448 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
452 + && ((append = get_append_command (ctx->realpath, ctx))
453 + || (append = ci->close))))
455 + /* if we can not or should not append, we only have to remove the */
456 + /* compressed info, because sync was already called */
457 + mutt_fast_close_compressed (ctx);
467 + if (append == ci->close)
468 + mutt_message (_("Compressing %s..."), ctx->realpath);
470 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
473 + cmd = get_compression_cmd (append, ctx);
477 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
479 + mutt_perror (ctx->realpath);
483 + mutt_block_signals ();
484 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
487 + mutt_unblock_signals ();
488 + mutt_error _("Unable to lock mailbox!");
493 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
498 + if (append == ci->close)
499 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
501 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
503 + if (mutt_system (cmd))
505 + mutt_any_key_to_continue (NULL);
506 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
509 + mbox_unlock_compressed (ctx, fp);
510 + mutt_unblock_signals ();
515 + mbox_unlock_compressed (ctx, fp);
516 + mutt_unblock_signals ();
519 + restore_path (ctx);
521 + FREE (&ctx->compressinfo);
526 +#endif /* USE_COMPRESSED */
527 Index: debian-mutt/compress.h
528 ===================================================================
529 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
530 +++ debian-mutt/compress.h 2007-05-16 23:54:01.000000000 +0200
533 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
535 + * This program is free software; you can redistribute it and/or modify
536 + * it under the terms of the GNU General Public License as published by
537 + * the Free Software Foundation; either version 2 of the License, or
538 + * (at your option) any later version.
540 + * This program is distributed in the hope that it will be useful,
541 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
542 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
543 + * GNU General Public License for more details.
545 + * You should have received a copy of the GNU General Public License
546 + * along with this program; if not, write to the Free Software
547 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
550 +int mutt_can_read_compressed (const char *);
551 +int mutt_can_append_compressed (const char *);
552 +int mutt_open_read_compressed (CONTEXT *);
553 +int mutt_open_append_compressed (CONTEXT *);
554 +int mutt_slow_close_compressed (CONTEXT *);
555 +int mutt_sync_compressed (CONTEXT *);
556 +int mutt_test_compress_command (const char *);
557 +int mutt_check_mailbox_compressed (CONTEXT *);
558 +void mutt_fast_close_compressed (CONTEXT *);
559 Index: debian-mutt/configure.ac
560 ===================================================================
561 --- debian-mutt.orig/configure.ac 2007-05-16 23:53:59.000000000 +0200
562 +++ debian-mutt/configure.ac 2007-05-16 23:54:02.000000000 +0200
563 @@ -785,6 +785,11 @@ AC_ARG_ENABLE(locales-fix, AC_HELP_STRIN
564 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
567 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
568 + [if test x$enableval = xyes; then
569 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
572 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
573 [if test $withval != yes; then
574 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
575 Index: debian-mutt/curs_main.c
576 ===================================================================
577 --- debian-mutt.orig/curs_main.c 2007-05-16 23:53:59.000000000 +0200
578 +++ debian-mutt/curs_main.c 2007-05-17 00:13:50.000000000 +0200
579 @@ -1111,6 +1111,11 @@ int mutt_index_menu (void)
583 +#ifdef USE_COMPRESSED
584 + if (Context->compressinfo && Context->realpath)
585 + mutt_str_replace (&LastFolder, Context->realpath);
588 mutt_str_replace (&LastFolder, Context->path);
589 oldcount = Context ? Context->msgcount : 0;
591 Index: debian-mutt/doc/manual.xml.head
592 ===================================================================
593 --- debian-mutt.orig/doc/manual.xml.head 2007-05-16 23:53:59.000000000 +0200
594 +++ debian-mutt/doc/manual.xml.head 2007-05-17 00:13:50.000000000 +0200
595 @@ -4910,6 +4910,205 @@ becomes an issue as mutt will silently f
599 +<sect1 id="compressedfolders">
600 +<title>Compressed folders Support (OPTIONAL)</title>
603 +If Mutt was compiled with compressed folders support (by running the
604 +<emphasis>configure</emphasis> script with the
605 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
606 +stored in an arbitrary format, provided that the user has a script to
607 +convert from/to this format to one of the accepted.
609 +The most common use is to open compressed archived folders e.g. with
612 +In addition, the user can provide a script that gets a folder in an
613 +accepted format and appends its context to the folder in the
614 +user-defined format, which may be faster than converting the entire
615 +folder to the accepted format, appending to it and converting back to
616 +the user-defined format.
618 +There are three hooks defined (<link
619 +linkend="open-hook">open-hook</link>, <link
620 +linkend="close-hook">close-hook</link> and <link
621 +linkend="append-hook">append-hook</link>) which define commands to
622 +uncompress and compress a folder and to append messages to an existing
623 +compressed folder respectively.
628 +open-hook \\.gz$ "gzip -cd %f > %t"
629 +close-hook \\.gz$ "gzip -c %t > %f"
630 +append-hook \\.gz$ "gzip -c %t >> %f"
633 +You do not have to specify all of the commands. If you omit <link
634 +linkend="append-hook">append-hook</link>, the folder will be open and
635 +closed again each time you will add to it. If you omit <link
636 +linkend="close-hook">close-hook</link> (or give empty command) , the
637 +folder will be open in the mode. If you specify <link
638 +linkend="append-hook">append-hook</link> though you'll be able to
639 +append to the folder.
641 +Note that Mutt will only try to use hooks if the file is not in one of
642 +the accepted formats. In particular, if the file is empty, mutt
643 +supposes it is not compressed. This is important because it allows the
644 +use of programs that do not have well defined extensions. Just use
645 +"." as a regexp. But this may be surprising if your
646 +compressing script produces empty files. In this situation, unset
647 +<link linkend="save-empty">$save_empty</link>, so that
648 +the compressed file will be removed if you delete all of the messages.
651 +<sect2 id="open-hook">
652 +<title>Open a compressed mailbox for reading</title>
655 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
657 +The <emphasis>command</emphasis> is the command that can be used for
658 +opening the folders whose names match <emphasis>regexp</emphasis>.
660 +The <emphasis>command</emphasis> string is the printf-like format
661 +string, and it should accept two parameters: %f, which is
662 +replaced with the (compressed) folder name, and %t which is
663 +replaced with the name of the temporary folder to which to write.
665 +%f and %t can be repeated any number of times in the
666 +command string, and all of the entries are replaced with the
667 +appropriate folder name. In addition, %% is replaced by
668 +%, as in printf, and any other %anything is left as is.
670 +The <emphasis>command</emphasis> should <emphasis
671 +role="bold">not</emphasis> remove the original compressed file. The
672 +<emphasis>command</emphasis> should return non-zero exit status if it
673 +fails, so mutt knows something's wrong.
678 +open-hook \\.gz$ "gzip -cd %f > %t"
681 +If the <emphasis>command</emphasis> is empty, this operation is
682 +disabled for this file type.
686 +<sect2 id="close-hook">
687 +<title>Write a compressed mailbox</title>
690 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
692 +This is used to close the folder that was open with the <link
693 +linkend="open-hook">open-hook</link> command after some changes were
696 +The <emphasis>command</emphasis> string is the command that can be
697 +used for closing the folders whose names match
698 +<emphasis>regexp</emphasis>. It has the same format as in the <link
699 +linkend="open-hook">open-hook</link> command. Temporary folder in this
700 +case is the folder previously produced by the <link
701 +linkend="open-hook">open-hook</link> command.
703 +The <emphasis>command</emphasis> should <emphasis
704 +role="bold">not</emphasis> remove the decompressed file. The
705 +<emphasis>command</emphasis> should return non-zero exit status if it
706 +fails, so mutt knows something's wrong.
711 +close-hook \\.gz$ "gzip -c %t > %f"
714 +If the <emphasis>command</emphasis> is empty, this operation is
715 +disabled for this file type, and the file can only be open in the
718 +<link linkend="close-hook">close-hook</link> is not called when you
719 +exit from the folder if the folder was not changed.
723 +<sect2 id="append-hook">
724 +<title>Append a message to a compressed mailbox</title>
727 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
729 +This command is used for saving to an existing compressed folder. The
730 +<emphasis>command</emphasis> is the command that can be used for
731 +appending to the folders whose names match
732 +<emphasis>regexp</emphasis>. It has the same format as in the <link
733 +linkend="open-hook">open-hook</link> command. The temporary folder in
734 +this case contains the messages that are being appended.
736 +The <emphasis>command</emphasis> should <emphasis
737 +role="bold">not</emphasis> remove the decompressed file. The
738 +<emphasis>command</emphasis> should return non-zero exit status if it
739 +fails, so mutt knows something's wrong.
744 +append-hook \\.gz$ "gzip -c %t >> %f"
747 +When <link linkend="append-hook">append-hook</link> is used, the folder
748 +is not opened, which saves time, but this means that we can not find
749 +out what the folder type is. Thus the default (<link
750 +linkend="mbox-type">$mbox_type</link>) type is always
751 +supposed (i.e. this is the format used for the temporary folder).
753 +If the file does not exist when you save to it, <link
754 +linkend="close-hook">close-hook</link> is called, and not <link
755 +linkend="append-hook">append-hook</link>. <link
756 +linkend="append-hook">append-hook</link> is only for appending to
759 +If the <emphasis>command</emphasis> is empty, this operation is
760 +disabled for this file type. In this case, the folder will be open and
761 +closed again (using <link linkend="open-hook">open-hook</link> and
762 +<link linkend="close-hook">close-hook</link>respectively) each time you
768 +<title>Encrypted folders</title>
771 +The compressed folders support can also be used to handle encrypted
772 +folders. If you want to encrypt a folder with PGP, you may want to use
773 +the following hooks:
776 +open-hook \\.pgp$ "pgp -f < %f > %t"
777 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
780 +Please note, that PGP does not support appending to an encrypted
781 +folder, so there is no append-hook defined.
783 +If you are using GnuPG instead of PGP, you may use the following hooks
787 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
788 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
791 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
792 +decrypted in the /tmp directory, where it can be read by your system
793 +administrator. So think about the security aspects of this.
798 <chapter id="mimesupport">
799 <title>Mutt's MIME Support</title>
801 Index: debian-mutt/doc/muttrc.man.head
802 ===================================================================
803 --- debian-mutt.orig/doc/muttrc.man.head 2007-05-16 23:53:59.000000000 +0200
804 +++ debian-mutt/doc/muttrc.man.head 2007-05-16 23:54:01.000000000 +0200
805 @@ -345,6 +345,24 @@ specify the ID of the public key to be u
806 to a certain recipient. The meaning of "key ID" is to be taken
807 broadly: This can be a different e-mail address, a numerical key ID,
808 or even just an arbitrary search string.
811 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
812 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
813 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
816 +These commands provide a way to handle compressed folders. The given
817 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
818 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
819 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
820 +compressed mail to a compressed folder (\fBappend-hook\fP). The
821 +\fIcommand\fP string is the
823 +like format string, and it should accept two parameters: \fB%f\fP,
824 +which is replaced with the (compressed) folder name, and \fB%t\fP
825 +which is replaced with the name of the temporary folder to which to
828 \fBpush\fP \fIstring\fP
829 This command adds the named \fIstring\fP to the keyboard buffer.
830 Index: debian-mutt/hook.c
831 ===================================================================
832 --- debian-mutt.orig/hook.c 2007-05-16 23:53:59.000000000 +0200
833 +++ debian-mutt/hook.c 2007-05-16 23:54:01.000000000 +0200
836 #include "mutt_crypt.h"
838 +#ifdef USE_COMPRESSED
839 +#include "compress.h"
845 @@ -92,6 +96,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
846 memset (&pattern, 0, sizeof (pattern));
847 pattern.data = safe_strdup (path);
849 +#ifdef USE_COMPRESSED
850 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
852 + if (mutt_test_compress_command (command.data))
854 + strfcpy (err->data, _("bad formatted command string"), err->dsize);
859 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
860 && (!WithCrypto || !(data & M_CRYPTHOOK))
862 Index: debian-mutt/init.h
863 ===================================================================
864 --- debian-mutt.orig/init.h 2007-05-16 23:53:58.000000000 +0200
865 +++ debian-mutt/init.h 2007-05-17 00:13:50.000000000 +0200
866 @@ -3129,6 +3129,11 @@ struct command_t Commands[] = {
867 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
868 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
869 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
870 +#ifdef USE_COMPRESSED
871 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
872 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
873 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
875 { "group", parse_group, 0 },
876 { "ungroup", parse_ungroup, 0 },
877 { "hdr_order", parse_list, UL &HeaderOrderList },
878 Index: debian-mutt/main.c
879 ===================================================================
880 --- debian-mutt.orig/main.c 2007-05-16 23:53:58.000000000 +0200
881 +++ debian-mutt/main.c 2007-05-16 23:54:01.000000000 +0200
882 @@ -401,6 +401,12 @@ static void show_version (void)
887 +#ifdef USE_COMPRESSED
895 Index: debian-mutt/Makefile.am
896 ===================================================================
897 --- debian-mutt.orig/Makefile.am 2007-05-16 23:53:59.000000000 +0200
898 +++ debian-mutt/Makefile.am 2007-05-16 23:54:01.000000000 +0200
899 @@ -18,7 +18,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.
900 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
901 mutt_SOURCES = $(BUILT_SOURCES) \
902 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
903 - crypt.c cryptglue.c \
904 + crypt.c cryptglue.c compress.c \
905 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
906 edit.c enter.c flags.c init.c filter.c from.c \
907 getdomain.c group.c \
908 @@ -66,7 +66,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
911 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
912 - configure account.h \
913 + configure account.h compress.h \
914 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
915 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
916 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
917 Index: debian-mutt/mbox.c
918 ===================================================================
919 --- debian-mutt.orig/mbox.c 2007-05-16 23:53:58.000000000 +0200
920 +++ debian-mutt/mbox.c 2007-05-16 23:54:01.000000000 +0200
923 #include "mutt_curses.h"
925 +#ifdef USE_COMPRESSED
926 +#include "compress.h"
929 #include <sys/stat.h>
932 @@ -1026,6 +1030,12 @@ bail: /* Come here in case of disaster
933 int mbox_close_mailbox (CONTEXT *ctx)
935 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
937 +#ifdef USE_COMPRESSED
938 + if (ctx->compressinfo)
939 + mutt_slow_close_compressed (ctx);
942 mutt_unblock_signals ();
943 mx_fastclose_mailbox (ctx);
945 Index: debian-mutt/mutt.h
946 ===================================================================
947 --- debian-mutt.orig/mutt.h 2007-05-16 23:53:58.000000000 +0200
948 +++ debian-mutt/mutt.h 2007-05-17 00:13:50.000000000 +0200
949 @@ -160,6 +160,11 @@ typedef enum
950 #define M_ACCOUNTHOOK (1<<9)
951 #define M_REPLYHOOK (1<<10)
952 #define M_SEND2HOOK (1<<11)
953 +#ifdef USE_COMPRESSED
954 +#define M_OPENHOOK (1<<12)
955 +#define M_APPENDHOOK (1<<13)
956 +#define M_CLOSEHOOK (1<<14)
959 /* tree characters for linearize_tree and print_enriched_string */
960 #define M_TREE_LLCORNER 1
961 @@ -885,6 +890,11 @@ typedef struct _context
962 int flagged; /* how many flagged messages */
963 int msgnotreadyet; /* which msg "new" in pager, -1 if none */
965 +#ifdef USE_COMPRESSED
966 + void *compressinfo; /* compressed mbox module private data */
967 + char *realpath; /* path to compressed mailbox */
968 +#endif /* USE_COMPRESSED */
970 short magic; /* mailbox type */
972 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
973 Index: debian-mutt/mx.c
974 ===================================================================
975 --- debian-mutt.orig/mx.c 2007-05-16 23:53:58.000000000 +0200
976 +++ debian-mutt/mx.c 2007-05-17 00:13:49.000000000 +0200
981 +#ifdef USE_COMPRESSED
982 +#include "compress.h"
988 @@ -450,6 +454,10 @@ int mx_get_magic (const char *path)
992 +#ifdef USE_COMPRESSED
993 + if (magic == 0 && mutt_can_read_compressed (path))
994 + return M_COMPRESSED;
999 @@ -489,6 +497,13 @@ static int mx_open_mailbox_append (CONTE
1003 +#ifdef USE_COMPRESSED
1004 + /* special case for appending to compressed folders -
1005 + * even if we can not open them for reading */
1006 + if (mutt_can_append_compressed (ctx->path))
1007 + mutt_open_append_compressed (ctx);
1013 @@ -652,7 +667,12 @@ CONTEXT *mx_open_mailbox (const char *pa
1016 ctx->magic = mx_get_magic (path);
1019 +#ifdef USE_COMPRESSED
1020 + if (ctx->magic == M_COMPRESSED)
1021 + mutt_open_read_compressed (ctx);
1025 mutt_error (_("%s is not a mailbox."), path);
1027 @@ -753,6 +773,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
1028 mutt_free_header (&ctx->hdrs[i]);
1031 +#ifdef USE_COMPRESSED
1032 + if (ctx->compressinfo)
1033 + mutt_fast_close_compressed (ctx);
1036 FREE (&ctx->pattern);
1037 if (ctx->limit_pattern)
1038 @@ -805,6 +829,12 @@ static int sync_mailbox (CONTEXT *ctx, i
1040 if (tmp && tmp->new == 0)
1041 mutt_update_mailbox (tmp);
1043 +#ifdef USE_COMPRESSED
1044 + if (rc == 0 && ctx->compressinfo)
1045 + return mutt_sync_compressed (ctx);
1051 @@ -1006,6 +1036,11 @@ int mx_close_mailbox (CONTEXT *ctx, int
1052 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1053 mx_unlink_empty (ctx->path);
1055 +#ifdef USE_COMPRESSED
1056 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1060 mx_fastclose_mailbox (ctx);
1063 @@ -1315,6 +1350,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
1067 +#ifdef USE_COMPRESSED
1068 + if (ctx->compressinfo)
1069 + return mutt_check_mailbox_compressed (ctx);
1074 if (ctx->locked) lock = 0;
1075 Index: debian-mutt/mx.h
1076 ===================================================================
1077 --- debian-mutt.orig/mx.h 2007-05-16 23:53:59.000000000 +0200
1078 +++ debian-mutt/mx.h 2007-05-16 23:54:01.000000000 +0200
1079 @@ -40,6 +40,9 @@ enum
1083 +#ifdef USE_COMPRESSED
1088 WHERE short DefaultMagic INITVAL (M_MBOX);
1089 Index: debian-mutt/PATCHES
1090 ===================================================================
1091 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1092 +++ debian-mutt/PATCHES 2007-05-17 00:13:50.000000000 +0200
1094 +patch-1.5.14.rr.compressed.1
1095 Index: debian-mutt/po/de.po
1096 ===================================================================
1097 --- debian-mutt.orig/po/de.po 2007-05-16 23:53:59.000000000 +0200
1098 +++ debian-mutt/po/de.po 2007-05-16 23:54:01.000000000 +0200
1099 @@ -1280,6 +1280,48 @@ msgstr "Prüfung des Absenders fehlgeschl
1100 msgid "Failed to figure out sender"
1101 msgstr "Kann Absender nicht ermitteln"
1103 +#: compress.c:203 mbox.c:661
1104 +msgid "Mailbox was corrupted!"
1105 +msgstr "Mailbox wurde zerstört!"
1107 +#: compress.c:228 compress.c:253
1109 +msgid "Decompressing %s...\n"
1110 +msgstr "Entpacke %s...\n"
1112 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1113 +msgid "Unable to lock mailbox!"
1114 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1118 +msgid "Error executing: %s : unable to open the mailbox!\n"
1119 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1121 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1123 +msgid "Compressing %s...\n"
1124 +msgstr "Komprimiere %s...\n"
1129 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1132 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1133 +"entpackte gespeichert!\n"
1135 +#: compress.c:425 compress.c:456
1137 +msgid "Compressed-appending to %s...\n"
1138 +msgstr "Hänge komprimiert an %s... an\n"
1142 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1143 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1147 msgid " (current time: %c)"
1148 @@ -3437,18 +3479,10 @@ msgstr "Lese %s..."
1149 msgid "Mailbox is corrupt!"
1150 msgstr "Mailbox fehlerhaft!"
1153 -msgid "Mailbox was corrupted!"
1154 -msgstr "Mailbox wurde zerstört!"
1156 #: mbox.c:711 mbox.c:964
1157 msgid "Fatal error! Could not reopen mailbox!"
1158 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1161 -msgid "Unable to lock mailbox!"
1162 -msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1164 #. this means ctx->changed or ctx->deleted was set, but no
1165 #. * messages were found to be changed or deleted. This should
1166 #. * never happen, is we presume it is a bug in mutt.
1167 Index: debian-mutt/po/POTFILES.in
1168 ===================================================================
1169 --- debian-mutt.orig/po/POTFILES.in 2007-05-16 23:53:59.000000000 +0200
1170 +++ debian-mutt/po/POTFILES.in 2007-05-16 23:54:01.000000000 +0200
1171 @@ -8,6 +8,7 @@ charset.c
1179 Index: debian-mutt/status.c
1180 ===================================================================
1181 --- debian-mutt.orig/status.c 2007-05-16 23:53:58.000000000 +0200
1182 +++ debian-mutt/status.c 2007-05-17 00:13:49.000000000 +0200
1183 @@ -99,6 +99,14 @@ status_format_str (char *buf, size_t buf
1186 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1187 +#ifdef USE_COMPRESSED
1188 + if (Context && Context->compressinfo && Context->realpath)
1190 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1191 + mutt_pretty_mailbox (tmp);
1195 if (Context && Context->path)
1197 strfcpy (tmp, Context->path, sizeof (tmp));