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.18.rr.compressed.1.gz
14 - 2008-05-20 myon: refreshed to remove hunks in auto* files
15 - 2009-09-15 myon: refreshed for mutt-1.5.19
16 status.c:103: add sizeof (tmp) to mutt_pretty_mailbox
17 - 2009-09-15 scotton: removed doc/Muttrc for mutt-1.5.19 (only patch doc/Muttrc.head)
20 Index: mutt/compress.c
21 ===================================================================
22 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
23 +++ mutt/compress.c 2009-06-25 12:36:25.000000000 +0200
26 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
28 + * This program is free software; you can redistribute it and/or modify
29 + * it under the terms of the GNU General Public License as published by
30 + * the Free Software Foundation; either version 2 of the License, or
31 + * (at your option) any later version.
33 + * This program is distributed in the hope that it will be useful,
34 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
35 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 + * GNU General Public License for more details.
38 + * You should have received a copy of the GNU General Public License
39 + * along with this program; if not, write to the Free Software
40 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
49 +#ifdef USE_COMPRESSED
53 +#include "mutt_curses.h"
58 +#include <sys/stat.h>
62 + const char *close; /* close-hook command */
63 + const char *open; /* open-hook command */
64 + const char *append; /* append-hook command */
65 + off_t size; /* size of real folder */
70 + * ctx - context to lock
71 + * excl - exclusive lock?
72 + * retry - should retry if unable to lock?
74 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
78 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
80 + else if (retry && !excl)
89 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
95 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
100 +static int is_new (const char *path)
102 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
105 +static const char* find_compress_hook (int type, const char *path)
107 + const char* c = mutt_find_hook (type, path);
108 + return (!c || !*c) ? NULL : c;
111 +int mutt_can_read_compressed (const char *path)
113 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
117 + * if the file is new, we really do not append, but create, and so use
118 + * close-hook, and not append-hook
120 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
122 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
123 + return (is_new (path)) ? ci->close : ci->append;
126 +int mutt_can_append_compressed (const char *path)
132 + char *dir_path = safe_strdup(path);
133 + char *aux = strrchr(dir_path, '/');
138 + if (access(dir_path, W_OK|X_OK))
141 + safe_free((void**)&dir_path);
142 + return dir_valid && (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
145 + magic = mx_get_magic (path);
147 + if (magic != 0 && magic != M_COMPRESSED)
150 + return (find_compress_hook (M_APPENDHOOK, path)
151 + || (find_compress_hook (M_OPENHOOK, path)
152 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
155 +/* open a compressed mailbox */
156 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
160 + /* Now lets uncompress this thing */
161 + ci = safe_malloc (sizeof (COMPRESS_INFO));
162 + ctx->compressinfo = (void*) ci;
163 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
164 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
165 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
169 +static void set_path (CONTEXT* ctx)
171 + char tmppath[_POSIX_PATH_MAX];
173 + /* Setup the right paths */
174 + ctx->realpath = ctx->path;
176 + /* Uncompress to /tmp */
177 + mutt_mktemp (tmppath);
178 + ctx->path = safe_malloc (strlen (tmppath) + 1);
179 + strcpy (ctx->path, tmppath);
182 +static int get_size (const char* path)
185 + if (stat (path, &sb) != 0)
187 + return (sb.st_size);
190 +static void store_size (CONTEXT* ctx)
192 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
193 + ci->size = get_size (ctx->realpath);
197 +compresshook_format_str (char *dest, size_t destlen, size_t col, char op,
198 + const char *src, const char *fmt,
199 + const char *ifstring, const char *elsestring,
200 + unsigned long data, format_flag flags)
202 + char tmp[SHORT_STRING];
204 + CONTEXT *ctx = (CONTEXT *) data;
208 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
209 + snprintf (dest, destlen, tmp, ctx->realpath);
212 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
213 + snprintf (dest, destlen, tmp, ctx->path);
220 + * check that the command has both %f and %t
221 + * 0 means OK, -1 means error
223 +int mutt_test_compress_command (const char* cmd)
225 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
228 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
230 + char expanded[_POSIX_PATH_MAX];
231 + mutt_FormatString (expanded, sizeof (expanded), 0, cmd,
232 + compresshook_format_str, (unsigned long) ctx, 0);
233 + return safe_strdup (expanded);
236 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
238 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
239 + if (ci->size != get_size (ctx->realpath))
241 + FREE (&ctx->compressinfo);
242 + FREE (&ctx->realpath);
243 + mutt_error _("Mailbox was corrupted!");
249 +int mutt_open_read_compressed (CONTEXT *ctx)
255 + COMPRESS_INFO *ci = set_compress_info (ctx);
258 + FREE (&ctx->compressinfo);
261 + if (!ci->close || access (ctx->path, W_OK) != 0)
268 + mutt_message (_("Decompressing %s..."), ctx->realpath);
270 + cmd = get_compression_cmd (ci->open, ctx);
273 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
275 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
277 + mutt_perror (ctx->realpath);
281 + mutt_block_signals ();
282 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
285 + mutt_unblock_signals ();
286 + mutt_error _("Unable to lock mailbox!");
293 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
294 + rc = mutt_system (cmd);
295 + mbox_unlock_compressed (ctx, fp);
296 + mutt_unblock_signals ();
301 + mutt_any_key_to_continue (NULL);
303 + FREE (&ctx->compressinfo);
304 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
310 + if (mutt_check_mailbox_compressed (ctx))
313 + ctx->magic = mx_get_magic (ctx->path);
318 +void restore_path (CONTEXT* ctx)
321 + ctx->path = ctx->realpath;
324 +/* remove the temporary mailbox */
325 +void remove_file (CONTEXT* ctx)
327 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
328 + remove (ctx->path);
331 +int mutt_open_append_compressed (CONTEXT *ctx)
334 + COMPRESS_INFO *ci = set_compress_info (ctx);
336 + if (!get_append_command (ctx->path, ctx))
338 + if (ci->open && ci->close)
339 + return (mutt_open_read_compressed (ctx));
342 + FREE (&ctx->compressinfo);
348 + ctx->magic = DefaultMagic;
350 + if (!is_new (ctx->realpath))
351 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
352 + if ((fh = fopen (ctx->path, "w")))
354 + /* No error checking - the parent function will catch it */
359 +/* close a compressed mailbox */
360 +void mutt_fast_close_compressed (CONTEXT *ctx)
362 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
365 + if (ctx->compressinfo)
370 + /* if the folder was removed, remove the gzipped folder too */
371 + if ((ctx->magic > 0)
372 + && (access (ctx->path, F_OK) != 0)
373 + && ! option (OPTSAVEEMPTY))
374 + remove (ctx->realpath);
378 + restore_path (ctx);
379 + FREE (&ctx->compressinfo);
383 +/* return 0 on success, -1 on failure */
384 +int mutt_sync_compressed (CONTEXT* ctx)
389 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
392 + mutt_message (_("Compressing %s..."), ctx->realpath);
394 + cmd = get_compression_cmd (ci->close, ctx);
398 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
400 + mutt_perror (ctx->realpath);
404 + mutt_block_signals ();
405 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
408 + mutt_unblock_signals ();
409 + mutt_error _("Unable to lock mailbox!");
415 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
419 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
420 + if (mutt_system (cmd))
422 + mutt_any_key_to_continue (NULL);
423 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
427 + mbox_unlock_compressed (ctx, fp);
428 + mutt_unblock_signals ();
438 +int mutt_slow_close_compressed (CONTEXT *ctx)
441 + const char *append;
443 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
445 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
449 + && ((append = get_append_command (ctx->realpath, ctx))
450 + || (append = ci->close))))
452 + /* if we can not or should not append, we only have to remove the */
453 + /* compressed info, because sync was already called */
454 + mutt_fast_close_compressed (ctx);
464 + if (append == ci->close)
465 + mutt_message (_("Compressing %s..."), ctx->realpath);
467 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
470 + cmd = get_compression_cmd (append, ctx);
474 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
476 + mutt_perror (ctx->realpath);
480 + mutt_block_signals ();
481 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
484 + mutt_unblock_signals ();
485 + mutt_error _("Unable to lock mailbox!");
490 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
495 + if (append == ci->close)
496 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
498 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
500 + if (mutt_system (cmd))
502 + mutt_any_key_to_continue (NULL);
503 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
506 + mbox_unlock_compressed (ctx, fp);
507 + mutt_unblock_signals ();
512 + mbox_unlock_compressed (ctx, fp);
513 + mutt_unblock_signals ();
516 + restore_path (ctx);
518 + FREE (&ctx->compressinfo);
523 +#endif /* USE_COMPRESSED */
524 Index: mutt/compress.h
525 ===================================================================
526 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
527 +++ mutt/compress.h 2009-06-25 12:36:26.000000000 +0200
530 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
532 + * This program is free software; you can redistribute it and/or modify
533 + * it under the terms of the GNU General Public License as published by
534 + * the Free Software Foundation; either version 2 of the License, or
535 + * (at your option) any later version.
537 + * This program is distributed in the hope that it will be useful,
538 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
539 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
540 + * GNU General Public License for more details.
542 + * You should have received a copy of the GNU General Public License
543 + * along with this program; if not, write to the Free Software
544 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
547 +int mutt_can_read_compressed (const char *);
548 +int mutt_can_append_compressed (const char *);
549 +int mutt_open_read_compressed (CONTEXT *);
550 +int mutt_open_append_compressed (CONTEXT *);
551 +int mutt_slow_close_compressed (CONTEXT *);
552 +int mutt_sync_compressed (CONTEXT *);
553 +int mutt_test_compress_command (const char *);
554 +int mutt_check_mailbox_compressed (CONTEXT *);
555 +void mutt_fast_close_compressed (CONTEXT *);
556 Index: mutt/configure.ac
557 ===================================================================
558 --- mutt.orig/configure.ac 2009-06-25 12:35:38.000000000 +0200
559 +++ mutt/configure.ac 2009-06-25 12:36:26.000000000 +0200
561 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
564 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
565 + [if test x$enableval = xyes; then
566 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
569 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
570 [if test $withval != yes; then
571 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
572 Index: mutt/curs_main.c
573 ===================================================================
574 --- mutt.orig/curs_main.c 2009-06-25 12:36:14.000000000 +0200
575 +++ mutt/curs_main.c 2009-06-25 12:36:26.000000000 +0200
576 @@ -1135,6 +1135,11 @@
580 +#ifdef USE_COMPRESSED
581 + if (Context->compressinfo && Context->realpath)
582 + mutt_str_replace (&LastFolder, Context->realpath);
585 mutt_str_replace (&LastFolder, Context->path);
586 oldcount = Context ? Context->msgcount : 0;
588 Index: mutt/doc/manual.xml.head
589 ===================================================================
590 --- mutt.orig/doc/manual.xml.head 2009-06-25 12:35:42.000000000 +0200
591 +++ mutt/doc/manual.xml.head 2009-06-25 12:36:26.000000000 +0200
592 @@ -5678,6 +5678,205 @@
596 +<sect1 id="compressedfolders">
597 +<title>Compressed folders Support (OPTIONAL)</title>
600 +If Mutt was compiled with compressed folders support (by running the
601 +<emphasis>configure</emphasis> script with the
602 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
603 +stored in an arbitrary format, provided that the user has a script to
604 +convert from/to this format to one of the accepted.
606 +The most common use is to open compressed archived folders e.g. with
609 +In addition, the user can provide a script that gets a folder in an
610 +accepted format and appends its context to the folder in the
611 +user-defined format, which may be faster than converting the entire
612 +folder to the accepted format, appending to it and converting back to
613 +the user-defined format.
615 +There are three hooks defined (<link
616 +linkend="open-hook">open-hook</link>, <link
617 +linkend="close-hook">close-hook</link> and <link
618 +linkend="append-hook">append-hook</link>) which define commands to
619 +uncompress and compress a folder and to append messages to an existing
620 +compressed folder respectively.
625 +open-hook \\.gz$ "gzip -cd %f > %t"
626 +close-hook \\.gz$ "gzip -c %t > %f"
627 +append-hook \\.gz$ "gzip -c %t >> %f"
630 +You do not have to specify all of the commands. If you omit <link
631 +linkend="append-hook">append-hook</link>, the folder will be open and
632 +closed again each time you will add to it. If you omit <link
633 +linkend="close-hook">close-hook</link> (or give empty command) , the
634 +folder will be open in the mode. If you specify <link
635 +linkend="append-hook">append-hook</link> though you'll be able to
636 +append to the folder.
638 +Note that Mutt will only try to use hooks if the file is not in one of
639 +the accepted formats. In particular, if the file is empty, mutt
640 +supposes it is not compressed. This is important because it allows the
641 +use of programs that do not have well defined extensions. Just use
642 +"." as a regexp. But this may be surprising if your
643 +compressing script produces empty files. In this situation, unset
644 +<link linkend="save-empty">$save_empty</link>, so that
645 +the compressed file will be removed if you delete all of the messages.
648 +<sect2 id="open-hook">
649 +<title>Open a compressed mailbox for reading</title>
652 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
654 +The <emphasis>command</emphasis> is the command that can be used for
655 +opening the folders whose names match <emphasis>regexp</emphasis>.
657 +The <emphasis>command</emphasis> string is the printf-like format
658 +string, and it should accept two parameters: %f, which is
659 +replaced with the (compressed) folder name, and %t which is
660 +replaced with the name of the temporary folder to which to write.
662 +%f and %t can be repeated any number of times in the
663 +command string, and all of the entries are replaced with the
664 +appropriate folder name. In addition, %% is replaced by
665 +%, as in printf, and any other %anything is left as is.
667 +The <emphasis>command</emphasis> should <emphasis
668 +role="bold">not</emphasis> remove the original compressed file. The
669 +<emphasis>command</emphasis> should return non-zero exit status if it
670 +fails, so mutt knows something's wrong.
675 +open-hook \\.gz$ "gzip -cd %f > %t"
678 +If the <emphasis>command</emphasis> is empty, this operation is
679 +disabled for this file type.
683 +<sect2 id="close-hook">
684 +<title>Write a compressed mailbox</title>
687 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
689 +This is used to close the folder that was open with the <link
690 +linkend="open-hook">open-hook</link> command after some changes were
693 +The <emphasis>command</emphasis> string is the command that can be
694 +used for closing the folders whose names match
695 +<emphasis>regexp</emphasis>. It has the same format as in the <link
696 +linkend="open-hook">open-hook</link> command. Temporary folder in this
697 +case is the folder previously produced by the <link
698 +linkend="open-hook">open-hook</link> command.
700 +The <emphasis>command</emphasis> should <emphasis
701 +role="bold">not</emphasis> remove the decompressed file. The
702 +<emphasis>command</emphasis> should return non-zero exit status if it
703 +fails, so mutt knows something's wrong.
708 +close-hook \\.gz$ "gzip -c %t > %f"
711 +If the <emphasis>command</emphasis> is empty, this operation is
712 +disabled for this file type, and the file can only be open in the
715 +<link linkend="close-hook">close-hook</link> is not called when you
716 +exit from the folder if the folder was not changed.
720 +<sect2 id="append-hook">
721 +<title>Append a message to a compressed mailbox</title>
724 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
726 +This command is used for saving to an existing compressed folder. The
727 +<emphasis>command</emphasis> is the command that can be used for
728 +appending to the folders whose names match
729 +<emphasis>regexp</emphasis>. It has the same format as in the <link
730 +linkend="open-hook">open-hook</link> command. The temporary folder in
731 +this case contains the messages that are being appended.
733 +The <emphasis>command</emphasis> should <emphasis
734 +role="bold">not</emphasis> remove the decompressed file. The
735 +<emphasis>command</emphasis> should return non-zero exit status if it
736 +fails, so mutt knows something's wrong.
741 +append-hook \\.gz$ "gzip -c %t >> %f"
744 +When <link linkend="append-hook">append-hook</link> is used, the folder
745 +is not opened, which saves time, but this means that we can not find
746 +out what the folder type is. Thus the default (<link
747 +linkend="mbox-type">$mbox_type</link>) type is always
748 +supposed (i.e. this is the format used for the temporary folder).
750 +If the file does not exist when you save to it, <link
751 +linkend="close-hook">close-hook</link> is called, and not <link
752 +linkend="append-hook">append-hook</link>. <link
753 +linkend="append-hook">append-hook</link> is only for appending to
756 +If the <emphasis>command</emphasis> is empty, this operation is
757 +disabled for this file type. In this case, the folder will be open and
758 +closed again (using <link linkend="open-hook">open-hook</link> and
759 +<link linkend="close-hook">close-hook</link>respectively) each time you
765 +<title>Encrypted folders</title>
768 +The compressed folders support can also be used to handle encrypted
769 +folders. If you want to encrypt a folder with PGP, you may want to use
770 +the following hooks:
773 +open-hook \\.pgp$ "pgp -f < %f > %t"
774 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
777 +Please note, that PGP does not support appending to an encrypted
778 +folder, so there is no append-hook defined.
780 +If you are using GnuPG instead of PGP, you may use the following hooks
784 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
785 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
788 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
789 +decrypted in the /tmp directory, where it can be read by your system
790 +administrator. So think about the security aspects of this.
795 <chapter id="mimesupport">
796 <title>Mutt's MIME Support</title>
798 Index: mutt/doc/Muttrc.head
799 ===================================================================
800 --- mutt.orig/doc/Muttrc.head 2009-06-25 12:35:36.000000000 +0200
801 +++ mutt/doc/Muttrc.head 2009-06-25 12:36:26.000000000 +0200
803 macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
806 +# Use folders which match on \\.gz$ as gzipped folders:
807 +# open-hook \\.gz$ "gzip -cd %f > %t"
808 +# close-hook \\.gz$ "gzip -c %t > %f"
809 +# append-hook \\.gz$ "gzip -c %t >> %f"
811 # If Mutt is unable to determine your site's domain name correctly, you can
812 # set the default here.
814 Index: mutt/doc/muttrc.man.head
815 ===================================================================
816 --- mutt.orig/doc/muttrc.man.head 2009-06-25 12:35:36.000000000 +0200
817 +++ mutt/doc/muttrc.man.head 2009-06-25 12:36:26.000000000 +0200
819 to a certain recipient. The meaning of "key ID" is to be taken
820 broadly: This can be a different e-mail address, a numerical key ID,
821 or even just an arbitrary search string.
824 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
825 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
826 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
829 +These commands provide a way to handle compressed folders. The given
830 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
831 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
832 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
833 +compressed mail to a compressed folder (\fBappend-hook\fP). The
834 +\fIcommand\fP string is the
836 +like format string, and it should accept two parameters: \fB%f\fP,
837 +which is replaced with the (compressed) folder name, and \fB%t\fP
838 +which is replaced with the name of the temporary folder to which to
841 \fBpush\fP \fIstring\fP
842 This command adds the named \fIstring\fP to the keyboard buffer.
844 ===================================================================
845 --- mutt.orig/hook.c 2009-06-25 12:35:36.000000000 +0200
846 +++ mutt/hook.c 2009-06-25 12:36:26.000000000 +0200
849 #include "mutt_crypt.h"
851 +#ifdef USE_COMPRESSED
852 +#include "compress.h"
859 memset (&pattern, 0, sizeof (pattern));
860 pattern.data = safe_strdup (path);
862 +#ifdef USE_COMPRESSED
863 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
865 + if (mutt_test_compress_command (command.data))
867 + strfcpy (err->data, _("badly formatted command string"), err->dsize);
872 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
873 && (!WithCrypto || !(data & M_CRYPTHOOK))
876 ===================================================================
877 --- mutt.orig/init.h 2009-06-25 12:36:22.000000000 +0200
878 +++ mutt/init.h 2009-06-25 12:36:26.000000000 +0200
879 @@ -3504,6 +3504,11 @@
880 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
881 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
882 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
883 +#ifdef USE_COMPRESSED
884 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
885 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
886 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
888 { "group", parse_group, 0 },
889 { "ungroup", parse_ungroup, 0 },
890 { "hdr_order", parse_list, UL &HeaderOrderList },
892 ===================================================================
893 --- mutt.orig/main.c 2009-06-25 12:35:36.000000000 +0200
894 +++ mutt/main.c 2009-06-25 12:36:26.000000000 +0200
900 +#ifdef USE_COMPRESSED
908 Index: mutt/Makefile.am
909 ===================================================================
910 --- mutt.orig/Makefile.am 2009-06-25 12:35:36.000000000 +0200
911 +++ mutt/Makefile.am 2009-06-25 12:36:26.000000000 +0200
913 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
915 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
916 - crypt.c cryptglue.c \
917 + crypt.c cryptglue.c compress.c \
918 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
919 edit.c enter.c flags.c init.c filter.c from.c \
920 getdomain.c group.c \
922 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
924 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
925 - configure account.h \
926 + configure account.h compress.h \
927 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
928 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
929 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
931 ===================================================================
932 --- mutt.orig/mbox.c 2009-06-25 12:35:36.000000000 +0200
933 +++ mutt/mbox.c 2009-06-25 12:36:26.000000000 +0200
936 #include "mutt_curses.h"
938 +#ifdef USE_COMPRESSED
939 +#include "compress.h"
942 #include <sys/stat.h>
945 @@ -1048,6 +1052,12 @@
946 int mbox_close_mailbox (CONTEXT *ctx)
948 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
950 +#ifdef USE_COMPRESSED
951 + if (ctx->compressinfo)
952 + mutt_slow_close_compressed (ctx);
955 mutt_unblock_signals ();
956 mx_fastclose_mailbox (ctx);
959 ===================================================================
960 --- mutt.orig/mutt.h 2009-06-25 12:36:14.000000000 +0200
961 +++ mutt/mutt.h 2009-06-25 12:36:26.000000000 +0200
963 #define M_ACCOUNTHOOK (1<<9)
964 #define M_REPLYHOOK (1<<10)
965 #define M_SEND2HOOK (1<<11)
966 +#ifdef USE_COMPRESSED
967 +#define M_OPENHOOK (1<<12)
968 +#define M_APPENDHOOK (1<<13)
969 +#define M_CLOSEHOOK (1<<14)
972 /* tree characters for linearize_tree and print_enriched_string */
973 #define M_TREE_LLCORNER 1
975 int flagged; /* how many flagged messages */
976 int msgnotreadyet; /* which msg "new" in pager, -1 if none */
978 +#ifdef USE_COMPRESSED
979 + void *compressinfo; /* compressed mbox module private data */
980 + char *realpath; /* path to compressed mailbox */
981 +#endif /* USE_COMPRESSED */
983 short magic; /* mailbox type */
985 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
987 ===================================================================
988 --- mutt.orig/mx.c 2009-06-25 12:36:14.000000000 +0200
989 +++ mutt/mx.c 2009-06-25 12:36:26.000000000 +0200
994 +#ifdef USE_COMPRESSED
995 +#include "compress.h"
1001 @@ -415,6 +419,10 @@
1005 +#ifdef USE_COMPRESSED
1006 + if (magic == 0 && mutt_can_read_compressed (path))
1007 + return M_COMPRESSED;
1012 @@ -454,6 +462,13 @@
1016 +#ifdef USE_COMPRESSED
1017 + /* special case for appending to compressed folders -
1018 + * even if we can not open them for reading */
1019 + if (mutt_can_append_compressed (ctx->path))
1020 + mutt_open_append_compressed (ctx);
1026 @@ -617,7 +632,12 @@
1029 ctx->magic = mx_get_magic (path);
1032 +#ifdef USE_COMPRESSED
1033 + if (ctx->magic == M_COMPRESSED)
1034 + mutt_open_read_compressed (ctx);
1038 mutt_error (_("%s is not a mailbox."), path);
1040 @@ -718,6 +738,10 @@
1041 mutt_free_header (&ctx->hdrs[i]);
1044 +#ifdef USE_COMPRESSED
1045 + if (ctx->compressinfo)
1046 + mutt_fast_close_compressed (ctx);
1049 FREE (&ctx->pattern);
1050 if (ctx->limit_pattern)
1051 @@ -770,6 +794,12 @@
1053 if (tmp && tmp->new == 0)
1054 mutt_update_mailbox (tmp);
1056 +#ifdef USE_COMPRESSED
1057 + if (rc == 0 && ctx->compressinfo)
1058 + return mutt_sync_compressed (ctx);
1064 @@ -1033,6 +1063,11 @@
1065 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1066 mx_unlink_empty (ctx->path);
1068 +#ifdef USE_COMPRESSED
1069 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1073 mx_fastclose_mailbox (ctx);
1076 @@ -1355,6 +1390,11 @@
1080 +#ifdef USE_COMPRESSED
1081 + if (ctx->compressinfo)
1082 + return mutt_check_mailbox_compressed (ctx);
1087 if (ctx->locked) lock = 0;
1089 ===================================================================
1090 --- mutt.orig/mx.h 2009-06-25 12:35:36.000000000 +0200
1091 +++ mutt/mx.h 2009-06-25 12:36:26.000000000 +0200
1096 +#ifdef USE_COMPRESSED
1101 WHERE short DefaultMagic INITVAL (M_MBOX);
1102 Index: mutt/po/de.po
1103 ===================================================================
1104 --- mutt.orig/po/de.po 2009-06-25 12:35:36.000000000 +0200
1105 +++ mutt/po/de.po 2009-06-25 12:36:26.000000000 +0200
1106 @@ -2005,6 +2005,10 @@
1107 msgid "Bad history file format (line %d)"
1108 msgstr "Falsches Format der Datei früherer Eingaben (Zeile %d)"
1111 +msgid "badly formatted command string"
1112 +msgstr "Hook enthält nicht die Muster %f und %t"
1116 msgid "unhook: Can't do unhook * from within a hook."
1117 @@ -2766,7 +2770,7 @@
1118 msgid "Mailbox is corrupt!"
1119 msgstr "Mailbox fehlerhaft!"
1122 +#: mbox.c:678 compress.c:203 mbox.c:661
1123 msgid "Mailbox was corrupted!"
1124 msgstr "Mailbox wurde zerstört!"
1126 @@ -2774,10 +2778,11 @@
1127 msgid "Fatal error! Could not reopen mailbox!"
1128 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1131 +#: mbox.c:746 compress.c:264 compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1132 msgid "Unable to lock mailbox!"
1133 msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1136 #. this means ctx->changed or ctx->deleted was set, but no
1137 #. * messages were found to be changed or deleted. This should
1138 #. * never happen, is we presume it is a bug in mutt.
1139 @@ -5378,3 +5383,32 @@
1141 #~ msgid "Authentication method is unknown."
1142 #~ msgstr "Authentifizierungsmethode unbekannt."
1144 +#: compress.c:228 compress.c:253
1146 +msgid "Decompressing %s...\n"
1147 +msgstr "Entpacke %s...\n"
1149 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1151 +msgid "Compressing %s...\n"
1152 +msgstr "Komprimiere %s...\n"
1157 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1160 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1161 +"entpackte gespeichert!\n"
1163 +#: compress.c:425 compress.c:456
1165 +msgid "Compressed-appending to %s...\n"
1166 +msgstr "Hänge komprimiert an %s... an\n"
1170 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1171 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1172 Index: mutt/po/POTFILES.in
1173 ===================================================================
1174 --- mutt.orig/po/POTFILES.in 2009-06-25 12:35:36.000000000 +0200
1175 +++ mutt/po/POTFILES.in 2009-06-25 12:36:26.000000000 +0200
1184 Index: mutt/status.c
1185 ===================================================================
1186 --- mutt.orig/status.c 2009-06-25 12:35:44.000000000 +0200
1187 +++ mutt/status.c 2009-06-25 12:36:26.000000000 +0200
1191 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1192 +#ifdef USE_COMPRESSED
1193 + if (Context && Context->compressinfo && Context->realpath)
1195 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1196 + mutt_pretty_mailbox (tmp, sizeof (tmp));
1200 if (Context && Context->path)
1202 strfcpy (tmp, Context->path, sizeof (tmp));