1 diff -urN mutt-1.5.15/compress.c mutt-1.5.15-ro/compress.c
2 --- mutt-1.5.15/compress.c 1970-01-01 01:00:00.000000000 +0100
3 +++ mutt-1.5.15-ro/compress.c 2007-05-27 14:20:23.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)
112 + char *dir_path = safe_strdup(path);
113 + char *aux = strrchr(dir_path, '/');
118 + if (access(dir_path, W_OK|X_OK))
121 + safe_free((void**)&dir_path);
122 + return dir_valid && (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
125 + magic = mx_get_magic (path);
127 + if (magic != 0 && magic != M_COMPRESSED)
130 + return (find_compress_hook (M_APPENDHOOK, path)
131 + || (find_compress_hook (M_OPENHOOK, path)
132 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
135 +/* open a compressed mailbox */
136 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
140 + /* Now lets uncompress this thing */
141 + ci = safe_malloc (sizeof (COMPRESS_INFO));
142 + ctx->compressinfo = (void*) ci;
143 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
144 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
145 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
149 +static void set_path (CONTEXT* ctx)
151 + char tmppath[_POSIX_PATH_MAX];
153 + /* Setup the right paths */
154 + ctx->realpath = ctx->path;
156 + /* Uncompress to /tmp */
157 + mutt_mktemp (tmppath);
158 + ctx->path = safe_malloc (strlen (tmppath) + 1);
159 + strcpy (ctx->path, tmppath);
162 +static int get_size (const char* path)
165 + if (stat (path, &sb) != 0)
167 + return (sb.st_size);
170 +static void store_size (CONTEXT* ctx)
172 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
173 + ci->size = get_size (ctx->realpath);
177 +compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
178 + const char *fmt, const char *ifstring,
179 + const char *elsestring, unsigned long data,
182 + char tmp[SHORT_STRING];
184 + CONTEXT *ctx = (CONTEXT *) data;
188 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
189 + snprintf (dest, destlen, tmp, ctx->realpath);
192 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
193 + snprintf (dest, destlen, tmp, ctx->path);
200 + * check that the command has both %f and %t
201 + * 0 means OK, -1 means error
203 +int mutt_test_compress_command (const char* cmd)
205 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
208 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
210 + char expanded[_POSIX_PATH_MAX];
211 + mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str,
212 + (unsigned long) ctx, 0);
213 + return safe_strdup (expanded);
216 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
218 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
219 + if (ci->size != get_size (ctx->realpath))
221 + FREE (&ctx->compressinfo);
222 + FREE (&ctx->realpath);
223 + mutt_error _("Mailbox was corrupted!");
229 +int mutt_open_read_compressed (CONTEXT *ctx)
235 + COMPRESS_INFO *ci = set_compress_info (ctx);
238 + FREE (&ctx->compressinfo);
241 + if (!ci->close || access (ctx->path, W_OK) != 0)
248 + mutt_message (_("Decompressing %s..."), ctx->realpath);
250 + cmd = get_compression_cmd (ci->open, ctx);
253 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
255 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
257 + mutt_perror (ctx->realpath);
261 + mutt_block_signals ();
262 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
265 + mutt_unblock_signals ();
266 + mutt_error _("Unable to lock mailbox!");
273 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
274 + rc = mutt_system (cmd);
275 + mbox_unlock_compressed (ctx, fp);
276 + mutt_unblock_signals ();
281 + mutt_any_key_to_continue (NULL);
283 + FREE (&ctx->compressinfo);
284 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
290 + if (mutt_check_mailbox_compressed (ctx))
293 + ctx->magic = mx_get_magic (ctx->path);
298 +void restore_path (CONTEXT* ctx)
301 + ctx->path = ctx->realpath;
304 +/* remove the temporary mailbox */
305 +void remove_file (CONTEXT* ctx)
307 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
308 + remove (ctx->path);
311 +int mutt_open_append_compressed (CONTEXT *ctx)
314 + COMPRESS_INFO *ci = set_compress_info (ctx);
316 + if (!get_append_command (ctx->path, ctx))
318 + if (ci->open && ci->close)
319 + return (mutt_open_read_compressed (ctx));
322 + FREE (&ctx->compressinfo);
328 + ctx->magic = DefaultMagic;
330 + if (!is_new (ctx->realpath))
331 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
332 + if ((fh = fopen (ctx->path, "w")))
334 + /* No error checking - the parent function will catch it */
339 +/* close a compressed mailbox */
340 +void mutt_fast_close_compressed (CONTEXT *ctx)
342 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
345 + if (ctx->compressinfo)
350 + /* if the folder was removed, remove the gzipped folder too */
351 + if ((ctx->magic > 0)
352 + && (access (ctx->path, F_OK) != 0)
353 + && ! option (OPTSAVEEMPTY))
354 + remove (ctx->realpath);
358 + restore_path (ctx);
359 + FREE (&ctx->compressinfo);
363 +/* return 0 on success, -1 on failure */
364 +int mutt_sync_compressed (CONTEXT* ctx)
369 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
372 + mutt_message (_("Compressing %s..."), ctx->realpath);
374 + cmd = get_compression_cmd (ci->close, ctx);
378 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
380 + mutt_perror (ctx->realpath);
384 + mutt_block_signals ();
385 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
388 + mutt_unblock_signals ();
389 + mutt_error _("Unable to lock mailbox!");
395 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
399 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
400 + if (mutt_system (cmd))
402 + mutt_any_key_to_continue (NULL);
403 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
407 + mbox_unlock_compressed (ctx, fp);
408 + mutt_unblock_signals ();
418 +int mutt_slow_close_compressed (CONTEXT *ctx)
421 + const char *append;
423 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
425 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
429 + && ((append = get_append_command (ctx->realpath, ctx))
430 + || (append = ci->close))))
432 + /* if we can not or should not append, we only have to remove the */
433 + /* compressed info, because sync was already called */
434 + mutt_fast_close_compressed (ctx);
444 + if (append == ci->close)
445 + mutt_message (_("Compressing %s..."), ctx->realpath);
447 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
450 + cmd = get_compression_cmd (append, ctx);
454 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
456 + mutt_perror (ctx->realpath);
460 + mutt_block_signals ();
461 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
464 + mutt_unblock_signals ();
465 + mutt_error _("Unable to lock mailbox!");
470 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
475 + if (append == ci->close)
476 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
478 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
480 + if (mutt_system (cmd))
482 + mutt_any_key_to_continue (NULL);
483 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
486 + mbox_unlock_compressed (ctx, fp);
487 + mutt_unblock_signals ();
492 + mbox_unlock_compressed (ctx, fp);
493 + mutt_unblock_signals ();
496 + restore_path (ctx);
498 + FREE (&ctx->compressinfo);
503 +#endif /* USE_COMPRESSED */
504 diff -urN mutt-1.5.15/compress.h mutt-1.5.15-ro/compress.h
505 --- mutt-1.5.15/compress.h 1970-01-01 01:00:00.000000000 +0100
506 +++ mutt-1.5.15-ro/compress.h 2007-05-27 14:20:23.000000000 +0200
509 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
511 + * This program is free software; you can redistribute it and/or modify
512 + * it under the terms of the GNU General Public License as published by
513 + * the Free Software Foundation; either version 2 of the License, or
514 + * (at your option) any later version.
516 + * This program is distributed in the hope that it will be useful,
517 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
518 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
519 + * GNU General Public License for more details.
521 + * You should have received a copy of the GNU General Public License
522 + * along with this program; if not, write to the Free Software
523 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
526 +int mutt_can_read_compressed (const char *);
527 +int mutt_can_append_compressed (const char *);
528 +int mutt_open_read_compressed (CONTEXT *);
529 +int mutt_open_append_compressed (CONTEXT *);
530 +int mutt_slow_close_compressed (CONTEXT *);
531 +int mutt_sync_compressed (CONTEXT *);
532 +int mutt_test_compress_command (const char *);
533 +int mutt_check_mailbox_compressed (CONTEXT *);
534 +void mutt_fast_close_compressed (CONTEXT *);
535 diff -urN mutt-1.5.15/config.h.in mutt-1.5.15-ro/config.h.in
536 --- mutt-1.5.15/config.h.in 2007-04-06 09:18:47.000000000 +0200
537 +++ mutt-1.5.15-ro/config.h.in 2007-05-27 14:20:23.000000000 +0200
539 /* Define to enable Sun mailtool attachments support. */
540 #undef SUN_ATTACHMENT
542 +/* Define to enable compressed mailboxes support */
543 +#undef USE_COMPRESSED
545 /* Define to use dotlocking for mailboxes. */
548 diff -urN mutt-1.5.15/configure mutt-1.5.15-ro/configure
549 --- mutt-1.5.15/configure 2007-04-06 09:17:16.000000000 +0200
550 +++ mutt-1.5.15-ro/configure 2007-05-27 14:20:23.000000000 +0200
551 @@ -1354,6 +1354,7 @@
552 --enable-hcache Enable header caching
553 --disable-iconv Disable iconv support
554 --disable-nls Do not use Native Language Support
555 + --enable-compressed Enable compressed folders support
558 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
559 @@ -17502,6 +17503,17 @@
563 +# Check whether --enable-compressed or --disable-compressed was given.
564 +if test "${enable_compressed+set}" = set; then
565 + enableval="$enable_compressed"; if test x$enableval = xyes; then
567 +cat >>confdefs.h <<\_ACEOF
568 +#define USE_COMPRESSED 1
575 # Check whether --with-exec-shell was given.
576 if test "${with_exec_shell+set}" = set; then
577 diff -urN mutt-1.5.15/configure.ac mutt-1.5.15-ro/configure.ac
578 --- mutt-1.5.15/configure.ac 2007-04-06 09:11:53.000000000 +0200
579 +++ mutt-1.5.15-ro/configure.ac 2007-05-27 14:33:52.000000000 +0200
581 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
584 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
585 + [if test x$enableval = xyes; then
586 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
589 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
590 [if test $withval != yes; then
591 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
592 diff -urN mutt-1.5.15/curs_main.c mutt-1.5.15-ro/curs_main.c
593 --- mutt-1.5.15/curs_main.c 2007-04-03 19:41:14.000000000 +0200
594 +++ mutt-1.5.15-ro/curs_main.c 2007-05-27 14:20:26.000000000 +0200
595 @@ -1096,6 +1096,11 @@
599 +#ifdef USE_COMPRESSED
600 + if (Context->compressinfo && Context->realpath)
601 + mutt_str_replace (&LastFolder, Context->realpath);
604 mutt_str_replace (&LastFolder, Context->path);
605 oldcount = Context ? Context->msgcount : 0;
607 diff -urN mutt-1.5.15/doc/manual.xml.head mutt-1.5.15-ro/doc/manual.xml.head
608 --- mutt-1.5.15/doc/manual.xml.head 2007-04-04 07:37:13.000000000 +0200
609 +++ mutt-1.5.15-ro/doc/manual.xml.head 2007-05-27 14:20:26.000000000 +0200
610 @@ -4910,6 +4910,205 @@
614 +<sect1 id="compressedfolders">
615 +<title>Compressed folders Support (OPTIONAL)</title>
618 +If Mutt was compiled with compressed folders support (by running the
619 +<emphasis>configure</emphasis> script with the
620 +<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
621 +stored in an arbitrary format, provided that the user has a script to
622 +convert from/to this format to one of the accepted.
624 +The most common use is to open compressed archived folders e.g. with
627 +In addition, the user can provide a script that gets a folder in an
628 +accepted format and appends its context to the folder in the
629 +user-defined format, which may be faster than converting the entire
630 +folder to the accepted format, appending to it and converting back to
631 +the user-defined format.
633 +There are three hooks defined (<link
634 +linkend="open-hook">open-hook</link>, <link
635 +linkend="close-hook">close-hook</link> and <link
636 +linkend="append-hook">append-hook</link>) which define commands to
637 +uncompress and compress a folder and to append messages to an existing
638 +compressed folder respectively.
643 +open-hook \\.gz$ "gzip -cd %f > %t"
644 +close-hook \\.gz$ "gzip -c %t > %f"
645 +append-hook \\.gz$ "gzip -c %t >> %f"
648 +You do not have to specify all of the commands. If you omit <link
649 +linkend="append-hook">append-hook</link>, the folder will be open and
650 +closed again each time you will add to it. If you omit <link
651 +linkend="close-hook">close-hook</link> (or give empty command) , the
652 +folder will be open in the mode. If you specify <link
653 +linkend="append-hook">append-hook</link> though you'll be able to
654 +append to the folder.
656 +Note that Mutt will only try to use hooks if the file is not in one of
657 +the accepted formats. In particular, if the file is empty, mutt
658 +supposes it is not compressed. This is important because it allows the
659 +use of programs that do not have well defined extensions. Just use
660 +"." as a regexp. But this may be surprising if your
661 +compressing script produces empty files. In this situation, unset
662 +<link linkend="save-empty">$save_empty</link>, so that
663 +the compressed file will be removed if you delete all of the messages.
666 +<sect2 id="open-hook">
667 +<title>Open a compressed mailbox for reading</title>
670 +Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
672 +The <emphasis>command</emphasis> is the command that can be used for
673 +opening the folders whose names match <emphasis>regexp</emphasis>.
675 +The <emphasis>command</emphasis> string is the printf-like format
676 +string, and it should accept two parameters: %f, which is
677 +replaced with the (compressed) folder name, and %t which is
678 +replaced with the name of the temporary folder to which to write.
680 +%f and %t can be repeated any number of times in the
681 +command string, and all of the entries are replaced with the
682 +appropriate folder name. In addition, %% is replaced by
683 +%, as in printf, and any other %anything is left as is.
685 +The <emphasis>command</emphasis> should <emphasis
686 +role="bold">not</emphasis> remove the original compressed file. The
687 +<emphasis>command</emphasis> should return non-zero exit status if it
688 +fails, so mutt knows something's wrong.
693 +open-hook \\.gz$ "gzip -cd %f > %t"
696 +If the <emphasis>command</emphasis> is empty, this operation is
697 +disabled for this file type.
701 +<sect2 id="close-hook">
702 +<title>Write a compressed mailbox</title>
705 +Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
707 +This is used to close the folder that was open with the <link
708 +linkend="open-hook">open-hook</link> command after some changes were
711 +The <emphasis>command</emphasis> string is the command that can be
712 +used for closing the folders whose names match
713 +<emphasis>regexp</emphasis>. It has the same format as in the <link
714 +linkend="open-hook">open-hook</link> command. Temporary folder in this
715 +case is the folder previously produced by the <link
716 +linkend="open-hook">open-hook</link> command.
718 +The <emphasis>command</emphasis> should <emphasis
719 +role="bold">not</emphasis> remove the decompressed file. The
720 +<emphasis>command</emphasis> should return non-zero exit status if it
721 +fails, so mutt knows something's wrong.
726 +close-hook \\.gz$ "gzip -c %t > %f"
729 +If the <emphasis>command</emphasis> is empty, this operation is
730 +disabled for this file type, and the file can only be open in the
733 +<link linkend="close-hook">close-hook</link> is not called when you
734 +exit from the folder if the folder was not changed.
738 +<sect2 id="append-hook">
739 +<title>Append a message to a compressed mailbox</title>
742 +Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> "<emphasis>command</emphasis>"
744 +This command is used for saving to an existing compressed folder. The
745 +<emphasis>command</emphasis> is the command that can be used for
746 +appending to the folders whose names match
747 +<emphasis>regexp</emphasis>. It has the same format as in the <link
748 +linkend="open-hook">open-hook</link> command. The temporary folder in
749 +this case contains the messages that are being appended.
751 +The <emphasis>command</emphasis> should <emphasis
752 +role="bold">not</emphasis> remove the decompressed file. The
753 +<emphasis>command</emphasis> should return non-zero exit status if it
754 +fails, so mutt knows something's wrong.
759 +append-hook \\.gz$ "gzip -c %t >> %f"
762 +When <link linkend="append-hook">append-hook</link> is used, the folder
763 +is not opened, which saves time, but this means that we can not find
764 +out what the folder type is. Thus the default (<link
765 +linkend="mbox-type">$mbox_type</link>) type is always
766 +supposed (i.e. this is the format used for the temporary folder).
768 +If the file does not exist when you save to it, <link
769 +linkend="close-hook">close-hook</link> is called, and not <link
770 +linkend="append-hook">append-hook</link>. <link
771 +linkend="append-hook">append-hook</link> is only for appending to
774 +If the <emphasis>command</emphasis> is empty, this operation is
775 +disabled for this file type. In this case, the folder will be open and
776 +closed again (using <link linkend="open-hook">open-hook</link> and
777 +<link linkend="close-hook">close-hook</link>respectively) each time you
783 +<title>Encrypted folders</title>
786 +The compressed folders support can also be used to handle encrypted
787 +folders. If you want to encrypt a folder with PGP, you may want to use
788 +the following hooks:
791 +open-hook \\.pgp$ "pgp -f < %f > %t"
792 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
795 +Please note, that PGP does not support appending to an encrypted
796 +folder, so there is no append-hook defined.
798 +If you are using GnuPG instead of PGP, you may use the following hooks
802 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
803 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
806 +<emphasis role="bold">Note:</emphasis> the folder is temporary stored
807 +decrypted in the /tmp directory, where it can be read by your system
808 +administrator. So think about the security aspects of this.
813 <chapter id="mimesupport">
814 <title>Mutt's MIME Support</title>
816 diff -urN mutt-1.5.15/doc/muttrc.man.head mutt-1.5.15-ro/doc/muttrc.man.head
817 --- mutt-1.5.15/doc/muttrc.man.head 2007-04-01 23:58:55.000000000 +0200
818 +++ mutt-1.5.15-ro/doc/muttrc.man.head 2007-05-27 14:20:26.000000000 +0200
820 to a certain recipient. The meaning of "key ID" is to be taken
821 broadly: This can be a different e-mail address, a numerical key ID,
822 or even just an arbitrary search string.
825 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
826 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
827 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
830 +These commands provide a way to handle compressed folders. The given
831 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
832 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
833 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
834 +compressed mail to a compressed folder (\fBappend-hook\fP). The
835 +\fIcommand\fP string is the
837 +like format string, and it should accept two parameters: \fB%f\fP,
838 +which is replaced with the (compressed) folder name, and \fB%t\fP
839 +which is replaced with the name of the temporary folder to which to
842 \fBpush\fP \fIstring\fP
843 This command adds the named \fIstring\fP to the keyboard buffer.
844 diff -urN mutt-1.5.15/hook.c mutt-1.5.15-ro/hook.c
845 --- mutt-1.5.15/hook.c 2007-04-01 23:58:56.000000000 +0200
846 +++ mutt-1.5.15-ro/hook.c 2007-05-27 14:23:46.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, _("bad formatted command string"), err->dsize);
872 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
873 && (!WithCrypto || !(data & M_CRYPTHOOK))
875 diff -urN mutt-1.5.15/init.h mutt-1.5.15-ro/init.h
876 --- mutt-1.5.15/init.h 2007-04-05 18:03:55.000000000 +0200
877 +++ mutt-1.5.15-ro/init.h 2007-05-27 14:20:26.000000000 +0200
878 @@ -3111,6 +3111,11 @@
879 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
880 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
881 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
882 +#ifdef USE_COMPRESSED
883 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
884 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
885 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
887 { "group", parse_group, 0 },
888 { "ungroup", parse_ungroup, 0 },
889 { "hdr_order", parse_list, UL &HeaderOrderList },
890 diff -urN mutt-1.5.15/main.c mutt-1.5.15-ro/main.c
891 --- mutt-1.5.15/main.c 2007-04-04 07:37:13.000000000 +0200
892 +++ mutt-1.5.15-ro/main.c 2007-05-27 14:20:26.000000000 +0200
898 +#ifdef USE_COMPRESSED
906 diff -urN mutt-1.5.15/Makefile.am mutt-1.5.15-ro/Makefile.am
907 --- mutt-1.5.15/Makefile.am 2007-04-06 22:04:45.000000000 +0200
908 +++ mutt-1.5.15-ro/Makefile.am 2007-05-27 14:20:26.000000000 +0200
910 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
911 mutt_SOURCES = $(BUILT_SOURCES) \
912 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
913 - crypt.c cryptglue.c \
914 + crypt.c cryptglue.c compress.c \
915 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
916 edit.c enter.c flags.c init.c filter.c from.c \
917 getdomain.c group.c \
921 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
922 - configure account.h \
923 + configure account.h compress.h \
924 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
925 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
926 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
927 diff -urN mutt-1.5.15/Makefile.in mutt-1.5.15-ro/Makefile.in
928 --- mutt-1.5.15/Makefile.in 2007-04-06 22:05:40.000000000 +0200
929 +++ mutt-1.5.15-ro/Makefile.in 2007-05-27 14:20:26.000000000 +0200
931 attach.$(OBJEXT) base64.$(OBJEXT) browser.$(OBJEXT) \
932 buffy.$(OBJEXT) color.$(OBJEXT) crypt.$(OBJEXT) \
933 cryptglue.$(OBJEXT) commands.$(OBJEXT) complete.$(OBJEXT) \
934 - compose.$(OBJEXT) copy.$(OBJEXT) curs_lib.$(OBJEXT) \
935 + compose.$(OBJEXT) compress.$(OBJEXT) copy.$(OBJEXT) curs_lib.$(OBJEXT) \
936 curs_main.$(OBJEXT) date.$(OBJEXT) edit.$(OBJEXT) \
937 enter.$(OBJEXT) flags.$(OBJEXT) init.$(OBJEXT) \
938 filter.$(OBJEXT) from.$(OBJEXT) getdomain.$(OBJEXT) \
940 BUILT_SOURCES = keymap_defs.h patchlist.c reldate.h hcversion.h
941 mutt_SOURCES = $(BUILT_SOURCES) \
942 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
943 - crypt.c cryptglue.c \
944 + crypt.c cryptglue.c compress.c \
945 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
946 edit.c enter.c flags.c init.c filter.c from.c \
947 getdomain.c group.c \
951 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
952 - configure account.h \
953 + configure account.h compress.h \
954 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
955 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
956 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
958 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/commands.Po@am__quote@
959 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/complete.Po@am__quote@
960 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compose.Po@am__quote@
961 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compress.Po@am__quote@
962 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copy.Po@am__quote@
963 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypt-gpgme.Po@am__quote@
964 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypt-mod-pgp-classic.Po@am__quote@
965 diff -urN mutt-1.5.15/mbox.c mutt-1.5.15-ro/mbox.c
966 --- mutt-1.5.15/mbox.c 2007-04-01 23:58:56.000000000 +0200
967 +++ mutt-1.5.15-ro/mbox.c 2007-05-27 14:20:26.000000000 +0200
970 #include "mutt_curses.h"
972 +#ifdef USE_COMPRESSED
973 +#include "compress.h"
976 #include <sys/stat.h>
979 @@ -1026,6 +1030,12 @@
980 int mbox_close_mailbox (CONTEXT *ctx)
982 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
984 +#ifdef USE_COMPRESSED
985 + if (ctx->compressinfo)
986 + mutt_slow_close_compressed (ctx);
989 mutt_unblock_signals ();
990 mx_fastclose_mailbox (ctx);
992 diff -urN mutt-1.5.15/mutt.h mutt-1.5.15-ro/mutt.h
993 --- mutt-1.5.15/mutt.h 2007-04-02 20:04:35.000000000 +0200
994 +++ mutt-1.5.15-ro/mutt.h 2007-05-27 14:20:26.000000000 +0200
996 #define M_ACCOUNTHOOK (1<<9)
997 #define M_REPLYHOOK (1<<10)
998 #define M_SEND2HOOK (1<<11)
999 +#ifdef USE_COMPRESSED
1000 +#define M_OPENHOOK (1<<12)
1001 +#define M_APPENDHOOK (1<<13)
1002 +#define M_CLOSEHOOK (1<<14)
1005 /* tree characters for linearize_tree and print_enriched_string */
1006 #define M_TREE_LLCORNER 1
1007 @@ -882,6 +887,11 @@
1008 int flagged; /* how many flagged messages */
1009 int msgnotreadyet; /* which msg "new" in pager, -1 if none */
1011 +#ifdef USE_COMPRESSED
1012 + void *compressinfo; /* compressed mbox module private data */
1013 + char *realpath; /* path to compressed mailbox */
1014 +#endif /* USE_COMPRESSED */
1016 short magic; /* mailbox type */
1018 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
1019 diff -urN mutt-1.5.15/Muttrc mutt-1.5.15-ro/Muttrc
1020 --- mutt-1.5.15/Muttrc 2007-04-06 22:34:36.000000000 +0200
1021 +++ mutt-1.5.15-ro/Muttrc 2007-05-27 14:20:26.000000000 +0200
1023 macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
1026 +# Use folders which match on \\.gz$ as gzipped folders:
1027 +# open-hook \\.gz$ "gzip -cd %f > %t"
1028 +# close-hook \\.gz$ "gzip -c %t > %f"
1029 +# append-hook \\.gz$ "gzip -c %t >> %f"
1031 # If Mutt is unable to determine your site's domain name correctly, you can
1032 # set the default here.
1034 diff -urN mutt-1.5.15/Muttrc.head mutt-1.5.15-ro/Muttrc.head
1035 --- mutt-1.5.15/Muttrc.head 2007-04-01 23:58:55.000000000 +0200
1036 +++ mutt-1.5.15-ro/Muttrc.head 2007-05-27 14:20:26.000000000 +0200
1038 macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
1041 +# Use folders which match on \\.gz$ as gzipped folders:
1042 +# open-hook \\.gz$ "gzip -cd %f > %t"
1043 +# close-hook \\.gz$ "gzip -c %t > %f"
1044 +# append-hook \\.gz$ "gzip -c %t >> %f"
1046 # If Mutt is unable to determine your site's domain name correctly, you can
1047 # set the default here.
1049 diff -urN mutt-1.5.15/mx.c mutt-1.5.15-ro/mx.c
1050 --- mutt-1.5.15/mx.c 2007-04-03 19:41:14.000000000 +0200
1051 +++ mutt-1.5.15-ro/mx.c 2007-05-27 14:24:41.000000000 +0200
1056 +#ifdef USE_COMPRESSED
1057 +#include "compress.h"
1063 @@ -450,6 +454,10 @@
1067 +#ifdef USE_COMPRESSED
1068 + if (magic == 0 && mutt_can_read_compressed (path))
1069 + return M_COMPRESSED;
1074 @@ -489,6 +497,13 @@
1078 +#ifdef USE_COMPRESSED
1079 + /* special case for appending to compressed folders -
1080 + * even if we can not open them for reading */
1081 + if (mutt_can_append_compressed (ctx->path))
1082 + mutt_open_append_compressed (ctx);
1088 @@ -652,7 +667,12 @@
1091 ctx->magic = mx_get_magic (path);
1094 +#ifdef USE_COMPRESSED
1095 + if (ctx->magic == M_COMPRESSED)
1096 + mutt_open_read_compressed (ctx);
1100 mutt_error (_("%s is not a mailbox."), path);
1102 @@ -753,6 +773,10 @@
1103 mutt_free_header (&ctx->hdrs[i]);
1106 +#ifdef USE_COMPRESSED
1107 + if (ctx->compressinfo)
1108 + mutt_fast_close_compressed (ctx);
1111 FREE (&ctx->pattern);
1112 if (ctx->limit_pattern)
1113 @@ -805,6 +829,12 @@
1115 if (tmp && tmp->new == 0)
1116 mutt_update_mailbox (tmp);
1118 +#ifdef USE_COMPRESSED
1119 + if (rc == 0 && ctx->compressinfo)
1120 + return mutt_sync_compressed (ctx);
1126 @@ -1006,6 +1036,11 @@
1127 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1128 mx_unlink_empty (ctx->path);
1130 +#ifdef USE_COMPRESSED
1131 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1135 mx_fastclose_mailbox (ctx);
1138 @@ -1315,6 +1350,11 @@
1142 +#ifdef USE_COMPRESSED
1143 + if (ctx->compressinfo)
1144 + return mutt_check_mailbox_compressed (ctx);
1149 if (ctx->locked) lock = 0;
1150 diff -urN mutt-1.5.15/mx.h mutt-1.5.15-ro/mx.h
1151 --- mutt-1.5.15/mx.h 2007-04-01 23:58:56.000000000 +0200
1152 +++ mutt-1.5.15-ro/mx.h 2007-05-27 14:20:29.000000000 +0200
1157 +#ifdef USE_COMPRESSED
1162 WHERE short DefaultMagic INITVAL (M_MBOX);
1163 diff -urN mutt-1.5.15/PATCHES mutt-1.5.15-ro/PATCHES
1164 --- mutt-1.5.15/PATCHES 2007-03-15 16:49:37.000000000 +0100
1165 +++ mutt-1.5.15-ro/PATCHES 2007-05-27 14:38:02.000000000 +0200
1167 +patch-1.5.15.rr.compressed.2
1168 diff -urN mutt-1.5.15/po/de.po mutt-1.5.15-ro/po/de.po
1169 --- mutt-1.5.15/po/de.po 2007-04-06 22:35:40.000000000 +0200
1170 +++ mutt-1.5.15-ro/po/de.po 2007-05-27 14:22:49.000000000 +0200
1171 @@ -1280,6 +1280,48 @@
1172 msgid "Failed to figure out sender"
1173 msgstr "Kann Absender nicht ermitteln"
1175 +#: compress.c:203 mbox.c:661
1176 +msgid "Mailbox was corrupted!"
1177 +msgstr "Mailbox wurde zerstört!"
1179 +#: compress.c:228 compress.c:253
1181 +msgid "Decompressing %s...\n"
1182 +msgstr "Entpacke %s...\n"
1184 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1185 +msgid "Unable to lock mailbox!"
1186 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1190 +msgid "Error executing: %s : unable to open the mailbox!\n"
1191 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1193 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1195 +msgid "Compressing %s...\n"
1196 +msgstr "Komprimiere %s...\n"
1201 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1204 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1205 +"entpackte gespeichert!\n"
1207 +#: compress.c:425 compress.c:456
1209 +msgid "Compressed-appending to %s...\n"
1210 +msgstr "Hänge komprimiert an %s... an\n"
1214 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1215 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1219 msgid " (current time: %c)"
1220 @@ -1945,6 +1987,10 @@
1221 msgid "Bad history file format (line %d)"
1225 +msgid "bad formatted command string"
1226 +msgstr "Hook enthält nicht die Muster %f und %t"
1230 msgid "unhook: Can't do unhook * from within a hook."
1231 @@ -3437,18 +3483,10 @@
1232 msgid "Mailbox is corrupt!"
1233 msgstr "Mailbox fehlerhaft!"
1236 -msgid "Mailbox was corrupted!"
1237 -msgstr "Mailbox wurde zerstört!"
1239 #: mbox.c:711 mbox.c:964
1240 msgid "Fatal error! Could not reopen mailbox!"
1241 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1244 -msgid "Unable to lock mailbox!"
1245 -msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1247 #. this means ctx->changed or ctx->deleted was set, but no
1248 #. * messages were found to be changed or deleted. This should
1249 #. * never happen, is we presume it is a bug in mutt.
1250 diff -urN mutt-1.5.15/po/POTFILES.in mutt-1.5.15-ro/po/POTFILES.in
1251 --- mutt-1.5.15/po/POTFILES.in 2007-04-01 23:58:57.000000000 +0200
1252 +++ mutt-1.5.15-ro/po/POTFILES.in 2007-05-27 14:20:29.000000000 +0200
1261 diff -urN mutt-1.5.15/status.c mutt-1.5.15-ro/status.c
1262 --- mutt-1.5.15/status.c 2007-04-01 23:58:58.000000000 +0200
1263 +++ mutt-1.5.15-ro/status.c 2007-05-27 14:20:29.000000000 +0200
1267 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1268 +#ifdef USE_COMPRESSED
1269 + if (Context && Context->compressinfo && Context->realpath)
1271 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1272 + mutt_pretty_mailbox (tmp);
1276 if (Context && Context->path)
1278 strfcpy (tmp, Context->path, sizeof (tmp));