]> git.pld-linux.org Git - packages/mutt.git/blame - mutt-rr.compressed.patch
- updated for 1.5.16
[packages/mutt.git] / mutt-rr.compressed.patch
CommitLineData
4cc0f761
JB
1diff -udprP mutt-1.5.16.orig/Makefile.am mutt-1.5.16/Makefile.am
2--- mutt-1.5.16.orig/Makefile.am 2007-06-04 07:20:01.000000000 +0300
3+++ mutt-1.5.16/Makefile.am 2007-06-12 14:22:35.000000000 +0300
4@@ -18,6 +18,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.
5 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
6 mutt_SOURCES = $(BUILT_SOURCES) \
7 addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
8+ compress.c \
9 crypt.c cryptglue.c \
10 commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
11 edit.c enter.c flags.c init.c filter.c from.c \
12@@ -67,6 +68,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
13
14 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
15 configure account.h \
16+ compress.h \
17 attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
18 globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
19 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
20diff -udprP mutt-1.5.16.orig/Makefile.in mutt-1.5.16/Makefile.in
21--- mutt-1.5.16.orig/Makefile.in 2007-06-10 05:43:26.000000000 +0300
22+++ mutt-1.5.16/Makefile.in 2007-06-12 14:22:35.000000000 +0300
23@@ -14,6 +14,10 @@
24
25 @SET_MAKE@
26
27+mutt_SOURCES += compress.c
28+EXTRA_DIST += compress.h
29+mutt_OBJECTS += compress.o
30+
31
32 srcdir = @srcdir@
33 top_srcdir = @top_srcdir@
34diff -udprP mutt-1.5.16.orig/Muttrc.head mutt-1.5.16/Muttrc.head
35--- mutt-1.5.16.orig/Muttrc.head 2007-06-06 19:02:56.000000000 +0300
36+++ mutt-1.5.16/Muttrc.head 2007-06-12 14:22:35.000000000 +0300
37@@ -24,6 +24,11 @@ macro generic,pager <F1> "<shell-escape>
38 macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
39 bind browser y exit
40
41+# Use folders which match on \\.gz$ as gzipped folders:
42+# open-hook \\.gz$ "gzip -cd %f > %t"
43+# close-hook \\.gz$ "gzip -c %t > %f"
44+# append-hook \\.gz$ "gzip -c %t >> %f"
45+
46 # If Mutt is unable to determine your site's domain name correctly, you can
47 # set the default here.
48 #
49diff -udprP mutt-1.5.16.orig/PATCHES mutt-1.5.16/PATCHES
50--- mutt-1.5.16.orig/PATCHES 2007-04-30 05:07:48.000000000 +0300
51+++ mutt-1.5.16/PATCHES 2007-06-12 14:22:35.000000000 +0300
52@@ -0,0 +1 @@
53+rr.compressed
54diff -udprP mutt-1.5.16.orig/compress.c mutt-1.5.16/compress.c
55--- mutt-1.5.16.orig/compress.c 1970-01-01 03:00:00.000000000 +0300
56+++ mutt-1.5.16/compress.c 2007-06-12 14:22:35.000000000 +0300
57@@ -0,0 +1,490 @@
643a7814
JB
58+/*
59+ * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
60+ *
61+ * This program is free software; you can redistribute it and/or modify
62+ * it under the terms of the GNU General Public License as published by
63+ * the Free Software Foundation; either version 2 of the License, or
64+ * (at your option) any later version.
65+ *
66+ * This program is distributed in the hope that it will be useful,
67+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
68+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69+ * GNU General Public License for more details.
70+ *
71+ * You should have received a copy of the GNU General Public License
72+ * along with this program; if not, write to the Free Software
73+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
74+ */
75+
68eeb855 76+#if HAVE_CONFIG_H
77+# include "config.h"
78+#endif
79+
643a7814
JB
80+#include "mutt.h"
81+
82+#ifdef USE_COMPRESSED
83+
84+#include "mx.h"
85+#include "mailbox.h"
86+#include "mutt_curses.h"
87+
88+#include <errno.h>
89+#include <string.h>
90+#include <unistd.h>
91+#include <sys/stat.h>
92+
93+typedef struct
94+{
95+ const char *close; /* close-hook command */
96+ const char *open; /* open-hook command */
97+ const char *append; /* append-hook command */
98+ off_t size; /* size of real folder */
99+} COMPRESS_INFO;
100+
4cc0f761 101+char echo_cmd[HUGE_STRING];
643a7814 102+
4cc0f761 103+/* parameters:
643a7814
JB
104+ * ctx - context to lock
105+ * excl - exclusive lock?
106+ * retry - should retry if unable to lock?
107+ */
108+int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
109+{
110+ int r;
111+
112+ if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
113+ ctx->locked = 1;
114+ else if (retry && !excl)
115+ {
116+ ctx->readonly = 1;
117+ return 0;
118+ }
119+
120+ return (r);
121+}
122+
123+void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
124+{
125+ if (ctx->locked)
126+ {
127+ fflush (fp);
128+
129+ mx_unlock_file (ctx->realpath, fileno (fp), 1);
130+ ctx->locked = 0;
131+ }
132+}
133+
134+static int is_new (const char *path)
135+{
136+ return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
137+}
138+
139+static const char* find_compress_hook (int type, const char *path)
140+{
141+ const char* c = mutt_find_hook (type, path);
142+ return (!c || !*c) ? NULL : c;
143+}
144+
145+int mutt_can_read_compressed (const char *path)
146+{
147+ return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
148+}
149+
4cc0f761
JB
150+/* if the file is new, we really do not append, but create, and so use
151+ * close-hook, and not append-hook
643a7814
JB
152+ */
153+static const char* get_append_command (const char *path, const CONTEXT* ctx)
154+{
155+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
156+ return (is_new (path)) ? ci->close : ci->append;
157+}
4cc0f761 158+
643a7814
JB
159+int mutt_can_append_compressed (const char *path)
160+{
161+ int magic;
162+
163+ if (is_new (path))
4cc0f761 164+ return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
643a7814
JB
165+
166+ magic = mx_get_magic (path);
4cc0f761 167+
643a7814
JB
168+ if (magic != 0 && magic != M_COMPRESSED)
169+ return 0;
170+
171+ return (find_compress_hook (M_APPENDHOOK, path)
4cc0f761 172+ || (find_compress_hook (M_OPENHOOK, path)
643a7814
JB
173+ && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
174+}
175+
176+/* open a compressed mailbox */
177+static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
178+{
179+ COMPRESS_INFO *ci;
180+
181+ /* Now lets uncompress this thing */
182+ ci = safe_malloc (sizeof (COMPRESS_INFO));
183+ ctx->compressinfo = (void*) ci;
184+ ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
185+ ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
186+ ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
187+ return ci;
188+}
4cc0f761 189+
643a7814
JB
190+static void set_path (CONTEXT* ctx)
191+{
192+ char tmppath[_POSIX_PATH_MAX];
193+
194+ /* Setup the right paths */
195+ ctx->realpath = ctx->path;
196+
197+ /* Uncompress to /tmp */
198+ mutt_mktemp (tmppath);
199+ ctx->path = safe_malloc (strlen (tmppath) + 1);
200+ strcpy (ctx->path, tmppath);
201+}
202+
4cc0f761 203+static int get_size (const char* path)
643a7814
JB
204+{
205+ struct stat sb;
206+ if (stat (path, &sb) != 0)
207+ return 0;
208+ return (sb.st_size);
209+}
210+
4cc0f761 211+static void store_size (CONTEXT* ctx)
643a7814
JB
212+{
213+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
214+ ci->size = get_size (ctx->realpath);
215+}
216+
217+static const char *
218+compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
4cc0f761
JB
219+ const char *fmt, const char *ifstring,
220+ const char *elsestring, unsigned long data,
643a7814
JB
221+ format_flag flags)
222+{
223+ char tmp[SHORT_STRING];
4cc0f761 224+
643a7814
JB
225+ CONTEXT *ctx = (CONTEXT *) data;
226+ switch (op)
227+ {
228+ case 'f':
229+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
230+ snprintf (dest, destlen, tmp, ctx->realpath);
231+ break;
232+ case 't':
233+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
234+ snprintf (dest, destlen, tmp, ctx->path);
235+ break;
236+ }
237+ return (src);
238+}
239+
4cc0f761 240+/* check that the command has both %f and %t
643a7814
JB
241+ * 0 means OK, -1 means error
242+ */
243+int mutt_test_compress_command (const char* cmd)
244+{
245+ return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
246+}
247+
248+static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
249+{
250+ char expanded[_POSIX_PATH_MAX];
4cc0f761 251+ mutt_FormatString (expanded, sizeof (expanded), 0, cmd, compresshook_format_str,
643a7814
JB
252+ (unsigned long) ctx, 0);
253+ return safe_strdup (expanded);
254+}
255+
256+int mutt_check_mailbox_compressed (CONTEXT* ctx)
257+{
258+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
259+ if (ci->size != get_size (ctx->realpath))
260+ {
68eeb855 261+ FREE (&ctx->compressinfo);
262+ FREE (&ctx->realpath);
643a7814
JB
263+ mutt_error _("Mailbox was corrupted!");
264+ return (-1);
265+ }
266+ return (0);
267+}
268+
269+int mutt_open_read_compressed (CONTEXT *ctx)
270+{
271+ char *cmd;
272+ FILE *fp;
273+ int rc;
274+
275+ COMPRESS_INFO *ci = set_compress_info (ctx);
276+ if (!ci->open) {
277+ ctx->magic = 0;
4cc0f761 278+ FREE (ctx->compressinfo);
643a7814
JB
279+ return (-1);
280+ }
281+ if (!ci->close || access (ctx->path, W_OK) != 0)
282+ ctx->readonly = 1;
283+
284+ set_path (ctx);
285+ store_size (ctx);
286+
287+ if (!ctx->quiet)
288+ mutt_message (_("Decompressing %s..."), ctx->realpath);
289+
290+ cmd = get_compression_cmd (ci->open, ctx);
4cc0f761 291+ if (cmd == NULL)
643a7814
JB
292+ return (-1);
293+ dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
294+
295+ if ((fp = fopen (ctx->realpath, "r")) == NULL)
296+ {
297+ mutt_perror (ctx->realpath);
68eeb855 298+ FREE (&cmd);
643a7814
JB
299+ return (-1);
300+ }
301+ mutt_block_signals ();
302+ if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
303+ {
304+ fclose (fp);
305+ mutt_unblock_signals ();
306+ mutt_error _("Unable to lock mailbox!");
68eeb855 307+ FREE (&cmd);
643a7814
JB
308+ return (-1);
309+ }
310+
311+ endwin ();
312+ fflush (stdout);
4cc0f761
JB
313+ sprintf(echo_cmd,_("echo Decompressing %s..."),ctx->realpath);
314+ mutt_system(echo_cmd);
643a7814
JB
315+ rc = mutt_system (cmd);
316+ mbox_unlock_compressed (ctx, fp);
317+ mutt_unblock_signals ();
318+ fclose (fp);
319+
320+ if (rc)
321+ {
322+ mutt_any_key_to_continue (NULL);
323+ ctx->magic = 0;
4cc0f761 324+ FREE (ctx->compressinfo);
643a7814
JB
325+ mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
326+ }
68eeb855 327+ FREE (&cmd);
4cc0f761 328+ if (rc)
643a7814
JB
329+ return (-1);
330+
331+ if (mutt_check_mailbox_compressed (ctx))
332+ return (-1);
333+
334+ ctx->magic = mx_get_magic (ctx->path);
335+
336+ return (0);
337+}
338+
339+void restore_path (CONTEXT* ctx)
340+{
68eeb855 341+ FREE (&ctx->path);
643a7814
JB
342+ ctx->path = ctx->realpath;
343+}
344+
345+/* remove the temporary mailbox */
4cc0f761 346+void remove_file (CONTEXT* ctx)
643a7814
JB
347+{
348+ if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
349+ remove (ctx->path);
350+}
351+
352+int mutt_open_append_compressed (CONTEXT *ctx)
353+{
354+ FILE *fh;
355+ COMPRESS_INFO *ci = set_compress_info (ctx);
356+
357+ if (!get_append_command (ctx->path, ctx))
358+ {
359+ if (ci->open && ci->close)
360+ return (mutt_open_read_compressed (ctx));
361+
362+ ctx->magic = 0;
68eeb855 363+ FREE (&ctx->compressinfo);
643a7814
JB
364+ return (-1);
365+ }
366+
367+ set_path (ctx);
368+
369+ ctx->magic = DefaultMagic;
370+
371+ if (!is_new (ctx->realpath))
372+ if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
373+ if ((fh = fopen (ctx->path, "w")))
374+ fclose (fh);
375+ /* No error checking - the parent function will catch it */
376+
377+ return (0);
378+}
379+
380+/* close a compressed mailbox */
381+void mutt_fast_close_compressed (CONTEXT *ctx)
382+{
383+ dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
384+ ctx->path));
385+
386+ if (ctx->compressinfo)
387+ {
388+ if (ctx->fp)
389+ fclose (ctx->fp);
390+ ctx->fp = NULL;
391+ /* if the folder was removed, remove the gzipped folder too */
4cc0f761 392+ if (access (ctx->path, F_OK) != 0 && ! option (OPTSAVEEMPTY))
643a7814
JB
393+ remove (ctx->realpath);
394+ else
395+ remove_file (ctx);
396+
397+ restore_path (ctx);
68eeb855 398+ FREE (&ctx->compressinfo);
643a7814
JB
399+ }
400+}
401+
402+/* return 0 on success, -1 on failure */
403+int mutt_sync_compressed (CONTEXT* ctx)
404+{
405+ char *cmd;
406+ int rc = 0;
407+ FILE *fp;
408+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
409+
410+ if (!ctx->quiet)
411+ mutt_message (_("Compressing %s..."), ctx->realpath);
412+
413+ cmd = get_compression_cmd (ci->close, ctx);
4cc0f761 414+ if (cmd == NULL)
643a7814
JB
415+ return (-1);
416+
417+ if ((fp = fopen (ctx->realpath, "a")) == NULL)
418+ {
419+ mutt_perror (ctx->realpath);
68eeb855 420+ FREE (&cmd);
643a7814
JB
421+ return (-1);
422+ }
423+ mutt_block_signals ();
424+ if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
425+ {
426+ fclose (fp);
427+ mutt_unblock_signals ();
428+ mutt_error _("Unable to lock mailbox!");
4cc0f761
JB
429+
430+ store_size (ctx);
431+
68eeb855 432+ FREE (&cmd);
643a7814
JB
433+ return (-1);
434+ }
435+
436+ dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
437+
438+ endwin ();
439+ fflush (stdout);
4cc0f761
JB
440+ sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath);
441+ mutt_system(echo_cmd);
643a7814
JB
442+ if (mutt_system (cmd))
443+ {
444+ mutt_any_key_to_continue (NULL);
445+ mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
446+ rc = -1;
447+ }
448+
449+ mbox_unlock_compressed (ctx, fp);
450+ mutt_unblock_signals ();
451+ fclose (fp);
452+
68eeb855 453+ FREE (&cmd);
4cc0f761 454+
643a7814
JB
455+ store_size (ctx);
456+
457+ return (rc);
458+}
459+
460+int mutt_slow_close_compressed (CONTEXT *ctx)
461+{
462+ FILE *fp;
463+ const char *append;
464+ char *cmd;
465+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
466+
4cc0f761 467+ dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
643a7814
JB
468+ ctx->path));
469+
4cc0f761 470+ if (! (ctx->append
643a7814
JB
471+ && ((append = get_append_command (ctx->realpath, ctx))
472+ || (append = ci->close))))
4cc0f761
JB
473+ { /* if we can not or should not append,
474+ * we only have to remove the compressed info, because sync was already
475+ * called
476+ */
643a7814
JB
477+ mutt_fast_close_compressed (ctx);
478+ return (0);
479+ }
480+
481+ if (ctx->fp)
482+ fclose (ctx->fp);
483+ ctx->fp = NULL;
484+
485+ if (!ctx->quiet)
486+ {
487+ if (append == ci->close)
488+ mutt_message (_("Compressing %s..."), ctx->realpath);
489+ else
490+ mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
491+ }
492+
493+ cmd = get_compression_cmd (append, ctx);
4cc0f761 494+ if (cmd == NULL)
643a7814
JB
495+ return (-1);
496+
497+ if ((fp = fopen (ctx->realpath, "a")) == NULL)
498+ {
499+ mutt_perror (ctx->realpath);
68eeb855 500+ FREE (&cmd);
643a7814
JB
501+ return (-1);
502+ }
503+ mutt_block_signals ();
504+ if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
505+ {
506+ fclose (fp);
507+ mutt_unblock_signals ();
508+ mutt_error _("Unable to lock mailbox!");
68eeb855 509+ FREE (&cmd);
643a7814
JB
510+ return (-1);
511+ }
512+
513+ dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
514+
515+ endwin ();
516+ fflush (stdout);
517+
518+ if (append == ci->close)
4cc0f761 519+ sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath);
643a7814 520+ else
4cc0f761
JB
521+ sprintf(echo_cmd,_("echo Compressed-appending to %s..."), ctx->realpath);
522+ mutt_system(echo_cmd);
643a7814
JB
523+
524+ if (mutt_system (cmd))
525+ {
526+ mutt_any_key_to_continue (NULL);
527+ mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
528+ ctx->path);
68eeb855 529+ FREE (&cmd);
643a7814
JB
530+ mbox_unlock_compressed (ctx, fp);
531+ mutt_unblock_signals ();
532+ fclose (fp);
533+ return (-1);
534+ }
535+
536+ mbox_unlock_compressed (ctx, fp);
537+ mutt_unblock_signals ();
538+ fclose (fp);
539+ remove_file (ctx);
540+ restore_path (ctx);
68eeb855 541+ FREE (&cmd);
542+ FREE (&ctx->compressinfo);
643a7814
JB
543+
544+ return (0);
545+}
546+
547+#endif /* USE_COMPRESSED */
4cc0f761
JB
548diff -udprP mutt-1.5.16.orig/compress.h mutt-1.5.16/compress.h
549--- mutt-1.5.16.orig/compress.h 1970-01-01 03:00:00.000000000 +0300
550+++ mutt-1.5.16/compress.h 2007-06-12 14:22:35.000000000 +0300
643a7814
JB
551@@ -0,0 +1,27 @@
552+/*
553+ * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
554+ *
555+ * This program is free software; you can redistribute it and/or modify
556+ * it under the terms of the GNU General Public License as published by
557+ * the Free Software Foundation; either version 2 of the License, or
558+ * (at your option) any later version.
559+ *
560+ * This program is distributed in the hope that it will be useful,
561+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
562+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
563+ * GNU General Public License for more details.
564+ *
565+ * You should have received a copy of the GNU General Public License
566+ * along with this program; if not, write to the Free Software
567+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
568+ */
569+
570+int mutt_can_read_compressed (const char *);
571+int mutt_can_append_compressed (const char *);
572+int mutt_open_read_compressed (CONTEXT *);
573+int mutt_open_append_compressed (CONTEXT *);
574+int mutt_slow_close_compressed (CONTEXT *);
575+int mutt_sync_compressed (CONTEXT *);
576+int mutt_test_compress_command (const char *);
577+int mutt_check_mailbox_compressed (CONTEXT *);
578+void mutt_fast_close_compressed (CONTEXT *);
4cc0f761
JB
579diff -udprP mutt-1.5.16.orig/config.h.in mutt-1.5.16/config.h.in
580--- mutt-1.5.16.orig/config.h.in 2007-06-10 05:44:57.000000000 +0300
581+++ mutt-1.5.16/config.h.in 2007-06-12 14:22:35.000000000 +0300
582@@ -512,6 +512,9 @@
583
68eeb855 584 /* Define to enable Sun mailtool attachments support. */
585 #undef SUN_ATTACHMENT
4cc0f761
JB
586+
587+/* The compressed mailboxes support */
68eeb855 588+#undef USE_COMPRESSED
4cc0f761 589
68eeb855 590 /* Define to use dotlocking for mailboxes. */
591 #undef USE_DOTLOCK
4cc0f761
JB
592diff -udprP mutt-1.5.16.orig/configure mutt-1.5.16/configure
593--- mutt-1.5.16.orig/configure 2007-06-10 05:43:29.000000000 +0300
594+++ mutt-1.5.16/configure 2007-06-12 14:22:35.000000000 +0300
595@@ -1350,6 +1350,7 @@ Optional Features:
596 --disable-warnings Turn off compiler warnings (not recommended)
597 --enable-nfs-fix Work around an NFS with broken attributes caching
598 --enable-mailtool Enable Sun mailtool attachments support
68eeb855 599+ --enable-compressed Enable compressed folders support
4cc0f761
JB
600 --enable-locales-fix The result of isprint() is unreliable
601 --enable-exact-address Enable regeneration of email addresses
602 --enable-hcache Enable header caching
603@@ -14414,6 +14415,18 @@ echo "${ECHO_T}$mutt_cv_regex_broken" >&
604 fi
68eeb855 605 fi
606
4cc0f761 607+
68eeb855 608+# Check whether --enable-compressed or --disable-compressed was given.
609+if test "${enable_compressed+set}" = set; then
4cc0f761
JB
610+ enableval="$enable_compressed"
611+ if test x$enableval = xyes; then
612+ cat >> confdefs.h <<\EOF
68eeb855 613+#define USE_COMPRESSED 1
4cc0f761 614+EOF
68eeb855 615+
616+ fi
617+fi
618+
4cc0f761 619 if test $mutt_cv_regex = yes; then
68eeb855 620
4cc0f761
JB
621 cat >>confdefs.h <<\_ACEOF
622diff -udprP mutt-1.5.16.orig/configure.ac mutt-1.5.16/configure.ac
623--- mutt-1.5.16.orig/configure.ac 2007-06-04 07:20:01.000000000 +0300
624+++ mutt-1.5.16/configure.ac 2007-06-12 14:22:35.000000000 +0300
625@@ -780,6 +780,11 @@ AC_ARG_ENABLE(mailtool, AC_HELP_STRING([
626 AC_DEFINE(SUN_ATTACHMENT,1,[ Define to enable Sun mailtool attachments support. ])
643a7814
JB
627 fi])
628
68eeb855 629+AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]),
4cc0f761
JB
630+ [if test x$enableval = xyes; then
631+ AC_DEFINE(USE_COMPRESSED,1,[ Define to enable compressed folders support. ])
643a7814
JB
632+ fi])
633+
4cc0f761
JB
634 AC_ARG_ENABLE(locales-fix, AC_HELP_STRING([--enable-locales-fix], [The result of isprint() is unreliable]),
635 [if test x$enableval = xyes; then
636 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
637diff -udprP mutt-1.5.16.orig/curs_main.c mutt-1.5.16/curs_main.c
638--- mutt-1.5.16.orig/curs_main.c 2007-05-20 10:30:00.000000000 +0300
639+++ mutt-1.5.16/curs_main.c 2007-06-12 14:22:35.000000000 +0300
640@@ -1111,6 +1111,11 @@ int mutt_index_menu (void)
643a7814
JB
641 {
642 int check;
643
644+#ifdef USE_COMPRESSED
645+ if (Context->compressinfo && Context->realpath)
646+ mutt_str_replace (&LastFolder, Context->realpath);
647+ else
648+#endif
649 mutt_str_replace (&LastFolder, Context->path);
650 oldcount = Context ? Context->msgcount : 0;
651
4cc0f761
JB
652diff -udprP mutt-1.5.16.orig/doc/Makefile.am mutt-1.5.16/doc/Makefile.am
653--- mutt-1.5.16.orig/doc/Makefile.am 2007-04-13 19:43:45.000000000 +0300
654+++ mutt-1.5.16/doc/Makefile.am 2007-06-12 14:22:35.000000000 +0300
655@@ -27,7 +27,7 @@ EXTRA_DIST = dotlock.man \
656
657 HTML_DOCFILES = manual.html index.html intro.html gettingstarted.html \
658 configuration.html mimesupport.html advancedusage.html \
659- tuning.html reference.html miscellany.html
660+ tuning.html reference.html miscellany.html compressed-folders.html
661
662 BUILT_DISTFILES = stamp-doc-xml stamp-doc-chunked manual.txt $(HTML_DOCFILES)
663
664diff -udprP mutt-1.5.16.orig/doc/Makefile.in mutt-1.5.16/doc/Makefile.in
665--- mutt-1.5.16.orig/doc/Makefile.in 2007-06-10 05:43:25.000000000 +0300
666+++ mutt-1.5.16/doc/Makefile.in 2007-06-12 14:22:35.000000000 +0300
667@@ -223,7 +223,7 @@ EXTRA_DIST = dotlock.man \
668
669 HTML_DOCFILES = manual.html index.html intro.html gettingstarted.html \
670 configuration.html mimesupport.html advancedusage.html \
671- tuning.html reference.html miscellany.html
672+ tuning.html reference.html miscellany.html compressed-folders.html
673
674 BUILT_DISTFILES = stamp-doc-xml stamp-doc-chunked manual.txt $(HTML_DOCFILES)
675 srcdir_DOCFILES = PGP-Notes.txt applying-patches.txt \
676diff -udprP mutt-1.5.16.orig/doc/manual.xml.head mutt-1.5.16/doc/manual.xml.head
677--- mutt-1.5.16.orig/doc/manual.xml.head 2007-04-04 08:37:13.000000000 +0300
678+++ mutt-1.5.16/doc/manual.xml.head 2007-06-12 14:22:35.000000000 +0300
679@@ -4083,6 +4083,24 @@ configuration option/command. See
680 <link linkend="fcc-save-hook">fcc-save-hook</link>
681 </para>
682 </listitem>
683+<listitem>
684+
685+<para>
686+<link linkend="open-hook">open-hook</link>
687+</para>
688+</listitem>
689+<listitem>
690+
691+<para>
692+<link linkend="close-hook">close-hook</link>
693+</para>
694+</listitem>
695+<listitem>
696+
697+<para>
698+<link linkend="append-hook">append-hook</link>
699+</para>
700+</listitem>
701
702 </itemizedlist>
703
704@@ -4910,6 +4928,254 @@ becomes an issue as mutt will silently f
643a7814 705
68eeb855 706 </chapter>
707
4cc0f761 708+<chapter id="compressed-folders">
68eeb855 709+<title>Compressed folders Support (OPTIONAL)</title>
643a7814 710+
68eeb855 711+<para>
643a7814 712+If Mutt was compiled with compressed folders support (by running the
68eeb855 713+<emphasis>configure</emphasis> script with the
714+<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders
715+stored in an arbitrary format, provided that the user has a script to
716+convert from/to this format to one of the accepted.
4cc0f761 717+</para>
643a7814 718+
4cc0f761 719+<para>
643a7814
JB
720+The most common use is to open compressed archived folders e.g. with
721+gzip.
4cc0f761 722+</para>
643a7814 723+
4cc0f761 724+<para>
643a7814
JB
725+In addition, the user can provide a script that gets a folder in an
726+accepted format and appends its context to the folder in the
727+user-defined format, which may be faster than converting the entire
728+folder to the accepted format, appending to it and converting back to
729+the user-defined format.
4cc0f761 730+</para>
643a7814 731+
4cc0f761
JB
732+<para>
733+There are three hooks defined
734+(<link linkend="open-hook">open-hook</link>,
735+<link linkend="close-hook">close-hook</link> and
736+<link linkend="append-hook">append-hook</link>) which define commands
737+to uncompress and compress a folder and to append messages to an
738+existing compressed folder respectively.
739+</para>
643a7814 740+
4cc0f761 741+<para>
643a7814
JB
742+For example:
743+
68eeb855 744+<screen>
4cc0f761
JB
745+open-hook \\.gz$ "gzip -cd %f > %t"
746+close-hook \\.gz$ "gzip -c %t > %f"
747+append-hook \\.gz$ "gzip -c %t >> %f"
68eeb855 748+</screen>
4cc0f761 749+</para>
643a7814 750+
4cc0f761
JB
751+<para>
752+You do not have to specify all of the commands. If you omit
753+<link linkend="append-hook">append-hook</link>, the folder will be open
754+and closed again each time you will add to it. If you omit
755+<link linkend="close-hook">close-hook</link> (or give empty command),
756+the folder will be open in the mode. If you specify
757+<link linkend="append-hook">append-hook</link> though you'll be able to
68eeb855 758+append to the folder.
4cc0f761 759+</para>
643a7814 760+
4cc0f761 761+<para>
643a7814
JB
762+Note that Mutt will only try to use hooks if the file is not in one of
763+the accepted formats. In particular, if the file is empty, mutt
764+supposes it is not compressed. This is important because it allows the
765+use of programs that do not have well defined extensions. Just use
4cc0f761
JB
766+``.'' as a regexp. But this may be surprising if your compressing
767+script produces empty files. In this situation, unset
68eeb855 768+<link linkend="save-empty">&dollar;save&lowbar;empty</link>, so that
769+the compressed file will be removed if you delete all of the messages.
770+</para>
771+
4cc0f761 772+<sect1 id="open-hook">
68eeb855 773+<title>Open a compressed mailbox for reading</title>
643a7814 774+
68eeb855 775+<para>
4cc0f761
JB
776+Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis>
777+</para>
643a7814 778+
4cc0f761 779+<para>
68eeb855 780+The <emphasis>command</emphasis> is the command that can be used for
781+opening the folders whose names match <emphasis>regexp</emphasis>.
4cc0f761 782+</para>
643a7814 783+
4cc0f761 784+<para>
68eeb855 785+The <emphasis>command</emphasis> string is the printf-like format
786+string, and it should accept two parameters: &percnt;f, which is
787+replaced with the (compressed) folder name, and &percnt;t which is
788+replaced with the name of the temporary folder to which to write.
4cc0f761 789+</para>
643a7814 790+
4cc0f761 791+<para>
643a7814
JB
792+&percnt;f and &percnt;t can be repeated any number of times in the
793+command string, and all of the entries are replaced with the
794+appropriate folder name. In addition, &percnt;&percnt; is replaced by
795+&percnt;, as in printf, and any other &percnt;anything is left as is.
4cc0f761 796+</para>
643a7814 797+
4cc0f761
JB
798+<para>
799+The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis>
800+remove the original compressed file. The <emphasis>command</emphasis>
801+should return non-zero exit status if it fails, so mutt knows
802+something's wrong.
803+</para>
643a7814 804+
4cc0f761 805+<para>
643a7814
JB
806+Example:
807+
68eeb855 808+<screen>
4cc0f761 809+open-hook \\.gz$ "gzip -cd %f > %t"
68eeb855 810+</screen>
4cc0f761 811+</para>
643a7814 812+
4cc0f761 813+<para>
68eeb855 814+If the <emphasis>command</emphasis> is empty, this operation is
815+disabled for this file type.
816+</para>
643a7814 817+
4cc0f761
JB
818+</sect1>
819+
820+<sect1 id="close-hook">
68eeb855 821+<title>Write a compressed mailbox</title>
643a7814 822+
68eeb855 823+<para>
4cc0f761
JB
824+Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis>
825+</para>
643a7814 826+
4cc0f761
JB
827+<para>
828+This is used to close the folder that was open with the
829+<link linkend="open-hook">open-hook</link> command after some changes
830+were made to it.
831+</para>
643a7814 832+
4cc0f761 833+<para>
68eeb855 834+The <emphasis>command</emphasis> string is the command that can be
4cc0f761
JB
835+used for closing the folders whose names match <emphasis>regexp</emphasis>.
836+It has the same format as in the <link linkend="open-hook">open-hook</link>
837+command. Temporary folder in this case is the folder previously
838+produced by the <link linkend="open-hook">open-hook</link> command.
839+</para>
643a7814 840+
4cc0f761
JB
841+<para>
842+The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis>
843+remove the decompressed file. The <emphasis>command</emphasis> should
844+return non-zero exit status if it fails, so mutt knows something's
845+wrong.
846+</para>
643a7814 847+
4cc0f761 848+<para>
643a7814
JB
849+Example:
850+
68eeb855 851+<screen>
4cc0f761 852+close-hook \\.gz$ "gzip -c %t > %f"
68eeb855 853+</screen>
4cc0f761 854+</para>
643a7814 855+
4cc0f761 856+<para>
68eeb855 857+If the <emphasis>command</emphasis> is empty, this operation is
858+disabled for this file type, and the file can only be open in the
4cc0f761
JB
859+readonly mode.
860+</para>
643a7814 861+
4cc0f761 862+<para>
68eeb855 863+<link linkend="close-hook">close-hook</link> is not called when you
864+exit from the folder if the folder was not changed.
865+</para>
643a7814 866+
4cc0f761
JB
867+</sect1>
868+
869+<sect1 id="append-hook">
68eeb855 870+<title>Append a message to a compressed mailbox</title>
643a7814 871+
68eeb855 872+<para>
4cc0f761
JB
873+Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis>
874+</para>
643a7814 875+
4cc0f761
JB
876+<para>
877+This command is used for saving to an existing compressed folder.
878+The <emphasis>command</emphasis> is the command that can be used for
879+appending to the folders whose names match <emphasis>regexp</emphasis>.
880+It has the same format as in the <link linkend="open-hook">open-hook</link>
881+command. The temporary folder in this case contains the messages that
882+are being appended.
883+</para>
643a7814 884+
4cc0f761
JB
885+<para>
886+The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis>
887+remove the decompressed file. The <emphasis>command</emphasis> should
888+return non-zero exit status if it fails, so mutt knows something's
889+wrong.
890+</para>
643a7814 891+
4cc0f761 892+<para>
643a7814
JB
893+Example:
894+
68eeb855 895+<screen>
4cc0f761 896+append-hook \\.gz$ "gzip -c %t >> %f"
68eeb855 897+</screen>
4cc0f761 898+</para>
68eeb855 899+
4cc0f761 900+<para>
68eeb855 901+When <link linkend="append-hook">append-hook</link> is used, the folder
902+is not opened, which saves time, but this means that we can not find
4cc0f761
JB
903+out what the folder type is. Thus the default
904+(<link linkend="mbox-type">&dollar;mbox&lowbar;type</link>) type is
905+always supposed (i.e. this is the format used for the temporary
906+folder).
907+</para>
68eeb855 908+
4cc0f761
JB
909+<para>
910+If the file does not exist when you save to it,
911+<link linkend="close-hook">close-hook</link> is called, and not
912+<link linkend="append-hook">append-hook</link>.
913+<link linkend="append-hook">append-hook</link> is only for appending
914+to existing folders.
915+</para>
68eeb855 916+
4cc0f761 917+<para>
68eeb855 918+If the <emphasis>command</emphasis> is empty, this operation is
919+disabled for this file type. In this case, the folder will be open and
920+closed again (using <link linkend="open-hook">open-hook</link> and
4cc0f761
JB
921+<link linkend="close-hook">close-hook</link> respectively) each time
922+you will add to it.
68eeb855 923+</para>
68eeb855 924+
4cc0f761
JB
925+</sect1>
926+
927+<sect1>
68eeb855 928+<title>Encrypted folders</title>
929+
930+<para>
643a7814
JB
931+The compressed folders support can also be used to handle encrypted
932+folders. If you want to encrypt a folder with PGP, you may want to use
933+the following hooks:
934+
68eeb855 935+<screen>
643a7814
JB
936+open-hook \\.pgp$ "pgp -f &lt; %f &gt; %t"
937+close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId &lt; %t &gt; %f"
68eeb855 938+</screen>
4cc0f761 939+</para>
643a7814 940+
4cc0f761 941+<para>
643a7814
JB
942+Please note, that PGP does not support appending to an encrypted
943+folder, so there is no append-hook defined.
4cc0f761 944+</para>
643a7814 945+
4cc0f761 946+<para>
68eeb855 947+<emphasis role="bold">Note:</emphasis> the folder is temporary stored
948+decrypted in the /tmp directory, where it can be read by your system
949+administrator. So think about the security aspects of this.
950+</para>
4cc0f761 951+
68eeb855 952+</sect1>
4cc0f761
JB
953+
954+</chapter>
68eeb855 955+
956 <chapter id="mimesupport">
957 <title>Mutt's MIME Support</title>
958
4cc0f761
JB
959@@ -6056,6 +6322,12 @@ The following are the commands understoo
960 <listitem>
961
962 <para>
963+<literal><link linkend="append-hook">append-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>command</emphasis>
964+</para>
965+</listitem>
966+<listitem>
967+
968+<para>
969 <literal><link linkend="auto-view">auto&lowbar;view</link></literal> <emphasis>mimetype</emphasis> &lsqb; <emphasis>mimetype</emphasis> ... &rsqb;
970 </para>
971 </listitem>
972@@ -6086,6 +6358,12 @@ The following are the commands understoo
973 <listitem>
974
975 <para>
976+<literal><link linkend="close-hook">close-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>command</emphasis>
977+</para>
978+</listitem>
979+<listitem>
980+
981+<para>
982 <literal><link linkend="color">color</link></literal> <emphasis>object</emphasis> <emphasis>foreground</emphasis> <emphasis>background</emphasis> &lsqb; <emphasis>regexp</emphasis> &rsqb;
983 </para>
984 </listitem>
985@@ -6218,6 +6496,12 @@ The following are the commands understoo
986 <listitem>
987
988 <para>
989+<literal><link linkend="open-hook">open-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>command</emphasis>
990+</para>
991+</listitem>
992+<listitem>
993+
994+<para>
995 <literal><link linkend="crypt-hook">crypt-hook</link></literal> <emphasis>pattern</emphasis> <emphasis>key-id</emphasis>
996 </para>
997 </listitem>
998diff -udprP mutt-1.5.16.orig/doc/muttrc.man.head mutt-1.5.16/doc/muttrc.man.head
999--- mutt-1.5.16.orig/doc/muttrc.man.head 2007-04-02 00:58:55.000000000 +0300
1000+++ mutt-1.5.16/doc/muttrc.man.head 2007-06-12 14:22:35.000000000 +0300
1001@@ -345,6 +345,24 @@ specify the ID of the public key to be u
68eeb855 1002 to a certain recipient. The meaning of "key ID" is to be taken
1003 broadly: This can be a different e-mail address, a numerical key ID,
1004 or even just an arbitrary search string.
643a7814
JB
1005+.PP
1006+.nf
1007+\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
1008+\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
1009+\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
1010+.fi
1011+.IP
1012+These commands provide a way to handle compressed folders. The given
1013+\fBregexp\fP specifies which folders are taken as compressed (e.g.
1014+"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
1015+(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
1016+compressed mail to a compressed folder (\fBappend-hook\fP). The
1017+\fIcommand\fP string is the
1018+.BR printf (3)
1019+like format string, and it should accept two parameters: \fB%f\fP,
1020+which is replaced with the (compressed) folder name, and \fB%t\fP
1021+which is replaced with the name of the temporary folder to which to
1022+write.
1023 .TP
1024 \fBpush\fP \fIstring\fP
1025 This command adds the named \fIstring\fP to the keyboard buffer.
4cc0f761
JB
1026diff -udprP mutt-1.5.16.orig/hook.c mutt-1.5.16/hook.c
1027--- mutt-1.5.16.orig/hook.c 2007-04-08 02:36:55.000000000 +0300
1028+++ mutt-1.5.16/hook.c 2007-06-12 14:22:35.000000000 +0300
68eeb855 1029@@ -24,6 +24,10 @@
643a7814 1030 #include "mailbox.h"
68eeb855 1031 #include "mutt_crypt.h"
643a7814
JB
1032
1033+#ifdef USE_COMPRESSED
1034+#include "compress.h"
1035+#endif
1036+
1037 #include <limits.h>
1038 #include <string.h>
1039 #include <stdlib.h>
4cc0f761 1040@@ -92,6 +96,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
643a7814
JB
1041 memset (&pattern, 0, sizeof (pattern));
1042 pattern.data = safe_strdup (path);
1043 }
1044+#ifdef USE_COMPRESSED
1045+ else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
1046+ {
1047+ if (mutt_test_compress_command (command.data))
1048+ {
4cc0f761
JB
1049+ strfcpy (err->data, _("bad formatted command string"), err->dsize);
1050+ return (-1);
643a7814
JB
1051+ }
1052+ }
1053+#endif
f870a5ba 1054 else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK))
68eeb855 1055 && (!WithCrypto || !(data & M_CRYPTHOOK))
1056 )
4cc0f761
JB
1057diff -udprP mutt-1.5.16.orig/init.h mutt-1.5.16/init.h
1058--- mutt-1.5.16.orig/init.h 2007-06-10 05:29:21.000000000 +0300
1059+++ mutt-1.5.16/init.h 2007-06-12 14:22:35.000000000 +0300
1060@@ -3129,6 +3129,11 @@ struct command_t Commands[] = {
643a7814
JB
1061 { "fcc-hook", mutt_parse_hook, M_FCCHOOK },
1062 { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
1063 { "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
1064+#ifdef USE_COMPRESSED
1065+ { "open-hook", mutt_parse_hook, M_OPENHOOK },
1066+ { "close-hook", mutt_parse_hook, M_CLOSEHOOK },
1067+ { "append-hook", mutt_parse_hook, M_APPENDHOOK },
1068+#endif
68eeb855 1069 { "group", parse_group, 0 },
1070 { "ungroup", parse_ungroup, 0 },
643a7814 1071 { "hdr_order", parse_list, UL &HeaderOrderList },
4cc0f761
JB
1072diff -udprP mutt-1.5.16.orig/main.c mutt-1.5.16/main.c
1073--- mutt-1.5.16.orig/main.c 2007-04-10 23:53:08.000000000 +0300
1074+++ mutt-1.5.16/main.c 2007-06-12 14:22:35.000000000 +0300
1075@@ -310,6 +310,12 @@ static void show_version (void)
1076 "-USE_GNU_REGEX "
643a7814 1077 #endif
4cc0f761 1078
643a7814
JB
1079+#ifdef USE_COMPRESSED
1080+ "+COMPRESSED "
1081+#else
1082+ "-COMPRESSED "
1083+#endif
4cc0f761
JB
1084+
1085 "\n"
1086
1087 #ifdef HAVE_COLOR
1088diff -udprP mutt-1.5.16.orig/mbox.c mutt-1.5.16/mbox.c
1089--- mutt-1.5.16.orig/mbox.c 2007-04-02 00:58:56.000000000 +0300
1090+++ mutt-1.5.16/mbox.c 2007-06-12 14:22:35.000000000 +0300
f870a5ba 1091@@ -29,6 +29,10 @@
643a7814 1092 #include "copy.h"
f870a5ba 1093 #include "mutt_curses.h"
643a7814
JB
1094
1095+#ifdef USE_COMPRESSED
1096+#include "compress.h"
1097+#endif
1098+
1099 #include <sys/stat.h>
1100 #include <dirent.h>
1101 #include <string.h>
4cc0f761 1102@@ -1026,6 +1030,12 @@ bail: /* Come here in case of disaster
643a7814
JB
1103 int mbox_close_mailbox (CONTEXT *ctx)
1104 {
1105 mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
1106+
1107+#ifdef USE_COMPRESSED
1108+ if (ctx->compressinfo)
1109+ mutt_slow_close_compressed (ctx);
1110+#endif
1111+
1112 mutt_unblock_signals ();
1113 mx_fastclose_mailbox (ctx);
1114 return 0;
4cc0f761
JB
1115diff -udprP mutt-1.5.16.orig/mutt.h mutt-1.5.16/mutt.h
1116--- mutt-1.5.16.orig/mutt.h 2007-04-11 06:14:01.000000000 +0300
1117+++ mutt-1.5.16/mutt.h 2007-06-12 14:22:35.000000000 +0300
1118@@ -160,6 +160,11 @@ typedef enum
643a7814 1119 #define M_ACCOUNTHOOK (1<<9)
68eeb855 1120 #define M_REPLYHOOK (1<<10)
1121 #define M_SEND2HOOK (1<<11)
643a7814 1122+#ifdef USE_COMPRESSED
68eeb855 1123+#define M_OPENHOOK (1<<12)
1124+#define M_APPENDHOOK (1<<13)
1125+#define M_CLOSEHOOK (1<<14)
643a7814
JB
1126+#endif
1127
1128 /* tree characters for linearize_tree and print_enriched_string */
1129 #define M_TREE_LLCORNER 1
4cc0f761
JB
1130@@ -889,6 +894,11 @@ typedef struct _context
1131
1132 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
643a7814
JB
1133
1134+#ifdef USE_COMPRESSED
1135+ void *compressinfo; /* compressed mbox module private data */
1136+ char *realpath; /* path to compressed mailbox */
1137+#endif /* USE_COMPRESSED */
1138+
4cc0f761
JB
1139 unsigned int locked : 1; /* is the mailbox locked? */
1140 unsigned int changed : 1; /* mailbox has been modified */
1141 unsigned int readonly : 1; /* don't allow changes to the mailbox */
1142diff -udprP mutt-1.5.16.orig/mx.c mutt-1.5.16/mx.c
1143--- mutt-1.5.16.orig/mx.c 2007-04-03 20:41:14.000000000 +0300
1144+++ mutt-1.5.16/mx.c 2007-06-12 14:22:35.000000000 +0300
68eeb855 1145@@ -30,6 +30,10 @@
643a7814
JB
1146 #include "keymap.h"
1147 #include "url.h"
c9dd7ba8 1148
643a7814
JB
1149+#ifdef USE_COMPRESSED
1150+#include "compress.h"
1151+#endif
1152+
68eeb855 1153 #ifdef USE_IMAP
1154 #include "imap.h"
643a7814 1155 #endif
4cc0f761 1156@@ -450,6 +454,11 @@ int mx_get_magic (const char *path)
643a7814
JB
1157 return (-1);
1158 }
c9dd7ba8 1159
643a7814
JB
1160+#ifdef USE_COMPRESSED
1161+ if (magic == 0 && mutt_can_read_compressed (path))
1162+ return M_COMPRESSED;
1163+#endif
4cc0f761 1164+
643a7814
JB
1165 return (magic);
1166 }
c9dd7ba8 1167
4cc0f761 1168@@ -489,6 +498,13 @@ static int mx_open_mailbox_append (CONTE
643a7814
JB
1169 {
1170 struct stat sb;
c9dd7ba8 1171
643a7814
JB
1172+#ifdef USE_COMPRESSED
1173+ /* special case for appending to compressed folders -
1174+ * even if we can not open them for reading */
1175+ if (mutt_can_append_compressed (ctx->path))
1176+ mutt_open_append_compressed (ctx);
1177+#endif
1178+
1179 ctx->append = 1;
1180
1181 #ifdef USE_IMAP
4cc0f761 1182@@ -653,6 +669,11 @@ CONTEXT *mx_open_mailbox (const char *pa
643a7814
JB
1183
1184 ctx->magic = mx_get_magic (path);
4cc0f761 1185
643a7814
JB
1186+#ifdef USE_COMPRESSED
1187+ if (ctx->magic == M_COMPRESSED)
1188+ mutt_open_read_compressed (ctx);
1189+#endif
1190+
1191 if(ctx->magic == 0)
1192 mutt_error (_("%s is not a mailbox."), path);
1193
4cc0f761 1194@@ -753,6 +774,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
643a7814 1195 mutt_free_header (&ctx->hdrs[i]);
68eeb855 1196 FREE (&ctx->hdrs);
1197 FREE (&ctx->v2r);
643a7814
JB
1198+#ifdef USE_COMPRESSED
1199+ if (ctx->compressinfo)
1200+ mutt_fast_close_compressed (ctx);
1201+#endif
68eeb855 1202 FREE (&ctx->path);
1203 FREE (&ctx->pattern);
643a7814 1204 if (ctx->limit_pattern)
4cc0f761 1205@@ -805,6 +830,12 @@ static int sync_mailbox (CONTEXT *ctx, i
f870a5ba 1206
643a7814
JB
1207 if (tmp && tmp->new == 0)
1208 mutt_update_mailbox (tmp);
643a7814
JB
1209+
1210+#ifdef USE_COMPRESSED
1211+ if (rc == 0 && ctx->compressinfo)
1212+ return mutt_sync_compressed (ctx);
1213+#endif
1214+
1215 return rc;
1216 }
1217
4cc0f761 1218@@ -1006,6 +1037,11 @@ int mx_close_mailbox (CONTEXT *ctx, int
643a7814
JB
1219 !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1220 mx_unlink_empty (ctx->path);
1221
1222+#ifdef USE_COMPRESSED
1223+ if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1224+ return (-1);
1225+#endif
1226+
1227 mx_fastclose_mailbox (ctx);
1228
1229 return 0;
4cc0f761 1230@@ -1315,6 +1351,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
643a7814
JB
1231 {
1232 int rc;
1233
1234+#ifdef USE_COMPRESSED
1235+ if (ctx->compressinfo)
1236+ return mutt_check_mailbox_compressed (ctx);
1237+#endif
1238+
1239 if (ctx)
1240 {
1241 if (ctx->locked) lock = 0;
4cc0f761
JB
1242diff -udprP mutt-1.5.16.orig/mx.h mutt-1.5.16/mx.h
1243--- mutt-1.5.16.orig/mx.h 2007-04-02 00:58:56.000000000 +0300
1244+++ mutt-1.5.16/mx.h 2007-06-12 14:22:35.000000000 +0300
1245@@ -40,6 +40,9 @@ enum
643a7814
JB
1246 #ifdef USE_POP
1247 , M_POP
1248 #endif
1249+#ifdef USE_COMPRESSED
1250+ , M_COMPRESSED
1251+#endif
1252 };
1253
1254 WHERE short DefaultMagic INITVAL (M_MBOX);
4cc0f761
JB
1255diff -udprP mutt-1.5.16.orig/po/POTFILES.in mutt-1.5.16/po/POTFILES.in
1256--- mutt-1.5.16.orig/po/POTFILES.in 2007-04-02 00:58:57.000000000 +0300
1257+++ mutt-1.5.16/po/POTFILES.in 2007-06-12 14:22:35.000000000 +0300
1258@@ -8,6 +8,7 @@ charset.c
68eeb855 1259 color.c
1260 commands.c
1261 compose.c
1262+compress.c
1263 crypt-gpgme.c
1264 crypt.c
1265 cryptglue.c
4cc0f761
JB
1266diff -udprP mutt-1.5.16.orig/status.c mutt-1.5.16/status.c
1267--- mutt-1.5.16.orig/status.c 2007-04-16 02:56:26.000000000 +0300
1268+++ mutt-1.5.16/status.c 2007-06-12 14:22:35.000000000 +0300
1269@@ -99,6 +99,14 @@ status_format_str (char *buf, size_t buf
643a7814
JB
1270
1271 case 'f':
1272 snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1273+#ifdef USE_COMPRESSED
1274+ if (Context && Context->compressinfo && Context->realpath)
1275+ {
1276+ strfcpy (tmp, Context->realpath, sizeof (tmp));
1277+ mutt_pretty_mailbox (tmp);
1278+ }
1279+ else
1280+#endif
1281 if (Context && Context->path)
1282 {
1283 strfcpy (tmp, Context->path, sizeof (tmp));
This page took 0.264856 seconds and 4 git commands to generate.