Репозитории ALT
S: | 2.1.1.0.3.g6c0f75cca-alt1 |
5.1: | 1.4.2.3-alt3 |
4.1: | 1.4.2.3-alt1 |
4.0: | 1.4.2.3-alt1 |
3.0: | 1.4.2.1i-alt4 |
Группа :: Сети/Почта
Пакет: mutt
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: mutt-1.4.2.2-vvv-compressed.patch
Скачать
Скачать
diff -udprP mutt-1.4.2.2.orig/acconfig.h mutt-1.4.2.2/acconfig.h
--- mutt-1.4.2.2.orig/acconfig.h 2002-01-16 00:08:12.000000000 +0200
+++ mutt-1.4.2.2/acconfig.h 2006-07-18 12:32:38.000000000 +0300
@@ -55,3 +55,6 @@
* all return values other than (size_t)(-1) as equivalent. */
#undef ICONV_NONTRANS
+/* The compressed mailboxes support */
+#undef USE_COMPRESSED
+
diff -udprP mutt-1.4.2.2.orig/compress.c mutt-1.4.2.2/compress.c
--- mutt-1.4.2.2.orig/compress.c 1970-01-01 03:00:00.000000000 +0300
+++ mutt-1.4.2.2/compress.c 2006-07-18 12:32:38.000000000 +0300
@@ -0,0 +1,486 @@
+/*
+ * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "mutt.h"
+
+#ifdef USE_COMPRESSED
+
+#include "mx.h"
+#include "mailbox.h"
+#include "mutt_curses.h"
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+typedef struct
+{
+ const char *close; /* close-hook command */
+ const char *open; /* open-hook command */
+ const char *append; /* append-hook command */
+ off_t size; /* size of real folder */
+} COMPRESS_INFO;
+
+char echo_cmd[HUGE_STRING];
+
+/* parameters:
+ * ctx - context to lock
+ * excl - exclusive lock?
+ * retry - should retry if unable to lock?
+ */
+int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
+{
+ int r;
+
+ if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
+ ctx->locked = 1;
+ else if (retry && !excl)
+ {
+ ctx->readonly = 1;
+ return 0;
+ }
+
+ return (r);
+}
+
+void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
+{
+ if (ctx->locked)
+ {
+ fflush (fp);
+
+ mx_unlock_file (ctx->realpath, fileno (fp), 1);
+ ctx->locked = 0;
+ }
+}
+
+static int is_new (const char *path)
+{
+ return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
+}
+
+static const char* find_compress_hook (int type, const char *path)
+{
+ const char* c = mutt_find_hook (type, path);
+ return (!c || !*c) ? NULL : c;
+}
+
+int mutt_can_read_compressed (const char *path)
+{
+ return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
+}
+
+/* if the file is new, we really do not append, but create, and so use
+ * close-hook, and not append-hook
+ */
+static const char* get_append_command (const char *path, const CONTEXT* ctx)
+{
+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
+ return (is_new (path)) ? ci->close : ci->append;
+}
+
+int mutt_can_append_compressed (const char *path)
+{
+ int magic;
+
+ if (is_new (path))
+ return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
+
+ magic = mx_get_magic (path);
+
+ if (magic != 0 && magic != M_COMPRESSED)
+ return 0;
+
+ return (find_compress_hook (M_APPENDHOOK, path)
+ || (find_compress_hook (M_OPENHOOK, path)
+ && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
+}
+
+/* open a compressed mailbox */
+static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
+{
+ COMPRESS_INFO *ci;
+
+ /* Now lets uncompress this thing */
+ ci = safe_malloc (sizeof (COMPRESS_INFO));
+ ctx->compressinfo = (void*) ci;
+ ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
+ ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
+ ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
+ return ci;
+}
+
+static void set_path (CONTEXT* ctx)
+{
+ char tmppath[_POSIX_PATH_MAX];
+
+ /* Setup the right paths */
+ ctx->realpath = ctx->path;
+
+ /* Uncompress to /tmp */
+ mutt_mktemp (tmppath);
+ ctx->path = safe_malloc (strlen (tmppath) + 1);
+ strcpy (ctx->path, tmppath);
+}
+
+static int get_size (const char* path)
+{
+ struct stat sb;
+ if (stat (path, &sb) != 0)
+ return 0;
+ return (sb.st_size);
+}
+
+static void store_size (CONTEXT* ctx)
+{
+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
+ ci->size = get_size (ctx->realpath);
+}
+
+static const char *
+compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
+ const char *fmt, const char *ifstring,
+ const char *elsestring, unsigned long data,
+ format_flag flags)
+{
+ char tmp[SHORT_STRING];
+
+ CONTEXT *ctx = (CONTEXT *) data;
+ switch (op)
+ {
+ case 'f':
+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
+ snprintf (dest, destlen, tmp, ctx->realpath);
+ break;
+ case 't':
+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
+ snprintf (dest, destlen, tmp, ctx->path);
+ break;
+ }
+ return (src);
+}
+
+/* check that the command has both %f and %t
+ * 0 means OK, -1 means error
+ */
+int mutt_test_compress_command (const char* cmd)
+{
+ return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
+}
+
+static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
+{
+ char expanded[_POSIX_PATH_MAX];
+ mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str,
+ (unsigned long) ctx, 0);
+ return safe_strdup (expanded);
+}
+
+int mutt_check_mailbox_compressed (CONTEXT* ctx)
+{
+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
+ if (ci->size != get_size (ctx->realpath))
+ {
+ safe_free ((void**)&ctx->compressinfo);
+ safe_free ((void**)&ctx->realpath);
+ mutt_error _("Mailbox was corrupted!");
+ return (-1);
+ }
+ return (0);
+}
+
+int mutt_open_read_compressed (CONTEXT *ctx)
+{
+ char *cmd;
+ FILE *fp;
+ int rc;
+
+ COMPRESS_INFO *ci = set_compress_info (ctx);
+ if (!ci->open) {
+ ctx->magic = 0;
+ safe_free ((void**)ctx->compressinfo);
+ return (-1);
+ }
+ if (!ci->close || access (ctx->path, W_OK) != 0)
+ ctx->readonly = 1;
+
+ set_path (ctx);
+ store_size (ctx);
+
+ if (!ctx->quiet)
+ mutt_message (_("Decompressing %s..."), ctx->realpath);
+
+ cmd = get_compression_cmd (ci->open, ctx);
+ if (cmd == NULL)
+ return (-1);
+ dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
+
+ if ((fp = fopen (ctx->realpath, "r")) == NULL)
+ {
+ mutt_perror (ctx->realpath);
+ safe_free ((void **)&cmd);
+ return (-1);
+ }
+ mutt_block_signals ();
+ if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
+ {
+ fclose (fp);
+ mutt_unblock_signals ();
+ mutt_error _("Unable to lock mailbox!");
+ safe_free ((void **)&cmd);
+ return (-1);
+ }
+
+ endwin ();
+ fflush (stdout);
+ sprintf(echo_cmd,_("echo Decompressing %s..."),ctx->realpath);
+ mutt_system(echo_cmd);
+ rc = mutt_system (cmd);
+ mbox_unlock_compressed (ctx, fp);
+ mutt_unblock_signals ();
+ fclose (fp);
+
+ if (rc)
+ {
+ mutt_any_key_to_continue (NULL);
+ ctx->magic = 0;
+ safe_free ((void**)ctx->compressinfo);
+ mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
+ }
+ safe_free ((void **)&cmd);
+ if (rc)
+ return (-1);
+
+ if (mutt_check_mailbox_compressed (ctx))
+ return (-1);
+
+ ctx->magic = mx_get_magic (ctx->path);
+
+ return (0);
+}
+
+void restore_path (CONTEXT* ctx)
+{
+ safe_free ((void **)&ctx->path);
+ ctx->path = ctx->realpath;
+}
+
+/* remove the temporary mailbox */
+void remove_file (CONTEXT* ctx)
+{
+ if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
+ remove (ctx->path);
+}
+
+int mutt_open_append_compressed (CONTEXT *ctx)
+{
+ FILE *fh;
+ COMPRESS_INFO *ci = set_compress_info (ctx);
+
+ if (!get_append_command (ctx->path, ctx))
+ {
+ if (ci->open && ci->close)
+ return (mutt_open_read_compressed (ctx));
+
+ ctx->magic = 0;
+ safe_free ((void**)&ctx->compressinfo);
+ return (-1);
+ }
+
+ set_path (ctx);
+
+ ctx->magic = DefaultMagic;
+
+ if (!is_new (ctx->realpath))
+ if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
+ if ((fh = fopen (ctx->path, "w")))
+ fclose (fh);
+ /* No error checking - the parent function will catch it */
+
+ return (0);
+}
+
+/* close a compressed mailbox */
+void mutt_fast_close_compressed (CONTEXT *ctx)
+{
+ dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
+ ctx->path));
+
+ if (ctx->compressinfo)
+ {
+ if (ctx->fp)
+ fclose (ctx->fp);
+ ctx->fp = NULL;
+ /* if the folder was removed, remove the gzipped folder too */
+ if (access (ctx->path, F_OK) != 0 && ! option (OPTSAVEEMPTY))
+ remove (ctx->realpath);
+ else
+ remove_file (ctx);
+
+ restore_path (ctx);
+ safe_free ((void**)&ctx->compressinfo);
+ }
+}
+
+/* return 0 on success, -1 on failure */
+int mutt_sync_compressed (CONTEXT* ctx)
+{
+ char *cmd;
+ int rc = 0;
+ FILE *fp;
+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
+
+ if (!ctx->quiet)
+ mutt_message (_("Compressing %s..."), ctx->realpath);
+
+ cmd = get_compression_cmd (ci->close, ctx);
+ if (cmd == NULL)
+ return (-1);
+
+ if ((fp = fopen (ctx->realpath, "a")) == NULL)
+ {
+ mutt_perror (ctx->realpath);
+ safe_free ((void **)&cmd);
+ return (-1);
+ }
+ mutt_block_signals ();
+ if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
+ {
+ fclose (fp);
+ mutt_unblock_signals ();
+ mutt_error _("Unable to lock mailbox!");
+
+ store_size (ctx);
+
+ safe_free ((void **)&cmd);
+ return (-1);
+ }
+
+ dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
+
+ endwin ();
+ fflush (stdout);
+ sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath);
+ mutt_system(echo_cmd);
+ if (mutt_system (cmd))
+ {
+ mutt_any_key_to_continue (NULL);
+ mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
+ rc = -1;
+ }
+
+ mbox_unlock_compressed (ctx, fp);
+ mutt_unblock_signals ();
+ fclose (fp);
+
+ safe_free ((void **)&cmd);
+
+ store_size (ctx);
+
+ return (rc);
+}
+
+int mutt_slow_close_compressed (CONTEXT *ctx)
+{
+ FILE *fp;
+ const char *append;
+ char *cmd;
+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
+
+ dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
+ ctx->path));
+
+ if (! (ctx->append
+ && ((append = get_append_command (ctx->realpath, ctx))
+ || (append = ci->close))))
+ { /* if we can not or should not append,
+ * we only have to remove the compressed info, because sync was already
+ * called
+ */
+ mutt_fast_close_compressed (ctx);
+ return (0);
+ }
+
+ if (ctx->fp)
+ fclose (ctx->fp);
+ ctx->fp = NULL;
+
+ if (!ctx->quiet)
+ {
+ if (append == ci->close)
+ mutt_message (_("Compressing %s..."), ctx->realpath);
+ else
+ mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
+ }
+
+ cmd = get_compression_cmd (append, ctx);
+ if (cmd == NULL)
+ return (-1);
+
+ if ((fp = fopen (ctx->realpath, "a")) == NULL)
+ {
+ mutt_perror (ctx->realpath);
+ safe_free ((void **)&cmd);
+ return (-1);
+ }
+ mutt_block_signals ();
+ if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
+ {
+ fclose (fp);
+ mutt_unblock_signals ();
+ mutt_error _("Unable to lock mailbox!");
+ safe_free ((void **)&cmd);
+ return (-1);
+ }
+
+ dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
+
+ endwin ();
+ fflush (stdout);
+
+ if (append == ci->close)
+ sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath);
+ else
+ sprintf(echo_cmd,_("echo Compressed-appending to %s..."), ctx->realpath);
+ mutt_system(echo_cmd);
+
+ if (mutt_system (cmd))
+ {
+ mutt_any_key_to_continue (NULL);
+ mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
+ ctx->path);
+ safe_free ((void **)&cmd);
+ mbox_unlock_compressed (ctx, fp);
+ mutt_unblock_signals ();
+ fclose (fp);
+ return (-1);
+ }
+
+ mbox_unlock_compressed (ctx, fp);
+ mutt_unblock_signals ();
+ fclose (fp);
+ remove_file (ctx);
+ restore_path (ctx);
+ safe_free ((void **)&cmd);
+ safe_free ((void **)&ctx->compressinfo);
+
+ return (0);
+}
+
+#endif /* USE_COMPRESSED */
diff -udprP mutt-1.4.2.2.orig/compress.h mutt-1.4.2.2/compress.h
--- mutt-1.4.2.2.orig/compress.h 1970-01-01 03:00:00.000000000 +0300
+++ mutt-1.4.2.2/compress.h 2006-07-18 12:32:38.000000000 +0300
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+int mutt_can_read_compressed (const char *);
+int mutt_can_append_compressed (const char *);
+int mutt_open_read_compressed (CONTEXT *);
+int mutt_open_append_compressed (CONTEXT *);
+int mutt_slow_close_compressed (CONTEXT *);
+int mutt_sync_compressed (CONTEXT *);
+int mutt_test_compress_command (const char *);
+int mutt_check_mailbox_compressed (CONTEXT *);
+void mutt_fast_close_compressed (CONTEXT *);
diff -udprP mutt-1.4.2.2.orig/config.h.in mutt-1.4.2.2/config.h.in
--- mutt-1.4.2.2.orig/config.h.in 2006-07-14 21:38:56.000000000 +0300
+++ mutt-1.4.2.2/config.h.in 2006-07-18 12:33:42.000000000 +0300
@@ -432,6 +432,9 @@
/* Define to enable Sun mailtool attachments support. */
#undef SUN_ATTACHMENT
+/* The compressed mailboxes support */
+#undef USE_COMPRESSED
+
/* Define to use dotlocking for mailboxes. */
#undef USE_DOTLOCK
diff -udprP mutt-1.4.2.2.orig/configure mutt-1.4.2.2/configure
--- mutt-1.4.2.2.orig/configure 2006-07-14 21:38:42.000000000 +0300
+++ mutt-1.4.2.2/configure 2006-07-18 12:35:20.000000000 +0300
@@ -862,6 +862,7 @@ Optional Features:
--enable-nfs-fix Work around an NFS with broken attributes caching
--enable-buffy-size Use file size attribute instead of access time
--enable-mailtool Enable Sun mailtool attachments support
+ --enable-compressed Enable compressed folders support
--enable-locales-fix The result of isprint() is unreliable
--enable-exact-address Enable regeneration of email addresses
--disable-iconv Disable iconv support
@@ -10070,6 +10071,18 @@ echo "${ECHO_T}$mutt_cv_regex_broken" >&
fi
fi
+
+# Check whether --enable-compressed or --disable-compressed was given.
+if test "${enable_compressed+set}" = set; then
+ enableval="$enable_compressed"
+ if test x$enableval = xyes; then
+ cat >> confdefs.h <<\EOF
+#define USE_COMPRESSED 1
+EOF
+
+ fi
+fi
+
if test $mutt_cv_regex = yes; then
cat >>confdefs.h <<\_ACEOF
diff -udprP mutt-1.4.2.2.orig/configure.in mutt-1.4.2.2/configure.in
--- mutt-1.4.2.2.orig/configure.in 2006-07-14 21:38:34.000000000 +0300
+++ mutt-1.4.2.2/configure.in 2006-07-18 12:32:38.000000000 +0300
@@ -645,6 +645,11 @@ AC_ARG_ENABLE(mailtool, [ --enable-mail
AC_DEFINE(SUN_ATTACHMENT,1,[ Define to enable Sun mailtool attachments support. ])
fi])
+AC_ARG_ENABLE(compressed, [ --enable-compressed Enable compressed folders support ],
+ [if test x$enableval = xyes; then
+ AC_DEFINE(USE_COMPRESSED)
+ fi])
+
AC_ARG_ENABLE(locales-fix, [ --enable-locales-fix The result of isprint() is unreliable ],
[if test x$enableval = xyes; then
AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
diff -udprP mutt-1.4.2.2.orig/curs_main.c mutt-1.4.2.2/curs_main.c
--- mutt-1.4.2.2.orig/curs_main.c 2002-01-16 22:44:25.000000000 +0200
+++ mutt-1.4.2.2/curs_main.c 2006-07-18 12:32:38.000000000 +0300
@@ -1010,6 +1010,11 @@ int mutt_index_menu (void)
{
int check;
+#ifdef USE_COMPRESSED
+ if (Context->compressinfo && Context->realpath)
+ mutt_str_replace (&LastFolder, Context->realpath);
+ else
+#endif
mutt_str_replace (&LastFolder, Context->path);
oldcount = Context ? Context->msgcount : 0;
diff -udprP mutt-1.4.2.2.orig/doc/manual.sgml mutt-1.4.2.2/doc/manual.sgml
--- mutt-1.4.2.2.orig/doc/manual.sgml 2006-07-14 21:38:52.000000000 +0300
+++ mutt-1.4.2.2/doc/manual.sgml 2006-07-18 12:32:38.000000000 +0300
@@ -2336,6 +2336,168 @@ macro index \cb |urlview\n
macro pager \cb |urlview\n
</verb></tscreen>
+<sect1>Compressed folders Support (OPTIONAL)
+<p>
+
+If Mutt was compiled with compressed folders support (by running the
+<em/configure/ script with the <em/--enable-compressed/ flag), Mutt
+can open folders stored in an arbitrary format, provided that the user
+has a script to convert from/to this format to one of the accepted.
+
+The most common use is to open compressed archived folders e.g. with
+gzip.
+
+In addition, the user can provide a script that gets a folder in an
+accepted format and appends its context to the folder in the
+user-defined format, which may be faster than converting the entire
+folder to the accepted format, appending to it and converting back to
+the user-defined format.
+
+There are three hooks defined (<ref id="open-hook" name="open-hook">,
+<ref id="close-hook" name="close-hook"> and <ref id="append-hook"
+name="append-hook">) which define commands to uncompress and compress
+a folder and to append messages to an existing compressed folder
+respectively.
+
+For example:
+
+<tscreen><verb>
+open-hook \\.gz$ "gzip -cd %f > %t"
+close-hook \\.gz$ "gzip -c %t > %f"
+append-hook \\.gz$ "gzip -c %t >> %f"
+</verb></tscreen>
+
+You do not have to specify all of the commands. If you omit <ref
+id="append-hook" name="append-hook">, the folder will be open and
+closed again each time you will add to it. If you omit <ref
+id="close-hook" name="close-hook"> (or give empty command) , the
+folder will be open in the mode. If you specify <ref
+id="append-hook" name="append-hook"> though you'll be able to append
+to the folder.
+
+Note that Mutt will only try to use hooks if the file is not in one of
+the accepted formats. In particular, if the file is empty, mutt
+supposes it is not compressed. This is important because it allows the
+use of programs that do not have well defined extensions. Just use
+&dquot;.&dquot; as a regexp. But this may be surprising if your
+compressing script produces empty files. In this situation, unset <ref
+id="save_empty" name="$save_empty">, so that the compressed file
+will be removed if you delete all of the messages.
+
+<sect2>Open a compressed mailbox for reading<label id="open-hook">
+<p>
+Usage: <tt/open-hook/ <em/regexp/ &dquot;<em/command/&dquot;
+
+The <em/command/ is the command that can be used for opening the
+folders whose names match <em/regexp/.
+
+The <em/command/ string is the printf-like format string, and it
+should accept two parameters: %f, which is replaced with the
+(compressed) folder name, and %t which is replaced with the
+name of the temporary folder to which to write.
+
+%f and %t can be repeated any number of times in the
+command string, and all of the entries are replaced with the
+appropriate folder name. In addition, %% is replaced by
+%, as in printf, and any other %anything is left as is.
+
+The <em/command/ should <bf/not/ remove the original compressed file.
+The <em/command/ should return non-zero exit status if it fails, so
+mutt knows something's wrong.
+
+Example:
+
+<tscreen><verb>
+open-hook \\.gz$ "gzip -cd %f > %t"
+</verb></tscreen>
+
+If the <em/command/ is empty, this operation is disabled for this file
+type.
+
+<sect2>Write a compressed mailbox<label id="close-hook">
+<p>
+Usage: <tt/close-hook/ <em/regexp/ &dquot;<em/command/&dquot;
+
+This is used to close the folder that was open with the <ref id="open-hook"
+name="open-hook"> command after some changes were made to it.
+
+The <em/command/ string is the command that can be used for closing the
+folders whose names match <em/regexp/. It has the same format as in
+the <ref id="open-hook" name="open-hook"> command. Temporary folder
+in this case is the folder previously produced by the <<ref id="open-hook"
+name="open-hook"> command.
+
+The <em/command/ should <bf/not/ remove the decompressed file. The
+<em/command/ should return non-zero exit status if it fails, so mutt
+knows something's wrong.
+
+Example:
+
+<tscreen><verb>
+close-hook \\.gz$ "gzip -c %t > %f"
+</verb></tscreen>
+
+If the <em/command/ is empty, this operation is disabled for this file
+type, and the file can only be open in the readonly mode.
+
+<ref id="close-hook" name ="close-hook"> is not called when you exit
+from the folder if the folder was not changed.
+
+<sect2>Append a message to a compressed mailbox<label id="append-hook">
+<p>
+Usage: <tt/append-hook/ <em/regexp/ &dquot;<em/command/&dquot;
+
+This command is used for saving to an existing compressed folder.
+The <em/command/ is the command that can be used for appending to the
+folders whose names match <em/regexp/. It has the same format as in
+ the <ref id="open-hook" name="open-hook"> command.
+The temporary folder in this case contains the messages that are being
+appended.
+
+The <em/command/ should <bf/not/ remove the decompressed file. The
+<em/command/ should return non-zero exit status if it fails, so mutt
+knows something's wrong.
+
+Example:
+
+<tscreen><verb>
+append-hook \\.gz$ "gzip -c %t >> %f"
+</verb></tscreen>
+
+When <ref id="append-hook" name="append-hook"> is used, the folder is
+not opened, which saves time, but this means that we can not find out
+what the folder type is. Thus the default (<ref id="mbox_type"
+name="$mbox_type">) type is always supposed (i.e.
+this is the format used for the temporary folder).
+
+If the file does not exist when you save to it, <ref id="close-hook"
+name="close-hook"> is called, and not <ref id="append-hook"
+name="append-hook">. <ref id="append-hook" name="append-hook"> is only
+for appending to existing folders.
+
+If the <em/command/ is empty, this operation is disabled for this file
+type. In this case, the folder will be open and closed again (using
+<ref id="open-hook" name="open-hook"> and <ref id="close-hook"
+name="close-hook">respectively) each time you will add to it.
+
+<sect2>Encrypted folders
+<p>
+The compressed folders support can also be used to handle encrypted
+folders. If you want to encrypt a folder with PGP, you may want to use
+the following hooks:
+
+<tscreen><verb>
+open-hook \\.pgp$ "pgp -f < %f > %t"
+close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
+</verb></tscreen>
+
+Please note, that PGP does not support appending to an encrypted
+folder, so there is no append-hook defined.
+
+<bf/Note:/ the folder is temporary stored decrypted in the /tmp
+directory, where it can be read by your system administrator. So think
+about the security aspects of this.
+
<sect>Mutt's MIME Support
<p>
Quite a bit of effort has been made to make Mutt the premier text-mode
@@ -2887,12 +3049,16 @@ The following are the commands understoo
<item>
<tt><ref id="alternative_order" name="alternative_order"></tt> <em/mimetype/ [ <em/mimetype/ ... ]
<item>
+<tt><ref id="append-hook" name="append-hook"></tt> <em/regexp/ <em/command/
+<item>
<tt><ref id="auto_view" name="auto_view"></tt> <em/mimetype/ [ <em/mimetype/ ... ]
<item>
<tt><ref id="bind" name="bind"></tt> <em/map/ <em/key/ <em/function/
<item>
<tt><ref id="charset-hook" name="charset-hook"></tt> <em/alias/ <em/charset/
<item>
+<tt><ref id="close-hook" name="close-hook"></tt> <em/regexp/ <em/command/
+<item>
<tt><ref id="color" name="color"></tt> <em/object/ <em/foreground/ <em/background/ [ <em/regexp/ ]
<item>
<tt><ref id="color" name="uncolor"></tt> <em/index/ <em/pattern/ [ <em/pattern/ ... ]
@@ -2935,6 +3101,8 @@ The following are the commands understoo
<item>
<tt><ref id="my_hdr" name="unmy_hdr"></tt> <em/field/ [ <em/field/ ... ]
<item>
+<tt><ref id="open-hook" name="open-hook"></tt> <em/regexp/ <em/command/
+<item>
<tt><ref id="pgp-hook" name="pgp-hook"></tt> <em/pattern/ <em/key-id/
<item>
<tt><ref id="push" name="push"></tt> <em/string/
diff -udprP mutt-1.4.2.2.orig/doc/manual.sgml.head mutt-1.4.2.2/doc/manual.sgml.head
--- mutt-1.4.2.2.orig/doc/manual.sgml.head 2002-10-10 12:43:11.000000000 +0300
+++ mutt-1.4.2.2/doc/manual.sgml.head 2006-07-18 12:32:38.000000000 +0300
@@ -2336,6 +2336,168 @@ macro index \cb |urlview\n
macro pager \cb |urlview\n
</verb></tscreen>
+<sect1>Compressed folders Support (OPTIONAL)
+<p>
+
+If Mutt was compiled with compressed folders support (by running the
+<em/configure/ script with the <em/--enable-compressed/ flag), Mutt
+can open folders stored in an arbitrary format, provided that the user
+has a script to convert from/to this format to one of the accepted.
+
+The most common use is to open compressed archived folders e.g. with
+gzip.
+
+In addition, the user can provide a script that gets a folder in an
+accepted format and appends its context to the folder in the
+user-defined format, which may be faster than converting the entire
+folder to the accepted format, appending to it and converting back to
+the user-defined format.
+
+There are three hooks defined (<ref id="open-hook" name="open-hook">,
+<ref id="close-hook" name="close-hook"> and <ref id="append-hook"
+name="append-hook">) which define commands to uncompress and compress
+a folder and to append messages to an existing compressed folder
+respectively.
+
+For example:
+
+<tscreen><verb>
+open-hook \\.gz$ "gzip -cd %f > %t"
+close-hook \\.gz$ "gzip -c %t > %f"
+append-hook \\.gz$ "gzip -c %t >> %f"
+</verb></tscreen>
+
+You do not have to specify all of the commands. If you omit <ref
+id="append-hook" name="append-hook">, the folder will be open and
+closed again each time you will add to it. If you omit <ref
+id="close-hook" name="close-hook"> (or give empty command) , the
+folder will be open in the mode. If you specify <ref
+id="append-hook" name="append-hook"> though you'll be able to append
+to the folder.
+
+Note that Mutt will only try to use hooks if the file is not in one of
+the accepted formats. In particular, if the file is empty, mutt
+supposes it is not compressed. This is important because it allows the
+use of programs that do not have well defined extensions. Just use
+&dquot;.&dquot; as a regexp. But this may be surprising if your
+compressing script produces empty files. In this situation, unset <ref
+id="save_empty" name="$save_empty">, so that the compressed file
+will be removed if you delete all of the messages.
+
+<sect2>Open a compressed mailbox for reading<label id="open-hook">
+<p>
+Usage: <tt/open-hook/ <em/regexp/ &dquot;<em/command/&dquot;
+
+The <em/command/ is the command that can be used for opening the
+folders whose names match <em/regexp/.
+
+The <em/command/ string is the printf-like format string, and it
+should accept two parameters: %f, which is replaced with the
+(compressed) folder name, and %t which is replaced with the
+name of the temporary folder to which to write.
+
+%f and %t can be repeated any number of times in the
+command string, and all of the entries are replaced with the
+appropriate folder name. In addition, %% is replaced by
+%, as in printf, and any other %anything is left as is.
+
+The <em/command/ should <bf/not/ remove the original compressed file.
+The <em/command/ should return non-zero exit status if it fails, so
+mutt knows something's wrong.
+
+Example:
+
+<tscreen><verb>
+open-hook \\.gz$ "gzip -cd %f > %t"
+</verb></tscreen>
+
+If the <em/command/ is empty, this operation is disabled for this file
+type.
+
+<sect2>Write a compressed mailbox<label id="close-hook">
+<p>
+Usage: <tt/close-hook/ <em/regexp/ &dquot;<em/command/&dquot;
+
+This is used to close the folder that was open with the <ref id="open-hook"
+name="open-hook"> command after some changes were made to it.
+
+The <em/command/ string is the command that can be used for closing the
+folders whose names match <em/regexp/. It has the same format as in
+the <ref id="open-hook" name="open-hook"> command. Temporary folder
+in this case is the folder previously produced by the <<ref id="open-hook"
+name="open-hook"> command.
+
+The <em/command/ should <bf/not/ remove the decompressed file. The
+<em/command/ should return non-zero exit status if it fails, so mutt
+knows something's wrong.
+
+Example:
+
+<tscreen><verb>
+close-hook \\.gz$ "gzip -c %t > %f"
+</verb></tscreen>
+
+If the <em/command/ is empty, this operation is disabled for this file
+type, and the file can only be open in the readonly mode.
+
+<ref id="close-hook" name ="close-hook"> is not called when you exit
+from the folder if the folder was not changed.
+
+<sect2>Append a message to a compressed mailbox<label id="append-hook">
+<p>
+Usage: <tt/append-hook/ <em/regexp/ &dquot;<em/command/&dquot;
+
+This command is used for saving to an existing compressed folder.
+The <em/command/ is the command that can be used for appending to the
+folders whose names match <em/regexp/. It has the same format as in
+ the <ref id="open-hook" name="open-hook"> command.
+The temporary folder in this case contains the messages that are being
+appended.
+
+The <em/command/ should <bf/not/ remove the decompressed file. The
+<em/command/ should return non-zero exit status if it fails, so mutt
+knows something's wrong.
+
+Example:
+
+<tscreen><verb>
+append-hook \\.gz$ "gzip -c %t >> %f"
+</verb></tscreen>
+
+When <ref id="append-hook" name="append-hook"> is used, the folder is
+not opened, which saves time, but this means that we can not find out
+what the folder type is. Thus the default (<ref id="mbox_type"
+name="$mbox_type">) type is always supposed (i.e.
+this is the format used for the temporary folder).
+
+If the file does not exist when you save to it, <ref id="close-hook"
+name="close-hook"> is called, and not <ref id="append-hook"
+name="append-hook">. <ref id="append-hook" name="append-hook"> is only
+for appending to existing folders.
+
+If the <em/command/ is empty, this operation is disabled for this file
+type. In this case, the folder will be open and closed again (using
+<ref id="open-hook" name="open-hook"> and <ref id="close-hook"
+name="close-hook">respectively) each time you will add to it.
+
+<sect2>Encrypted folders
+<p>
+The compressed folders support can also be used to handle encrypted
+folders. If you want to encrypt a folder with PGP, you may want to use
+the following hooks:
+
+<tscreen><verb>
+open-hook \\.pgp$ "pgp -f < %f > %t"
+close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
+</verb></tscreen>
+
+Please note, that PGP does not support appending to an encrypted
+folder, so there is no append-hook defined.
+
+<bf/Note:/ the folder is temporary stored decrypted in the /tmp
+directory, where it can be read by your system administrator. So think
+about the security aspects of this.
+
<sect>Mutt's MIME Support
<p>
Quite a bit of effort has been made to make Mutt the premier text-mode
@@ -2887,12 +3049,16 @@ The following are the commands understoo
<item>
<tt><ref id="alternative_order" name="alternative_order"></tt> <em/mimetype/ [ <em/mimetype/ ... ]
<item>
+<tt><ref id="append-hook" name="append-hook"></tt> <em/regexp/ <em/command/
+<item>
<tt><ref id="auto_view" name="auto_view"></tt> <em/mimetype/ [ <em/mimetype/ ... ]
<item>
<tt><ref id="bind" name="bind"></tt> <em/map/ <em/key/ <em/function/
<item>
<tt><ref id="charset-hook" name="charset-hook"></tt> <em/alias/ <em/charset/
<item>
+<tt><ref id="close-hook" name="close-hook"></tt> <em/regexp/ <em/command/
+<item>
<tt><ref id="color" name="color"></tt> <em/object/ <em/foreground/ <em/background/ [ <em/regexp/ ]
<item>
<tt><ref id="color" name="uncolor"></tt> <em/index/ <em/pattern/ [ <em/pattern/ ... ]
@@ -2935,6 +3101,8 @@ The following are the commands understoo
<item>
<tt><ref id="my_hdr" name="unmy_hdr"></tt> <em/field/ [ <em/field/ ... ]
<item>
+<tt><ref id="open-hook" name="open-hook"></tt> <em/regexp/ <em/command/
+<item>
<tt><ref id="pgp-hook" name="pgp-hook"></tt> <em/pattern/ <em/key-id/
<item>
<tt><ref id="push" name="push"></tt> <em/string/
diff -udprP mutt-1.4.2.2.orig/doc/muttrc.man mutt-1.4.2.2/doc/muttrc.man
--- mutt-1.4.2.2.orig/doc/muttrc.man 2006-07-14 21:34:51.000000000 +0300
+++ mutt-1.4.2.2/doc/muttrc.man 2006-07-18 12:32:38.000000000 +0300
@@ -258,6 +258,24 @@ in the order in which they occur in the
The pgp-hook command provides a method by which you can
specify the ID of the public key to be used when encrypting messages
to a certain recipient.
+.PP
+.nf
+\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
+\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
+\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
+.fi
+.IP
+These commands provide a way to handle compressed folders. The given
+\fBregexp\fP specifies which folders are taken as compressed (e.g.
+"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
+(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
+compressed mail to a compressed folder (\fBappend-hook\fP). The
+\fIcommand\fP string is the
+.BR printf (3)
+like format string, and it should accept two parameters: \fB%f\fP,
+which is replaced with the (compressed) folder name, and \fB%t\fP
+which is replaced with the name of the temporary folder to which to
+write.
.TP
\fBpush\fP \fIstring\fP
This command adds the named \fIstring\fP to the keyboard buffer.
diff -udprP mutt-1.4.2.2.orig/doc/muttrc.man.head mutt-1.4.2.2/doc/muttrc.man.head
--- mutt-1.4.2.2.orig/doc/muttrc.man.head 2002-05-09 12:51:46.000000000 +0300
+++ mutt-1.4.2.2/doc/muttrc.man.head 2006-07-18 12:32:38.000000000 +0300
@@ -258,6 +258,24 @@ in the order in which they occur in the
The pgp-hook command provides a method by which you can
specify the ID of the public key to be used when encrypting messages
to a certain recipient.
+.PP
+.nf
+\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
+\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
+\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
+.fi
+.IP
+These commands provide a way to handle compressed folders. The given
+\fBregexp\fP specifies which folders are taken as compressed (e.g.
+"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
+(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
+compressed mail to a compressed folder (\fBappend-hook\fP). The
+\fIcommand\fP string is the
+.BR printf (3)
+like format string, and it should accept two parameters: \fB%f\fP,
+which is replaced with the (compressed) folder name, and \fB%t\fP
+which is replaced with the name of the temporary folder to which to
+write.
.TP
\fBpush\fP \fIstring\fP
This command adds the named \fIstring\fP to the keyboard buffer.
diff -udprP mutt-1.4.2.2.orig/hook.c mutt-1.4.2.2/hook.c
--- mutt-1.4.2.2.orig/hook.c 2001-06-29 13:06:14.000000000 +0300
+++ mutt-1.4.2.2/hook.c 2006-07-18 12:32:38.000000000 +0300
@@ -19,6 +19,10 @@
#include "mutt.h"
#include "mailbox.h"
+#ifdef USE_COMPRESSED
+#include "compress.h"
+#endif
+
#include <limits.h>
#include <string.h>
#include <stdlib.h>
@@ -87,6 +91,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
memset (&pattern, 0, sizeof (pattern));
pattern.data = safe_strdup (path);
}
+#ifdef USE_COMPRESSED
+ else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
+ {
+ if (mutt_test_compress_command (command.data))
+ {
+ strfcpy (err->data, _("bad formatted command string"), err->dsize);
+ return (-1);
+ }
+ }
+#endif
else if (DefaultHook && (data & (M_FOLDERHOOK | M_MBOXHOOK | M_SENDHOOK |
M_FCCHOOK | M_SAVEHOOK | M_MESSAGEHOOK)))
{
diff -udprP mutt-1.4.2.2.orig/init.h mutt-1.4.2.2/init.h
--- mutt-1.4.2.2.orig/init.h 2002-07-24 11:41:29.000000000 +0300
+++ mutt-1.4.2.2/init.h 2006-07-18 12:32:38.000000000 +0300
@@ -2468,6 +2468,11 @@ struct command_t Commands[] = {
{ "fcc-hook", mutt_parse_hook, M_FCCHOOK },
{ "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
{ "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
+#ifdef USE_COMPRESSED
+ { "open-hook", mutt_parse_hook, M_OPENHOOK },
+ { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
+ { "append-hook", mutt_parse_hook, M_APPENDHOOK },
+#endif
{ "hdr_order", parse_list, UL &HeaderOrderList },
#ifdef HAVE_ICONV
{ "iconv-hook", mutt_parse_hook, M_ICONVHOOK },
diff -udprP mutt-1.4.2.2.orig/main.c mutt-1.4.2.2/main.c
--- mutt-1.4.2.2.orig/main.c 2002-07-16 10:28:00.000000000 +0300
+++ mutt-1.4.2.2/main.c 2006-07-18 12:32:38.000000000 +0300
@@ -240,6 +240,13 @@ static void show_version (void)
"-USE_GNU_REGEX "
#endif
+#ifdef USE_COMPRESSED
+ "+"
+#else
+ "-"
+#endif
+ "COMPRESSED "
+
"\n"
#ifdef HAVE_COLOR
diff -udprP mutt-1.4.2.2.orig/Makefile.am mutt-1.4.2.2/Makefile.am
--- mutt-1.4.2.2.orig/Makefile.am 2004-02-12 10:46:17.000000000 +0200
+++ mutt-1.4.2.2/Makefile.am 2006-07-18 12:32:38.000000000 +0300
@@ -18,6 +18,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.
bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
mutt_SOURCES = $(BUILT_SOURCES) \
addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
+ compress.c \
commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
edit.c enter.c flags.c init.c filter.c from.c getdomain.c \
handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c \
@@ -70,6 +71,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
browser.h mbyte.h remailer.h url.h mutt_ssl_nss.c pgppacket.c
EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP TODO configure acconfig.h account.h \
+ compress.h \
attach.h buffy.h charset.h copy.h dotlock.h functions.h gen_defs \
globals.h hash.h history.h init.h keymap.h \
mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
diff -udprP mutt-1.4.2.2.orig/mbox.c mutt-1.4.2.2/mbox.c
--- mutt-1.4.2.2.orig/mbox.c 2002-02-28 09:59:24.000000000 +0200
+++ mutt-1.4.2.2/mbox.c 2006-07-18 12:32:38.000000000 +0300
@@ -28,6 +28,10 @@
#include "sort.h"
#include "copy.h"
+#ifdef USE_COMPRESSED
+#include "compress.h"
+#endif
+
#include <sys/stat.h>
#include <dirent.h>
#include <string.h>
@@ -1045,6 +1049,12 @@ bail: /* Come here in case of disaster
int mbox_close_mailbox (CONTEXT *ctx)
{
mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
+
+#ifdef USE_COMPRESSED
+ if (ctx->compressinfo)
+ mutt_slow_close_compressed (ctx);
+#endif
+
mutt_unblock_signals ();
mx_fastclose_mailbox (ctx);
return 0;
diff -udprP mutt-1.4.2.2.orig/mutt.h mutt-1.4.2.2/mutt.h
--- mutt-1.4.2.2.orig/mutt.h 2002-07-24 12:46:58.000000000 +0300
+++ mutt-1.4.2.2/mutt.h 2006-07-18 12:32:38.000000000 +0300
@@ -71,6 +71,11 @@
#define WHERE extern
#define INITVAL(x)
#endif
+#ifdef USE_COMPRESSED
+#define M_OPENHOOK (1<<12)
+#define M_APPENDHOOK (1<<13)
+#define M_CLOSEHOOK (1<<14)
+#endif
/* flags for mutt_copy_header() */
#define CH_UPDATE 1 /* update the status and x-status fields? */
@@ -761,6 +766,11 @@ typedef struct
short magic; /* mailbox type */
+#ifdef USE_COMPRESSED
+ void *compressinfo; /* compressed mbox module private data */
+ char *realpath; /* path to compressed mailbox */
+#endif /* USE_COMPRESSED */
+
unsigned int locked : 1; /* is the mailbox locked? */
unsigned int changed : 1; /* mailbox has been modified */
unsigned int readonly : 1; /* don't allow changes to the mailbox */
diff -udprP mutt-1.4.2.2.orig/Muttrc.head mutt-1.4.2.2/Muttrc.head
--- mutt-1.4.2.2.orig/Muttrc.head 2006-07-14 21:38:52.000000000 +0300
+++ mutt-1.4.2.2/Muttrc.head 2006-07-18 12:32:38.000000000 +0300
@@ -19,6 +19,11 @@ macro generic <f1> "!less /usr/local/doc
macro index <f1> "!less /usr/local/doc/mutt/manual.txt\n" "Show Mutt documentation"
macro pager <f1> "!less /usr/local/doc/mutt/manual.txt\n" "Show Mutt documentation"
+# Use folders which match on \\.gz$ as gzipped folders:
+# open-hook \\.gz$ "gzip -cd %f > %t"
+# close-hook \\.gz$ "gzip -c %t > %f"
+# append-hook \\.gz$ "gzip -c %t >> %f"
+
# If Mutt is unable to determine your site's domain name correctly, you can
# set the default here.
#
diff -udprP mutt-1.4.2.2.orig/mx.c mutt-1.4.2.2/mx.c
--- mutt-1.4.2.2.orig/mx.c 2002-03-20 11:53:42.000000000 +0200
+++ mutt-1.4.2.2/mx.c 2006-07-18 12:32:38.000000000 +0300
@@ -26,6 +26,10 @@
#include "keymap.h"
#include "url.h"
+#ifdef USE_COMPRESSED
+#include "compress.h"
+#endif
+
#ifdef HAVE_PGP
#include "pgp.h"
#endif
@@ -448,6 +452,10 @@ int mx_get_magic (const char *path)
return (-1);
}
+#ifdef USE_COMPRESSED
+ if (magic == 0 && mutt_can_read_compressed (path))
+ return M_COMPRESSED;
+#endif
return (magic);
}
@@ -489,6 +497,13 @@ static int mx_open_mailbox_append (CONTE
{
struct stat sb;
+#ifdef USE_COMPRESSED
+ /* special case for appending to compressed folders -
+ * even if we can not open them for reading */
+ if (mutt_can_append_compressed (ctx->path))
+ mutt_open_append_compressed (ctx);
+#endif
+
ctx->append = 1;
#ifdef USE_IMAP
@@ -649,7 +664,12 @@ CONTEXT *mx_open_mailbox (const char *pa
}
ctx->magic = mx_get_magic (path);
-
+
+#ifdef USE_COMPRESSED
+ if (ctx->magic == M_COMPRESSED)
+ mutt_open_read_compressed (ctx);
+#endif
+
if(ctx->magic == 0)
mutt_error (_("%s is not a mailbox."), path);
@@ -753,6 +773,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
mutt_free_header (&ctx->hdrs[i]);
safe_free ((void **) &ctx->hdrs);
safe_free ((void **) &ctx->v2r);
+#ifdef USE_COMPRESSED
+ if (ctx->compressinfo)
+ mutt_fast_close_compressed (ctx);
+#endif
safe_free ((void **) &ctx->path);
safe_free ((void **) &ctx->pattern);
if (ctx->limit_pattern)
@@ -810,6 +834,12 @@ static int sync_mailbox (CONTEXT *ctx, i
if (tmp && tmp->new == 0)
mutt_update_mailbox (tmp);
#endif
+
+#ifdef USE_COMPRESSED
+ if (rc == 0 && ctx->compressinfo)
+ return mutt_sync_compressed (ctx);
+#endif
+
return rc;
}
@@ -1016,6 +1046,11 @@ int mx_close_mailbox (CONTEXT *ctx, int
!mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
mx_unlink_empty (ctx->path);
+#ifdef USE_COMPRESSED
+ if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
+ return (-1);
+#endif
+
mx_fastclose_mailbox (ctx);
return 0;
@@ -1321,6 +1356,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
{
int rc;
+#ifdef USE_COMPRESSED
+ if (ctx->compressinfo)
+ return mutt_check_mailbox_compressed (ctx);
+#endif
+
if (ctx)
{
if (ctx->locked) lock = 0;
diff -udprP mutt-1.4.2.2.orig/mx.h mutt-1.4.2.2/mx.h
--- mutt-1.4.2.2.orig/mx.h 2001-10-31 11:20:38.000000000 +0200
+++ mutt-1.4.2.2/mx.h 2006-07-18 12:32:38.000000000 +0300
@@ -41,6 +41,9 @@ enum
#ifdef USE_POP
, M_POP
#endif
+#ifdef USE_COMPRESSED
+ , M_COMPRESSED
+#endif
};
WHERE short DefaultMagic INITVAL (M_MBOX);
diff -udprP mutt-1.4.2.2.orig/PATCHES mutt-1.4.2.2/PATCHES
--- mutt-1.4.2.2.orig/PATCHES 2001-11-26 21:16:52.000000000 +0200
+++ mutt-1.4.2.2/PATCHES 2006-07-18 12:32:38.000000000 +0300
@@ -0,0 +1 @@
+rr.compressed
diff -udprP mutt-1.4.2.2.orig/po/POTFILES.in mutt-1.4.2.2/po/POTFILES.in
--- mutt-1.4.2.2.orig/po/POTFILES.in 2000-10-10 22:22:48.000000000 +0300
+++ mutt-1.4.2.2/po/POTFILES.in 2006-07-18 12:32:38.000000000 +0300
@@ -8,6 +8,7 @@ charset.c
color.c
commands.c
compose.c
+compress.c
curs_lib.c
curs_main.c
edit.c
diff -udprP mutt-1.4.2.2.orig/status.c mutt-1.4.2.2/status.c
--- mutt-1.4.2.2.orig/status.c 2000-03-03 12:10:14.000000000 +0200
+++ mutt-1.4.2.2/status.c 2006-07-18 12:32:38.000000000 +0300
@@ -93,6 +93,14 @@ status_format_str (char *buf, size_t buf
case 'f':
snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
+#ifdef USE_COMPRESSED
+ if (Context && Context->compressinfo && Context->realpath)
+ {
+ strfcpy (tmp, Context->realpath, sizeof (tmp));
+ mutt_pretty_mailbox (tmp);
+ }
+ else
+#endif
if (Context && Context->path)
{
strfcpy (tmp, Context->path, sizeof (tmp));