1 diff -urN mutt-1.5.12/compress.c mutt-1.5.12-ro/compress.c
2 --- mutt-1.5.12/compress.c 1970-01-01 01:00:00.000000000 +0100
3 +++ mutt-1.5.12-ro/compress.c 2006-07-15 20:13:19.000000000 +0200
6 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
8 + * This program is free software; you can redistribute it and/or modify
9 + * it under the terms of the GNU General Public License as published by
10 + * the Free Software Foundation; either version 2 of the License, or
11 + * (at your option) any later version.
13 + * This program is distributed in the hope that it will be useful,
14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 + * GNU General Public License for more details.
18 + * You should have received a copy of the GNU General Public License
19 + * along with this program; if not, write to the Free Software
20 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 +#ifdef USE_COMPRESSED
33 +#include "mutt_curses.h"
38 +#include <sys/stat.h>
42 + const char *close; /* close-hook command */
43 + const char *open; /* open-hook command */
44 + const char *append; /* append-hook command */
45 + off_t size; /* size of real folder */
50 + * ctx - context to lock
51 + * excl - exclusive lock?
52 + * retry - should retry if unable to lock?
54 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
58 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
60 + else if (retry && !excl)
69 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
75 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
80 +static int is_new (const char *path)
82 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
85 +static const char* find_compress_hook (int type, const char *path)
87 + const char* c = mutt_find_hook (type, path);
88 + return (!c || !*c) ? NULL : c;
91 +int mutt_can_read_compressed (const char *path)
93 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
97 + * if the file is new, we really do not append, but create, and so use
98 + * close-hook, and not append-hook
100 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
102 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
103 + return (is_new (path)) ? ci->close : ci->append;
106 +int mutt_can_append_compressed (const char *path)
111 + return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
113 + magic = mx_get_magic (path);
115 + if (magic != 0 && magic != M_COMPRESSED)
118 + return (find_compress_hook (M_APPENDHOOK, path)
119 + || (find_compress_hook (M_OPENHOOK, path)
120 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
123 +/* open a compressed mailbox */
124 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
128 + /* Now lets uncompress this thing */
129 + ci = safe_malloc (sizeof (COMPRESS_INFO));
130 + ctx->compressinfo = (void*) ci;
131 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
132 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
133 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
137 +static void set_path (CONTEXT* ctx)
139 + char tmppath[_POSIX_PATH_MAX];
141 + /* Setup the right paths */
142 + ctx->realpath = ctx->path;
144 + /* Uncompress to /tmp */
145 + mutt_mktemp (tmppath);
146 + ctx->path = safe_malloc (strlen (tmppath) + 1);
147 + strcpy (ctx->path, tmppath);
150 +static int get_size (const char* path)
153 + if (stat (path, &sb) != 0)
155 + return (sb.st_size);
158 +static void store_size (CONTEXT* ctx)
160 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
161 + ci->size = get_size (ctx->realpath);
165 +compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
166 + const char *fmt, const char *ifstring,
167 + const char *elsestring, unsigned long data,
170 + char tmp[SHORT_STRING];
172 + CONTEXT *ctx = (CONTEXT *) data;
176 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
177 + snprintf (dest, destlen, tmp, ctx->realpath);
180 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
181 + snprintf (dest, destlen, tmp, ctx->path);
188 + * check that the command has both %f and %t
189 + * 0 means OK, -1 means error
191 +int mutt_test_compress_command (const char* cmd)
193 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
196 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
198 + char expanded[_POSIX_PATH_MAX];
199 + mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str,
200 + (unsigned long) ctx, 0);
201 + return safe_strdup (expanded);
204 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
206 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
207 + if (ci->size != get_size (ctx->realpath))
209 + FREE (&ctx->compressinfo);
210 + FREE (&ctx->realpath);
211 + mutt_error _("Mailbox was corrupted!");
217 +int mutt_open_read_compressed (CONTEXT *ctx)
223 + COMPRESS_INFO *ci = set_compress_info (ctx);
226 + FREE (ctx->compressinfo);
229 + if (!ci->close || access (ctx->path, W_OK) != 0)
236 + mutt_message (_("Decompressing %s..."), ctx->realpath);
238 + cmd = get_compression_cmd (ci->open, ctx);
241 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
243 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
245 + mutt_perror (ctx->realpath);
249 + mutt_block_signals ();
250 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
253 + mutt_unblock_signals ();
254 + mutt_error _("Unable to lock mailbox!");
261 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
262 + rc = mutt_system (cmd);
263 + mbox_unlock_compressed (ctx, fp);
264 + mutt_unblock_signals ();
269 + mutt_any_key_to_continue (NULL);
271 + FREE (ctx->compressinfo);
272 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
278 + if (mutt_check_mailbox_compressed (ctx))
281 + ctx->magic = mx_get_magic (ctx->path);
286 +void restore_path (CONTEXT* ctx)
289 + ctx->path = ctx->realpath;
292 +/* remove the temporary mailbox */
293 +void remove_file (CONTEXT* ctx)
295 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
296 + remove (ctx->path);
299 +int mutt_open_append_compressed (CONTEXT *ctx)
302 + COMPRESS_INFO *ci = set_compress_info (ctx);
304 + if (!get_append_command (ctx->path, ctx))
306 + if (ci->open && ci->close)
307 + return (mutt_open_read_compressed (ctx));
310 + FREE (&ctx->compressinfo);
316 + ctx->magic = DefaultMagic;
318 + if (!is_new (ctx->realpath))
319 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
320 + if ((fh = fopen (ctx->path, "w")))
322 + /* No error checking - the parent function will catch it */
327 +/* close a compressed mailbox */
328 +void mutt_fast_close_compressed (CONTEXT *ctx)
330 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
333 + if (ctx->compressinfo)
338 + /* if the folder was removed, remove the gzipped folder too */
339 + if ((ctx->magic > 0)
340 + && (access (ctx->path, F_OK) != 0)
341 + && ! option (OPTSAVEEMPTY))
342 + remove (ctx->realpath);
346 + restore_path (ctx);
347 + FREE (&ctx->compressinfo);
351 +/* return 0 on success, -1 on failure */
352 +int mutt_sync_compressed (CONTEXT* ctx)
357 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
360 + mutt_message (_("Compressing %s..."), ctx->realpath);
362 + cmd = get_compression_cmd (ci->close, ctx);
366 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
368 + mutt_perror (ctx->realpath);
372 + mutt_block_signals ();
373 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
376 + mutt_unblock_signals ();
377 + mutt_error _("Unable to lock mailbox!");
383 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
387 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
388 + if (mutt_system (cmd))
390 + mutt_any_key_to_continue (NULL);
391 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
395 + mbox_unlock_compressed (ctx, fp);
396 + mutt_unblock_signals ();
406 +int mutt_slow_close_compressed (CONTEXT *ctx)
409 + const char *append;
411 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
413 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
417 + && ((append = get_append_command (ctx->realpath, ctx))
418 + || (append = ci->close))))
420 + /* if we can not or should not append, we only have to remove the */
421 + /* compressed info, because sync was already called */
422 + mutt_fast_close_compressed (ctx);
432 + if (append == ci->close)
433 + mutt_message (_("Compressing %s..."), ctx->realpath);
435 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
438 + cmd = get_compression_cmd (append, ctx);
442 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
444 + mutt_perror (ctx->realpath);
448 + mutt_block_signals ();
449 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
452 + mutt_unblock_signals ();
453 + mutt_error _("Unable to lock mailbox!");
458 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
463 + if (append == ci->close)
464 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
466 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
468 + if (mutt_system (cmd))
470 + mutt_any_key_to_continue (NULL);
471 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
474 + mbox_unlock_compressed (ctx, fp);
475 + mutt_unblock_signals ();
480 + mbox_unlock_compressed (ctx, fp);
481 + mutt_unblock_signals ();
484 + restore_path (ctx);
486 + FREE (&ctx->compressinfo);
491 +#endif /* USE_COMPRESSED */
492 diff -urN mutt-1.5.12/compress.h mutt-1.5.12-ro/compress.h
493 --- mutt-1.5.12/compress.h 1970-01-01 01:00:00.000000000 +0100
494 +++ mutt-1.5.12-ro/compress.h 2006-07-15 20:13:19.000000000 +0200
497 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
499 + * This program is free software; you can redistribute it and/or modify
500 + * it under the terms of the GNU General Public License as published by
501 + * the Free Software Foundation; either version 2 of the License, or
502 + * (at your option) any later version.
504 + * This program is distributed in the hope that it will be useful,
505 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
506 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
507 + * GNU General Public License for more details.
509 + * You should have received a copy of the GNU General Public License
510 + * along with this program; if not, write to the Free Software
511 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
514 +int mutt_can_read_compressed (const char *);
515 +int mutt_can_append_compressed (const char *);
516 +int mutt_open_read_compressed (CONTEXT *);
517 +int mutt_open_append_compressed (CONTEXT *);
518 +int mutt_slow_close_compressed (CONTEXT *);
519 +int mutt_sync_compressed (CONTEXT *);
520 +int mutt_test_compress_command (const char *);
521 +int mutt_check_mailbox_compressed (CONTEXT *);
522 +void mutt_fast_close_compressed (CONTEXT *);
523 diff -urN mutt-1.5.12/config.h.in mutt-1.5.12-ro/config.h.in
524 --- mutt-1.5.12/config.h.in 2006-07-14 20:15:56.000000000 +0200
525 +++ mutt-1.5.12-ro/config.h.in 2006-07-15 20:13:19.000000000 +0200
527 /* Define to enable Sun mailtool attachments support. */
528 #undef SUN_ATTACHMENT
530 +/* Define to enable compressed mailboxes support */
531 +#undef USE_COMPRESSED
533 /* Define to use dotlocking for mailboxes. */
536 diff -urN mutt-1.5.12/configure mutt-1.5.12-ro/configure
537 --- mutt-1.5.12/configure 2006-07-14 20:15:42.000000000 +0200
538 +++ mutt-1.5.12-ro/configure 2006-07-15 20:13:19.000000000 +0200
540 --enable-hcache Enable header caching
541 --disable-iconv Disable iconv support
542 --disable-nls Do not use Native Language Support
543 + --enable-compressed Enable compressed folders support
546 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
547 @@ -14882,6 +14883,18 @@
551 +# Check whether --enable-compressed or --disable-compressed was given.
552 +if test "${enable_compressed+set}" = set; then
553 + enableval="$enable_compressed"
554 + if test x$enableval = xyes; then
555 + cat >> confdefs.h <<\EOF
556 +#define USE_COMPRESSED 1
563 # Check whether --with-exec-shell or --without-exec-shell was given.
564 if test "${with_exec_shell+set}" = set; then
565 withval="$with_exec_shell"
566 diff -urN mutt-1.5.12/configure.in mutt-1.5.12-ro/configure.in
567 --- mutt-1.5.12/configure.in 2006-07-14 20:15:32.000000000 +0200
568 +++ mutt-1.5.12-ro/configure.in 2006-07-15 20:13:19.000000000 +0200
570 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
573 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
574 + [if test x$enableval = xyes; then
575 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
578 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
579 [if test $withval != yes; then
580 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
581 diff -urN mutt-1.5.12/curs_main.c mutt-1.5.12-ro/curs_main.c
582 --- mutt-1.5.12/curs_main.c 2006-06-08 13:50:29.000000000 +0200
583 +++ mutt-1.5.12-ro/curs_main.c 2006-07-15 20:13:19.000000000 +0200
584 @@ -1096,6 +1096,11 @@
588 +#ifdef USE_COMPRESSED
589 + if (Context->compressinfo && Context->realpath)
590 + mutt_str_replace (&LastFolder, Context->realpath);
593 mutt_str_replace (&LastFolder, Context->path);
594 oldcount = Context ? Context->msgcount : 0;
596 diff -urN mutt-1.5.12/doc/manual.xml.head mutt-1.5.12-ro/doc/manual.xml.head
597 --- mutt-1.5.12/doc/manual.xml.head 2006-07-14 20:09:13.000000000 +0200
598 +++ mutt-1.5.12-ro/doc/manual.xml.head 2006-07-15 20:20:18.000000000 +0200
599 @@ -4747,6 +4747,205 @@
603 +<sect1 id="compressedfolders">
604 +<title>Compressed folders Support (OPTIONAL)</title>
607 +If Mutt was compiled with compressed folders support (by running the
608 +<emphasis>configure</emphasis> script with the
609 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
610 +stored in an arbitrary format, provided that the user has a script to
611 +convert from/to this format to one of the accepted.
613 +The most common use is to open compressed archived folders e.g. with
616 +In addition, the user can provide a script that gets a folder in an
617 +accepted format and appends its context to the folder in the
618 +user-defined format, which may be faster than converting the entire
619 +folder to the accepted format, appending to it and converting back to
620 +the user-defined format.
622 +There are three hooks defined (<link
623 +linkend="open-hook">open-hook</link>, <link
624 +linkend="close-hook">close-hook</link> and <link
625 +linkend="append-hook">append-hook</link>) which define commands to
626 +uncompress and compress a folder and to append messages to an existing
627 +compressed folder respectively.
632 +open-hook \\.gz$ "gzip -cd %f > %t"
633 +close-hook \\.gz$ "gzip -c %t > %f"
634 +append-hook \\.gz$ "gzip -c %t >> %f"
637 +You do not have to specify all of the commands. If you omit <link
638 +linkend="append-hook">append-hook</link>, the folder will be open and
639 +closed again each time you will add to it. If you omit <link
640 +linkend="close-hook">close-hook</link> (or give empty command) , the
641 +folder will be open in the mode. If you specify <link
642 +linkend="append-hook">append-hook</link> though you'll be able to
643 +append to the folder.
645 +Note that Mutt will only try to use hooks if the file is not in one of
646 +the accepted formats. In particular, if the file is empty, mutt
647 +supposes it is not compressed. This is important because it allows the
648 +use of programs that do not have well defined extensions. Just use
649 +"." as a regexp. But this may be surprising if your
650 +compressing script produces empty files. In this situation, unset
651 +<link linkend="save-empty">$save_empty</link>, so that
652 +the compressed file will be removed if you delete all of the messages.
655 +<sect2 id="open-hook">
656 +<title>Open a compressed mailbox for reading</title>
659 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
661 +The <emphasis>command</emphasis> is the command that can be used for
662 +opening the folders whose names match <emphasis>regexp</emphasis>.
664 +The <emphasis>command</emphasis> string is the printf-like format
665 +string, and it should accept two parameters: %f, which is
666 +replaced with the (compressed) folder name, and %t which is
667 +replaced with the name of the temporary folder to which to write.
669 +%f and %t can be repeated any number of times in the
670 +command string, and all of the entries are replaced with the
671 +appropriate folder name. In addition, %% is replaced by
672 +%, as in printf, and any other %anything is left as is.
674 +The <emphasis>command</emphasis> should <emphasis
675 +role="bold">not</emphasis> remove the original compressed file. The
676 +<emphasis>command</emphasis> should return non-zero exit status if it
677 +fails, so mutt knows something's wrong.
682 +open-hook \\.gz$ "gzip -cd %f > %t"
685 +If the <emphasis>command</emphasis> is empty, this operation is
686 +disabled for this file type.
690 +<sect2 id="close-hook">
691 +<title>Write a compressed mailbox</title>
694 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
696 +This is used to close the folder that was open with the <link
697 +linkend="open-hook">open-hook</link> command after some changes were
700 +The <emphasis>command</emphasis> string is the command that can be
701 +used for closing the folders whose names match
702 +<emphasis>regexp</emphasis>. It has the same format as in the <link
703 +linkend="open-hook">open-hook</link> command. Temporary folder in this
704 +case is the folder previously produced by the <link
705 +linkend="open-hook">open-hook</link> command.
707 +The <emphasis>command</emphasis> should <emphasis
708 +role="bold">not</emphasis> remove the decompressed file. The
709 +<emphasis>command</emphasis> should return non-zero exit status if it
710 +fails, so mutt knows something's wrong.
715 +close-hook \\.gz$ "gzip -c %t > %f"
718 +If the <emphasis>command</emphasis> is empty, this operation is
719 +disabled for this file type, and the file can only be open in the
722 +<link linkend="close-hook">close-hook</link> is not called when you
723 +exit from the folder if the folder was not changed.
727 +<sect2 id="append-hook">
728 +<title>Append a message to a compressed mailbox</title>
731 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
733 +This command is used for saving to an existing compressed folder. The
734 +<emphasis>command</emphasis> is the command that can be used for
735 +appending to the folders whose names match
736 +<emphasis>regexp</emphasis>. It has the same format as in the <link
737 +linkend="open-hook">open-hook</link> command. The temporary folder in
738 +this case contains the messages that are being appended.
740 +The <emphasis>command</emphasis> should <emphasis
741 +role="bold">not</emphasis> remove the decompressed file. The
742 +<emphasis>command</emphasis> should return non-zero exit status if it
743 +fails, so mutt knows something's wrong.
748 +append-hook \\.gz$ "gzip -c %t >> %f"
751 +When <link linkend="append-hook">append-hook</link> is used, the folder
752 +is not opened, which saves time, but this means that we can not find
753 +out what the folder type is. Thus the default (<link
754 +linkend="mbox-type">$mbox_type</link>) type is always
755 +supposed (i.e. this is the format used for the temporary folder).
757 +If the file does not exist when you save to it, <link
758 +linkend="close-hook">close-hook</link> is called, and not <link
759 +linkend="append-hook">append-hook</link>. <link
760 +linkend="append-hook">append-hook</link> is only for appending to
763 +If the <emphasis>command</emphasis> is empty, this operation is
764 +disabled for this file type. In this case, the folder will be open and
765 +closed again (using <link linkend="open-hook">open-hook</link> and
766 +<link linkend="close-hook">close-hook</link>respectively) each time you
772 +<title>Encrypted folders</title>
775 +The compressed folders support can also be used to handle encrypted
776 +folders. If you want to encrypt a folder with PGP, you may want to use
777 +the following hooks:
780 +open-hook \\.pgp$ "pgp -f < %f > %t"
781 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
784 +Please note, that PGP does not support appending to an encrypted
785 +folder, so there is no append-hook defined.
787 +If you are using GnuPG instead of PGP, you may use the following hooks
791 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
792 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
795 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
796 +decrypted in the /tmp directory, where it can be read by your system
797 +administrator. So think about the security aspects of this.
802 <chapter id="mimesupport">
803 <title>Mutt's MIME Support</title>
805 diff -urN mutt-1.5.12/doc/muttrc.man.head mutt-1.5.12-ro/doc/muttrc.man.head
806 --- mutt-1.5.12/doc/muttrc.man.head 2006-07-11 17:01:04.000000000 +0200
807 +++ mutt-1.5.12-ro/doc/muttrc.man.head 2006-07-15 20:13:19.000000000 +0200
809 to a certain recipient. The meaning of "key ID" is to be taken
810 broadly: This can be a different e-mail address, a numerical key ID,
811 or even just an arbitrary search string.
814 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
815 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
816 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
819 +These commands provide a way to handle compressed folders. The given
820 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
821 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
822 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
823 +compressed mail to a compressed folder (\fBappend-hook\fP). The
824 +\fIcommand\fP string is the
826 +like format string, and it should accept two parameters: \fB%f\fP,
827 +which is replaced with the (compressed) folder name, and \fB%t\fP
828 +which is replaced with the name of the temporary folder to which to
831 \fBpush\fP \fIstring\fP
832 This command adds the named \fIstring\fP to the keyboard buffer.
833 diff -urN mutt-1.5.12/hook.c mutt-1.5.12-ro/hook.c
834 --- mutt-1.5.12/hook.c 2006-03-03 11:11:43.000000000 +0100
835 +++ mutt-1.5.12-ro/hook.c 2006-07-15 20:13:19.000000000 +0200
838 #include "mutt_crypt.h"
840 +#ifdef USE_COMPRESSED
841 +#include "compress.h"
848 memset (&pattern, 0, sizeof (pattern));
849 pattern.data = safe_strdup (path);
851 +#ifdef USE_COMPRESSED
852 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
854 + if (mutt_test_compress_command (command.data))
856 + strfcpy (err->data, _("bad formatted command string"), err->dsize);
861 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ACCOUNTHOOK))
862 && (!WithCrypto || !(data & M_CRYPTHOOK))
864 diff -urN mutt-1.5.12/init.h mutt-1.5.12-ro/init.h
865 --- mutt-1.5.12/init.h 2006-07-05 10:40:05.000000000 +0200
866 +++ mutt-1.5.12-ro/init.h 2006-07-15 20:14:00.000000000 +0200
867 @@ -3052,6 +3052,11 @@
868 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
869 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
870 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
871 +#ifdef USE_COMPRESSED
872 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
873 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
874 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
876 { "group", parse_group, 0 },
877 { "ungroup", parse_ungroup, 0 },
878 { "hdr_order", parse_list, UL &HeaderOrderList },
879 diff -urN mutt-1.5.12/main.c mutt-1.5.12-ro/main.c
880 --- mutt-1.5.12/main.c 2006-07-12 01:38:47.000000000 +0200
881 +++ mutt-1.5.12-ro/main.c 2006-07-15 20:13:19.000000000 +0200
887 +#ifdef USE_COMPRESSED
895 diff -urN mutt-1.5.12/Makefile.am mutt-1.5.12-ro/Makefile.am
896 --- mutt-1.5.12/Makefile.am 2006-07-05 10:43:47.000000000 +0200
897 +++ mutt-1.5.12-ro/Makefile.am 2006-07-15 20:14:59.000000000 +0200
899 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
900 mutt_SOURCES = $(BUILT_SOURCES) \
901 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
902 - crypt.c cryptglue.c \
903 + crypt.c cryptglue.c compress.c \
904 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
905 edit.c enter.c flags.c init.c filter.c from.c \
906 getdomain.c group.c \
908 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c
910 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
911 - configure account.h \
912 + configure account.h compress.h \
913 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
914 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
915 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
916 diff -urN mutt-1.5.12/Makefile.in mutt-1.5.12-ro/Makefile.in
917 --- mutt-1.5.12/Makefile.in 2006-07-14 20:21:03.000000000 +0200
918 +++ mutt-1.5.12-ro/Makefile.in 2006-07-15 20:15:35.000000000 +0200
920 attach.$(OBJEXT) base64.$(OBJEXT) browser.$(OBJEXT) \
921 buffy.$(OBJEXT) color.$(OBJEXT) crypt.$(OBJEXT) \
922 cryptglue.$(OBJEXT) commands.$(OBJEXT) complete.$(OBJEXT) \
923 - compose.$(OBJEXT) copy.$(OBJEXT) curs_lib.$(OBJEXT) \
924 + compose.$(OBJEXT) compress.$(OBJEXT) copy.$(OBJEXT) curs_lib.$(OBJEXT) \
925 curs_main.$(OBJEXT) date.$(OBJEXT) edit.$(OBJEXT) \
926 enter.$(OBJEXT) flags.$(OBJEXT) init.$(OBJEXT) \
927 filter.$(OBJEXT) from.$(OBJEXT) getdomain.$(OBJEXT) \
929 BUILT_SOURCES = keymap_defs.h patchlist.c reldate.h
930 mutt_SOURCES = $(BUILT_SOURCES) \
931 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
932 - crypt.c cryptglue.c \
933 + compress.c crypt.c cryptglue.c \
934 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
935 edit.c enter.c flags.c init.c filter.c from.c \
936 getdomain.c group.c \
938 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c
940 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
941 - configure account.h \
942 + configure account.h compress.h \
943 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
944 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
945 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
947 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/commands.Po@am__quote@
948 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/complete.Po@am__quote@
949 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compose.Po@am__quote@
950 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compress.Po@am__quote@
951 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copy.Po@am__quote@
952 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypt-gpgme.Po@am__quote@
953 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypt-mod-pgp-classic.Po@am__quote@
954 diff -urN mutt-1.5.12/mbox.c mutt-1.5.12-ro/mbox.c
955 --- mutt-1.5.12/mbox.c 2005-10-31 11:02:08.000000000 +0100
956 +++ mutt-1.5.12-ro/mbox.c 2006-07-15 20:13:19.000000000 +0200
961 +#ifdef USE_COMPRESSED
962 +#include "compress.h"
965 #include <sys/stat.h>
968 @@ -1014,6 +1018,12 @@
969 int mbox_close_mailbox (CONTEXT *ctx)
971 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
973 +#ifdef USE_COMPRESSED
974 + if (ctx->compressinfo)
975 + mutt_slow_close_compressed (ctx);
978 mutt_unblock_signals ();
979 mx_fastclose_mailbox (ctx);
981 diff -urN mutt-1.5.12/mutt.h mutt-1.5.12-ro/mutt.h
982 --- mutt-1.5.12/mutt.h 2006-06-08 13:49:07.000000000 +0200
983 +++ mutt-1.5.12-ro/mutt.h 2006-07-15 20:13:19.000000000 +0200
985 #define M_ACCOUNTHOOK (1<<9)
986 #define M_REPLYHOOK (1<<10)
987 #define M_SEND2HOOK (1<<11)
988 +#ifdef USE_COMPRESSED
989 +#define M_OPENHOOK (1<<12)
990 +#define M_APPENDHOOK (1<<13)
991 +#define M_CLOSEHOOK (1<<14)
994 /* tree characters for linearize_tree and print_enriched_string */
995 #define M_TREE_LLCORNER 1
997 void *data; /* driver specific data */
998 #endif /* USE_IMAP */
1000 +#ifdef USE_COMPRESSED
1001 + void *compressinfo; /* compressed mbox module private data */
1002 + char *realpath; /* path to compressed mailbox */
1003 +#endif /* USE_COMPRESSED */
1005 short magic; /* mailbox type */
1007 unsigned int locked : 1; /* is the mailbox locked? */
1008 diff -urN mutt-1.5.12/Muttrc mutt-1.5.12-ro/Muttrc
1009 --- mutt-1.5.12/Muttrc 2006-07-14 20:15:57.000000000 +0200
1010 +++ mutt-1.5.12-ro/Muttrc 2006-07-15 20:13:19.000000000 +0200
1012 macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
1015 +# Use folders which match on \\.gz$ as gzipped folders:
1016 +# open-hook \\.gz$ "gzip -cd %f > %t"
1017 +# close-hook \\.gz$ "gzip -c %t > %f"
1018 +# append-hook \\.gz$ "gzip -c %t >> %f"
1020 # If Mutt is unable to determine your site's domain name correctly, you can
1021 # set the default here.
1023 diff -urN mutt-1.5.12/Muttrc.head mutt-1.5.12-ro/Muttrc.head
1024 --- mutt-1.5.12/Muttrc.head 2006-07-14 20:15:55.000000000 +0200
1025 +++ mutt-1.5.12-ro/Muttrc.head 2006-07-15 20:13:19.000000000 +0200
1027 macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
1030 +# Use folders which match on \\.gz$ as gzipped folders:
1031 +# open-hook \\.gz$ "gzip -cd %f > %t"
1032 +# close-hook \\.gz$ "gzip -c %t > %f"
1033 +# append-hook \\.gz$ "gzip -c %t >> %f"
1035 # If Mutt is unable to determine your site's domain name correctly, you can
1036 # set the default here.
1038 diff -urN mutt-1.5.12/Muttrc.head.in mutt-1.5.12-ro/Muttrc.head.in
1039 --- mutt-1.5.12/Muttrc.head.in 2005-10-04 17:05:34.000000000 +0200
1040 +++ mutt-1.5.12-ro/Muttrc.head.in 2006-07-15 20:13:19.000000000 +0200
1042 macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
1045 +# Use folders which match on \\.gz$ as gzipped folders:
1046 +# open-hook \\.gz$ "gzip -cd %f > %t"
1047 +# close-hook \\.gz$ "gzip -c %t > %f"
1048 +# append-hook \\.gz$ "gzip -c %t >> %f"
1050 # If Mutt is unable to determine your site's domain name correctly, you can
1051 # set the default here.
1053 diff -urN mutt-1.5.12/mx.c mutt-1.5.12-ro/mx.c
1054 --- mutt-1.5.12/mx.c 2006-05-18 20:44:29.000000000 +0200
1055 +++ mutt-1.5.12-ro/mx.c 2006-07-15 20:13:19.000000000 +0200
1060 +#ifdef USE_COMPRESSED
1061 +#include "compress.h"
1067 @@ -454,6 +458,10 @@
1071 +#ifdef USE_COMPRESSED
1072 + if (magic == 0 && mutt_can_read_compressed (path))
1073 + return M_COMPRESSED;
1078 @@ -493,6 +501,13 @@
1082 +#ifdef USE_COMPRESSED
1083 + /* special case for appending to compressed folders -
1084 + * even if we can not open them for reading */
1085 + if (mutt_can_append_compressed (ctx->path))
1086 + mutt_open_append_compressed (ctx);
1092 @@ -653,7 +668,12 @@
1095 ctx->magic = mx_get_magic (path);
1098 +#ifdef USE_COMPRESSED
1099 + if (ctx->magic == M_COMPRESSED)
1100 + mutt_open_read_compressed (ctx);
1104 mutt_error (_("%s is not a mailbox."), path);
1106 @@ -759,6 +779,10 @@
1107 mutt_free_header (&ctx->hdrs[i]);
1110 +#ifdef USE_COMPRESSED
1111 + if (ctx->compressinfo)
1112 + mutt_fast_close_compressed (ctx);
1115 FREE (&ctx->pattern);
1116 if (ctx->limit_pattern)
1117 @@ -816,6 +840,12 @@
1118 if (tmp && tmp->new == 0)
1119 mutt_update_mailbox (tmp);
1122 +#ifdef USE_COMPRESSED
1123 + if (rc == 0 && ctx->compressinfo)
1124 + return mutt_sync_compressed (ctx);
1130 @@ -1017,6 +1047,11 @@
1131 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1132 mx_unlink_empty (ctx->path);
1134 +#ifdef USE_COMPRESSED
1135 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1139 mx_fastclose_mailbox (ctx);
1142 @@ -1326,6 +1361,11 @@
1146 +#ifdef USE_COMPRESSED
1147 + if (ctx->compressinfo)
1148 + return mutt_check_mailbox_compressed (ctx);
1153 if (ctx->locked) lock = 0;
1154 diff -urN mutt-1.5.12/mx.h mutt-1.5.12-ro/mx.h
1155 --- mutt-1.5.12/mx.h 2005-09-18 10:22:22.000000000 +0200
1156 +++ mutt-1.5.12-ro/mx.h 2006-07-15 20:13:19.000000000 +0200
1161 +#ifdef USE_COMPRESSED
1166 WHERE short DefaultMagic INITVAL (M_MBOX);
1167 diff -urN mutt-1.5.12/PATCHES mutt-1.5.12-ro/PATCHES
1168 --- mutt-1.5.12/PATCHES 2006-07-14 20:12:47.000000000 +0200
1169 +++ mutt-1.5.12-ro/PATCHES 2006-07-15 20:21:02.000000000 +0200
1171 +patch-1.5.12.rr.compressed.1
1172 diff -urN mutt-1.5.12/po/de.po mutt-1.5.12-ro/po/de.po
1173 --- mutt-1.5.12/po/de.po 2006-07-14 20:16:36.000000000 +0200
1174 +++ mutt-1.5.12-ro/po/de.po 2006-07-15 20:13:19.000000000 +0200
1175 @@ -1262,6 +1262,48 @@
1176 msgid "Failed to figure out sender"
1177 msgstr "Kann Absender nicht ermitteln"
1179 +#: compress.c:203 mbox.c:661
1180 +msgid "Mailbox was corrupted!"
1181 +msgstr "Mailbox wurde zerstört!"
1183 +#: compress.c:228 compress.c:253
1185 +msgid "Decompressing %s...\n"
1186 +msgstr "Entpacke %s...\n"
1188 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1189 +msgid "Unable to lock mailbox!"
1190 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1194 +msgid "Error executing: %s : unable to open the mailbox!\n"
1195 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1197 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1199 +msgid "Compressing %s...\n"
1200 +msgstr "Komprimiere %s...\n"
1205 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1208 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1209 +"entpackte gespeichert!\n"
1211 +#: compress.c:425 compress.c:456
1213 +msgid "Compressed-appending to %s...\n"
1214 +msgstr "Hänge komprimiert an %s... an\n"
1218 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1219 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1223 msgid " (current time: %c)"
1224 @@ -1910,6 +1952,10 @@
1226 msgstr "Hilfe für %s"
1229 +msgid "bad formatted command string"
1230 +msgstr "Hook enthält nicht die Muster %f und %t"
1234 msgid "unhook: Can't do unhook * from within a hook."
1235 @@ -3424,18 +3470,10 @@
1236 msgid "Mailbox is corrupt!"
1237 msgstr "Mailbox fehlerhaft!"
1240 -msgid "Mailbox was corrupted!"
1241 -msgstr "Mailbox wurde zerstört!"
1243 #: mbox.c:701 mbox.c:952
1244 msgid "Fatal error! Could not reopen mailbox!"
1245 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1248 -msgid "Unable to lock mailbox!"
1249 -msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1251 #. this means ctx->changed or ctx->deleted was set, but no
1252 #. * messages were found to be changed or deleted. This should
1253 #. * never happen, is we presume it is a bug in mutt.
1254 diff -urN mutt-1.5.12/po/POTFILES.in mutt-1.5.12-ro/po/POTFILES.in
1255 --- mutt-1.5.12/po/POTFILES.in 2005-08-03 11:17:47.000000000 +0200
1256 +++ mutt-1.5.12-ro/po/POTFILES.in 2006-07-15 20:13:19.000000000 +0200
1265 diff -urN mutt-1.5.12/status.c mutt-1.5.12-ro/status.c
1266 --- mutt-1.5.12/status.c 2005-09-18 10:22:22.000000000 +0200
1267 +++ mutt-1.5.12-ro/status.c 2006-07-15 20:13:19.000000000 +0200
1271 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1272 +#ifdef USE_COMPRESSED
1273 + if (Context && Context->compressinfo && Context->realpath)
1275 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1276 + mutt_pretty_mailbox (tmp);
1280 if (Context && Context->path)
1282 strfcpy (tmp, Context->path, sizeof (tmp));