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.8.rr.compressed.1.gz
15 $(for f in Makefile.in config.h.in configure Muttrc doc/manual.txt \
16 doc/manual.sgml 'doc/manual*.html' doc/muttrc.man; do echo "-x $f"; done)
17 - 2005-03-10: fix configure.in to match latest CVS.
20 diff -urN mutt-1.5.8/compress.c mutt-1.5.8-ro/compress.c
21 --- mutt-1.5.8/compress.c 1970-01-01 01:00:00.000000000 +0100
22 +++ mutt-1.5.8-ro/compress.c 2005-02-13 18:54:39.000000000 +0100
25 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
27 + * This program is free software; you can redistribute it and/or modify
28 + * it under the terms of the GNU General Public License as published by
29 + * the Free Software Foundation; either version 2 of the License, or
30 + * (at your option) any later version.
32 + * This program is distributed in the hope that it will be useful,
33 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 + * GNU General Public License for more details.
37 + * You should have received a copy of the GNU General Public License
38 + * along with this program; if not, write to the Free Software
39 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
48 +#ifdef USE_COMPRESSED
52 +#include "mutt_curses.h"
57 +#include <sys/stat.h>
61 + const char *close; /* close-hook command */
62 + const char *open; /* open-hook command */
63 + const char *append; /* append-hook command */
64 + off_t size; /* size of real folder */
69 + * ctx - context to lock
70 + * excl - exclusive lock?
71 + * retry - should retry if unable to lock?
73 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
77 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
79 + else if (retry && !excl)
88 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
94 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
99 +static int is_new (const char *path)
101 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
104 +static const char* find_compress_hook (int type, const char *path)
106 + const char* c = mutt_find_hook (type, path);
107 + return (!c || !*c) ? NULL : c;
110 +int mutt_can_read_compressed (const char *path)
112 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
116 + * if the file is new, we really do not append, but create, and so use
117 + * close-hook, and not append-hook
119 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
121 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
122 + return (is_new (path)) ? ci->close : ci->append;
125 +int mutt_can_append_compressed (const char *path)
130 + return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
132 + magic = mx_get_magic (path);
134 + if (magic != 0 && magic != M_COMPRESSED)
137 + return (find_compress_hook (M_APPENDHOOK, path)
138 + || (find_compress_hook (M_OPENHOOK, path)
139 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
142 +/* open a compressed mailbox */
143 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
147 + /* Now lets uncompress this thing */
148 + ci = safe_malloc (sizeof (COMPRESS_INFO));
149 + ctx->compressinfo = (void*) ci;
150 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
151 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
152 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
156 +static void set_path (CONTEXT* ctx)
158 + char tmppath[_POSIX_PATH_MAX];
160 + /* Setup the right paths */
161 + ctx->realpath = ctx->path;
163 + /* Uncompress to /tmp */
164 + mutt_mktemp (tmppath);
165 + ctx->path = safe_malloc (strlen (tmppath) + 1);
166 + strcpy (ctx->path, tmppath);
169 +static int get_size (const char* path)
172 + if (stat (path, &sb) != 0)
174 + return (sb.st_size);
177 +static void store_size (CONTEXT* ctx)
179 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
180 + ci->size = get_size (ctx->realpath);
184 +compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
185 + const char *fmt, const char *ifstring,
186 + const char *elsestring, unsigned long data,
189 + char tmp[SHORT_STRING];
191 + CONTEXT *ctx = (CONTEXT *) data;
195 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
196 + snprintf (dest, destlen, tmp, ctx->realpath);
199 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
200 + snprintf (dest, destlen, tmp, ctx->path);
207 + * check that the command has both %f and %t
208 + * 0 means OK, -1 means error
210 +int mutt_test_compress_command (const char* cmd)
212 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
215 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
217 + char expanded[_POSIX_PATH_MAX];
218 + mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str,
219 + (unsigned long) ctx, 0);
220 + return safe_strdup (expanded);
223 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
225 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
226 + if (ci->size != get_size (ctx->realpath))
228 + FREE (&ctx->compressinfo);
229 + FREE (&ctx->realpath);
230 + mutt_error _("Mailbox was corrupted!");
236 +int mutt_open_read_compressed (CONTEXT *ctx)
242 + COMPRESS_INFO *ci = set_compress_info (ctx);
245 + FREE (ctx->compressinfo);
248 + if (!ci->close || access (ctx->path, W_OK) != 0)
255 + mutt_message (_("Decompressing %s..."), ctx->realpath);
257 + cmd = get_compression_cmd (ci->open, ctx);
260 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
262 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
264 + mutt_perror (ctx->realpath);
268 + mutt_block_signals ();
269 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
272 + mutt_unblock_signals ();
273 + mutt_error _("Unable to lock mailbox!");
280 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
281 + rc = mutt_system (cmd);
282 + mbox_unlock_compressed (ctx, fp);
283 + mutt_unblock_signals ();
288 + mutt_any_key_to_continue (NULL);
290 + FREE (ctx->compressinfo);
291 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
297 + if (mutt_check_mailbox_compressed (ctx))
300 + ctx->magic = mx_get_magic (ctx->path);
305 +void restore_path (CONTEXT* ctx)
308 + ctx->path = ctx->realpath;
311 +/* remove the temporary mailbox */
312 +void remove_file (CONTEXT* ctx)
314 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
315 + remove (ctx->path);
318 +int mutt_open_append_compressed (CONTEXT *ctx)
321 + COMPRESS_INFO *ci = set_compress_info (ctx);
323 + if (!get_append_command (ctx->path, ctx))
325 + if (ci->open && ci->close)
326 + return (mutt_open_read_compressed (ctx));
329 + FREE (&ctx->compressinfo);
335 + ctx->magic = DefaultMagic;
337 + if (!is_new (ctx->realpath))
338 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
339 + if ((fh = fopen (ctx->path, "w")))
341 + /* No error checking - the parent function will catch it */
346 +/* close a compressed mailbox */
347 +void mutt_fast_close_compressed (CONTEXT *ctx)
349 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
352 + if (ctx->compressinfo)
357 + /* if the folder was removed, remove the gzipped folder too */
358 + if ((ctx->magic > 0)
359 + && (access (ctx->path, F_OK) != 0)
360 + && ! option (OPTSAVEEMPTY))
361 + remove (ctx->realpath);
365 + restore_path (ctx);
366 + FREE (&ctx->compressinfo);
370 +/* return 0 on success, -1 on failure */
371 +int mutt_sync_compressed (CONTEXT* ctx)
376 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
379 + mutt_message (_("Compressing %s..."), ctx->realpath);
381 + cmd = get_compression_cmd (ci->close, ctx);
385 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
387 + mutt_perror (ctx->realpath);
391 + mutt_block_signals ();
392 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
395 + mutt_unblock_signals ();
396 + mutt_error _("Unable to lock mailbox!");
402 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
406 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
407 + if (mutt_system (cmd))
409 + mutt_any_key_to_continue (NULL);
410 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
414 + mbox_unlock_compressed (ctx, fp);
415 + mutt_unblock_signals ();
425 +int mutt_slow_close_compressed (CONTEXT *ctx)
428 + const char *append;
430 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
432 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
436 + && ((append = get_append_command (ctx->realpath, ctx))
437 + || (append = ci->close))))
439 + /* if we can not or should not append, we only have to remove the */
440 + /* compressed info, because sync was already called */
441 + mutt_fast_close_compressed (ctx);
451 + if (append == ci->close)
452 + mutt_message (_("Compressing %s..."), ctx->realpath);
454 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
457 + cmd = get_compression_cmd (append, ctx);
461 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
463 + mutt_perror (ctx->realpath);
467 + mutt_block_signals ();
468 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
471 + mutt_unblock_signals ();
472 + mutt_error _("Unable to lock mailbox!");
477 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
482 + if (append == ci->close)
483 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
485 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
487 + if (mutt_system (cmd))
489 + mutt_any_key_to_continue (NULL);
490 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
493 + mbox_unlock_compressed (ctx, fp);
494 + mutt_unblock_signals ();
499 + mbox_unlock_compressed (ctx, fp);
500 + mutt_unblock_signals ();
503 + restore_path (ctx);
505 + FREE (&ctx->compressinfo);
510 +#endif /* USE_COMPRESSED */
511 diff -urN mutt-1.5.8/compress.h mutt-1.5.8-ro/compress.h
512 --- mutt-1.5.8/compress.h 1970-01-01 01:00:00.000000000 +0100
513 +++ mutt-1.5.8-ro/compress.h 2005-02-13 18:54:39.000000000 +0100
516 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
518 + * This program is free software; you can redistribute it and/or modify
519 + * it under the terms of the GNU General Public License as published by
520 + * the Free Software Foundation; either version 2 of the License, or
521 + * (at your option) any later version.
523 + * This program is distributed in the hope that it will be useful,
524 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
525 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
526 + * GNU General Public License for more details.
528 + * You should have received a copy of the GNU General Public License
529 + * along with this program; if not, write to the Free Software
530 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
533 +int mutt_can_read_compressed (const char *);
534 +int mutt_can_append_compressed (const char *);
535 +int mutt_open_read_compressed (CONTEXT *);
536 +int mutt_open_append_compressed (CONTEXT *);
537 +int mutt_slow_close_compressed (CONTEXT *);
538 +int mutt_sync_compressed (CONTEXT *);
539 +int mutt_test_compress_command (const char *);
540 +int mutt_check_mailbox_compressed (CONTEXT *);
541 +void mutt_fast_close_compressed (CONTEXT *);
542 diff -urN mutt-1.5.8/config.h.in mutt-1.5.8-ro/config.h.in
543 diff -urN mutt-1.5.8/configure mutt-1.5.8-ro/configure
544 diff -urN mutt-1.5.8/configure.in mutt-1.5.8-ro/configure.in
545 --- mutt-1.5.8/configure.in 2005-02-12 21:57:16.000000000 +0100
546 +++ mutt-1.5.8-ro/configure.in 2005-02-13 18:54:39.000000000 +0100
548 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
551 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
552 + [if test x$enableval = xyes; then
553 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
556 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
557 [if test $withval != yes; then
558 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
559 diff -urN mutt-1.5.8/curs_main.c mutt-1.5.8-ro/curs_main.c
560 --- mutt-1.5.8/curs_main.c 2005-02-12 20:22:15.000000000 +0100
561 +++ mutt-1.5.8-ro/curs_main.c 2005-02-13 18:54:39.000000000 +0100
562 @@ -1076,6 +1076,11 @@
566 +#ifdef USE_COMPRESSED
567 + if (Context->compressinfo && Context->realpath)
568 + mutt_str_replace (&LastFolder, Context->realpath);
571 mutt_str_replace (&LastFolder, Context->path);
572 oldcount = Context ? Context->msgcount : 0;
574 diff -urN mutt-1.5.8/doc/manual-4.html mutt-1.5.8-ro/doc/manual-4.html
575 diff -urN mutt-1.5.8/doc/manual-6.html mutt-1.5.8-ro/doc/manual-6.html
576 diff -urN mutt-1.5.8/doc/manual.html mutt-1.5.8-ro/doc/manual.html
577 diff -urN mutt-1.5.8/doc/manual.sgml mutt-1.5.8-ro/doc/manual.sgml
578 diff -urN mutt-1.5.8/doc/manual.sgml.head mutt-1.5.8-ro/doc/manual.sgml.head
579 --- mutt-1.5.8/doc/manual.sgml.head 2005-02-12 20:41:36.000000000 +0100
580 +++ mutt-1.5.8-ro/doc/manual.sgml.head 2005-02-13 18:54:39.000000000 +0100
581 @@ -2537,6 +2537,176 @@
582 macro pager \cb |urlview\n
585 +<sect1>Compressed folders Support (OPTIONAL)
588 +If Mutt was compiled with compressed folders support (by running the
589 +<em/configure/ script with the <em/--enable-compressed/ flag), Mutt
590 +can open folders stored in an arbitrary format, provided that the user
591 +has a script to convert from/to this format to one of the accepted.
593 +The most common use is to open compressed archived folders e.g. with
596 +In addition, the user can provide a script that gets a folder in an
597 +accepted format and appends its context to the folder in the
598 +user-defined format, which may be faster than converting the entire
599 +folder to the accepted format, appending to it and converting back to
600 +the user-defined format.
602 +There are three hooks defined (<ref id="open-hook" name="open-hook">,
603 +<ref id="close-hook" name="close-hook"> and <ref id="append-hook"
604 +name="append-hook">) which define commands to uncompress and compress
605 +a folder and to append messages to an existing compressed folder
611 +open-hook \\.gz$ "gzip -cd %f > %t"
612 +close-hook \\.gz$ "gzip -c %t > %f"
613 +append-hook \\.gz$ "gzip -c %t >> %f"
616 +You do not have to specify all of the commands. If you omit <ref
617 +id="append-hook" name="append-hook">, the folder will be open and
618 +closed again each time you will add to it. If you omit <ref
619 +id="close-hook" name="close-hook"> (or give empty command) , the
620 +folder will be open in the mode. If you specify <ref
621 +id="append-hook" name="append-hook"> though you'll be able to append
624 +Note that Mutt will only try to use hooks if the file is not in one of
625 +the accepted formats. In particular, if the file is empty, mutt
626 +supposes it is not compressed. This is important because it allows the
627 +use of programs that do not have well defined extensions. Just use
628 +&dquot;.&dquot; as a regexp. But this may be surprising if your
629 +compressing script produces empty files. In this situation, unset <ref
630 +id="save_empty" name="$save_empty">, so that the compressed file
631 +will be removed if you delete all of the messages.
633 +<sect2>Open a compressed mailbox for reading<label id="open-hook">
635 +Usage: <tt/open-hook/ <em/regexp/ &dquot;<em/command/&dquot;
637 +The <em/command/ is the command that can be used for opening the
638 +folders whose names match <em/regexp/.
640 +The <em/command/ string is the printf-like format string, and it
641 +should accept two parameters: %f, which is replaced with the
642 +(compressed) folder name, and %t which is replaced with the
643 +name of the temporary folder to which to write.
645 +%f and %t can be repeated any number of times in the
646 +command string, and all of the entries are replaced with the
647 +appropriate folder name. In addition, %% is replaced by
648 +%, as in printf, and any other %anything is left as is.
650 +The <em/command/ should <bf/not/ remove the original compressed file.
651 +The <em/command/ should return non-zero exit status if it fails, so
652 +mutt knows something's wrong.
657 +open-hook \\.gz$ "gzip -cd %f > %t"
660 +If the <em/command/ is empty, this operation is disabled for this file
663 +<sect2>Write a compressed mailbox<label id="close-hook">
665 +Usage: <tt/close-hook/ <em/regexp/ &dquot;<em/command/&dquot;
667 +This is used to close the folder that was open with the <ref id="open-hook"
668 +name="open-hook"> command after some changes were made to it.
670 +The <em/command/ string is the command that can be used for closing the
671 +folders whose names match <em/regexp/. It has the same format as in
672 +the <ref id="open-hook" name="open-hook"> command. Temporary folder
673 +in this case is the folder previously produced by the <ref id="open-hook"
674 +name="open-hook"> command.
676 +The <em/command/ should <bf/not/ remove the decompressed file. The
677 +<em/command/ should return non-zero exit status if it fails, so mutt
678 +knows something's wrong.
683 +close-hook \\.gz$ "gzip -c %t > %f"
686 +If the <em/command/ is empty, this operation is disabled for this file
687 +type, and the file can only be open in the read-only mode.
689 +<ref id="close-hook" name ="close-hook"> is not called when you exit
690 +from the folder if the folder was not changed.
692 +<sect2>Append a message to a compressed mailbox<label id="append-hook">
694 +Usage: <tt/append-hook/ <em/regexp/ &dquot;<em/command/&dquot;
696 +This command is used for saving to an existing compressed folder.
697 +The <em/command/ is the command that can be used for appending to the
698 +folders whose names match <em/regexp/. It has the same format as in
699 + the <ref id="open-hook" name="open-hook"> command.
700 +The temporary folder in this case contains the messages that are being
703 +The <em/command/ should <bf/not/ remove the decompressed file. The
704 +<em/command/ should return non-zero exit status if it fails, so mutt
705 +knows something's wrong.
710 +append-hook \\.gz$ "gzip -c %t >> %f"
713 +When <ref id="append-hook" name="append-hook"> is used, the folder is
714 +not opened, which saves time, but this means that we can not find out
715 +what the folder type is. Thus the default (<ref id="mbox_type"
716 +name="$mbox_type">) type is always supposed (i.e.
717 +this is the format used for the temporary folder).
719 +If the file does not exist when you save to it, <ref id="close-hook"
720 +name="close-hook"> is called, and not <ref id="append-hook"
721 +name="append-hook">. <ref id="append-hook" name="append-hook"> is only
722 +for appending to existing folders.
724 +If the <em/command/ is empty, this operation is disabled for this file
725 +type. In this case, the folder will be open and closed again (using
726 +<ref id="open-hook" name="open-hook"> and <ref id="close-hook"
727 +name="close-hook">respectively) each time you will add to it.
729 +<sect2>Encrypted folders
731 +The compressed folders support can also be used to handle encrypted
732 +folders. If you want to encrypt a folder with PGP, you may want to use
733 +the following hooks:
736 +open-hook \\.pgp$ "pgp -f < %f > %t"
737 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
740 +Please note, that PGP does not support appending to an encrypted
741 +folder, so there is no append-hook defined.
743 +If you are using GnuPG instead of PGP, you may use the following hooks
747 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
748 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
751 +<bf/Note:/ the folder is temporary stored decrypted in the /tmp
752 +directory, where it can be read by your system administrator. So think
753 +about the security aspects of this.
755 <sect>Mutt's MIME Support
757 Quite a bit of effort has been made to make Mutt the premier text-mode
758 @@ -3116,6 +3286,8 @@
760 <tt><ref id="alternative_order" name="unalternative_order"></tt> <em/mimetype/ [ <em/mimetype/ ... ]
762 +<tt><ref id="append-hook" name="append-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
764 <tt><ref id="auto_view" name="auto_view"></tt> <em/mimetype/ [ <em/mimetype/ ... ]
766 <tt><ref id="auto_view" name="unauto_view"></tt> <em/mimetype/ [ <em/mimetype/ ... ]
767 @@ -3124,6 +3296,8 @@
769 <tt><ref id="charset-hook" name="charset-hook"></tt> <em/alias/ <em/charset/
771 +<tt><ref id="close-hook" name="close-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
773 <tt><ref id="color" name="color"></tt> <em/object/ <em/foreground/ <em/background/ [ <em/regexp/ ]
775 <tt><ref id="color" name="uncolor"></tt> <em/index/ <em/pattern/ [ <em/pattern/ ... ]
776 @@ -3170,6 +3344,8 @@
778 <tt><ref id="my_hdr" name="unmy_hdr"></tt> <em/field/ [ <em/field/ ... ]
780 +<tt><ref id="open-hook" name="open-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
782 <tt><ref id="crypt-hook" name="crypt-hook"></tt> <em/pattern/ <em/key-id/
784 <tt><ref id="push" name="push"></tt> <em/string/
785 diff -urN mutt-1.5.8/doc/manual.txt mutt-1.5.8-ro/doc/manual.txt
786 diff -urN mutt-1.5.8/doc/muttrc.man mutt-1.5.8-ro/doc/muttrc.man
787 diff -urN mutt-1.5.8/doc/muttrc.man.head mutt-1.5.8-ro/doc/muttrc.man.head
788 --- mutt-1.5.8/doc/muttrc.man.head 2005-01-15 10:42:45.000000000 +0100
789 +++ mutt-1.5.8-ro/doc/muttrc.man.head 2005-02-13 18:54:39.000000000 +0100
791 to a certain recipient. The meaning of "key ID" is to be taken
792 broadly: This can be a different e-mail address, a numerical key ID,
793 or even just an arbitrary search string.
796 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
797 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
798 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
801 +These commands provide a way to handle compressed folders. The given
802 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
803 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
804 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
805 +compressed mail to a compressed folder (\fBappend-hook\fP). The
806 +\fIcommand\fP string is the
808 +like format string, and it should accept two parameters: \fB%f\fP,
809 +which is replaced with the (compressed) folder name, and \fB%t\fP
810 +which is replaced with the name of the temporary folder to which to
813 \fBpush\fP \fIstring\fP
814 This command adds the named \fIstring\fP to the keyboard buffer.
815 diff -urN mutt-1.5.8/hook.c mutt-1.5.8-ro/hook.c
816 --- mutt-1.5.8/hook.c 2005-02-03 19:47:52.000000000 +0100
817 +++ mutt-1.5.8-ro/hook.c 2005-02-13 18:54:39.000000000 +0100
820 #include "mutt_crypt.h"
822 +#ifdef USE_COMPRESSED
823 +#include "compress.h"
830 memset (&pattern, 0, sizeof (pattern));
831 pattern.data = safe_strdup (path);
833 +#ifdef USE_COMPRESSED
834 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
836 + if (mutt_test_compress_command (command.data))
838 + strfcpy (err->data, _("bad formatted command string"), err->dsize);
843 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ACCOUNTHOOK))
844 && (!WithCrypto || !(data & M_CRYPTHOOK))
846 diff -urN mutt-1.5.8/init.h mutt-1.5.8-ro/init.h
847 --- mutt-1.5.8/init.h 2005-02-12 21:01:10.000000000 +0100
848 +++ mutt-1.5.8-ro/init.h 2005-02-13 18:54:39.000000000 +0100
849 @@ -2926,6 +2926,11 @@
850 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
851 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
852 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
853 +#ifdef USE_COMPRESSED
854 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
855 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
856 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
858 { "hdr_order", parse_list, UL &HeaderOrderList },
860 { "iconv-hook", mutt_parse_hook, M_ICONVHOOK },
861 diff -urN mutt-1.5.8/main.c mutt-1.5.8-ro/main.c
862 --- mutt-1.5.8/main.c 2005-02-12 20:41:32.000000000 +0100
863 +++ mutt-1.5.8-ro/main.c 2005-02-13 18:54:40.000000000 +0100
869 +#ifdef USE_COMPRESSED
877 diff -urN mutt-1.5.8/Makefile.am mutt-1.5.8-ro/Makefile.am
878 --- mutt-1.5.8/Makefile.am 2005-02-12 21:54:39.000000000 +0100
879 +++ mutt-1.5.8-ro/Makefile.am 2005-02-13 18:54:40.000000000 +0100
881 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
882 mutt_SOURCES = $(BUILT_SOURCES) \
883 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
884 - crypt.c cryptglue.c \
885 + crypt.c cryptglue.c compress.c \
886 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
887 edit.c enter.c flags.c init.c filter.c from.c getdomain.c \
888 handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c \
890 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c
892 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \
893 - configure account.h \
894 + configure account.h compress.h \
895 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
896 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
897 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
898 diff -urN mutt-1.5.8/Makefile.in mutt-1.5.8-ro/Makefile.in
899 diff -urN mutt-1.5.8/mbox.c mutt-1.5.8-ro/mbox.c
900 --- mutt-1.5.8/mbox.c 2005-02-03 19:47:53.000000000 +0100
901 +++ mutt-1.5.8-ro/mbox.c 2005-02-13 18:54:40.000000000 +0100
906 +#ifdef USE_COMPRESSED
907 +#include "compress.h"
910 #include <sys/stat.h>
913 @@ -1020,6 +1024,12 @@
914 int mbox_close_mailbox (CONTEXT *ctx)
916 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
918 +#ifdef USE_COMPRESSED
919 + if (ctx->compressinfo)
920 + mutt_slow_close_compressed (ctx);
923 mutt_unblock_signals ();
924 mx_fastclose_mailbox (ctx);
926 diff -urN mutt-1.5.8/mutt.h mutt-1.5.8-ro/mutt.h
927 --- mutt-1.5.8/mutt.h 2005-02-12 21:01:20.000000000 +0100
928 +++ mutt-1.5.8-ro/mutt.h 2005-02-13 18:54:40.000000000 +0100
930 #define M_ACCOUNTHOOK (1<<9)
931 #define M_REPLYHOOK (1<<10)
932 #define M_SEND2HOOK (1<<11)
933 +#ifdef USE_COMPRESSED
934 +#define M_OPENHOOK (1<<12)
935 +#define M_APPENDHOOK (1<<13)
936 +#define M_CLOSEHOOK (1<<14)
939 /* tree characters for linearize_tree and print_enriched_string */
940 #define M_TREE_LLCORNER 1
942 void *data; /* driver specific data */
943 #endif /* USE_IMAP */
945 +#ifdef USE_COMPRESSED
946 + void *compressinfo; /* compressed mbox module private data */
947 + char *realpath; /* path to compressed mailbox */
948 +#endif /* USE_COMPRESSED */
950 short magic; /* mailbox type */
952 unsigned int locked : 1; /* is the mailbox locked? */
953 diff -urN mutt-1.5.8/Muttrc mutt-1.5.8-ro/Muttrc
954 diff -urN mutt-1.5.8/Muttrc.head mutt-1.5.8-ro/Muttrc.head
955 --- mutt-1.5.8/Muttrc.head 2005-02-12 21:57:45.000000000 +0100
956 +++ mutt-1.5.8-ro/Muttrc.head 2005-02-13 18:54:40.000000000 +0100
958 macro index <f1> "!less /usr/local/doc/mutt/manual.txt\n" "Show Mutt documentation"
959 macro pager <f1> "!less /usr/local/doc/mutt/manual.txt\n" "Show Mutt documentation"
961 +# Use folders which match on \\.gz$ as gzipped folders:
962 +# open-hook \\.gz$ "gzip -cd %f > %t"
963 +# close-hook \\.gz$ "gzip -c %t > %f"
964 +# append-hook \\.gz$ "gzip -c %t >> %f"
966 # If Mutt is unable to determine your site's domain name correctly, you can
967 # set the default here.
969 diff -urN mutt-1.5.8/Muttrc.head.in mutt-1.5.8-ro/Muttrc.head.in
970 --- mutt-1.5.8/Muttrc.head.in 2002-01-24 13:10:47.000000000 +0100
971 +++ mutt-1.5.8-ro/Muttrc.head.in 2005-02-13 18:54:40.000000000 +0100
973 macro index <f1> "!less @docdir@/manual.txt\n" "Show Mutt documentation"
974 macro pager <f1> "!less @docdir@/manual.txt\n" "Show Mutt documentation"
976 +# Use folders which match on \\.gz$ as gzipped folders:
977 +# open-hook \\.gz$ "gzip -cd %f > %t"
978 +# close-hook \\.gz$ "gzip -c %t > %f"
979 +# append-hook \\.gz$ "gzip -c %t >> %f"
981 # If Mutt is unable to determine your site's domain name correctly, you can
982 # set the default here.
984 diff -urN mutt-1.5.8/mx.c mutt-1.5.8-ro/mx.c
985 --- mutt-1.5.8/mx.c 2005-02-03 19:47:53.000000000 +0100
986 +++ mutt-1.5.8-ro/mx.c 2005-02-13 18:54:40.000000000 +0100
991 +#ifdef USE_COMPRESSED
992 +#include "compress.h"
1002 +#ifdef USE_COMPRESSED
1003 + if (magic == 0 && mutt_can_read_compressed (path))
1004 + return M_COMPRESSED;
1009 @@ -493,6 +501,13 @@
1013 +#ifdef USE_COMPRESSED
1014 + /* special case for appending to compressed folders -
1015 + * even if we can not open them for reading */
1016 + if (mutt_can_append_compressed (ctx->path))
1017 + mutt_open_append_compressed (ctx);
1023 @@ -653,7 +668,12 @@
1026 ctx->magic = mx_get_magic (path);
1029 +#ifdef USE_COMPRESSED
1030 + if (ctx->magic == M_COMPRESSED)
1031 + mutt_open_read_compressed (ctx);
1035 mutt_error (_("%s is not a mailbox."), path);
1037 @@ -759,6 +779,10 @@
1038 mutt_free_header (&ctx->hdrs[i]);
1041 +#ifdef USE_COMPRESSED
1042 + if (ctx->compressinfo)
1043 + mutt_fast_close_compressed (ctx);
1046 FREE (&ctx->pattern);
1047 if (ctx->limit_pattern)
1048 @@ -816,6 +840,12 @@
1049 if (tmp && tmp->new == 0)
1050 mutt_update_mailbox (tmp);
1053 +#ifdef USE_COMPRESSED
1054 + if (rc == 0 && ctx->compressinfo)
1055 + return mutt_sync_compressed (ctx);
1061 @@ -1021,6 +1051,11 @@
1062 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1063 mx_unlink_empty (ctx->path);
1065 +#ifdef USE_COMPRESSED
1066 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1070 mx_fastclose_mailbox (ctx);
1073 @@ -1325,6 +1360,11 @@
1077 +#ifdef USE_COMPRESSED
1078 + if (ctx->compressinfo)
1079 + return mutt_check_mailbox_compressed (ctx);
1084 if (ctx->locked) lock = 0;
1085 diff -urN mutt-1.5.8/mx.h mutt-1.5.8-ro/mx.h
1086 --- mutt-1.5.8/mx.h 2003-08-05 15:58:16.000000000 +0200
1087 +++ mutt-1.5.8-ro/mx.h 2005-02-13 18:54:40.000000000 +0100
1092 +#ifdef USE_COMPRESSED
1097 WHERE short DefaultMagic INITVAL (M_MBOX);
1098 diff -urN mutt-1.5.8/PATCHES mutt-1.5.8-ro/PATCHES
1099 --- mutt-1.5.8/PATCHES 2005-02-12 21:55:51.000000000 +0100
1100 +++ mutt-1.5.8-ro/PATCHES 2005-02-13 18:54:40.000000000 +0100
1102 +patch-1.5.8.rr.compressed.1
1103 diff -urN mutt-1.5.8/po/de.po mutt-1.5.8-ro/po/de.po
1104 --- mutt-1.5.8/po/de.po 2005-02-12 21:58:50.000000000 +0100
1105 +++ mutt-1.5.8-ro/po/de.po 2005-02-13 18:56:06.000000000 +0100
1106 @@ -710,6 +710,48 @@
1107 msgid "PGP already selected. Clear & continue ? "
1108 msgstr "PGP bereits ausgewählt. Löschen und weiter?"
1110 +#: compress.c:203 mbox.c:661
1111 +msgid "Mailbox was corrupted!"
1112 +msgstr "Mailbox wurde zerstört!"
1114 +#: compress.c:228 compress.c:253
1116 +msgid "Decompressing %s...\n"
1117 +msgstr "Entpacke %s...\n"
1119 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1120 +msgid "Unable to lock mailbox!"
1121 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1125 +msgid "Error executing: %s : unable to open the mailbox!\n"
1126 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1128 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1130 +msgid "Compressing %s...\n"
1131 +msgstr "Komprimiere %s...\n"
1136 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1139 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1140 +"entpackte gespeichert!\n"
1142 +#: compress.c:425 compress.c:456
1144 +msgid "Compressed-appending to %s...\n"
1145 +msgstr "Hänge komprimiert an %s... an\n"
1149 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1150 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1154 msgid " (current time: %c)"
1155 @@ -1300,6 +1342,10 @@
1157 msgstr "Hilfe für %s"
1160 +msgid "bad formatted command string"
1161 +msgstr "Hook enthält nicht die Muster %f und %t"
1165 msgid "unhook: Can't do unhook * from within a hook."
1166 @@ -2713,18 +2759,10 @@
1167 msgid "Mailbox is corrupt!"
1168 msgstr "Mailbox fehlerhaft!"
1171 -msgid "Mailbox was corrupted!"
1172 -msgstr "Mailbox wurde zerstört!"
1174 #: mbox.c:699 mbox.c:953
1175 msgid "Fatal error! Could not reopen mailbox!"
1176 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1179 -msgid "Unable to lock mailbox!"
1180 -msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1182 #. this means ctx->changed or ctx->deleted was set, but no
1183 #. * messages were found to be changed or deleted. This should
1184 #. * never happen, is we presume it is a bug in mutt.
1185 diff -urN mutt-1.5.8/po/POTFILES.in mutt-1.5.8-ro/po/POTFILES.in
1186 --- mutt-1.5.8/po/POTFILES.in 2002-03-27 09:44:17.000000000 +0100
1187 +++ mutt-1.5.8-ro/po/POTFILES.in 2005-02-13 18:54:40.000000000 +0100
1196 diff -urN mutt-1.5.8/status.c mutt-1.5.8-ro/status.c
1197 --- mutt-1.5.8/status.c 2005-02-03 19:47:53.000000000 +0100
1198 +++ mutt-1.5.8-ro/status.c 2005-02-13 18:54:40.000000000 +0100
1202 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1203 +#ifdef USE_COMPRESSED
1204 + if (Context && Context->compressinfo && Context->realpath)
1206 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1207 + mutt_pretty_mailbox (tmp);
1211 if (Context && Context->path)
1213 strfcpy (tmp, Context->path, sizeof (tmp));