]> git.pld-linux.org Git - packages/mutt.git/blame - mutt-rr.compressed.patch
- fixed; it seems that mutt 1.3.25i + diffs to 1.3.27i is not the same as mutt 1...
[packages/mutt.git] / mutt-rr.compressed.patch
CommitLineData
c9dd7ba8
JB
1diff -Nur mutt-1.3.27.orig/Makefile.am mutt-1.3.27/Makefile.am
2--- mutt-1.3.27.orig/Makefile.am Fri Nov 9 01:18:28 2001
3+++ mutt-1.3.27/Makefile.am Fri Feb 1 22:51:32 2002
4@@ -18,7 +18,8 @@
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- commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
9+ commands.c complete.c compose.c compress.c copy.c curs_lib.c \
10+ curs_main.c date.c \
11 edit.c enter.c flags.c init.c filter.c from.c getdomain.c \
12 handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c \
13 main.c mbox.c menu.c mh.c mx.c pager.c parse.c pattern.c \
14@@ -70,8 +71,8 @@
15 browser.h mbyte.h remailer.h url.h mutt_ssl_nss.c pgppacket.c
16
17 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP TODO configure acconfig.h account.h \
18- attach.h buffy.h charset.h copy.h dotlock.h functions.h gen_defs \
19- globals.h hash.h history.h init.h keymap.h \
20+ attach.h buffy.h charset.h compress.h copy.h dotlock.h functions.h \
21+ gen_defs globals.h hash.h history.h init.h keymap.h \
22 mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
23 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
24 mx.h pager.h pgp.h pop.h protos.h reldate.h rfc1524.h rfc2047.h \
25diff -Nur mutt-1.3.27.orig/Makefile.in mutt-1.3.27/Makefile.in
26--- mutt-1.3.27.orig/Makefile.in Tue Jan 1 21:18:15 2002
27+++ mutt-1.3.27/Makefile.in Fri Feb 1 22:51:32 2002
28@@ -117,7 +117,7 @@
29 BUILT_SOURCES = keymap_defs.h patchlist.c
30
31 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
32-mutt_SOURCES = $(BUILT_SOURCES) addrbook.c alias.c attach.c base64.c browser.c buffy.c color.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 main.c mbox.c menu.c mh.c mx.c pager.c parse.c pattern.c postpone.c query.c recvattach.c recvcmd.c rfc822.c rfc1524.c rfc2047.c rfc2231.c score.c send.c sendlib.c signal.c sort.c status.c system.c thread.c charset.c history.c lib.c muttlib.c editmsg.c utf8.c mbyte.c wcwidth.c url.c ascii.c
33+mutt_SOURCES = $(BUILT_SOURCES) addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c commands.c complete.c compose.c compress.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 main.c mbox.c menu.c mh.c mx.c pager.c parse.c pattern.c postpone.c query.c recvattach.c recvcmd.c rfc822.c rfc1524.c rfc2047.c rfc2231.c score.c send.c sendlib.c signal.c sort.c status.c system.c thread.c charset.c history.c lib.c muttlib.c editmsg.c utf8.c mbyte.c wcwidth.c url.c ascii.c
34
35
36 mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) $(INTLLIBS) $(LIBICONV)
37@@ -152,7 +152,7 @@
38 EXTRA_mutt_SOURCES = account.c md5c.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_tunnel.c pop.c pop_auth.c pop_lib.c pgp.c pgpinvoke.c pgpkey.c pgplib.c sha1.c pgpmicalg.c gnupgparse.c resize.c dotlock.c remailer.c browser.h mbyte.h remailer.h url.h mutt_ssl_nss.c pgppacket.c
39
40
41-EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP TODO configure acconfig.h account.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 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h mx.h pager.h pgp.h pop.h protos.h reldate.h rfc1524.h rfc2047.h rfc2231.h rfc822.h sha1.h sort.h mime.types VERSION prepare _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h mbyte.h lib.h extlib.c pgpewrap.c pgplib.h Muttrc.head Muttrc makedoc.c stamp-doc-rc README.SSL muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh
42+EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP TODO configure acconfig.h account.h attach.h buffy.h charset.h compress.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 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h mx.h pager.h pgp.h pop.h protos.h reldate.h rfc1524.h rfc2047.h rfc2231.h rfc822.h sha1.h sort.h mime.types VERSION prepare _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h mbyte.h lib.h extlib.c pgpewrap.c pgplib.h Muttrc.head Muttrc makedoc.c stamp-doc-rc README.SSL muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh
43
44
45 mutt_dotlock_SOURCES = mutt_dotlock.c
46@@ -187,7 +187,7 @@
47 makedoc_OBJECTS = makedoc.o
48 makedoc_LDFLAGS =
49 mutt_OBJECTS = patchlist.o addrbook.o alias.o attach.o base64.o \
50-browser.o buffy.o color.o commands.o complete.o compose.o copy.o \
51+browser.o buffy.o color.o commands.o complete.o compose.o compress.o copy.o \
52 curs_lib.o curs_main.o date.o edit.o enter.o flags.o init.o filter.o \
53 from.o getdomain.o handler.o hash.o hdrline.o headers.o help.o hook.o \
54 keymap.o main.o mbox.o menu.o mh.o mx.o pager.o parse.o pattern.o \
55diff -Nur mutt-1.3.27.orig/Muttrc mutt-1.3.27/Muttrc
56--- mutt-1.3.27.orig/Muttrc Tue Jan 1 21:18:05 2002
57+++ mutt-1.3.27/Muttrc Fri Feb 1 22:51:32 2002
58@@ -19,6 +19,11 @@
59 macro index <f1> "!less /usr/local/doc/mutt/manual.txt\n" "Show Mutt documentation"
60 macro pager <f1> "!less /usr/local/doc/mutt/manual.txt\n" "Show Mutt documentation"
61
62+# Use folders which match on \\.gz$ as gzipped folders:
63+# open-hook \\.gz$ "gzip -cd %f > %t"
64+# close-hook \\.gz$ "gzip -c %t > %f"
65+# append-hook \\.gz$ "gzip -c %t >> %f"
66+
67 # If Mutt is unable to determine your site's domain name correctly, you can
68 # set the default here.
69 #
70diff -Nur mutt-1.3.27.orig/Muttrc.head mutt-1.3.27/Muttrc.head
71--- mutt-1.3.27.orig/Muttrc.head Tue Jan 1 21:18:02 2002
72+++ mutt-1.3.27/Muttrc.head Fri Feb 1 22:51:32 2002
73@@ -19,6 +19,11 @@
74 macro index <f1> "!less /usr/local/doc/mutt/manual.txt\n" "Show Mutt documentation"
75 macro pager <f1> "!less /usr/local/doc/mutt/manual.txt\n" "Show Mutt documentation"
76
77+# Use folders which match on \\.gz$ as gzipped folders:
78+# open-hook \\.gz$ "gzip -cd %f > %t"
79+# close-hook \\.gz$ "gzip -c %t > %f"
80+# append-hook \\.gz$ "gzip -c %t >> %f"
81+
82 # If Mutt is unable to determine your site's domain name correctly, you can
83 # set the default here.
84 #
85diff -Nur mutt-1.3.27.orig/Muttrc.head.in mutt-1.3.27/Muttrc.head.in
86--- mutt-1.3.27.orig/Muttrc.head.in Mon Mar 20 11:25:49 2000
87+++ mutt-1.3.27/Muttrc.head.in Fri Feb 1 22:51:32 2002
88@@ -19,6 +19,11 @@
89 macro index <f1> "!less @docdir@/manual.txt\n" "Show Mutt documentation"
90 macro pager <f1> "!less @docdir@/manual.txt\n" "Show Mutt documentation"
91
92+# Use folders which match on \\.gz$ as gzipped folders:
93+# open-hook \\.gz$ "gzip -cd %f > %t"
94+# close-hook \\.gz$ "gzip -c %t > %f"
95+# append-hook \\.gz$ "gzip -c %t >> %f"
96+
97 # If Mutt is unable to determine your site's domain name correctly, you can
98 # set the default here.
99 #
100diff -Nur mutt-1.3.27.orig/PATCHES mutt-1.3.27/PATCHES
101--- mutt-1.3.27.orig/PATCHES Mon Nov 26 20:16:22 2001
102+++ mutt-1.3.27/PATCHES Fri Feb 1 22:51:32 2002
103@@ -0,0 +1 @@
104+patch-1.3.27.rr.compressed.1
105diff -Nur mutt-1.3.27.orig/compress.c mutt-1.3.27/compress.c
106--- mutt-1.3.27.orig/compress.c Thu Jan 1 01:00:00 1970
107+++ mutt-1.3.27/compress.c Fri Feb 1 22:51:32 2002
108@@ -0,0 +1,483 @@
109+/*
110+ * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
111+ *
112+ * This program is free software; you can redistribute it and/or modify
113+ * it under the terms of the GNU General Public License as published by
114+ * the Free Software Foundation; either version 2 of the License, or
115+ * (at your option) any later version.
116+ *
117+ * This program is distributed in the hope that it will be useful,
118+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
119+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
120+ * GNU General Public License for more details.
121+ *
122+ * You should have received a copy of the GNU General Public License
123+ * along with this program; if not, write to the Free Software
124+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
125+ */
126+
127+#include "mutt.h"
128+
129+#ifdef USE_COMPRESSED
130+
131+#include "mx.h"
132+#include "mailbox.h"
133+#include "mutt_curses.h"
134+
135+#include <errno.h>
136+#include <string.h>
137+#include <unistd.h>
138+#include <sys/stat.h>
139+
140+typedef struct
141+{
142+ const char *close; /* close-hook command */
143+ const char *open; /* open-hook command */
144+ const char *append; /* append-hook command */
145+ off_t size; /* size of real folder */
146+} COMPRESS_INFO;
147+
148+
149+/*
150+ * ctx - context to lock
151+ * excl - exclusive lock?
152+ * retry - should retry if unable to lock?
153+ */
154+int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
155+{
156+ int r;
157+
158+ if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
159+ ctx->locked = 1;
160+ else if (retry && !excl)
161+ {
162+ ctx->readonly = 1;
163+ return 0;
164+ }
165+
166+ return (r);
167+}
168+
169+void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
170+{
171+ if (ctx->locked)
172+ {
173+ fflush (fp);
174+
175+ mx_unlock_file (ctx->realpath, fileno (fp), 1);
176+ ctx->locked = 0;
177+ }
178+}
179+
180+static int is_new (const char *path)
181+{
182+ return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
183+}
184+
185+static const char* find_compress_hook (int type, const char *path)
186+{
187+ const char* c = mutt_find_hook (type, path);
188+ return (!c || !*c) ? NULL : c;
189+}
190+
191+int mutt_can_read_compressed (const char *path)
192+{
193+ return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
194+}
195+
196+/*
197+ * if the file is new, we really do not append, but create, and so use
198+ * close-hook, and not append-hook
199+ */
200+static const char* get_append_command (const char *path, const CONTEXT* ctx)
201+{
202+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
203+ return (is_new (path)) ? ci->close : ci->append;
204+}
205+
206+int mutt_can_append_compressed (const char *path)
207+{
208+ int magic;
209+
210+ if (is_new (path))
211+ return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
212+
213+ magic = mx_get_magic (path);
214+
215+ if (magic != 0 && magic != M_COMPRESSED)
216+ return 0;
217+
218+ return (find_compress_hook (M_APPENDHOOK, path)
219+ || (find_compress_hook (M_OPENHOOK, path)
220+ && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
221+}
222+
223+/* open a compressed mailbox */
224+static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
225+{
226+ COMPRESS_INFO *ci;
227+
228+ /* Now lets uncompress this thing */
229+ ci = safe_malloc (sizeof (COMPRESS_INFO));
230+ ctx->compressinfo = (void*) ci;
231+ ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
232+ ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
233+ ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
234+ return ci;
235+}
236+
237+static void set_path (CONTEXT* ctx)
238+{
239+ char tmppath[_POSIX_PATH_MAX];
240+
241+ /* Setup the right paths */
242+ ctx->realpath = ctx->path;
243+
244+ /* Uncompress to /tmp */
245+ mutt_mktemp (tmppath);
246+ ctx->path = safe_malloc (strlen (tmppath) + 1);
247+ strcpy (ctx->path, tmppath);
248+}
249+
250+static int get_size (const char* path)
251+{
252+ struct stat sb;
253+ if (stat (path, &sb) != 0)
254+ return 0;
255+ return (sb.st_size);
256+}
257+
258+static void store_size (CONTEXT* ctx)
259+{
260+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
261+ ci->size = get_size (ctx->realpath);
262+}
263+
264+static const char *
265+compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
266+ const char *fmt, const char *ifstring,
267+ const char *elsestring, unsigned long data,
268+ format_flag flags)
269+{
270+ char tmp[SHORT_STRING];
271+
272+ CONTEXT *ctx = (CONTEXT *) data;
273+ switch (op)
274+ {
275+ case 'f':
276+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
277+ snprintf (dest, destlen, tmp, ctx->realpath);
278+ break;
279+ case 't':
280+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
281+ snprintf (dest, destlen, tmp, ctx->path);
282+ break;
283+ }
284+ return (src);
285+}
286+
287+/*
288+ * check that the command has both %f and %t
289+ * 0 means OK, -1 means error
290+ */
291+int mutt_test_compress_command (const char* cmd)
292+{
293+ return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
294+}
295+
296+static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
297+{
298+ char expanded[_POSIX_PATH_MAX];
299+ mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str,
300+ (unsigned long) ctx, 0);
301+ return safe_strdup (expanded);
302+}
303+
304+int mutt_check_mailbox_compressed (CONTEXT* ctx)
305+{
306+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
307+ if (ci->size != get_size (ctx->realpath))
308+ {
309+ safe_free ((void**)&ctx->compressinfo);
310+ safe_free ((void**)&ctx->realpath);
311+ mutt_error _("Mailbox was corrupted!");
312+ return (-1);
313+ }
314+ return (0);
315+}
316+
317+int mutt_open_read_compressed (CONTEXT *ctx)
318+{
319+ char *cmd;
320+ FILE *fp;
321+ int rc;
322+
323+ COMPRESS_INFO *ci = set_compress_info (ctx);
324+ if (!ci->open) {
325+ ctx->magic = 0;
326+ safe_free ((void**)ctx->compressinfo);
327+ return (-1);
328+ }
329+ if (!ci->close || access (ctx->path, W_OK) != 0)
330+ ctx->readonly = 1;
331+
332+ set_path (ctx);
333+ store_size (ctx);
334+
335+ if (!ctx->quiet)
336+ mutt_message (_("Decompressing %s..."), ctx->realpath);
337+
338+ cmd = get_compression_cmd (ci->open, ctx);
339+ if (cmd == NULL)
340+ return (-1);
341+ dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
342+
343+ if ((fp = fopen (ctx->realpath, "r")) == NULL)
344+ {
345+ mutt_perror (ctx->realpath);
346+ safe_free ((void **)&cmd);
347+ return (-1);
348+ }
349+ mutt_block_signals ();
350+ if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
351+ {
352+ fclose (fp);
353+ mutt_unblock_signals ();
354+ mutt_error _("Unable to lock mailbox!");
355+ safe_free ((void **)&cmd);
356+ return (-1);
357+ }
358+
359+ endwin ();
360+ fflush (stdout);
361+ fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
362+ rc = mutt_system (cmd);
363+ mbox_unlock_compressed (ctx, fp);
364+ mutt_unblock_signals ();
365+ fclose (fp);
366+
367+ if (rc)
368+ {
369+ mutt_any_key_to_continue (NULL);
370+ ctx->magic = 0;
371+ safe_free ((void**)ctx->compressinfo);
372+ mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
373+ }
374+ safe_free ((void **)&cmd);
375+ if (rc)
376+ return (-1);
377+
378+ if (mutt_check_mailbox_compressed (ctx))
379+ return (-1);
380+
381+ ctx->magic = mx_get_magic (ctx->path);
382+
383+ return (0);
384+}
385+
386+void restore_path (CONTEXT* ctx)
387+{
388+ safe_free ((void **)&ctx->path);
389+ ctx->path = ctx->realpath;
390+}
391+
392+/* remove the temporary mailbox */
393+void remove_file (CONTEXT* ctx)
394+{
395+ if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
396+ remove (ctx->path);
397+}
398+
399+int mutt_open_append_compressed (CONTEXT *ctx)
400+{
401+ FILE *fh;
402+ COMPRESS_INFO *ci = set_compress_info (ctx);
403+
404+ if (!get_append_command (ctx->path, ctx))
405+ {
406+ if (ci->open && ci->close)
407+ return (mutt_open_read_compressed (ctx));
408+
409+ ctx->magic = 0;
410+ safe_free ((void**)&ctx->compressinfo);
411+ return (-1);
412+ }
413+
414+ set_path (ctx);
415+
416+ ctx->magic = DefaultMagic;
417+
418+ if (!is_new (ctx->realpath))
419+ if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
420+ if ((fh = fopen (ctx->path, "w")))
421+ fclose (fh);
422+ /* No error checking - the parent function will catch it */
423+
424+ return (0);
425+}
426+
427+/* close a compressed mailbox */
428+void mutt_fast_close_compressed (CONTEXT *ctx)
429+{
430+ dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
431+ ctx->path));
432+
433+ if (ctx->compressinfo)
434+ {
435+ if (ctx->fp)
436+ fclose (ctx->fp);
437+ ctx->fp = NULL;
438+ /* if the folder was removed, remove the gzipped folder too */
439+ if ((ctx->magic > 0)
440+ && (access (ctx->path, F_OK) != 0)
441+ && ! option (OPTSAVEEMPTY))
442+ remove (ctx->realpath);
443+ else
444+ remove_file (ctx);
445+
446+ restore_path (ctx);
447+ safe_free ((void**)&ctx->compressinfo);
448+ }
449+}
450+
451+/* return 0 on success, -1 on failure */
452+int mutt_sync_compressed (CONTEXT* ctx)
453+{
454+ char *cmd;
455+ int rc = 0;
456+ FILE *fp;
457+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
458+
459+ if (!ctx->quiet)
460+ mutt_message (_("Compressing %s..."), ctx->realpath);
461+
462+ cmd = get_compression_cmd (ci->close, ctx);
463+ if (cmd == NULL)
464+ return (-1);
465+
466+ if ((fp = fopen (ctx->realpath, "a")) == NULL)
467+ {
468+ mutt_perror (ctx->realpath);
469+ safe_free ((void **)&cmd);
470+ return (-1);
471+ }
472+ mutt_block_signals ();
473+ if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
474+ {
475+ fclose (fp);
476+ mutt_unblock_signals ();
477+ mutt_error _("Unable to lock mailbox!");
478+ store_size (ctx);
479+ safe_free ((void **)&cmd);
480+ return (-1);
481+ }
482+
483+ dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
484+
485+ endwin ();
486+ fflush (stdout);
487+ fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
488+ if (mutt_system (cmd))
489+ {
490+ mutt_any_key_to_continue (NULL);
491+ mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
492+ rc = -1;
493+ }
494+
495+ mbox_unlock_compressed (ctx, fp);
496+ mutt_unblock_signals ();
497+ fclose (fp);
498+
499+ safe_free ((void **)&cmd);
500+
501+ store_size (ctx);
502+
503+ return (rc);
504+}
505+
506+int mutt_slow_close_compressed (CONTEXT *ctx)
507+{
508+ FILE *fp;
509+ const char *append;
510+ char *cmd;
511+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
512+
513+ dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
514+ ctx->path));
515+
516+ if (! (ctx->append
517+ && ((append = get_append_command (ctx->realpath, ctx))
518+ || (append = ci->close))))
519+ {
520+ /* if we can not or should not append, we only have to remove the */
521+ /* compressed info, because sync was already called */
522+ mutt_fast_close_compressed (ctx);
523+ return (0);
524+ }
525+
526+ if (ctx->fp)
527+ fclose (ctx->fp);
528+ ctx->fp = NULL;
529+
530+ if (!ctx->quiet)
531+ {
532+ if (append == ci->close)
533+ mutt_message (_("Compressing %s..."), ctx->realpath);
534+ else
535+ mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
536+ }
537+
538+ cmd = get_compression_cmd (append, ctx);
539+ if (cmd == NULL)
540+ return (-1);
541+
542+ if ((fp = fopen (ctx->realpath, "a")) == NULL)
543+ {
544+ mutt_perror (ctx->realpath);
545+ safe_free ((void **)&cmd);
546+ return (-1);
547+ }
548+ mutt_block_signals ();
549+ if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
550+ {
551+ fclose (fp);
552+ mutt_unblock_signals ();
553+ mutt_error _("Unable to lock mailbox!");
554+ safe_free ((void **)&cmd);
555+ return (-1);
556+ }
557+
558+ dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
559+
560+ endwin ();
561+ fflush (stdout);
562+
563+ if (append == ci->close)
564+ fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
565+ else
566+ fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
567+
568+ if (mutt_system (cmd))
569+ {
570+ mutt_any_key_to_continue (NULL);
571+ mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"),
572+ ctx->path);
573+ safe_free ((void **)&cmd);
574+ mbox_unlock_compressed (ctx, fp);
575+ mutt_unblock_signals ();
576+ fclose (fp);
577+ return (-1);
578+ }
579+
580+ mbox_unlock_compressed (ctx, fp);
581+ mutt_unblock_signals ();
582+ fclose (fp);
583+ remove_file (ctx);
584+ restore_path (ctx);
585+ safe_free ((void **)&cmd);
586+ safe_free ((void **)&ctx->compressinfo);
587+
588+ return (0);
589+}
590+
591+#endif /* USE_COMPRESSED */
592diff -Nur mutt-1.3.27.orig/compress.h mutt-1.3.27/compress.h
593--- mutt-1.3.27.orig/compress.h Thu Jan 1 01:00:00 1970
594+++ mutt-1.3.27/compress.h Fri Feb 1 22:51:32 2002
595@@ -0,0 +1,27 @@
596+/*
597+ * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
598+ *
599+ * This program is free software; you can redistribute it and/or modify
600+ * it under the terms of the GNU General Public License as published by
601+ * the Free Software Foundation; either version 2 of the License, or
602+ * (at your option) any later version.
603+ *
604+ * This program is distributed in the hope that it will be useful,
605+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
606+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
607+ * GNU General Public License for more details.
608+ *
609+ * You should have received a copy of the GNU General Public License
610+ * along with this program; if not, write to the Free Software
611+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
612+ */
613+
614+int mutt_can_read_compressed (const char *);
615+int mutt_can_append_compressed (const char *);
616+int mutt_open_read_compressed (CONTEXT *);
617+int mutt_open_append_compressed (CONTEXT *);
618+int mutt_slow_close_compressed (CONTEXT *);
619+int mutt_sync_compressed (CONTEXT *);
620+int mutt_test_compress_command (const char *);
621+int mutt_check_mailbox_compressed (CONTEXT *);
622+void mutt_fast_close_compressed (CONTEXT *);
623diff -Nur mutt-1.3.27.orig/config.h.in mutt-1.3.27/config.h.in
624--- mutt-1.3.27.orig/config.h.in Fri Aug 3 18:52:17 2001
625+++ mutt-1.3.27/config.h.in Fri Feb 1 22:52:59 2002
626@@ -151,6 +151,9 @@
64419b42
JB
627 /* Define to enable Sun mailtool attachments support. */
628 #undef SUN_ATTACHMENT
c9dd7ba8
JB
629
630+/* Define to enable compressed mailboxes support */
631+#undef USE_COMPRESSED
632+
64419b42 633 /* Define if the result of isprint() is unreliable. */
c9dd7ba8
JB
634 #undef LOCALES_HACK
635
636diff -Nur mutt-1.3.27.orig/configure mutt-1.3.27/configure
637--- mutt-1.3.27.orig/configure Tue Jan 1 21:17:56 2002
638+++ mutt-1.3.27/configure Fri Feb 1 22:51:32 2002
639@@ -60,6 +60,8 @@
640 ac_help="$ac_help
641 --enable-locales-fix The result of isprint() is unreliable "
642 ac_help="$ac_help
643+ --enable-compressed Enable compressed folders support "
644+ac_help="$ac_help
645 --with-exec-shell=SHELL Specify alternate shell (ONLY if /bin/sh is broken)"
646 ac_help="$ac_help
647 --enable-exact-address Enable regeneration of email addresses"
648@@ -5793,6 +5795,18 @@
649 EOF
650
651 fi
652+fi
653+
654+
655+# Check whether --enable-compressed or --disable-compressed was given.
656+if test "${enable_compressed+set}" = set; then
657+ enableval="$enable_compressed"
658+ if test x$enableval = xyes; then
659+ cat >> confdefs.h <<\EOF
660+#define USE_COMPRESSED 1
661+EOF
662+
663+ fi
664 fi
665
666
667diff -Nur mutt-1.3.27.orig/configure.in mutt-1.3.27/configure.in
668--- mutt-1.3.27.orig/configure.in Fri Feb 1 22:51:17 2002
669+++ mutt-1.3.27/configure.in Fri Feb 1 22:51:32 2002
670@@ -644,6 +644,11 @@
671 AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
672 fi])
673
674+AC_ARG_ENABLE(compressed, [ --enable-compressed Enable compressed folders support ],
675+ [if test x$enableval = xyes; then
676+ AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
677+ fi])
678+
679 AC_ARG_WITH(exec-shell, [ --with-exec-shell=SHELL Specify alternate shell (ONLY if /bin/sh is broken)],
680 [if test $withval != yes; then
681 AC_DEFINE_UNQUOTED(EXECSHELL, "$withval")
682diff -Nur mutt-1.3.27.orig/curs_main.c mutt-1.3.27/curs_main.c
683--- mutt-1.3.27.orig/curs_main.c Wed Jan 23 00:42:01 2002
684+++ mutt-1.3.27/curs_main.c Fri Feb 1 22:51:32 2002
685@@ -1010,6 +1010,11 @@
686 {
687 int check;
688
689+#ifdef USE_COMPRESSED
690+ if (Context->compressinfo && Context->realpath)
691+ mutt_str_replace (&LastFolder, Context->realpath);
692+ else
693+#endif
694 mutt_str_replace (&LastFolder, Context->path);
695 oldcount = Context ? Context->msgcount : 0;
696
697diff -Nur mutt-1.3.27.orig/doc/manual-4.html mutt-1.3.27/doc/manual-4.html
698--- mutt-1.3.27.orig/doc/manual-4.html Tue Jan 1 21:18:11 2002
699+++ mutt-1.3.27/doc/manual-4.html Fri Feb 1 22:51:32 2002
700@@ -788,7 +788,176 @@
701 macro pager \cb |urlview\n
702 </PRE>
703 </CODE></BLOCKQUOTE>
704+</P>
705+
706+<H2><A NAME="ss4.14">4.14 Compressed folders Support (OPTIONAL)</A>
707+</H2>
708+
709+
710+<P>If Mutt was compiled with compressed folders support (by running the
711+<EM>configure</EM> script with the <EM>--enable-compressed</EM> flag), Mutt
712+can open folders stored in an arbitrary format, provided that the user
713+has a script to convert from/to this format to one of the accepted.</P>
714+<P>The most common use is to open compressed archived folders e.g. with
715+gzip.</P>
716+<P>In addition, the user can provide a script that gets a folder in an
717+accepted format and appends its context to the folder in the
718+user-defined format, which may be faster than converting the entire
719+folder to the accepted format, appending to it and converting back to
720+the user-defined format.</P>
721+<P>There are three hooks defined (
722+<A HREF="#open-hook">open-hook</A>,
723+<A HREF="#close-hook">close-hook</A> and
724+<A HREF="#append-hook">append-hook</A>) which define commands to uncompress and compress
725+a folder and to append messages to an existing compressed folder
726+respectively.</P>
727+<P>For example:</P>
728 <P>
729+<BLOCKQUOTE><CODE>
730+<PRE>
731+open-hook \\.gz$ "gzip -cd %f &gt; %t"
732+close-hook \\.gz$ "gzip -c %t &gt; %f"
733+append-hook \\.gz$ "gzip -c %t &gt;&gt; %f"
734+</PRE>
735+</CODE></BLOCKQUOTE>
736+</P>
737+<P>You do not have to specify all of the commands. If you omit
738+<A HREF="#append-hook">append-hook</A>, the folder will be open and
739+closed again each time you will add to it. If you omit
740+<A HREF="#close-hook">close-hook</A> (or give empty command) , the
741+folder will be open in the mode. If you specify
742+<A HREF="#append-hook">append-hook</A> though you'll be able to append
743+to the folder.</P>
744+<P>Note that Mutt will only try to use hooks if the file is not in one of
745+the accepted formats. In particular, if the file is empty, mutt
746+supposes it is not compressed. This is important because it allows the
747+use of programs that do not have well defined extensions. Just use
748+&quot;.&quot; as a regexp. But this may be surprising if your
749+compressing script produces empty files. In this situation, unset
750+<A HREF="manual-6.html#save_empty">$save_empty</A>, so that the compressed file
751+will be removed if you delete all of the messages.</P>
752+
753+<H3><A NAME="open-hook"></A> Open a compressed mailbox for reading</H3>
754+
755+<P>Usage: <CODE>open-hook</CODE> <EM>regexp</EM> &quot;<EM>command</EM>&quot;</P>
756+<P>The <EM>command</EM> is the command that can be used for opening the
757+folders whose names match <EM>regexp</EM>.</P>
758+<P>The <EM>command</EM> string is the printf-like format string, and it
759+should accept two parameters: %f, which is replaced with the
760+(compressed) folder name, and %t which is replaced with the
761+name of the temporary folder to which to write.</P>
762+<P>%f and %t can be repeated any number of times in the
763+command string, and all of the entries are replaced with the
764+appropriate folder name. In addition, %% is replaced by
765+%, as in printf, and any other %anything is left as is.</P>
766+<P>The <EM>command</EM> should <B>not</B> remove the original compressed file.
767+The <EM>command</EM> should return non-zero exit status if it fails, so
768+mutt knows something's wrong.</P>
769+<P>Example:</P>
770+<P>
771+<BLOCKQUOTE><CODE>
772+<PRE>
773+open-hook \\.gz$ "gzip -cd %f &gt; %t"
774+</PRE>
775+</CODE></BLOCKQUOTE>
776+</P>
777+<P>If the <EM>command</EM> is empty, this operation is disabled for this file
778+type.</P>
779+
780+<H3><A NAME="close-hook"></A> Write a compressed mailbox</H3>
781+
782+<P>Usage: <CODE>close-hook</CODE> <EM>regexp</EM> &quot;<EM>command</EM>&quot;</P>
783+<P>This is used to close the folder that was open with the
784+<A HREF="#open-hook">open-hook</A> command after some changes were made to it.</P>
785+<P>The <EM>command</EM> string is the command that can be used for closing the
786+folders whose names match <EM>regexp</EM>. It has the same format as in
787+the
788+<A HREF="#open-hook">open-hook</A> command. Temporary folder
789+in this case is the folder previously produced by the
790+<A HREF="#open-hook">open-hook</A> command.</P>
791+<P>The <EM>command</EM> should <B>not</B> remove the decompressed file. The
792+<EM>command</EM> should return non-zero exit status if it fails, so mutt
793+knows something's wrong.</P>
794+<P>Example:</P>
795+<P>
796+<BLOCKQUOTE><CODE>
797+<PRE>
798+close-hook \\.gz$ "gzip -c %t &gt; %f"
799+</PRE>
800+</CODE></BLOCKQUOTE>
801+</P>
802+<P>If the <EM>command</EM> is empty, this operation is disabled for this file
803+type, and the file can only be open in the read-only mode.</P>
804+<P>
805+<A HREF="#close-hook">close-hook</A> is not called when you exit
806+from the folder if the folder was not changed.</P>
807+
808+<H3><A NAME="append-hook"></A> Append a message to a compressed mailbox</H3>
809+
810+<P>Usage: <CODE>append-hook</CODE> <EM>regexp</EM> &quot;<EM>command</EM>&quot;</P>
811+<P>This command is used for saving to an existing compressed folder.
812+The <EM>command</EM> is the command that can be used for appending to the
813+folders whose names match <EM>regexp</EM>. It has the same format as in
814+the
815+<A HREF="#open-hook">open-hook</A> command.
816+The temporary folder in this case contains the messages that are being
817+appended. </P>
818+<P>The <EM>command</EM> should <B>not</B> remove the decompressed file. The
819+<EM>command</EM> should return non-zero exit status if it fails, so mutt
820+knows something's wrong.</P>
821+<P>Example:</P>
822+<P>
823+<BLOCKQUOTE><CODE>
824+<PRE>
825+append-hook \\.gz$ "gzip -c %t &gt;&gt; %f"
826+</PRE>
827+</CODE></BLOCKQUOTE>
828+</P>
829+<P>When
830+<A HREF="#append-hook">append-hook</A> is used, the folder is
831+not opened, which saves time, but this means that we can not find out
832+what the folder type is. Thus the default (
833+<A HREF="manual-6.html#mbox_type">$mbox_type</A>) type is always supposed (i.e.
834+this is the format used for the temporary folder).</P>
835+<P>If the file does not exist when you save to it,
836+<A HREF="#close-hook">close-hook</A> is called, and not
837+<A HREF="#append-hook">append-hook</A>.
838+<A HREF="#append-hook">append-hook</A> is only
839+for appending to existing folders.</P>
840+<P>If the <EM>command</EM> is empty, this operation is disabled for this file
841+type. In this case, the folder will be open and closed again (using
842+<A HREF="#open-hook">open-hook</A> and
843+<A HREF="#close-hook">close-hook</A>respectively) each time you will add to it.</P>
844+
845+<H3>Encrypted folders</H3>
846+
847+<P>The compressed folders support can also be used to handle encrypted
848+folders. If you want to encrypt a folder with PGP, you may want to use
849+the following hooks:</P>
850+<P>
851+<BLOCKQUOTE><CODE>
852+<PRE>
853+open-hook \\.pgp$ "pgp -f &lt; %f &gt; %t"
854+close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId &lt; %t &gt; %f"
855+</PRE>
856+</CODE></BLOCKQUOTE>
857+</P>
858+<P>Please note, that PGP does not support appending to an encrypted
859+folder, so there is no append-hook defined.</P>
860+<P>If you are using GnuPG instead of PGP, you may use the following hooks
861+instead:</P>
862+<P>
863+<BLOCKQUOTE><CODE>
864+<PRE>
865+open-hook \\.gpg$ "gpg --decrypt &lt; %f &gt; %t"
866+close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId &lt; %t &gt; %f"
867+</PRE>
868+</CODE></BLOCKQUOTE>
869+</P>
870+<P><B>Note:</B> the folder is temporary stored decrypted in the /tmp
871+directory, where it can be read by your system administrator. So think
872+about the security aspects of this.</P>
873+
874 <HR>
875 <A HREF="manual-5.html">Next</A>
876 <A HREF="manual-3.html">Previous</A>
877diff -Nur mutt-1.3.27.orig/doc/manual-6.html mutt-1.3.27/doc/manual-6.html
878--- mutt-1.3.27.orig/doc/manual-6.html Tue Jan 1 21:18:13 2002
879+++ mutt-1.3.27/doc/manual-6.html Fri Feb 1 22:51:32 2002
880@@ -70,12 +70,16 @@
881 <LI><CODE>
882 <A HREF="manual-5.html#alternative_order">alternative_order</A></CODE> <EM>mimetype</EM> [ <EM>mimetype</EM> ... ]</LI>
883 <LI><CODE>
884+<A HREF="manual-4.html#append-hook">append-hook</A></CODE> <EM>regexp</EM> &quot;<EM>command</EM>&quot;</LI>
885+<LI><CODE>
886 <A HREF="manual-5.html#auto_view">auto_view</A></CODE> <EM>mimetype</EM> [ <EM>mimetype</EM> ... ]</LI>
887 <LI><CODE>
888 <A HREF="manual-3.html#bind">bind</A></CODE> <EM>map</EM> <EM>key</EM> <EM>function</EM></LI>
889 <LI><CODE>
890 <A HREF="manual-3.html#charset-hook">charset-hook</A></CODE> <EM>alias</EM> <EM>charset</EM></LI>
891 <LI><CODE>
892+<A HREF="manual-4.html#close-hook">close-hook</A></CODE> <EM>regexp</EM> &quot;<EM>command</EM>&quot;</LI>
893+<LI><CODE>
894 <A HREF="manual-3.html#color">color</A></CODE> <EM>object</EM> <EM>foreground</EM> <EM>background</EM> [ <EM>regexp</EM> ]</LI>
895 <LI><CODE>
896 <A HREF="manual-3.html#color">uncolor</A></CODE> <EM>index</EM> <EM>pattern</EM> [ <EM>pattern</EM> ... ]</LI>
897@@ -118,6 +122,8 @@
898 <LI><CODE>
899 <A HREF="manual-3.html#my_hdr">unmy_hdr</A></CODE> <EM>field</EM> [ <EM>field</EM> ... ]</LI>
900 <LI><CODE>
901+<A HREF="manual-4.html#open-hook">open-hook</A></CODE> <EM>regexp</EM> &quot;<EM>command</EM>&quot;</LI>
902+<LI><CODE>
903 <A HREF="manual-3.html#pgp-hook">pgp-hook</A></CODE> <EM>pattern</EM> <EM>key-id</EM></LI>
904 <LI><CODE>
905 <A HREF="manual-3.html#push">push</A></CODE> <EM>string</EM></LI>
906diff -Nur mutt-1.3.27.orig/doc/manual.sgml mutt-1.3.27/doc/manual.sgml
907--- mutt-1.3.27.orig/doc/manual.sgml Tue Jan 1 21:18:05 2002
908+++ mutt-1.3.27/doc/manual.sgml Fri Feb 1 22:51:32 2002
909@@ -2318,6 +2318,176 @@
910 macro pager \cb |urlview\n
911 </verb></tscreen>
912
913+<sect1>Compressed folders Support (OPTIONAL)
914+<p>
915+
916+If Mutt was compiled with compressed folders support (by running the
917+<em/configure/ script with the <em/--enable-compressed/ flag), Mutt
918+can open folders stored in an arbitrary format, provided that the user
919+has a script to convert from/to this format to one of the accepted.
920+
921+The most common use is to open compressed archived folders e.g. with
922+gzip.
923+
924+In addition, the user can provide a script that gets a folder in an
925+accepted format and appends its context to the folder in the
926+user-defined format, which may be faster than converting the entire
927+folder to the accepted format, appending to it and converting back to
928+the user-defined format.
929+
930+There are three hooks defined (<ref id="open-hook" name="open-hook">,
931+<ref id="close-hook" name="close-hook"> and <ref id="append-hook"
932+name="append-hook">) which define commands to uncompress and compress
933+a folder and to append messages to an existing compressed folder
934+respectively.
935+
936+For example:
937+
938+<tscreen><verb>
939+open-hook \\.gz$ "gzip -cd %f &gt; %t"
940+close-hook \\.gz$ "gzip -c %t &gt; %f"
941+append-hook \\.gz$ "gzip -c %t &gt;&gt; %f"
942+</verb></tscreen>
943+
944+You do not have to specify all of the commands. If you omit <ref
945+id="append-hook" name="append-hook">, the folder will be open and
946+closed again each time you will add to it. If you omit <ref
947+id="close-hook" name="close-hook"> (or give empty command) , the
948+folder will be open in the mode. If you specify <ref
949+id="append-hook" name="append-hook"> though you'll be able to append
950+to the folder.
951+
952+Note that Mutt will only try to use hooks if the file is not in one of
953+the accepted formats. In particular, if the file is empty, mutt
954+supposes it is not compressed. This is important because it allows the
955+use of programs that do not have well defined extensions. Just use
956+&dquot;.&dquot; as a regexp. But this may be surprising if your
957+compressing script produces empty files. In this situation, unset <ref
958+id="save_empty" name="&dollar;save&lowbar;empty">, so that the compressed file
959+will be removed if you delete all of the messages.
960+
961+<sect2>Open a compressed mailbox for reading<label id="open-hook">
962+<p>
963+Usage: <tt/open-hook/ <em/regexp/ &dquot;<em/command/&dquot;
964+
965+The <em/command/ is the command that can be used for opening the
966+folders whose names match <em/regexp/.
967+
968+The <em/command/ string is the printf-like format string, and it
969+should accept two parameters: &percnt;f, which is replaced with the
970+(compressed) folder name, and &percnt;t which is replaced with the
971+name of the temporary folder to which to write.
972+
973+&percnt;f and &percnt;t can be repeated any number of times in the
974+command string, and all of the entries are replaced with the
975+appropriate folder name. In addition, &percnt;&percnt; is replaced by
976+&percnt;, as in printf, and any other &percnt;anything is left as is.
977+
978+The <em/command/ should <bf/not/ remove the original compressed file.
979+The <em/command/ should return non-zero exit status if it fails, so
980+mutt knows something's wrong.
981+
982+Example:
983+
984+<tscreen><verb>
985+open-hook \\.gz$ "gzip -cd %f &gt; %t"
986+</verb></tscreen>
987+
988+If the <em/command/ is empty, this operation is disabled for this file
989+type.
990+
991+<sect2>Write a compressed mailbox<label id="close-hook">
992+<p>
993+Usage: <tt/close-hook/ <em/regexp/ &dquot;<em/command/&dquot;
994+
995+This is used to close the folder that was open with the <ref id="open-hook"
996+name="open-hook"> command after some changes were made to it.
997+
998+The <em/command/ string is the command that can be used for closing the
999+folders whose names match <em/regexp/. It has the same format as in
1000+the <ref id="open-hook" name="open-hook"> command. Temporary folder
1001+in this case is the folder previously produced by the <ref id="open-hook"
1002+name="open-hook"> command.
1003+
1004+The <em/command/ should <bf/not/ remove the decompressed file. The
1005+<em/command/ should return non-zero exit status if it fails, so mutt
1006+knows something's wrong.
1007+
1008+Example:
1009+
1010+<tscreen><verb>
1011+close-hook \\.gz$ "gzip -c %t &gt; %f"
1012+</verb></tscreen>
1013+
1014+If the <em/command/ is empty, this operation is disabled for this file
1015+type, and the file can only be open in the read-only mode.
1016+
1017+<ref id="close-hook" name ="close-hook"> is not called when you exit
1018+from the folder if the folder was not changed.
1019+
1020+<sect2>Append a message to a compressed mailbox<label id="append-hook">
1021+<p>
1022+Usage: <tt/append-hook/ <em/regexp/ &dquot;<em/command/&dquot;
1023+
1024+This command is used for saving to an existing compressed folder.
1025+The <em/command/ is the command that can be used for appending to the
1026+folders whose names match <em/regexp/. It has the same format as in
1027+ the <ref id="open-hook" name="open-hook"> command.
1028+The temporary folder in this case contains the messages that are being
1029+appended.
1030+
1031+The <em/command/ should <bf/not/ remove the decompressed file. The
1032+<em/command/ should return non-zero exit status if it fails, so mutt
1033+knows something's wrong.
1034+
1035+Example:
1036+
1037+<tscreen><verb>
1038+append-hook \\.gz$ "gzip -c %t &gt;&gt; %f"
1039+</verb></tscreen>
1040+
1041+When <ref id="append-hook" name="append-hook"> is used, the folder is
1042+not opened, which saves time, but this means that we can not find out
1043+what the folder type is. Thus the default (<ref id="mbox_type"
1044+name="&dollar;mbox&lowbar;type">) type is always supposed (i.e.
1045+this is the format used for the temporary folder).
1046+
1047+If the file does not exist when you save to it, <ref id="close-hook"
1048+name="close-hook"> is called, and not <ref id="append-hook"
1049+name="append-hook">. <ref id="append-hook" name="append-hook"> is only
1050+for appending to existing folders.
1051+
1052+If the <em/command/ is empty, this operation is disabled for this file
1053+type. In this case, the folder will be open and closed again (using
1054+<ref id="open-hook" name="open-hook"> and <ref id="close-hook"
1055+name="close-hook">respectively) each time you will add to it.
1056+
1057+<sect2>Encrypted folders
1058+<p>
1059+The compressed folders support can also be used to handle encrypted
1060+folders. If you want to encrypt a folder with PGP, you may want to use
1061+the following hooks:
1062+
1063+<tscreen><verb>
1064+open-hook \\.pgp$ "pgp -f &lt; %f &gt; %t"
1065+close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId &lt; %t &gt; %f"
1066+</verb></tscreen>
1067+
1068+Please note, that PGP does not support appending to an encrypted
1069+folder, so there is no append-hook defined.
1070+
1071+If you are using GnuPG instead of PGP, you may use the following hooks
1072+instead:
1073+
1074+<tscreen><verb>
1075+open-hook \\.gpg$ "gpg --decrypt &lt; %f &gt; %t"
1076+close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId &lt; %t &gt; %f"
1077+</verb></tscreen>
1078+
1079+<bf/Note:/ the folder is temporary stored decrypted in the /tmp
1080+directory, where it can be read by your system administrator. So think
1081+about the security aspects of this.
1082+
1083 <sect>Mutt's MIME Support
1084 <p>
1085 Quite a bit of effort has been made to make Mutt the premier text-mode
1086@@ -2868,12 +3038,16 @@
1087 <item>
1088 <tt><ref id="alternative_order" name="alternative&lowbar;order"></tt> <em/mimetype/ &lsqb; <em/mimetype/ ... &rsqb;
1089 <item>
1090+<tt><ref id="append-hook" name="append-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
1091+<item>
1092 <tt><ref id="auto_view" name="auto&lowbar;view"></tt> <em/mimetype/ &lsqb; <em/mimetype/ ... &rsqb;
1093 <item>
1094 <tt><ref id="bind" name="bind"></tt> <em/map/ <em/key/ <em/function/
1095 <item>
1096 <tt><ref id="charset-hook" name="charset-hook"></tt> <em/alias/ <em/charset/
1097 <item>
1098+<tt><ref id="close-hook" name="close-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
1099+<item>
1100 <tt><ref id="color" name="color"></tt> <em/object/ <em/foreground/ <em/background/ &lsqb; <em/regexp/ &rsqb;
1101 <item>
1102 <tt><ref id="color" name="uncolor"></tt> <em/index/ <em/pattern/ &lsqb; <em/pattern/ ... &rsqb;
1103@@ -2916,6 +3090,8 @@
1104 <item>
1105 <tt><ref id="my_hdr" name="unmy&lowbar;hdr"></tt> <em/field/ &lsqb; <em/field/ ... &rsqb;
1106 <item>
1107+<tt><ref id="open-hook" name="open-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
1108+<item>
1109 <tt><ref id="pgp-hook" name="pgp-hook"></tt> <em/pattern/ <em/key-id/
1110 <item>
1111 <tt><ref id="push" name="push"></tt> <em/string/
1112diff -Nur mutt-1.3.27.orig/doc/manual.sgml.head mutt-1.3.27/doc/manual.sgml.head
1113--- mutt-1.3.27.orig/doc/manual.sgml.head Wed Jan 23 00:42:01 2002
1114+++ mutt-1.3.27/doc/manual.sgml.head Fri Feb 1 22:51:32 2002
1115@@ -2319,6 +2319,176 @@
1116 macro pager \cb |urlview\n
1117 </verb></tscreen>
1118
1119+<sect1>Compressed folders Support (OPTIONAL)
1120+<p>
1121+
1122+If Mutt was compiled with compressed folders support (by running the
1123+<em/configure/ script with the <em/--enable-compressed/ flag), Mutt
1124+can open folders stored in an arbitrary format, provided that the user
1125+has a script to convert from/to this format to one of the accepted.
1126+
1127+The most common use is to open compressed archived folders e.g. with
1128+gzip.
1129+
1130+In addition, the user can provide a script that gets a folder in an
1131+accepted format and appends its context to the folder in the
1132+user-defined format, which may be faster than converting the entire
1133+folder to the accepted format, appending to it and converting back to
1134+the user-defined format.
1135+
1136+There are three hooks defined (<ref id="open-hook" name="open-hook">,
1137+<ref id="close-hook" name="close-hook"> and <ref id="append-hook"
1138+name="append-hook">) which define commands to uncompress and compress
1139+a folder and to append messages to an existing compressed folder
1140+respectively.
1141+
1142+For example:
1143+
1144+<tscreen><verb>
1145+open-hook \\.gz$ "gzip -cd %f &gt; %t"
1146+close-hook \\.gz$ "gzip -c %t &gt; %f"
1147+append-hook \\.gz$ "gzip -c %t &gt;&gt; %f"
1148+</verb></tscreen>
1149+
1150+You do not have to specify all of the commands. If you omit <ref
1151+id="append-hook" name="append-hook">, the folder will be open and
1152+closed again each time you will add to it. If you omit <ref
1153+id="close-hook" name="close-hook"> (or give empty command) , the
1154+folder will be open in the mode. If you specify <ref
1155+id="append-hook" name="append-hook"> though you'll be able to append
1156+to the folder.
1157+
1158+Note that Mutt will only try to use hooks if the file is not in one of
1159+the accepted formats. In particular, if the file is empty, mutt
1160+supposes it is not compressed. This is important because it allows the
1161+use of programs that do not have well defined extensions. Just use
1162+&dquot;.&dquot; as a regexp. But this may be surprising if your
1163+compressing script produces empty files. In this situation, unset <ref
1164+id="save_empty" name="&dollar;save&lowbar;empty">, so that the compressed file
1165+will be removed if you delete all of the messages.
1166+
1167+<sect2>Open a compressed mailbox for reading<label id="open-hook">
1168+<p>
1169+Usage: <tt/open-hook/ <em/regexp/ &dquot;<em/command/&dquot;
1170+
1171+The <em/command/ is the command that can be used for opening the
1172+folders whose names match <em/regexp/.
1173+
1174+The <em/command/ string is the printf-like format string, and it
1175+should accept two parameters: &percnt;f, which is replaced with the
1176+(compressed) folder name, and &percnt;t which is replaced with the
1177+name of the temporary folder to which to write.
1178+
1179+&percnt;f and &percnt;t can be repeated any number of times in the
1180+command string, and all of the entries are replaced with the
1181+appropriate folder name. In addition, &percnt;&percnt; is replaced by
1182+&percnt;, as in printf, and any other &percnt;anything is left as is.
1183+
1184+The <em/command/ should <bf/not/ remove the original compressed file.
1185+The <em/command/ should return non-zero exit status if it fails, so
1186+mutt knows something's wrong.
1187+
1188+Example:
1189+
1190+<tscreen><verb>
1191+open-hook \\.gz$ "gzip -cd %f &gt; %t"
1192+</verb></tscreen>
1193+
1194+If the <em/command/ is empty, this operation is disabled for this file
1195+type.
1196+
1197+<sect2>Write a compressed mailbox<label id="close-hook">
1198+<p>
1199+Usage: <tt/close-hook/ <em/regexp/ &dquot;<em/command/&dquot;
1200+
1201+This is used to close the folder that was open with the <ref id="open-hook"
1202+name="open-hook"> command after some changes were made to it.
1203+
1204+The <em/command/ string is the command that can be used for closing the
1205+folders whose names match <em/regexp/. It has the same format as in
1206+the <ref id="open-hook" name="open-hook"> command. Temporary folder
1207+in this case is the folder previously produced by the <ref id="open-hook"
1208+name="open-hook"> command.
1209+
1210+The <em/command/ should <bf/not/ remove the decompressed file. The
1211+<em/command/ should return non-zero exit status if it fails, so mutt
1212+knows something's wrong.
1213+
1214+Example:
1215+
1216+<tscreen><verb>
1217+close-hook \\.gz$ "gzip -c %t &gt; %f"
1218+</verb></tscreen>
1219+
1220+If the <em/command/ is empty, this operation is disabled for this file
1221+type, and the file can only be open in the read-only mode.
1222+
1223+<ref id="close-hook" name ="close-hook"> is not called when you exit
1224+from the folder if the folder was not changed.
1225+
1226+<sect2>Append a message to a compressed mailbox<label id="append-hook">
1227+<p>
1228+Usage: <tt/append-hook/ <em/regexp/ &dquot;<em/command/&dquot;
1229+
1230+This command is used for saving to an existing compressed folder.
1231+The <em/command/ is the command that can be used for appending to the
1232+folders whose names match <em/regexp/. It has the same format as in
1233+ the <ref id="open-hook" name="open-hook"> command.
1234+The temporary folder in this case contains the messages that are being
1235+appended.
1236+
1237+The <em/command/ should <bf/not/ remove the decompressed file. The
1238+<em/command/ should return non-zero exit status if it fails, so mutt
1239+knows something's wrong.
1240+
1241+Example:
1242+
1243+<tscreen><verb>
1244+append-hook \\.gz$ "gzip -c %t &gt;&gt; %f"
1245+</verb></tscreen>
1246+
1247+When <ref id="append-hook" name="append-hook"> is used, the folder is
1248+not opened, which saves time, but this means that we can not find out
1249+what the folder type is. Thus the default (<ref id="mbox_type"
1250+name="&dollar;mbox&lowbar;type">) type is always supposed (i.e.
1251+this is the format used for the temporary folder).
1252+
1253+If the file does not exist when you save to it, <ref id="close-hook"
1254+name="close-hook"> is called, and not <ref id="append-hook"
1255+name="append-hook">. <ref id="append-hook" name="append-hook"> is only
1256+for appending to existing folders.
1257+
1258+If the <em/command/ is empty, this operation is disabled for this file
1259+type. In this case, the folder will be open and closed again (using
1260+<ref id="open-hook" name="open-hook"> and <ref id="close-hook"
1261+name="close-hook">respectively) each time you will add to it.
1262+
1263+<sect2>Encrypted folders
1264+<p>
1265+The compressed folders support can also be used to handle encrypted
1266+folders. If you want to encrypt a folder with PGP, you may want to use
1267+the following hooks:
1268+
1269+<tscreen><verb>
1270+open-hook \\.pgp$ "pgp -f &lt; %f &gt; %t"
1271+close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId &lt; %t &gt; %f"
1272+</verb></tscreen>
1273+
1274+Please note, that PGP does not support appending to an encrypted
1275+folder, so there is no append-hook defined.
1276+
1277+If you are using GnuPG instead of PGP, you may use the following hooks
1278+instead:
1279+
1280+<tscreen><verb>
1281+open-hook \\.gpg$ "gpg --decrypt &lt; %f &gt; %t"
1282+close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId &lt; %t &gt; %f"
1283+</verb></tscreen>
1284+
1285+<bf/Note:/ the folder is temporary stored decrypted in the /tmp
1286+directory, where it can be read by your system administrator. So think
1287+about the security aspects of this.
1288+
1289 <sect>Mutt's MIME Support
1290 <p>
1291 Quite a bit of effort has been made to make Mutt the premier text-mode
1292@@ -2869,12 +3039,16 @@
1293 <item>
1294 <tt><ref id="alternative_order" name="alternative&lowbar;order"></tt> <em/mimetype/ &lsqb; <em/mimetype/ ... &rsqb;
1295 <item>
1296+<tt><ref id="append-hook" name="append-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
1297+<item>
1298 <tt><ref id="auto_view" name="auto&lowbar;view"></tt> <em/mimetype/ &lsqb; <em/mimetype/ ... &rsqb;
1299 <item>
1300 <tt><ref id="bind" name="bind"></tt> <em/map/ <em/key/ <em/function/
1301 <item>
1302 <tt><ref id="charset-hook" name="charset-hook"></tt> <em/alias/ <em/charset/
1303 <item>
1304+<tt><ref id="close-hook" name="close-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
1305+<item>
1306 <tt><ref id="color" name="color"></tt> <em/object/ <em/foreground/ <em/background/ &lsqb; <em/regexp/ &rsqb;
1307 <item>
1308 <tt><ref id="color" name="uncolor"></tt> <em/index/ <em/pattern/ &lsqb; <em/pattern/ ... &rsqb;
1309@@ -2917,6 +3091,8 @@
1310 <item>
1311 <tt><ref id="my_hdr" name="unmy&lowbar;hdr"></tt> <em/field/ &lsqb; <em/field/ ... &rsqb;
1312 <item>
1313+<tt><ref id="open-hook" name="open-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
1314+<item>
1315 <tt><ref id="pgp-hook" name="pgp-hook"></tt> <em/pattern/ <em/key-id/
1316 <item>
1317 <tt><ref id="push" name="push"></tt> <em/string/
1318diff -Nur mutt-1.3.27.orig/doc/manual.txt mutt-1.3.27/doc/manual.txt
1319--- mutt-1.3.27.orig/doc/manual.txt Tue Jan 1 21:18:08 2002
1320+++ mutt-1.3.27/doc/manual.txt Fri Feb 1 22:51:32 2002
1321@@ -78,6 +78,11 @@
1322 4.11.2 Authentication
1323 4.12 Managing multiple IMAP/POP accounts (OPTIONAL)
1324 4.13 Start a WWW Browser on URLs (EXTERNAL)
1325+ 4.14 Compressed folders Support (OPTIONAL)
1326+ 4.14.1 Open a compressed mailbox for reading
1327+ 4.14.2 Write a compressed mailbox
1328+ 4.14.3 Append a message to a compressed mailbox
1329+ 4.14.4 Encrypted folders
1330
1331 5. Mutt's MIME Support
1332 5.1 Using MIME in Mutt
1333@@ -2554,6 +2559,156 @@
1334 macro index \cb |urlview\n
1335 macro pager \cb |urlview\n
1336
1337+ 4\b4.\b.1\b14\b4.\b. C\bCo\bom\bmp\bpr\bre\bes\bss\bse\bed\bd f\bfo\bol\bld\bde\ber\brs\bs S\bSu\bup\bpp\bpo\bor\brt\bt (\b(O\bOP\bPT\bTI\bIO\bON\bNA\bAL\bL)\b)
1338+
1339+ If Mutt was compiled with compressed folders support (by running the
1340+ _\bc_\bo_\bn_\bf_\bi_\bg_\bu_\br_\be script with the _\b-_\b-_\be_\bn_\ba_\bb_\bl_\be_\b-_\bc_\bo_\bm_\bp_\br_\be_\bs_\bs_\be_\bd flag), Mutt can open
1341+ folders stored in an arbitrary format, provided that the user has a
1342+ script to convert from/to this format to one of the accepted.
1343+
1344+ The most common use is to open compressed archived folders e.g. with
1345+ gzip.
1346+
1347+ In addition, the user can provide a script that gets a folder in an
1348+ accepted format and appends its context to the folder in the user-
1349+ defined format, which may be faster than converting the entire folder
1350+ to the accepted format, appending to it and converting back to the
1351+ user-defined format.
1352+
1353+ There are three hooks defined (``open-hook'', ``close-hook'' and
1354+ ``append-hook'') which define commands to uncompress and compress a
1355+ folder and to append messages to an existing compressed folder
1356+ respectively.
1357+
1358+ For example:
1359+
1360+ open-hook \\.gz$ "gzip -cd %f > %t"
1361+ close-hook \\.gz$ "gzip -c %t > %f"
1362+ append-hook \\.gz$ "gzip -c %t >> %f"
1363+
1364+ You do not have to specify all of the commands. If you omit ``append-
1365+ hook'', the folder will be open and closed again each time you will
1366+ add to it. If you omit ``close-hook'' (or give empty command) , the
1367+ folder will be open in the mode. If you specify ``append-hook''
1368+ though you'll be able to append to the folder.
1369+
1370+ Note that Mutt will only try to use hooks if the file is not in one of
1371+ the accepted formats. In particular, if the file is empty, mutt
1372+ supposes it is not compressed. This is important because it allows the
1373+ use of programs that do not have well defined extensions. Just use "."
1374+ as a regexp. But this may be surprising if your compressing script
1375+ produces empty files. In this situation, unset ``$save_empty'', so
1376+ that the compressed file will be removed if you delete all of the
1377+ messages.
1378+
1379+ 4\b4.\b.1\b14\b4.\b.1\b1.\b. O\bOp\bpe\ben\bn a\ba c\bco\bom\bmp\bpr\bre\bes\bss\bse\bed\bd m\bma\bai\bil\blb\bbo\box\bx f\bfo\bor\br r\bre\bea\bad\bdi\bin\bng\bg
1380+
1381+ Usage: open-hook _\br_\be_\bg_\be_\bx_\bp "_\bc_\bo_\bm_\bm_\ba_\bn_\bd"
1382+
1383+ The _\bc_\bo_\bm_\bm_\ba_\bn_\bd is the command that can be used for opening the folders
1384+ whose names match _\br_\be_\bg_\be_\bx_\bp.
1385+
1386+ The _\bc_\bo_\bm_\bm_\ba_\bn_\bd string is the printf-like format string, and it should
1387+ accept two parameters: %f, which is replaced with the (compressed)
1388+ folder name, and %t which is replaced with the name of the temporary
1389+ folder to which to write.
1390+
1391+ %f and %t can be repeated any number of times in the command string,
1392+ and all of the entries are replaced with the appropriate folder name.
1393+ In addition, %% is replaced by %, as in printf, and any other
1394+ %anything is left as is.
1395+
1396+ The _\bc_\bo_\bm_\bm_\ba_\bn_\bd should n\bno\bot\bt remove the original compressed file. The
1397+ _\bc_\bo_\bm_\bm_\ba_\bn_\bd should return non-zero exit status if it fails, so mutt knows
1398+ something's wrong.
1399+
1400+ Example:
1401+
1402+ open-hook \\.gz$ "gzip -cd %f > %t"
1403+
1404+ If the _\bc_\bo_\bm_\bm_\ba_\bn_\bd is empty, this operation is disabled for this file
1405+ type.
1406+
1407+ 4\b4.\b.1\b14\b4.\b.2\b2.\b. W\bWr\bri\bit\bte\be a\ba c\bco\bom\bmp\bpr\bre\bes\bss\bse\bed\bd m\bma\bai\bil\blb\bbo\box\bx
1408+
1409+ Usage: close-hook _\br_\be_\bg_\be_\bx_\bp "_\bc_\bo_\bm_\bm_\ba_\bn_\bd"
1410+
1411+ This is used to close the folder that was open with the ``open-hook''
1412+ command after some changes were made to it.
1413+
1414+ The _\bc_\bo_\bm_\bm_\ba_\bn_\bd string is the command that can be used for closing the
1415+ folders whose names match _\br_\be_\bg_\be_\bx_\bp. It has the same format as in the
1416+ ``open-hook'' command. Temporary folder in this case is the folder
1417+ previously produced by the ``open-hook'' command.
1418+
1419+ The _\bc_\bo_\bm_\bm_\ba_\bn_\bd should n\bno\bot\bt remove the decompressed file. The _\bc_\bo_\bm_\bm_\ba_\bn_\bd
1420+ should return non-zero exit status if it fails, so mutt knows
1421+ something's wrong.
1422+
1423+ Example:
1424+
1425+ close-hook \\.gz$ "gzip -c %t > %f"
1426+
1427+ If the _\bc_\bo_\bm_\bm_\ba_\bn_\bd is empty, this operation is disabled for this file
1428+ type, and the file can only be open in the read-only mode.
1429+
1430+ ``close-hook'' is not called when you exit from the folder if the
1431+ folder was not changed.
1432+
1433+ 4\b4.\b.1\b14\b4.\b.3\b3.\b. A\bAp\bpp\bpe\ben\bnd\bd a\ba m\bme\bes\bss\bsa\bag\bge\be t\bto\bo a\ba c\bco\bom\bmp\bpr\bre\bes\bss\bse\bed\bd m\bma\bai\bil\blb\bbo\box\bx
1434+
1435+ Usage: append-hook _\br_\be_\bg_\be_\bx_\bp "_\bc_\bo_\bm_\bm_\ba_\bn_\bd"
1436+
1437+ This command is used for saving to an existing compressed folder. The
1438+ _\bc_\bo_\bm_\bm_\ba_\bn_\bd is the command that can be used for appending to the folders
1439+ whose names match _\br_\be_\bg_\be_\bx_\bp. It has the same format as in the ``open-
1440+ hook'' command. The temporary folder in this case contains the
1441+ messages that are being appended.
1442+
1443+ The _\bc_\bo_\bm_\bm_\ba_\bn_\bd should n\bno\bot\bt remove the decompressed file. The _\bc_\bo_\bm_\bm_\ba_\bn_\bd
1444+ should return non-zero exit status if it fails, so mutt knows
1445+ something's wrong.
1446+
1447+ Example:
1448+
1449+ append-hook \\.gz$ "gzip -c %t >> %f"
1450+
1451+ When ``append-hook'' is used, the folder is not opened, which saves
1452+ time, but this means that we can not find out what the folder type is.
1453+ Thus the default (``$mbox_type'') type is always supposed (i.e. this
1454+ is the format used for the temporary folder).
1455+
1456+ If the file does not exist when you save to it, ``close-hook'' is
1457+ called, and not ``append-hook''. ``append-hook'' is only for appending
1458+ to existing folders.
1459+
1460+ If the _\bc_\bo_\bm_\bm_\ba_\bn_\bd is empty, this operation is disabled for this file
1461+ type. In this case, the folder will be open and closed again (using
1462+ ``open-hook'' and ``close-hook''respectively) each time you will add
1463+ to it.
1464+
1465+ 4\b4.\b.1\b14\b4.\b.4\b4.\b. E\bEn\bnc\bcr\bry\byp\bpt\bte\bed\bd f\bfo\bol\bld\bde\ber\brs\bs
1466+
1467+ The compressed folders support can also be used to handle encrypted
1468+ folders. If you want to encrypt a folder with PGP, you may want to use
1469+ the following hooks:
1470+
1471+ open-hook \\.pgp$ "pgp -f < %f > %t"
1472+ close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
1473+
1474+ Please note, that PGP does not support appending to an encrypted
1475+ folder, so there is no append-hook defined.
1476+
1477+ If you are using GnuPG instead of PGP, you may use the following hooks
1478+ instead:
1479+
1480+ open-hook \\.gpg$ "gpg --decrypt < %f > %t"
1481+ close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
1482+
1483+ N\bNo\bot\bte\be:\b: the folder is temporary stored decrypted in the /tmp directory,
1484+ where it can be read by your system administrator. So think about the
1485+ security aspects of this.
1486+
1487 5\b5.\b. M\bMu\but\btt\bt'\b's\bs M\bMI\bIM\bME\bE S\bSu\bup\bpp\bpo\bor\brt\bt
1488
1489 Quite a bit of effort has been made to make Mutt the premier text-mode
1490@@ -3148,6 +3303,8 @@
1491
1492