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.10.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)
19 diff -urN mutt-1.5.10/compress.c mutt-1.5.10-ro/compress.c
20 --- mutt-1.5.10/compress.c 1970-01-01 01:00:00.000000000 +0100
21 +++ mutt-1.5.10-ro/compress.c 2005-08-14 12:10:21.000000000 +0200
24 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
26 + * This program is free software; you can redistribute it and/or modify
27 + * it under the terms of the GNU General Public License as published by
28 + * the Free Software Foundation; either version 2 of the License, or
29 + * (at your option) any later version.
31 + * This program is distributed in the hope that it will be useful,
32 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 + * GNU General Public License for more details.
36 + * You should have received a copy of the GNU General Public License
37 + * along with this program; if not, write to the Free Software
38 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
47 +#ifdef USE_COMPRESSED
51 +#include "mutt_curses.h"
56 +#include <sys/stat.h>
60 + const char *close; /* close-hook command */
61 + const char *open; /* open-hook command */
62 + const char *append; /* append-hook command */
63 + off_t size; /* size of real folder */
68 + * ctx - context to lock
69 + * excl - exclusive lock?
70 + * retry - should retry if unable to lock?
72 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
76 + if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
78 + else if (retry && !excl)
87 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
93 + mx_unlock_file (ctx->realpath, fileno (fp), 1);
98 +static int is_new (const char *path)
100 + return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
103 +static const char* find_compress_hook (int type, const char *path)
105 + const char* c = mutt_find_hook (type, path);
106 + return (!c || !*c) ? NULL : c;
109 +int mutt_can_read_compressed (const char *path)
111 + return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
115 + * if the file is new, we really do not append, but create, and so use
116 + * close-hook, and not append-hook
118 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
120 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
121 + return (is_new (path)) ? ci->close : ci->append;
124 +int mutt_can_append_compressed (const char *path)
129 + return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
131 + magic = mx_get_magic (path);
133 + if (magic != 0 && magic != M_COMPRESSED)
136 + return (find_compress_hook (M_APPENDHOOK, path)
137 + || (find_compress_hook (M_OPENHOOK, path)
138 + && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
141 +/* open a compressed mailbox */
142 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
146 + /* Now lets uncompress this thing */
147 + ci = safe_malloc (sizeof (COMPRESS_INFO));
148 + ctx->compressinfo = (void*) ci;
149 + ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
150 + ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
151 + ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
155 +static void set_path (CONTEXT* ctx)
157 + char tmppath[_POSIX_PATH_MAX];
159 + /* Setup the right paths */
160 + ctx->realpath = ctx->path;
162 + /* Uncompress to /tmp */
163 + mutt_mktemp (tmppath);
164 + ctx->path = safe_malloc (strlen (tmppath) + 1);
165 + strcpy (ctx->path, tmppath);
168 +static int get_size (const char* path)
171 + if (stat (path, &sb) != 0)
173 + return (sb.st_size);
176 +static void store_size (CONTEXT* ctx)
178 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
179 + ci->size = get_size (ctx->realpath);
183 +compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
184 + const char *fmt, const char *ifstring,
185 + const char *elsestring, unsigned long data,
188 + char tmp[SHORT_STRING];
190 + CONTEXT *ctx = (CONTEXT *) data;
194 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
195 + snprintf (dest, destlen, tmp, ctx->realpath);
198 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
199 + snprintf (dest, destlen, tmp, ctx->path);
206 + * check that the command has both %f and %t
207 + * 0 means OK, -1 means error
209 +int mutt_test_compress_command (const char* cmd)
211 + return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
214 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
216 + char expanded[_POSIX_PATH_MAX];
217 + mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str,
218 + (unsigned long) ctx, 0);
219 + return safe_strdup (expanded);
222 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
224 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
225 + if (ci->size != get_size (ctx->realpath))
227 + FREE (&ctx->compressinfo);
228 + FREE (&ctx->realpath);
229 + mutt_error _("Mailbox was corrupted!");
235 +int mutt_open_read_compressed (CONTEXT *ctx)
241 + COMPRESS_INFO *ci = set_compress_info (ctx);
244 + FREE (ctx->compressinfo);
247 + if (!ci->close || access (ctx->path, W_OK) != 0)
254 + mutt_message (_("Decompressing %s..."), ctx->realpath);
256 + cmd = get_compression_cmd (ci->open, ctx);
259 + dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
261 + if ((fp = fopen (ctx->realpath, "r")) == NULL)
263 + mutt_perror (ctx->realpath);
267 + mutt_block_signals ();
268 + if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
271 + mutt_unblock_signals ();
272 + mutt_error _("Unable to lock mailbox!");
279 + fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
280 + rc = mutt_system (cmd);
281 + mbox_unlock_compressed (ctx, fp);
282 + mutt_unblock_signals ();
287 + mutt_any_key_to_continue (NULL);
289 + FREE (ctx->compressinfo);
290 + mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
296 + if (mutt_check_mailbox_compressed (ctx))
299 + ctx->magic = mx_get_magic (ctx->path);
304 +void restore_path (CONTEXT* ctx)
307 + ctx->path = ctx->realpath;
310 +/* remove the temporary mailbox */
311 +void remove_file (CONTEXT* ctx)
313 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
314 + remove (ctx->path);
317 +int mutt_open_append_compressed (CONTEXT *ctx)
320 + COMPRESS_INFO *ci = set_compress_info (ctx);
322 + if (!get_append_command (ctx->path, ctx))
324 + if (ci->open && ci->close)
325 + return (mutt_open_read_compressed (ctx));
328 + FREE (&ctx->compressinfo);
334 + ctx->magic = DefaultMagic;
336 + if (!is_new (ctx->realpath))
337 + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
338 + if ((fh = fopen (ctx->path, "w")))
340 + /* No error checking - the parent function will catch it */
345 +/* close a compressed mailbox */
346 +void mutt_fast_close_compressed (CONTEXT *ctx)
348 + dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
351 + if (ctx->compressinfo)
356 + /* if the folder was removed, remove the gzipped folder too */
357 + if ((ctx->magic > 0)
358 + && (access (ctx->path, F_OK) != 0)
359 + && ! option (OPTSAVEEMPTY))
360 + remove (ctx->realpath);
364 + restore_path (ctx);
365 + FREE (&ctx->compressinfo);
369 +/* return 0 on success, -1 on failure */
370 +int mutt_sync_compressed (CONTEXT* ctx)
375 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
378 + mutt_message (_("Compressing %s..."), ctx->realpath);
380 + cmd = get_compression_cmd (ci->close, ctx);
384 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
386 + mutt_perror (ctx->realpath);
390 + mutt_block_signals ();
391 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
394 + mutt_unblock_signals ();
395 + mutt_error _("Unable to lock mailbox!");
401 + dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
405 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
406 + if (mutt_system (cmd))
408 + mutt_any_key_to_continue (NULL);
409 + mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
413 + mbox_unlock_compressed (ctx, fp);
414 + mutt_unblock_signals ();
424 +int mutt_slow_close_compressed (CONTEXT *ctx)
427 + const char *append;
429 + COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
431 + dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
435 + && ((append = get_append_command (ctx->realpath, ctx))
436 + || (append = ci->close))))
438 + /* if we can not or should not append, we only have to remove the */
439 + /* compressed info, because sync was already called */
440 + mutt_fast_close_compressed (ctx);
450 + if (append == ci->close)
451 + mutt_message (_("Compressing %s..."), ctx->realpath);
453 + mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
456 + cmd = get_compression_cmd (append, ctx);
460 + if ((fp = fopen (ctx->realpath, "a")) == NULL)
462 + mutt_perror (ctx->realpath);
466 + mutt_block_signals ();
467 + if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
470 + mutt_unblock_signals ();
471 + mutt_error _("Unable to lock mailbox!");
476 + dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
481 + if (append == ci->close)
482 + fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
484 + fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
486 + if (mutt_system (cmd))
488 + mutt_any_key_to_continue (NULL);
489 + mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
492 + mbox_unlock_compressed (ctx, fp);
493 + mutt_unblock_signals ();
498 + mbox_unlock_compressed (ctx, fp);
499 + mutt_unblock_signals ();
502 + restore_path (ctx);
504 + FREE (&ctx->compressinfo);
509 +#endif /* USE_COMPRESSED */
510 diff -urN mutt-1.5.10/compress.h mutt-1.5.10-ro/compress.h
511 --- mutt-1.5.10/compress.h 1970-01-01 01:00:00.000000000 +0100
512 +++ mutt-1.5.10-ro/compress.h 2005-08-14 12:10:21.000000000 +0200
515 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
517 + * This program is free software; you can redistribute it and/or modify
518 + * it under the terms of the GNU General Public License as published by
519 + * the Free Software Foundation; either version 2 of the License, or
520 + * (at your option) any later version.
522 + * This program is distributed in the hope that it will be useful,
523 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
524 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
525 + * GNU General Public License for more details.
527 + * You should have received a copy of the GNU General Public License
528 + * along with this program; if not, write to the Free Software
529 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
532 +int mutt_can_read_compressed (const char *);
533 +int mutt_can_append_compressed (const char *);
534 +int mutt_open_read_compressed (CONTEXT *);
535 +int mutt_open_append_compressed (CONTEXT *);
536 +int mutt_slow_close_compressed (CONTEXT *);
537 +int mutt_sync_compressed (CONTEXT *);
538 +int mutt_test_compress_command (const char *);
539 +int mutt_check_mailbox_compressed (CONTEXT *);
540 +void mutt_fast_close_compressed (CONTEXT *);
541 diff -urN mutt-1.5.10/config.h.in mutt-1.5.10-ro/config.h.in
542 diff -urN mutt-1.5.10/configure mutt-1.5.10-ro/configure
543 diff -urN mutt-1.5.10/configure.in mutt-1.5.10-ro/configure.in
544 --- mutt-1.5.10/configure.in 2005-08-11 23:49:24.000000000 +0200
545 +++ mutt-1.5.10-ro/configure.in 2005-08-14 12:10:21.000000000 +0200
547 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
550 +AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
551 + [if test x$enableval = xyes; then
552 + AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
555 AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
556 [if test $withval != yes; then
557 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
558 diff -urN mutt-1.5.10/curs_main.c mutt-1.5.10-ro/curs_main.c
559 --- mutt-1.5.10/curs_main.c 2005-08-11 21:37:01.000000000 +0200
560 +++ mutt-1.5.10-ro/curs_main.c 2005-08-14 12:10:21.000000000 +0200
561 @@ -1087,6 +1087,11 @@
565 +#ifdef USE_COMPRESSED
566 + if (Context->compressinfo && Context->realpath)
567 + mutt_str_replace (&LastFolder, Context->realpath);
570 mutt_str_replace (&LastFolder, Context->path);
571 oldcount = Context ? Context->msgcount : 0;
573 diff -urN mutt-1.5.10/doc/manual-4.html mutt-1.5.10-ro/doc/manual-4.html
574 diff -urN mutt-1.5.10/doc/manual-6.html mutt-1.5.10-ro/doc/manual-6.html
575 diff -urN mutt-1.5.10/doc/manual.html mutt-1.5.10-ro/doc/manual.html
576 diff -urN mutt-1.5.10/doc/manual.sgml mutt-1.5.10-ro/doc/manual.sgml
577 diff -urN mutt-1.5.10/doc/manual.sgml.head mutt-1.5.10-ro/doc/manual.sgml.head
578 --- mutt-1.5.10/doc/manual.sgml.head 2005-08-11 21:37:02.000000000 +0200
579 +++ mutt-1.5.10-ro/doc/manual.sgml.head 2005-08-14 12:10:21.000000000 +0200
580 @@ -2576,6 +2576,176 @@
581 macro pager \cb |urlview\n
584 +<sect1>Compressed folders Support (OPTIONAL)
587 +If Mutt was compiled with compressed folders support (by running the
588 +<em/configure/ script with the <em/--enable-compressed/ flag), Mutt
589 +can open folders stored in an arbitrary format, provided that the user
590 +has a script to convert from/to this format to one of the accepted.
592 +The most common use is to open compressed archived folders e.g. with
595 +In addition, the user can provide a script that gets a folder in an
596 +accepted format and appends its context to the folder in the
597 +user-defined format, which may be faster than converting the entire
598 +folder to the accepted format, appending to it and converting back to
599 +the user-defined format.
601 +There are three hooks defined (<ref id="open-hook" name="open-hook">,
602 +<ref id="close-hook" name="close-hook"> and <ref id="append-hook"
603 +name="append-hook">) which define commands to uncompress and compress
604 +a folder and to append messages to an existing compressed folder
610 +open-hook \\.gz$ "gzip -cd %f > %t"
611 +close-hook \\.gz$ "gzip -c %t > %f"
612 +append-hook \\.gz$ "gzip -c %t >> %f"
615 +You do not have to specify all of the commands. If you omit <ref
616 +id="append-hook" name="append-hook">, the folder will be open and
617 +closed again each time you will add to it. If you omit <ref
618 +id="close-hook" name="close-hook"> (or give empty command) , the
619 +folder will be open in the mode. If you specify <ref
620 +id="append-hook" name="append-hook"> though you'll be able to append
623 +Note that Mutt will only try to use hooks if the file is not in one of
624 +the accepted formats. In particular, if the file is empty, mutt
625 +supposes it is not compressed. This is important because it allows the
626 +use of programs that do not have well defined extensions. Just use
627 +&dquot;.&dquot; as a regexp. But this may be surprising if your
628 +compressing script produces empty files. In this situation, unset <ref
629 +id="save_empty" name="$save_empty">, so that the compressed file
630 +will be removed if you delete all of the messages.
632 +<sect2>Open a compressed mailbox for reading<label id="open-hook">
634 +Usage: <tt/open-hook/ <em/regexp/ &dquot;<em/command/&dquot;
636 +The <em/command/ is the command that can be used for opening the
637 +folders whose names match <em/regexp/.
639 +The <em/command/ string is the printf-like format string, and it
640 +should accept two parameters: %f, which is replaced with the
641 +(compressed) folder name, and %t which is replaced with the
642 +name of the temporary folder to which to write.
644 +%f and %t can be repeated any number of times in the
645 +command string, and all of the entries are replaced with the
646 +appropriate folder name. In addition, %% is replaced by
647 +%, as in printf, and any other %anything is left as is.
649 +The <em/command/ should <bf/not/ remove the original compressed file.
650 +The <em/command/ should return non-zero exit status if it fails, so
651 +mutt knows something's wrong.
656 +open-hook \\.gz$ "gzip -cd %f > %t"
659 +If the <em/command/ is empty, this operation is disabled for this file
662 +<sect2>Write a compressed mailbox<label id="close-hook">
664 +Usage: <tt/close-hook/ <em/regexp/ &dquot;<em/command/&dquot;
666 +This is used to close the folder that was open with the <ref id="open-hook"
667 +name="open-hook"> command after some changes were made to it.
669 +The <em/command/ string is the command that can be used for closing the
670 +folders whose names match <em/regexp/. It has the same format as in
671 +the <ref id="open-hook" name="open-hook"> command. Temporary folder
672 +in this case is the folder previously produced by the <ref id="open-hook"
673 +name="open-hook"> command.
675 +The <em/command/ should <bf/not/ remove the decompressed file. The
676 +<em/command/ should return non-zero exit status if it fails, so mutt
677 +knows something's wrong.
682 +close-hook \\.gz$ "gzip -c %t > %f"
685 +If the <em/command/ is empty, this operation is disabled for this file
686 +type, and the file can only be open in the read-only mode.
688 +<ref id="close-hook" name ="close-hook"> is not called when you exit
689 +from the folder if the folder was not changed.
691 +<sect2>Append a message to a compressed mailbox<label id="append-hook">
693 +Usage: <tt/append-hook/ <em/regexp/ &dquot;<em/command/&dquot;
695 +This command is used for saving to an existing compressed folder.
696 +The <em/command/ is the command that can be used for appending to the
697 +folders whose names match <em/regexp/. It has the same format as in
698 + the <ref id="open-hook" name="open-hook"> command.
699 +The temporary folder in this case contains the messages that are being
702 +The <em/command/ should <bf/not/ remove the decompressed file. The
703 +<em/command/ should return non-zero exit status if it fails, so mutt
704 +knows something's wrong.
709 +append-hook \\.gz$ "gzip -c %t >> %f"
712 +When <ref id="append-hook" name="append-hook"> is used, the folder is
713 +not opened, which saves time, but this means that we can not find out
714 +what the folder type is. Thus the default (<ref id="mbox_type"
715 +name="$mbox_type">) type is always supposed (i.e.
716 +this is the format used for the temporary folder).
718 +If the file does not exist when you save to it, <ref id="close-hook"
719 +name="close-hook"> is called, and not <ref id="append-hook"
720 +name="append-hook">. <ref id="append-hook" name="append-hook"> is only
721 +for appending to existing folders.
723 +If the <em/command/ is empty, this operation is disabled for this file
724 +type. In this case, the folder will be open and closed again (using
725 +<ref id="open-hook" name="open-hook"> and <ref id="close-hook"
726 +name="close-hook">respectively) each time you will add to it.
728 +<sect2>Encrypted folders
730 +The compressed folders support can also be used to handle encrypted
731 +folders. If you want to encrypt a folder with PGP, you may want to use
732 +the following hooks:
735 +open-hook \\.pgp$ "pgp -f < %f > %t"
736 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
739 +Please note, that PGP does not support appending to an encrypted
740 +folder, so there is no append-hook defined.
742 +If you are using GnuPG instead of PGP, you may use the following hooks
746 +open-hook \\.gpg$ "gpg --decrypt < %f > %t"
747 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
750 +<bf/Note:/ the folder is temporary stored decrypted in the /tmp
751 +directory, where it can be read by your system administrator. So think
752 +about the security aspects of this.
754 <sect>Mutt's MIME Support
756 Quite a bit of effort has been made to make Mutt the premier text-mode
757 @@ -3156,6 +3326,8 @@
759 <tt><ref id="alternative_order" name="unalternative_order"></tt> <em/mimetype/ [ <em/mimetype/ ... ]
761 +<tt><ref id="append-hook" name="append-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
763 <tt><ref id="auto_view" name="auto_view"></tt> <em/mimetype/ [ <em/mimetype/ ... ]
765 <tt><ref id="auto_view" name="unauto_view"></tt> <em/mimetype/ [ <em/mimetype/ ... ]
766 @@ -3164,6 +3336,8 @@
768 <tt><ref id="charset-hook" name="charset-hook"></tt> <em/alias/ <em/charset/
770 +<tt><ref id="close-hook" name="close-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
772 <tt><ref id="color" name="color"></tt> <em/object/ <em/foreground/ <em/background/ [ <em/regexp/ ]
774 <tt><ref id="color" name="uncolor"></tt> <em/index/ <em/pattern/ [ <em/pattern/ ... ]
775 @@ -3210,6 +3384,8 @@
777 <tt><ref id="my_hdr" name="unmy_hdr"></tt> <em/field/ [ <em/field/ ... ]
779 +<tt><ref id="open-hook" name="open-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
781 <tt><ref id="crypt-hook" name="crypt-hook"></tt> <em/pattern/ <em/key-id/
783 <tt><ref id="push" name="push"></tt> <em/string/
784 diff -urN mutt-1.5.10/doc/manual.txt mutt-1.5.10-ro/doc/manual.txt
785 diff -urN mutt-1.5.10/doc/muttrc.man mutt-1.5.10-ro/doc/muttrc.man
786 diff -urN mutt-1.5.10/doc/muttrc.man.head mutt-1.5.10-ro/doc/muttrc.man.head
787 --- mutt-1.5.10/doc/muttrc.man.head 2005-01-15 10:42:45.000000000 +0100
788 +++ mutt-1.5.10-ro/doc/muttrc.man.head 2005-08-14 12:10:21.000000000 +0200
790 to a certain recipient. The meaning of "key ID" is to be taken
791 broadly: This can be a different e-mail address, a numerical key ID,
792 or even just an arbitrary search string.
795 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
796 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
797 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
800 +These commands provide a way to handle compressed folders. The given
801 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
802 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
803 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
804 +compressed mail to a compressed folder (\fBappend-hook\fP). The
805 +\fIcommand\fP string is the
807 +like format string, and it should accept two parameters: \fB%f\fP,
808 +which is replaced with the (compressed) folder name, and \fB%t\fP
809 +which is replaced with the name of the temporary folder to which to
812 \fBpush\fP \fIstring\fP
813 This command adds the named \fIstring\fP to the keyboard buffer.
814 diff -urN mutt-1.5.10/hook.c mutt-1.5.10-ro/hook.c
815 --- mutt-1.5.10/hook.c 2005-02-03 19:47:52.000000000 +0100
816 +++ mutt-1.5.10-ro/hook.c 2005-08-14 12:10:21.000000000 +0200
819 #include "mutt_crypt.h"
821 +#ifdef USE_COMPRESSED
822 +#include "compress.h"
829 memset (&pattern, 0, sizeof (pattern));
830 pattern.data = safe_strdup (path);
832 +#ifdef USE_COMPRESSED
833 + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
835 + if (mutt_test_compress_command (command.data))
837 + strfcpy (err->data, _("bad formatted command string"), err->dsize);
842 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ACCOUNTHOOK))
843 && (!WithCrypto || !(data & M_CRYPTHOOK))
845 diff -urN mutt-1.5.10/init.h mutt-1.5.10-ro/init.h
846 --- mutt-1.5.10/init.h 2005-08-11 21:37:01.000000000 +0200
847 +++ mutt-1.5.10-ro/init.h 2005-08-14 12:10:21.000000000 +0200
848 @@ -2979,6 +2979,11 @@
849 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
850 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
851 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
852 +#ifdef USE_COMPRESSED
853 + { "open-hook", mutt_parse_hook, M_OPENHOOK },
854 + { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
855 + { "append-hook", mutt_parse_hook, M_APPENDHOOK },
857 { "hdr_order", parse_list, UL &HeaderOrderList },
859 { "iconv-hook", mutt_parse_hook, M_ICONVHOOK },
860 diff -urN mutt-1.5.10/main.c mutt-1.5.10-ro/main.c
861 --- mutt-1.5.10/main.c 2005-08-11 21:37:01.000000000 +0200
862 +++ mutt-1.5.10-ro/main.c 2005-08-14 12:10:21.000000000 +0200
868 +#ifdef USE_COMPRESSED
876 diff -urN mutt-1.5.10/Makefile.am mutt-1.5.10-ro/Makefile.am
877 --- mutt-1.5.10/Makefile.am 2005-08-11 23:27:28.000000000 +0200
878 +++ mutt-1.5.10-ro/Makefile.am 2005-08-14 12:10:21.000000000 +0200
880 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
881 mutt_SOURCES = $(BUILT_SOURCES) \
882 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
883 - crypt.c cryptglue.c \
884 + crypt.c cryptglue.c compress.c \
885 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
886 edit.c enter.c flags.c init.c filter.c from.c getdomain.c \
887 handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c \
889 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c
891 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \
892 - configure account.h \
893 + configure account.h compress.h \
894 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
895 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
896 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
897 diff -urN mutt-1.5.10/Makefile.in mutt-1.5.10-ro/Makefile.in
898 diff -urN mutt-1.5.10/mbox.c mutt-1.5.10-ro/mbox.c
899 --- mutt-1.5.10/mbox.c 2005-08-02 09:08:00.000000000 +0200
900 +++ mutt-1.5.10-ro/mbox.c 2005-08-14 12:10:21.000000000 +0200
905 +#ifdef USE_COMPRESSED
906 +#include "compress.h"
909 #include <sys/stat.h>
912 @@ -1014,6 +1018,12 @@
913 int mbox_close_mailbox (CONTEXT *ctx)
915 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
917 +#ifdef USE_COMPRESSED
918 + if (ctx->compressinfo)
919 + mutt_slow_close_compressed (ctx);
922 mutt_unblock_signals ();
923 mx_fastclose_mailbox (ctx);
925 diff -urN mutt-1.5.10/mutt.h mutt-1.5.10-ro/mutt.h
926 --- mutt-1.5.10/mutt.h 2005-08-11 21:37:23.000000000 +0200
927 +++ mutt-1.5.10-ro/mutt.h 2005-08-14 12:10:21.000000000 +0200
929 #define M_ACCOUNTHOOK (1<<9)
930 #define M_REPLYHOOK (1<<10)
931 #define M_SEND2HOOK (1<<11)
932 +#ifdef USE_COMPRESSED
933 +#define M_OPENHOOK (1<<12)
934 +#define M_APPENDHOOK (1<<13)
935 +#define M_CLOSEHOOK (1<<14)
938 /* tree characters for linearize_tree and print_enriched_string */
939 #define M_TREE_LLCORNER 1
941 void *data; /* driver specific data */
942 #endif /* USE_IMAP */
944 +#ifdef USE_COMPRESSED
945 + void *compressinfo; /* compressed mbox module private data */
946 + char *realpath; /* path to compressed mailbox */
947 +#endif /* USE_COMPRESSED */
949 short magic; /* mailbox type */
951 unsigned int locked : 1; /* is the mailbox locked? */
952 diff -urN mutt-1.5.10/Muttrc mutt-1.5.10-ro/Muttrc
953 diff -urN mutt-1.5.10/Muttrc.head mutt-1.5.10-ro/Muttrc.head
954 diff -urN mutt-1.5.10/Muttrc.head.in mutt-1.5.10-ro/Muttrc.head.in
955 diff -urN mutt-1.5.10/mx.c mutt-1.5.10-ro/mx.c
956 --- mutt-1.5.10/mx.c 2005-08-02 09:08:01.000000000 +0200
957 +++ mutt-1.5.10-ro/mx.c 2005-08-14 12:10:21.000000000 +0200
962 +#ifdef USE_COMPRESSED
963 +#include "compress.h"
973 +#ifdef USE_COMPRESSED
974 + if (magic == 0 && mutt_can_read_compressed (path))
975 + return M_COMPRESSED;
984 +#ifdef USE_COMPRESSED
985 + /* special case for appending to compressed folders -
986 + * even if we can not open them for reading */
987 + if (mutt_can_append_compressed (ctx->path))
988 + mutt_open_append_compressed (ctx);
997 ctx->magic = mx_get_magic (path);
1000 +#ifdef USE_COMPRESSED
1001 + if (ctx->magic == M_COMPRESSED)
1002 + mutt_open_read_compressed (ctx);
1006 mutt_error (_("%s is not a mailbox."), path);
1008 @@ -759,6 +779,10 @@
1009 mutt_free_header (&ctx->hdrs[i]);
1012 +#ifdef USE_COMPRESSED
1013 + if (ctx->compressinfo)
1014 + mutt_fast_close_compressed (ctx);
1017 FREE (&ctx->pattern);
1018 if (ctx->limit_pattern)
1019 @@ -816,6 +840,12 @@
1020 if (tmp && tmp->new == 0)
1021 mutt_update_mailbox (tmp);
1024 +#ifdef USE_COMPRESSED
1025 + if (rc == 0 && ctx->compressinfo)
1026 + return mutt_sync_compressed (ctx);
1032 @@ -1021,6 +1051,11 @@
1033 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1034 mx_unlink_empty (ctx->path);
1036 +#ifdef USE_COMPRESSED
1037 + if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1041 mx_fastclose_mailbox (ctx);
1044 @@ -1330,6 +1365,11 @@
1048 +#ifdef USE_COMPRESSED
1049 + if (ctx->compressinfo)
1050 + return mutt_check_mailbox_compressed (ctx);
1055 if (ctx->locked) lock = 0;
1056 diff -urN mutt-1.5.10/mx.h mutt-1.5.10-ro/mx.h
1057 --- mutt-1.5.10/mx.h 2003-08-05 15:58:16.000000000 +0200
1058 +++ mutt-1.5.10-ro/mx.h 2005-08-14 12:10:21.000000000 +0200
1063 +#ifdef USE_COMPRESSED
1068 WHERE short DefaultMagic INITVAL (M_MBOX);
1069 diff -urN mutt-1.5.10/PATCHES mutt-1.5.10-ro/PATCHES
1070 --- mutt-1.5.10/PATCHES 2005-08-11 23:27:30.000000000 +0200
1071 +++ mutt-1.5.10-ro/PATCHES 2005-08-14 12:10:35.000000000 +0200
1073 +patch-1.5.10.rr.compressed.1
1074 diff -urN mutt-1.5.10/po/de.po mutt-1.5.10-ro/po/de.po
1075 --- mutt-1.5.10/po/de.po 2005-08-11 23:50:35.000000000 +0200
1076 +++ mutt-1.5.10-ro/po/de.po 2005-08-14 12:12:20.000000000 +0200
1077 @@ -1281,6 +1281,48 @@
1078 msgid "Failed to figure out sender"
1079 msgstr "Kann Datei nicht öffnen, um Nachrichtenkopf zu untersuchen."
1081 +#: compress.c:203 mbox.c:661
1082 +msgid "Mailbox was corrupted!"
1083 +msgstr "Mailbox wurde zerstört!"
1085 +#: compress.c:228 compress.c:253
1087 +msgid "Decompressing %s...\n"
1088 +msgstr "Entpacke %s...\n"
1090 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1091 +msgid "Unable to lock mailbox!"
1092 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1096 +msgid "Error executing: %s : unable to open the mailbox!\n"
1097 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1099 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1101 +msgid "Compressing %s...\n"
1102 +msgstr "Komprimiere %s...\n"
1107 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1110 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1111 +"entpackte gespeichert!\n"
1113 +#: compress.c:425 compress.c:456
1115 +msgid "Compressed-appending to %s...\n"
1116 +msgstr "Hänge komprimiert an %s... an\n"
1120 +msgid " %s: Error compressing mailbox! Uncompressed one kept!\n"
1121 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1125 msgid " (current time: %c)"
1126 @@ -1901,6 +1943,10 @@
1128 msgstr "Hilfe für %s"
1131 +msgid "bad formatted command string"
1132 +msgstr "Hook enthält nicht die Muster %f und %t"
1136 msgid "unhook: Can't do unhook * from within a hook."
1137 @@ -3383,18 +3429,10 @@
1138 msgid "Mailbox is corrupt!"
1139 msgstr "Mailbox fehlerhaft!"
1142 -msgid "Mailbox was corrupted!"
1143 -msgstr "Mailbox wurde zerstört!"
1145 #: mbox.c:701 mbox.c:952
1146 msgid "Fatal error! Could not reopen mailbox!"
1147 msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1150 -msgid "Unable to lock mailbox!"
1151 -msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1153 #. this means ctx->changed or ctx->deleted was set, but no
1154 #. * messages were found to be changed or deleted. This should
1155 #. * never happen, is we presume it is a bug in mutt.
1156 diff -urN mutt-1.5.10/po/POTFILES.in mutt-1.5.10-ro/po/POTFILES.in
1157 --- mutt-1.5.10/po/POTFILES.in 2005-08-03 11:17:47.000000000 +0200
1158 +++ mutt-1.5.10-ro/po/POTFILES.in 2005-08-14 12:13:18.000000000 +0200
1167 diff -urN mutt-1.5.10/status.c mutt-1.5.10-ro/status.c
1168 --- mutt-1.5.10/status.c 2005-02-03 19:47:53.000000000 +0100
1169 +++ mutt-1.5.10-ro/status.c 2005-08-14 12:10:21.000000000 +0200
1173 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1174 +#ifdef USE_COMPRESSED
1175 + if (Context && Context->compressinfo && Context->realpath)
1177 + strfcpy (tmp, Context->realpath, sizeof (tmp));
1178 + mutt_pretty_mailbox (tmp);
1182 if (Context && Context->path)
1184 strfcpy (tmp, Context->path, sizeof (tmp));