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)
21 Index: debian-mutt/compress.c
22 ===================================================================
23 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
24 +++ debian-mutt/compress.c 2007-04-12 18:56:02.000000000 +0200
27 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
29 + * This program is free software; you can redistribute it and/or modify
30 + * it under the terms of the GNU General Public License as published by
31 + * the Free Software Foundation; either version 2 of the License, or
32 + * (at your option) any later version.
34 + * This program is distributed in the hope that it will be useful,
35 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
36 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 + * GNU General Public License for more details.
39 + * You should have received a copy of the GNU General Public License
40 + * along with this program; if not, write to the Free Software
41 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
50 +#ifdef USE_COMPRESSED
54 +#include "mutt_curses.h"
59 +#include <sys/stat.h>
63 + const char *close; /* close-hook command */
64 + const char *open; /* open-hook command */
65 + const char *append; /* append-hook command */
66 + off_t size; /* size of real folder */
71 + * ctx - context to lock
72 + * excl - exclusive lock?
73 + * retry - should retry if unable to lock?
75 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
79 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
81 + else if (retry && !excl)
90 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
96 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
101 +static int is_new (const char *path)
103 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
106 +static const char* find_compress_hook (int type, const char *path)
108 + const char* c = mutt_find_hook (type, path);
109 + return (!c || !*c) ? NULL : c;
112 +int mutt_can_read_compressed (const char *path)
114 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
118 + * if the file is new, we really do not append, but create, and so use
119 + * close-hook, and not append-hook
121 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
123 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
124 + return (is_new (path)) ? ci->close : ci->append;
127 +int mutt_can_append_compressed (const char *path)
133 + char *dir_path = safe_strdup(path);
134 + char *aux = strrchr(dir_path, '/');
139 + if (access(dir_path, W_OK|X_OK))
142 + safe_free((void**)&dir_path);
143 + return dir_valid && (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
146 + magic = mx_get_magic (path);
148 + if (magic != 0 && magic != M_COMPRESSED)
151 + return (find_compress_hook (M_APPENDHOOK, path)
152 + || (find_compress_hook (M_OPENHOOK, path)
153 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
156 +/* open a compressed mailbox */
157 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
161 + /* Now lets uncompress this thing */
162 + ci = safe_malloc (sizeof (COMPRESS_INFO));
163 + ctx->compressinfo = (void*) ci;
164 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
165 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
166 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
170 +static void set_path (CONTEXT* ctx)
172 + char tmppath[_POSIX_PATH_MAX];
174 + /* Setup the right paths */
175 + ctx->realpath = ctx->path;
177 + /* Uncompress to /tmp */
178 + mutt_mktemp (tmppath);
179 + ctx->path = safe_malloc (strlen (tmppath) + 1);
180 + strcpy (ctx->path, tmppath);
183 +static int get_size (const char* path)
186 + if (stat (path, &sb) != 0)
188 + return (sb.st_size);
191 +static void store_size (CONTEXT* ctx)
193 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
194 + ci->size = get_size (ctx->realpath);
198 +compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
199 + const char *fmt, const char *ifstring,
200 + const char *elsestring, unsigned long data,
203 + char tmp[SHORT_STRING];
205 + CONTEXT *ctx = (CONTEXT *) data;
209 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
210 + snprintf (dest, destlen, tmp, ctx->realpath);
213 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
214 + snprintf (dest, destlen, tmp, ctx->path);
221 + * check that the command has both %f and %t
222 + * 0 means OK, -1 means error
224 +int mutt_test_compress_command (const char* cmd)
226 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
229 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
231 + char expanded[_POSIX_PATH_MAX];
232 + mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str,
233 + (unsigned long) ctx, 0);
234 + return safe_strdup (expanded);
237 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
239 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
240 + if (ci->size != get_size (ctx->realpath))
242 + FREE (&ctx->compressinfo);
243 + FREE (&ctx->realpath);
244 + mutt_error _("Mailbox was corrupted!");
250 +int mutt_open_read_compressed (CONTEXT *ctx)
256 + COMPRESS_INFO *ci = set_compress_info (ctx);
259 + FREE (ctx->compressinfo);
262 + if (!ci->close || access (ctx->path, W_OK) != 0)
269 + mutt_message (_("Decompressing %s..."), ctx->realpath);
271 + cmd = get_compression_cmd (ci->open, ctx);
274 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
276 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
278 + mutt_perror (ctx->realpath);
282 + mutt_block_signals ();
283 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
286 + mutt_unblock_signals ();
287 + mutt_error _("Unable to lock mailbox!");
294 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
295 + rc = mutt_system (cmd);
296 + mbox_unlock_compressed (ctx, fp);
297 + mutt_unblock_signals ();
302 + mutt_any_key_to_continue (NULL);
304 + FREE (ctx->compressinfo);
305 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
311 + if (mutt_check_mailbox_compressed (ctx))
314 + ctx->magic = mx_get_magic (ctx->path);
319 +void restore_path (CONTEXT* ctx)
322 + ctx->path = ctx->realpath;
325 +/* remove the temporary mailbox */
326 +void remove_file (CONTEXT* ctx)
328 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
329 + remove (ctx->path);
332 +int mutt_open_append_compressed (CONTEXT *ctx)
335 + COMPRESS_INFO *ci = set_compress_info (ctx);
337 + if (!get_append_command (ctx->path, ctx))
339 + if (ci->open && ci->close)
340 + return (mutt_open_read_compressed (ctx));
343 + FREE (&ctx->compressinfo);
349 + ctx->magic = DefaultMagic;
351 + if (!is_new (ctx->realpath))
352 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
353 + if ((fh = fopen (ctx->path, "w")))
355 + /* No error checking - the parent function will catch it */
360 +/* close a compressed mailbox */
361 +void mutt_fast_close_compressed (CONTEXT *ctx)
363 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
366 + if (ctx->compressinfo)
371 + /* if the folder was removed, remove the gzipped folder too */
372 + if ((ctx->magic > 0)
373 + && (access (ctx->path, F_OK) != 0)
374 + && ! option (OPTSAVEEMPTY))
375 + remove (ctx->realpath);
379 + restore_path (ctx);
380 + FREE (&ctx->compressinfo);
384 +/* return 0 on success, -1 on failure */
385 +int mutt_sync_compressed (CONTEXT* ctx)
390 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
393 + mutt_message (_("Compressing %s..."), ctx->realpath);
395 + cmd = get_compression_cmd (ci->close, ctx);
399 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
401 + mutt_perror (ctx->realpath);
405 + mutt_block_signals ();
406 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
409 + mutt_unblock_signals ();
410 + mutt_error _("Unable to lock mailbox!");
416 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
420 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
421 + if (mutt_system (cmd))
423 + mutt_any_key_to_continue (NULL);
424 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
428 + mbox_unlock_compressed (ctx, fp);
429 + mutt_unblock_signals ();
439 +int mutt_slow_close_compressed (CONTEXT *ctx)
442 + const char *append;
444 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
446 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
450 + && ((append = get_append_command (ctx->realpath, ctx))
451 + || (append = ci->close))))
453 + /* if we can not or should not append, we only have to remove the */
454 + /* compressed info, because sync was already called */
455 + mutt_fast_close_compressed (ctx);
465 + if (append == ci->close)
466 + mutt_message (_("Compressing %s..."), ctx->realpath);
468 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
471 + cmd = get_compression_cmd (append, ctx);
475 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
477 + mutt_perror (ctx->realpath);
481 + mutt_block_signals ();
482 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
485 + mutt_unblock_signals ();
486 + mutt_error _("Unable to lock mailbox!");
491 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
496 + if (append == ci->close)
497 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
499 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
501 + if (mutt_system (cmd))
503 + mutt_any_key_to_continue (NULL);
504 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
507 + mbox_unlock_compressed (ctx, fp);
508 + mutt_unblock_signals ();
513 + mbox_unlock_compressed (ctx, fp);
514 + mutt_unblock_signals ();
517 + restore_path (ctx);
519 + FREE (&ctx->compressinfo);
524 +#endif /* USE_COMPRESSED */
525 Index: debian-mutt/compress.h
526 ===================================================================
527 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
528 +++ debian-mutt/compress.h 2007-04-12 18:56:02.000000000 +0200
531 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
533 + * This program is free software; you can redistribute it and/or modify
534 + * it under the terms of the GNU General Public License as published by
535 + * the Free Software Foundation; either version 2 of the License, or
536 + * (at your option) any later version.
538 + * This program is distributed in the hope that it will be useful,
539 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
540 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
541 + * GNU General Public License for more details.
543 + * You should have received a copy of the GNU General Public License
544 + * along with this program; if not, write to the Free Software
545 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
548 +int mutt_can_read_compressed (const char *);
549 +int mutt_can_append_compressed (const char *);
550 +int mutt_open_read_compressed (CONTEXT *);
551 +int mutt_open_append_compressed (CONTEXT *);
552 +int mutt_slow_close_compressed (CONTEXT *);
553 +int mutt_sync_compressed (CONTEXT *);
554 +int mutt_test_compress_command (const char *);
555 +int mutt_check_mailbox_compressed (CONTEXT *);
556 +void mutt_fast_close_compressed (CONTEXT *);
557 Index: debian-mutt/configure.ac
558 ===================================================================
559 --- debian-mutt.orig/configure.ac 2007-04-12 18:15:14.000000000 +0200
560 +++ debian-mutt/configure.ac 2007-04-12 18:56:02.000000000 +0200
561 @@ -803,6 +803,11 @@ AC_ARG_ENABLE(locales-fix, AC_HELP_STRIN
562 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
565 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
566 + [if test x$enableval = xyes; then
567 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
570 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
571 [if test $withval != yes; then
572 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
573 Index: debian-mutt/curs_main.c
574 ===================================================================
575 --- debian-mutt.orig/curs_main.c 2007-04-03 21:43:38.000000000 +0200
576 +++ debian-mutt/curs_main.c 2007-04-12 18:56:02.000000000 +0200
577 @@ -1096,6 +1096,11 @@ int mutt_index_menu (void)
581 +#ifdef USE_COMPRESSED
582 + if (Context->compressinfo && Context->realpath)
583 + mutt_str_replace (&LastFolder, Context->realpath);
586 mutt_str_replace (&LastFolder, Context->path);
587 oldcount = Context ? Context->msgcount : 0;
589 Index: debian-mutt/doc/manual.xml.head
590 ===================================================================
591 --- debian-mutt.orig/doc/manual.xml.head 2007-04-07 14:44:33.000000000 +0200
592 +++ debian-mutt/doc/manual.xml.head 2007-04-12 18:56:02.000000000 +0200
593 @@ -4910,6 +4910,205 @@ becomes an issue as mutt will silently f
597 +<sect1 id="compressedfolders">
598 +<title>Compressed folders Support (OPTIONAL)</title>
601 +If Mutt was compiled with compressed folders support (by running the
602 +<emphasis>configure</emphasis> script with the
603 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
604 +stored in an arbitrary format, provided that the user has a script to
605 +convert from/to this format to one of the accepted.
607 +The most common use is to open compressed archived folders e.g. with
610 +In addition, the user can provide a script that gets a folder in an
611 +accepted format and appends its context to the folder in the
612 +user-defined format, which may be faster than converting the entire
613 +folder to the accepted format, appending to it and converting back to
614 +the user-defined format.
616 +There are three hooks defined (<link
617 +linkend="open-hook">open-hook</link>, <link
618 +linkend="close-hook">close-hook</link> and <link
619 +linkend="append-hook">append-hook</link>) which define commands to
620 +uncompress and compress a folder and to append messages to an existing
621 +compressed folder respectively.
626 +open-hook \\.gz$ "gzip -cd %f > %t"
627 +close-hook \\.gz$ "gzip -c %t > %f"
628 +append-hook \\.gz$ "gzip -c %t >> %f"
631 +You do not have to specify all of the commands. If you omit <link
632 +linkend="append-hook">append-hook</link>, the folder will be open and
633 +closed again each time you will add to it. If you omit <link
634 +linkend="close-hook">close-hook</link> (or give empty command) , the
635 +folder will be open in the mode. If you specify <link
636 +linkend="append-hook">append-hook</link> though you'll be able to
637 +append to the folder.
639 +Note that Mutt will only try to use hooks if the file is not in one of
640 +the accepted formats. In particular, if the file is empty, mutt
641 +supposes it is not compressed. This is important because it allows the
642 +use of programs that do not have well defined extensions. Just use
643 +"." as a regexp. But this may be surprising if your
644 +compressing script produces empty files. In this situation, unset
645 +<link linkend="save-empty">$save_empty</link>, so that
646 +the compressed file will be removed if you delete all of the messages.
649 +<sect2 id="open-hook">
650 +<title>Open a compressed mailbox for reading</title>
653 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
655 +The <emphasis>command</emphasis> is the command that can be used for
656 +opening the folders whose names match <emphasis>regexp</emphasis>.
658 +The <emphasis>command</emphasis> string is the printf-like format
659 +string, and it should accept two parameters: %f, which is
660 +replaced with the (compressed) folder name, and %t which is
661 +replaced with the name of the temporary folder to which to write.
663 +%f and %t can be repeated any number of times in the
664 +command string, and all of the entries are replaced with the
665 +appropriate folder name. In addition, %% is replaced by
666 +%, as in printf, and any other %anything is left as is.
668 +The <emphasis>command</emphasis> should <emphasis
669 +role="bold">not</emphasis> remove the original compressed file. The
670 +<emphasis>command</emphasis> should return non-zero exit status if it
671 +fails, so mutt knows something's wrong.
676 +open-hook \\.gz$ "gzip -cd %f > %t"
679 +If the <emphasis>command</emphasis> is empty, this operation is
680 +disabled for this file type.
684 +<sect2 id="close-hook">
685 +<title>Write a compressed mailbox</title>
688 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
690 +This is used to close the folder that was open with the <link
691 +linkend="open-hook">open-hook</link> command after some changes were
694 +The <emphasis>command</emphasis> string is the command that can be
695 +used for closing the folders whose names match
696 +<emphasis>regexp</emphasis>. It has the same format as in the <link
697 +linkend="open-hook">open-hook</link> command. Temporary folder in this
698 +case is the folder previously produced by the <link
699 +linkend="open-hook">open-hook</link> command.
701 +The <emphasis>command</emphasis> should <emphasis
702 +role="bold">not</emphasis> remove the decompressed file. The
703 +<emphasis>command</emphasis> should return non-zero exit status if it
704 +fails, so mutt knows something's wrong.
709 +close-hook \\.gz$ "gzip -c %t > %f"
712 +If the <emphasis>command</emphasis> is empty, this operation is
713 +disabled for this file type, and the file can only be open in the
716 +<link linkend="close-hook">close-hook</link> is not called when you
717 +exit from the folder if the folder was not changed.
721 +<sect2 id="append-hook">
722 +<title>Append a message to a compressed mailbox</title>
725 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
727 +This command is used for saving to an existing compressed folder. The
728 +<emphasis>command</emphasis> is the command that can be used for
729 +appending to the folders whose names match
730 +<emphasis>regexp</emphasis>. It has the same format as in the <link
731 +linkend="open-hook">open-hook</link> command. The temporary folder in
732 +this case contains the messages that are being appended.
734 +The <emphasis>command</emphasis> should <emphasis
735 +role="bold">not</emphasis> remove the decompressed file. The
736 +<emphasis>command</emphasis> should return non-zero exit status if it
737 +fails, so mutt knows something's wrong.
742 +append-hook \\.gz$ "gzip -c %t >> %f"
745 +When <link linkend="append-hook">append-hook</link> is used, the folder
746 +is not opened, which saves time, but this means that we can not find
747 +out what the folder type is. Thus the default (<link
748 +linkend="mbox-type">$mbox_type</link>) type is always
749 +supposed (i.e. this is the format used for the temporary folder).
751 +If the file does not exist when you save to it, <link
752 +linkend="close-hook">close-hook</link> is called, and not <link
753 +linkend="append-hook">append-hook</link>. <link
754 +linkend="append-hook">append-hook</link> is only for appending to
757 +If the <emphasis>command</emphasis> is empty, this operation is
758 +disabled for this file type. In this case, the folder will be open and
759 +closed again (using <link linkend="open-hook">open-hook</link> and
760 +<link linkend="close-hook">close-hook</link>respectively) each time you
766 +<title>Encrypted folders</title>
769 +The compressed folders support can also be used to handle encrypted
770 +folders. If you want to encrypt a folder with PGP, you may want to use
771 +the following hooks:
774 +open-hook \\.pgp$ "pgp -f < %f > %t"
775 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
778 +Please note, that PGP does not support appending to an encrypted
779 +folder, so there is no append-hook defined.
781 +If you are using GnuPG instead of PGP, you may use the following hooks
785 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
786 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
789 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
790 +decrypted in the /tmp directory, where it can be read by your system
791 +administrator. So think about the security aspects of this.
796 <chapter id="mimesupport">
797 <title>Mutt's MIME Support</title>
799 Index: debian-mutt/doc/muttrc.man.head
800 ===================================================================
801 --- debian-mutt.orig/doc/muttrc.man.head 2007-04-03 21:43:38.000000000 +0200
802 +++ debian-mutt/doc/muttrc.man.head 2007-04-12 18:56:02.000000000 +0200
803 @@ -345,6 +345,24 @@ specify the ID of the public key to be u
804 to a certain recipient. The meaning of "key ID" is to be taken
805 broadly: This can be a different e-mail address, a numerical key ID,
806 or even just an arbitrary search string.
809 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
810 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
811 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
814 +These commands provide a way to handle compressed folders. The given
815 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
816 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
817 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
818 +compressed mail to a compressed folder (\fBappend-hook\fP). The
819 +\fIcommand\fP string is the
821 +like format string, and it should accept two parameters: \fB%f\fP,
822 +which is replaced with the (compressed) folder name, and \fB%t\fP
823 +which is replaced with the name of the temporary folder to which to
826 \fBpush\fP \fIstring\fP
827 This command adds the named \fIstring\fP to the keyboard buffer.
828 Index: debian-mutt/hook.c
829 ===================================================================
830 --- debian-mutt.orig/hook.c 2007-04-12 18:15:14.000000000 +0200
831 +++ debian-mutt/hook.c 2007-04-12 18:56:02.000000000 +0200
834 #include "mutt_crypt.h"
836 +#ifdef USE_COMPRESSED
837 +#include "compress.h"
843 @@ -92,6 +96,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
844 memset (&pattern, 0, sizeof (pattern));
845 pattern.data = safe_strdup (path);
847 +#ifdef USE_COMPRESSED
848 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
850 + if (mutt_test_compress_command (command.data))
852 + strfcpy (err->data, _("bad formatted command string"), err->dsize);
857 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
858 && (!WithCrypto || !(data & M_CRYPTHOOK))
860 Index: debian-mutt/init.h
861 ===================================================================
862 --- debian-mutt.orig/init.h 2007-04-12 18:15:14.000000000 +0200
863 +++ debian-mutt/init.h 2007-04-12 18:56:02.000000000 +0200
864 @@ -3128,6 +3128,11 @@ struct command_t Commands[] = {
865 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
866 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
867 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
868 +#ifdef USE_COMPRESSED
869 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
870 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
871 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
873 { "group", parse_group, 0 },
874 { "ungroup", parse_ungroup, 0 },
875 { "hdr_order", parse_list, UL &HeaderOrderList },
876 Index: debian-mutt/main.c
877 ===================================================================
878 --- debian-mutt.orig/main.c 2007-04-12 18:15:14.000000000 +0200
879 +++ debian-mutt/main.c 2007-04-12 18:56:02.000000000 +0200
880 @@ -401,6 +401,12 @@ static void show_version (void)
885 +#ifdef USE_COMPRESSED
893 Index: debian-mutt/Makefile.am
894 ===================================================================
895 --- debian-mutt.orig/Makefile.am 2007-04-07 14:44:20.000000000 +0200
896 +++ debian-mutt/Makefile.am 2007-04-12 18:56:02.000000000 +0200
897 @@ -18,7 +18,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.
898 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
899 mutt_SOURCES = $(BUILT_SOURCES) \
900 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
901 - crypt.c cryptglue.c \
902 + crypt.c cryptglue.c compress.c \
903 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
904 edit.c enter.c flags.c init.c filter.c from.c \
905 getdomain.c group.c \
906 @@ -66,7 +66,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
909 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
910 - configure account.h \
911 + configure account.h compress.h \
912 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
913 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
914 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
915 Index: debian-mutt/mbox.c
916 ===================================================================
917 --- debian-mutt.orig/mbox.c 2007-04-03 21:43:38.000000000 +0200
918 +++ debian-mutt/mbox.c 2007-04-12 18:56:02.000000000 +0200
921 #include "mutt_curses.h"
923 +#ifdef USE_COMPRESSED
924 +#include "compress.h"
927 #include <sys/stat.h>
930 @@ -1026,6 +1030,12 @@ bail: /* Come here in case of disaster
931 int mbox_close_mailbox (CONTEXT *ctx)
933 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
935 +#ifdef USE_COMPRESSED
936 + if (ctx->compressinfo)
937 + mutt_slow_close_compressed (ctx);
940 mutt_unblock_signals ();
941 mx_fastclose_mailbox (ctx);
943 Index: debian-mutt/mutt.h
944 ===================================================================
945 --- debian-mutt.orig/mutt.h 2007-04-12 18:15:14.000000000 +0200
946 +++ debian-mutt/mutt.h 2007-04-12 18:56:02.000000000 +0200
947 @@ -160,6 +160,11 @@ typedef enum
948 #define M_ACCOUNTHOOK (1<<9)
949 #define M_REPLYHOOK (1<<10)
950 #define M_SEND2HOOK (1<<11)
951 +#ifdef USE_COMPRESSED
952 +#define M_OPENHOOK (1<<12)
953 +#define M_APPENDHOOK (1<<13)
954 +#define M_CLOSEHOOK (1<<14)
957 /* tree characters for linearize_tree and print_enriched_string */
958 #define M_TREE_LLCORNER 1
959 @@ -885,6 +890,11 @@ typedef struct _context
960 int flagged; /* how many flagged messages */
961 int msgnotreadyet; /* which msg "new" in pager, -1 if none */
963 +#ifdef USE_COMPRESSED
964 + void *compressinfo; /* compressed mbox module private data */
965 + char *realpath; /* path to compressed mailbox */
966 +#endif /* USE_COMPRESSED */
968 short magic; /* mailbox type */
970 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
971 Index: debian-mutt/mx.c
972 ===================================================================
973 --- debian-mutt.orig/mx.c 2007-04-03 21:43:38.000000000 +0200
974 +++ debian-mutt/mx.c 2007-04-12 18:56:02.000000000 +0200
979 +#ifdef USE_COMPRESSED
980 +#include "compress.h"
986 @@ -450,6 +454,10 @@ int mx_get_magic (const char *path)
990 +#ifdef USE_COMPRESSED
991 + if (magic == 0 && mutt_can_read_compressed (path))
992 + return M_COMPRESSED;
997 @@ -489,6 +497,13 @@ static int mx_open_mailbox_append (CONTE
1001 +#ifdef USE_COMPRESSED
1002 + /* special case for appending to compressed folders -
1003 + * even if we can not open them for reading */
1004 + if (mutt_can_append_compressed (ctx->path))
1005 + mutt_open_append_compressed (ctx);
1011 @@ -652,7 +667,12 @@ CONTEXT *mx_open_mailbox (const char *pa
1014 ctx->magic = mx_get_magic (path);
1017 +#ifdef USE_COMPRESSED
1018 + if (ctx->magic == M_COMPRESSED)
1019 + mutt_open_read_compressed (ctx);
1023 mutt_error (_("%s is not a mailbox."), path);
1025 @@ -753,6 +773,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
1026 mutt_free_header (&ctx->hdrs[i]);
1029 +#ifdef USE_COMPRESSED
1030 + if (ctx->compressinfo)
1031 + mutt_fast_close_compressed (ctx);
1034 FREE (&ctx->pattern);
1035 if (ctx->limit_pattern)
1036 @@ -805,6 +829,12 @@ static int sync_mailbox (CONTEXT *ctx, i
1038 if (tmp && tmp->new == 0)
1039 mutt_update_mailbox (tmp);
1041 +#ifdef USE_COMPRESSED
1042 + if (rc == 0 && ctx->compressinfo)
1043 + return mutt_sync_compressed (ctx);
1049 @@ -1006,6 +1036,11 @@ int mx_close_mailbox (CONTEXT *ctx, int
1050 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1051 mx_unlink_empty (ctx->path);
1053 +#ifdef USE_COMPRESSED
1054 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1058 mx_fastclose_mailbox (ctx);
1061 @@ -1315,6 +1350,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
1065 +#ifdef USE_COMPRESSED
1066 + if (ctx->compressinfo)
1067 + return mutt_check_mailbox_compressed (ctx);
1072 if (ctx->locked) lock = 0;
1073 Index: debian-mutt/mx.h
1074 ===================================================================
1075 --- debian-mutt.orig/mx.h 2007-04-03 21:43:38.000000000 +0200
1076 +++ debian-mutt/mx.h 2007-04-12 18:56:02.000000000 +0200
1077 @@ -40,6 +40,9 @@ enum
1081 +#ifdef USE_COMPRESSED
1086 WHERE short DefaultMagic INITVAL (M_MBOX);
1087 Index: debian-mutt/PATCHES
1088 ===================================================================
1089 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1090 +++ debian-mutt/PATCHES 2007-04-12 18:56:02.000000000 +0200
1092 +patch-1.5.14.rr.compressed.1
1093 Index: debian-mutt/po/de.po
1094 ===================================================================
1095 --- debian-mutt.orig/po/de.po 2007-04-07 14:44:33.000000000 +0200
1096 +++ debian-mutt/po/de.po 2007-04-12 18:56:02.000000000 +0200
1097 @@ -1280,6 +1280,48 @@ msgstr "Prüfung des Absenders fehlgeschl
1098 msgid "Failed to figure out sender"
1099 msgstr "Kann Absender nicht ermitteln"
1101 +#: compress.c:203 mbox.c:661
1102 +msgid "Mailbox was corrupted!"
1103 +msgstr "Mailbox wurde zerstört!"
1105 +#: compress.c:228 compress.c:253
1107 +msgid "Decompressing %s...\n"
1108 +msgstr "Entpacke %s...\n"
1110 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1111 +msgid "Unable to lock mailbox!"
1112 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1116 +msgid "Error executing: %s : unable to open the mailbox!\n"
1117 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1119 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1121 +msgid "Compressing %s...\n"
1122 +msgstr "Komprimiere %s...\n"
1127 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1130 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1131 +"entpackte gespeichert!\n"
1133 +#: compress.c:425 compress.c:456
1135 +msgid "Compressed-appending to %s...\n"
1136 +msgstr "Hänge komprimiert an %s... an\n"
1140 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1141 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1145 msgid " (current time: %c)"
1146 @@ -3437,18 +3479,10 @@ msgstr "Lese %s..."
1147 msgid "Mailbox is corrupt!"
1148 msgstr "Mailbox fehlerhaft!"
1151 -msgid "Mailbox was corrupted!"
1152 -msgstr "Mailbox wurde zerstört!"
1154 #: mbox.c:711 mbox.c:964
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: debian-mutt/po/POTFILES.in
1166 ===================================================================
1167 --- debian-mutt.orig/po/POTFILES.in 2007-04-03 21:43:38.000000000 +0200
1168 +++ debian-mutt/po/POTFILES.in 2007-04-12 18:56:02.000000000 +0200
1169 @@ -8,6 +8,7 @@ charset.c
1177 Index: debian-mutt/status.c
1178 ===================================================================
1179 --- debian-mutt.orig/status.c 2007-04-03 21:43:38.000000000 +0200
1180 +++ debian-mutt/status.c 2007-04-12 18:56:02.000000000 +0200
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));