]> git.pld-linux.org Git - packages/mutt.git/blame - mutt-rr.compressed.patch
- use new %doc packing infrastructure.
[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
c9dd7ba8
JB
697diff -Nur mutt-1.3.27.orig/doc/manual-6.html mutt-1.3.27/doc/manual-6.html
698--- mutt-1.3.27.orig/doc/manual-6.html Tue Jan 1 21:18:13 2002
699+++ mutt-1.3.27/doc/manual-6.html Fri Feb 1 22:51:32 2002
700@@ -70,12 +70,16 @@
701 <LI><CODE>
702 <A HREF="manual-5.html#alternative_order">alternative_order</A></CODE> <EM>mimetype</EM> [ <EM>mimetype</EM> ... ]</LI>
703 <LI><CODE>
704+<A HREF="manual-4.html#append-hook">append-hook</A></CODE> <EM>regexp</EM> &quot;<EM>command</EM>&quot;</LI>
705+<LI><CODE>
706 <A HREF="manual-5.html#auto_view">auto_view</A></CODE> <EM>mimetype</EM> [ <EM>mimetype</EM> ... ]</LI>
707 <LI><CODE>
708 <A HREF="manual-3.html#bind">bind</A></CODE> <EM>map</EM> <EM>key</EM> <EM>function</EM></LI>
709 <LI><CODE>
710 <A HREF="manual-3.html#charset-hook">charset-hook</A></CODE> <EM>alias</EM> <EM>charset</EM></LI>
711 <LI><CODE>
712+<A HREF="manual-4.html#close-hook">close-hook</A></CODE> <EM>regexp</EM> &quot;<EM>command</EM>&quot;</LI>
713+<LI><CODE>
714 <A HREF="manual-3.html#color">color</A></CODE> <EM>object</EM> <EM>foreground</EM> <EM>background</EM> [ <EM>regexp</EM> ]</LI>
715 <LI><CODE>
716 <A HREF="manual-3.html#color">uncolor</A></CODE> <EM>index</EM> <EM>pattern</EM> [ <EM>pattern</EM> ... ]</LI>
717@@ -118,6 +122,8 @@
718 <LI><CODE>
719 <A HREF="manual-3.html#my_hdr">unmy_hdr</A></CODE> <EM>field</EM> [ <EM>field</EM> ... ]</LI>
720 <LI><CODE>
721+<A HREF="manual-4.html#open-hook">open-hook</A></CODE> <EM>regexp</EM> &quot;<EM>command</EM>&quot;</LI>
722+<LI><CODE>
723 <A HREF="manual-3.html#pgp-hook">pgp-hook</A></CODE> <EM>pattern</EM> <EM>key-id</EM></LI>
724 <LI><CODE>
725 <A HREF="manual-3.html#push">push</A></CODE> <EM>string</EM></LI>
726diff -Nur mutt-1.3.27.orig/doc/manual.sgml mutt-1.3.27/doc/manual.sgml
727--- mutt-1.3.27.orig/doc/manual.sgml Tue Jan 1 21:18:05 2002
728+++ mutt-1.3.27/doc/manual.sgml Fri Feb 1 22:51:32 2002
729@@ -2318,6 +2318,176 @@
730 macro pager \cb |urlview\n
731 </verb></tscreen>
732
733+<sect1>Compressed folders Support (OPTIONAL)
734+<p>
735+
736+If Mutt was compiled with compressed folders support (by running the
737+<em/configure/ script with the <em/--enable-compressed/ flag), Mutt
738+can open folders stored in an arbitrary format, provided that the user
739+has a script to convert from/to this format to one of the accepted.
740+
741+The most common use is to open compressed archived folders e.g. with
742+gzip.
743+
744+In addition, the user can provide a script that gets a folder in an
745+accepted format and appends its context to the folder in the
746+user-defined format, which may be faster than converting the entire
747+folder to the accepted format, appending to it and converting back to
748+the user-defined format.
749+
750+There are three hooks defined (<ref id="open-hook" name="open-hook">,
751+<ref id="close-hook" name="close-hook"> and <ref id="append-hook"
752+name="append-hook">) which define commands to uncompress and compress
753+a folder and to append messages to an existing compressed folder
754+respectively.
755+
756+For example:
757+
758+<tscreen><verb>
759+open-hook \\.gz$ "gzip -cd %f &gt; %t"
760+close-hook \\.gz$ "gzip -c %t &gt; %f"
761+append-hook \\.gz$ "gzip -c %t &gt;&gt; %f"
762+</verb></tscreen>
763+
764+You do not have to specify all of the commands. If you omit <ref
765+id="append-hook" name="append-hook">, the folder will be open and
766+closed again each time you will add to it. If you omit <ref
767+id="close-hook" name="close-hook"> (or give empty command) , the
768+folder will be open in the mode. If you specify <ref
769+id="append-hook" name="append-hook"> though you'll be able to append
770+to the folder.
771+
772+Note that Mutt will only try to use hooks if the file is not in one of
773+the accepted formats. In particular, if the file is empty, mutt
774+supposes it is not compressed. This is important because it allows the
775+use of programs that do not have well defined extensions. Just use
776+&dquot;.&dquot; as a regexp. But this may be surprising if your
777+compressing script produces empty files. In this situation, unset <ref
778+id="save_empty" name="&dollar;save&lowbar;empty">, so that the compressed file
779+will be removed if you delete all of the messages.
780+
781+<sect2>Open a compressed mailbox for reading<label id="open-hook">
782+<p>
783+Usage: <tt/open-hook/ <em/regexp/ &dquot;<em/command/&dquot;
784+
785+The <em/command/ is the command that can be used for opening the
786+folders whose names match <em/regexp/.
787+
788+The <em/command/ string is the printf-like format string, and it
789+should accept two parameters: &percnt;f, which is replaced with the
790+(compressed) folder name, and &percnt;t which is replaced with the
791+name of the temporary folder to which to write.
792+
793+&percnt;f and &percnt;t can be repeated any number of times in the
794+command string, and all of the entries are replaced with the
795+appropriate folder name. In addition, &percnt;&percnt; is replaced by
796+&percnt;, as in printf, and any other &percnt;anything is left as is.
797+
798+The <em/command/ should <bf/not/ remove the original compressed file.
799+The <em/command/ should return non-zero exit status if it fails, so
800+mutt knows something's wrong.
801+
802+Example:
803+
804+<tscreen><verb>
805+open-hook \\.gz$ "gzip -cd %f &gt; %t"
806+</verb></tscreen>
807+
808+If the <em/command/ is empty, this operation is disabled for this file
809+type.
810+
811+<sect2>Write a compressed mailbox<label id="close-hook">
812+<p>
813+Usage: <tt/close-hook/ <em/regexp/ &dquot;<em/command/&dquot;
814+
815+This is used to close the folder that was open with the <ref id="open-hook"
816+name="open-hook"> command after some changes were made to it.
817+
818+The <em/command/ string is the command that can be used for closing the
819+folders whose names match <em/regexp/. It has the same format as in
820+the <ref id="open-hook" name="open-hook"> command. Temporary folder
821+in this case is the folder previously produced by the <ref id="open-hook"
822+name="open-hook"> command.
823+
824+The <em/command/ should <bf/not/ remove the decompressed file. The
825+<em/command/ should return non-zero exit status if it fails, so mutt
826+knows something's wrong.
827+
828+Example:
829+
830+<tscreen><verb>
831+close-hook \\.gz$ "gzip -c %t &gt; %f"
832+</verb></tscreen>
833+
834+If the <em/command/ is empty, this operation is disabled for this file
835+type, and the file can only be open in the read-only mode.
836+
837+<ref id="close-hook" name ="close-hook"> is not called when you exit
838+from the folder if the folder was not changed.
839+
840+<sect2>Append a message to a compressed mailbox<label id="append-hook">
841+<p>
842+Usage: <tt/append-hook/ <em/regexp/ &dquot;<em/command/&dquot;
843+
844+This command is used for saving to an existing compressed folder.
845+The <em/command/ is the command that can be used for appending to the
846+folders whose names match <em/regexp/. It has the same format as in
847+ the <ref id="open-hook" name="open-hook"> command.
848+The temporary folder in this case contains the messages that are being
849+appended.
850+
851+The <em/command/ should <bf/not/ remove the decompressed file. The
852+<em/command/ should return non-zero exit status if it fails, so mutt
853+knows something's wrong.
854+
855+Example:
856+
857+<tscreen><verb>
858+append-hook \\.gz$ "gzip -c %t &gt;&gt; %f"
859+</verb></tscreen>
860+
861+When <ref id="append-hook" name="append-hook"> is used, the folder is
862+not opened, which saves time, but this means that we can not find out
863+what the folder type is. Thus the default (<ref id="mbox_type"
864+name="&dollar;mbox&lowbar;type">) type is always supposed (i.e.
865+this is the format used for the temporary folder).
866+
867+If the file does not exist when you save to it, <ref id="close-hook"
868+name="close-hook"> is called, and not <ref id="append-hook"
869+name="append-hook">. <ref id="append-hook" name="append-hook"> is only
870+for appending to existing folders.
871+
872+If the <em/command/ is empty, this operation is disabled for this file
873+type. In this case, the folder will be open and closed again (using
874+<ref id="open-hook" name="open-hook"> and <ref id="close-hook"
875+name="close-hook">respectively) each time you will add to it.
876+
877+<sect2>Encrypted folders
878+<p>
879+The compressed folders support can also be used to handle encrypted
880+folders. If you want to encrypt a folder with PGP, you may want to use
881+the following hooks:
882+
883+<tscreen><verb>
884+open-hook \\.pgp$ "pgp -f &lt; %f &gt; %t"
885+close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId &lt; %t &gt; %f"
886+</verb></tscreen>
887+
888+Please note, that PGP does not support appending to an encrypted
889+folder, so there is no append-hook defined.
890+
891+If you are using GnuPG instead of PGP, you may use the following hooks
892+instead:
893+
894+<tscreen><verb>
895+open-hook \\.gpg$ "gpg --decrypt &lt; %f &gt; %t"
896+close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId &lt; %t &gt; %f"
897+</verb></tscreen>
898+
899+<bf/Note:/ the folder is temporary stored decrypted in the /tmp
900+directory, where it can be read by your system administrator. So think
901+about the security aspects of this.
902+
903 <sect>Mutt's MIME Support
904 <p>
905 Quite a bit of effort has been made to make Mutt the premier text-mode
906@@ -2868,12 +3038,16 @@
907 <item>
908 <tt><ref id="alternative_order" name="alternative&lowbar;order"></tt> <em/mimetype/ &lsqb; <em/mimetype/ ... &rsqb;
909 <item>
910+<tt><ref id="append-hook" name="append-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
911+<item>
912 <tt><ref id="auto_view" name="auto&lowbar;view"></tt> <em/mimetype/ &lsqb; <em/mimetype/ ... &rsqb;
913 <item>
914 <tt><ref id="bind" name="bind"></tt> <em/map/ <em/key/ <em/function/
915 <item>
916 <tt><ref id="charset-hook" name="charset-hook"></tt> <em/alias/ <em/charset/
917 <item>
918+<tt><ref id="close-hook" name="close-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
919+<item>
920 <tt><ref id="color" name="color"></tt> <em/object/ <em/foreground/ <em/background/ &lsqb; <em/regexp/ &rsqb;
921 <item>
922 <tt><ref id="color" name="uncolor"></tt> <em/index/ <em/pattern/ &lsqb; <em/pattern/ ... &rsqb;
923@@ -2916,6 +3090,8 @@
924 <item>
925 <tt><ref id="my_hdr" name="unmy&lowbar;hdr"></tt> <em/field/ &lsqb; <em/field/ ... &rsqb;
926 <item>
927+<tt><ref id="open-hook" name="open-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
928+<item>
929 <tt><ref id="pgp-hook" name="pgp-hook"></tt> <em/pattern/ <em/key-id/
930 <item>
931 <tt><ref id="push" name="push"></tt> <em/string/
932diff -Nur mutt-1.3.27.orig/doc/manual.sgml.head mutt-1.3.27/doc/manual.sgml.head
933--- mutt-1.3.27.orig/doc/manual.sgml.head Wed Jan 23 00:42:01 2002
934+++ mutt-1.3.27/doc/manual.sgml.head Fri Feb 1 22:51:32 2002
935@@ -2319,6 +2319,176 @@
936 macro pager \cb |urlview\n
937 </verb></tscreen>
938
939+<sect1>Compressed folders Support (OPTIONAL)
940+<p>
941+
942+If Mutt was compiled with compressed folders support (by running the
943+<em/configure/ script with the <em/--enable-compressed/ flag), Mutt
944+can open folders stored in an arbitrary format, provided that the user
945+has a script to convert from/to this format to one of the accepted.
946+
947+The most common use is to open compressed archived folders e.g. with
948+gzip.
949+
950+In addition, the user can provide a script that gets a folder in an
951+accepted format and appends its context to the folder in the
952+user-defined format, which may be faster than converting the entire
953+folder to the accepted format, appending to it and converting back to
954+the user-defined format.
955+
956+There are three hooks defined (<ref id="open-hook" name="open-hook">,
957+<ref id="close-hook" name="close-hook"> and <ref id="append-hook"
958+name="append-hook">) which define commands to uncompress and compress
959+a folder and to append messages to an existing compressed folder
960+respectively.
961+
962+For example:
963+
964+<tscreen><verb>
965+open-hook \\.gz$ "gzip -cd %f &gt; %t"
966+close-hook \\.gz$ "gzip -c %t &gt; %f"
967+append-hook \\.gz$ "gzip -c %t &gt;&gt; %f"
968+</verb></tscreen>
969+
970+You do not have to specify all of the commands. If you omit <ref
971+id="append-hook" name="append-hook">, the folder will be open and
972+closed again each time you will add to it. If you omit <ref
973+id="close-hook" name="close-hook"> (or give empty command) , the
974+folder will be open in the mode. If you specify <ref
975+id="append-hook" name="append-hook"> though you'll be able to append
976+to the folder.
977+
978+Note that Mutt will only try to use hooks if the file is not in one of
979+the accepted formats. In particular, if the file is empty, mutt
980+supposes it is not compressed. This is important because it allows the
981+use of programs that do not have well defined extensions. Just use
982+&dquot;.&dquot; as a regexp. But this may be surprising if your
983+compressing script produces empty files. In this situation, unset <ref
984+id="save_empty" name="&dollar;save&lowbar;empty">, so that the compressed file
985+will be removed if you delete all of the messages.
986+
987+<sect2>Open a compressed mailbox for reading<label id="open-hook">
988+<p>
989+Usage: <tt/open-hook/ <em/regexp/ &dquot;<em/command/&dquot;
990+
991+The <em/command/ is the command that can be used for opening the
992+folders whose names match <em/regexp/.
993+
994+The <em/command/ string is the printf-like format string, and it
995+should accept two parameters: &percnt;f, which is replaced with the
996+(compressed) folder name, and &percnt;t which is replaced with the
997+name of the temporary folder to which to write.
998+
999+&percnt;f and &percnt;t can be repeated any number of times in the
1000+command string, and all of the entries are replaced with the
1001+appropriate folder name. In addition, &percnt;&percnt; is replaced by
1002+&percnt;, as in printf, and any other &percnt;anything is left as is.
1003+
1004+The <em/command/ should <bf/not/ remove the original compressed file.
1005+The <em/command/ should return non-zero exit status if it fails, so
1006+mutt knows something's wrong.
1007+
1008+Example:
1009+
1010+<tscreen><verb>
1011+open-hook \\.gz$ "gzip -cd %f &gt; %t"
1012+</verb></tscreen>
1013+
1014+If the <em/command/ is empty, this operation is disabled for this file
1015+type.
1016+
1017+<sect2>Write a compressed mailbox<label id="close-hook">
1018+<p>
1019+Usage: <tt/close-hook/ <em/regexp/ &dquot;<em/command/&dquot;
1020+
1021+This is used to close the folder that was open with the <ref id="open-hook"
1022+name="open-hook"> command after some changes were made to it.
1023+
1024+The <em/command/ string is the command that can be used for closing the
1025+folders whose names match <em/regexp/. It has the same format as in
1026+the <ref id="open-hook" name="open-hook"> command. Temporary folder
1027+in this case is the folder previously produced by the <ref id="open-hook"
1028+name="open-hook"> command.
1029+
1030+The <em/command/ should <bf/not/ remove the decompressed file. The
1031+<em/command/ should return non-zero exit status if it fails, so mutt
1032+knows something's wrong.
1033+
1034+Example:
1035+
1036+<tscreen><verb>
1037+close-hook \\.gz$ "gzip -c %t &gt; %f"
1038+</verb></tscreen>
1039+
1040+If the <em/command/ is empty, this operation is disabled for this file
1041+type, and the file can only be open in the read-only mode.
1042+
1043+<ref id="close-hook" name ="close-hook"> is not called when you exit
1044+from the folder if the folder was not changed.
1045+
1046+<sect2>Append a message to a compressed mailbox<label id="append-hook">
1047+<p>
1048+Usage: <tt/append-hook/ <em/regexp/ &dquot;<em/command/&dquot;
1049+
1050+This command is used for saving to an existing compressed folder.
1051+The <em/command/ is the command that can be used for appending to the
1052+folders whose names match <em/regexp/. It has the same format as in
1053+ the <ref id="open-hook" name="open-hook"> command.
1054+The temporary folder in this case contains the messages that are being
1055+appended.
1056+
1057+The <em/command/ should <bf/not/ remove the decompressed file. The
1058+<em/command/ should return non-zero exit status if it fails, so mutt
1059+knows something's wrong.
1060+
1061+Example:
1062+
1063+<tscreen><verb>
1064+append-hook \\.gz$ "gzip -c %t &gt;&gt; %f"
1065+</verb></tscreen>
1066+
1067+When <ref id="append-hook" name="append-hook"> is used, the folder is
1068+not opened, which saves time, but this means that we can not find out
1069+what the folder type is. Thus the default (<ref id="mbox_type"
1070+name="&dollar;mbox&lowbar;type">) type is always supposed (i.e.
1071+this is the format used for the temporary folder).
1072+
1073+If the file does not exist when you save to it, <ref id="close-hook"
1074+name="close-hook"> is called, and not <ref id="append-hook"
1075+name="append-hook">. <ref id="append-hook" name="append-hook"> is only
1076+for appending to existing folders.
1077+
1078+If the <em/command/ is empty, this operation is disabled for this file
1079+type. In this case, the folder will be open and closed again (using
1080+<ref id="open-hook" name="open-hook"> and <ref id="close-hook"
1081+name="close-hook">respectively) each time you will add to it.
1082+
1083+<sect2>Encrypted folders
1084+<p>
1085+The compressed folders support can also be used to handle encrypted
1086+folders. If you want to encrypt a folder with PGP, you may want to use
1087+the following hooks:
1088+
1089+<tscreen><verb>
1090+open-hook \\.pgp$ "pgp -f &lt; %f &gt; %t"
1091+close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId &lt; %t &gt; %f"
1092+</verb></tscreen>
1093+
1094+Please note, that PGP does not support appending to an encrypted
1095+folder, so there is no append-hook defined.
1096+
1097+If you are using GnuPG instead of PGP, you may use the following hooks
1098+instead:
1099+
1100+<tscreen><verb>
1101+open-hook \\.gpg$ "gpg --decrypt &lt; %f &gt; %t"
1102+close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId &lt; %t &gt; %f"
1103+</verb></tscreen>
1104+
1105+<bf/Note:/ the folder is temporary stored decrypted in the /tmp
1106+directory, where it can be read by your system administrator. So think
1107+about the security aspects of this.
1108+
1109 <sect>Mutt's MIME Support
1110 <p>
1111 Quite a bit of effort has been made to make Mutt the premier text-mode
1112@@ -2869,12 +3039,16 @@
1113 <item>
1114 <tt><ref id="alternative_order" name="alternative&lowbar;order"></tt> <em/mimetype/ &lsqb; <em/mimetype/ ... &rsqb;
1115 <item>
1116+<tt><ref id="append-hook" name="append-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
1117+<item>
1118 <tt><ref id="auto_view" name="auto&lowbar;view"></tt> <em/mimetype/ &lsqb; <em/mimetype/ ... &rsqb;
1119 <item>
1120 <tt><ref id="bind" name="bind"></tt> <em/map/ <em/key/ <em/function/
1121 <item>
1122 <tt><ref id="charset-hook" name="charset-hook"></tt> <em/alias/ <em/charset/
1123 <item>
1124+<tt><ref id="close-hook" name="close-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
1125+<item>
1126 <tt><ref id="color" name="color"></tt> <em/object/ <em/foreground/ <em/background/ &lsqb; <em/regexp/ &rsqb;
1127 <item>
1128 <tt><ref id="color" name="uncolor"></tt> <em/index/ <em/pattern/ &lsqb; <em/pattern/ ... &rsqb;
1129@@ -2917,6 +3091,8 @@
1130 <item>
1131 <tt><ref id="my_hdr" name="unmy&lowbar;hdr"></tt> <em/field/ &lsqb; <em/field/ ... &rsqb;
1132 <item>
1133+<tt><ref id="open-hook" name="open-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
1134+<item>
1135 <tt><ref id="pgp-hook" name="pgp-hook"></tt> <em/pattern/ <em/key-id/
1136 <item>
1137 <tt><ref id="push" name="push"></tt> <em/string/
1138diff -Nur mutt-1.3.27.orig/doc/manual.txt mutt-1.3.27/doc/manual.txt
1139--- mutt-1.3.27.orig/doc/manual.txt Tue Jan 1 21:18:08 2002
1140+++ mutt-1.3.27/doc/manual.txt Fri Feb 1 22:51:32 2002
1141@@ -78,6 +78,11 @@
1142 4.11.2 Authentication
1143 4.12 Managing multiple IMAP/POP accounts (OPTIONAL)
1144 4.13 Start a WWW Browser on URLs (EXTERNAL)
1145+ 4.14 Compressed folders Support (OPTIONAL)
1146+ 4.14.1 Open a compressed mailbox for reading
1147+ 4.14.2 Write a compressed mailbox
1148+ 4.14.3 Append a message to a compressed mailbox
1149+ 4.14.4 Encrypted folders
1150
1151 5. Mutt's MIME Support
1152 5.1 Using MIME in Mutt
1153@@ -2554,6 +2559,156 @@
1154 macro index \cb |urlview\n
1155 macro pager \cb |urlview\n
1156
1157+ 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)
1158+
1159+ If Mutt was compiled with compressed folders support (by running the
1160+ _\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
1161+ folders stored in an arbitrary format, provided that the user has a
1162+ script to convert from/to this format to one of the accepted.
1163+
1164+ The most common use is to open compressed archived folders e.g. with
1165+ gzip.
1166+
1167+ In addition, the user can provide a script that gets a folder in an
1168+ accepted format and appends its context to the folder in the user-
1169+ defined format, which may be faster than converting the entire folder
1170+ to the accepted format, appending to it and converting back to the
1171+ user-defined format.
1172+
1173+ There are three hooks defined (``open-hook'', ``close-hook'' and
1174+ ``append-hook'') which define commands to uncompress and compress a
1175+ folder and to append messages to an existing compressed folder
1176+ respectively.
1177+
1178+ For example:
1179+
1180+ open-hook \\.gz$ "gzip -cd %f > %t"
1181+ close-hook \\.gz$ "gzip -c %t > %f"
1182+ append-hook \\.gz$ "gzip -c %t >> %f"
1183+
1184+ You do not have to specify all of the commands. If you omit ``append-
1185+ hook'', the folder will be open and closed again each time you will
1186+ add to it. If you omit ``close-hook'' (or give empty command) , the
1187+ folder will be open in the mode. If you specify ``append-hook''
1188+ though you'll be able to append to the folder.
1189+
1190+ Note that Mutt will only try to use hooks if the file is not in one of
1191+ the accepted formats. In particular, if the file is empty, mutt
1192+ supposes it is not compressed. This is important because it allows the
1193+ use of programs that do not have well defined extensions. Just use "."
1194+ as a regexp. But this may be surprising if your compressing script
1195+ produces empty files. In this situation, unset ``$save_empty'', so
1196+ that the compressed file will be removed if you delete all of the
1197+ messages.
1198+
1199+ 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
1200+
1201+ Usage: open-hook _\br_\be_\bg_\be_\bx_\bp "_\bc_\bo_\bm_\bm_\ba_\bn_\bd"
1202+
1203+ The _\bc_\bo_\bm_\bm_\ba_\bn_\bd is the command that can be used for opening the folders
1204+ whose names match _\br_\be_\bg_\be_\bx_\bp.
1205+
1206+ The _\bc_\bo_\bm_\bm_\ba_\bn_\bd string is the printf-like format string, and it should
1207+ accept two parameters: %f, which is replaced with the (compressed)
1208+ folder name, and %t which is replaced with the name of the temporary
1209+ folder to which to write.
1210+
1211+ %f and %t can be repeated any number of times in the command string,
1212+ and all of the entries are replaced with the appropriate folder name.
1213+ In addition, %% is replaced by %, as in printf, and any other
1214+ %anything is left as is.
1215+
1216+ The _\bc_\bo_\bm_\bm_\ba_\bn_\bd should n\bno\bot\bt remove the original compressed file. The
1217+ _\bc_\bo_\bm_\bm_\ba_\bn_\bd should return non-zero exit status if it fails, so mutt knows
1218+ something's wrong.
1219+
1220+ Example:
1221+
1222+ open-hook \\.gz$ "gzip -cd %f > %t"
1223+
1224+ If the _\bc_\bo_\bm_\bm_\ba_\bn_\bd is empty, this operation is disabled for this file
1225+ type.
1226+
1227+ 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
1228+
1229+ Usage: close-hook _\br_\be_\bg_\be_\bx_\bp "_\bc_\bo_\bm_\bm_\ba_\bn_\bd"
1230+
1231+ This is used to close the folder that was open with the ``open-hook''
1232+ command after some changes were made to it.
1233+
1234+ The _\bc_\bo_\bm_\bm_\ba_\bn_\bd string is the command that can be used for closing the
1235+ folders whose names match _\br_\be_\bg_\be_\bx_\bp. It has the same format as in the
1236+ ``open-hook'' command. Temporary folder in this case is the folder
1237+ previously produced by the ``open-hook'' command.
1238+
1239+ 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
1240+ should return non-zero exit status if it fails, so mutt knows
1241+ something's wrong.
1242+
1243+ Example:
1244+
1245+ close-hook \\.gz$ "gzip -c %t > %f"
1246+
1247+ If the _\bc_\bo_\bm_\bm_\ba_\bn_\bd is empty, this operation is disabled for this file
1248+ type, and the file can only be open in the read-only mode.
1249+
1250+ ``close-hook'' is not called when you exit from the folder if the
1251+ folder was not changed.
1252+
1253+ 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
1254+
1255+ Usage: append-hook _\br_\be_\bg_\be_\bx_\bp "_\bc_\bo_\bm_\bm_\ba_\bn_\bd"
1256+
1257+ This command is used for saving to an existing compressed folder. The
1258+ _\bc_\bo_\bm_\bm_\ba_\bn_\bd is the command that can be used for appending to the folders
1259+ whose names match _\br_\be_\bg_\be_\bx_\bp. It has the same format as in the ``open-
1260+ hook'' command. The temporary folder in this case contains the
1261+ messages that are being appended.
1262+
1263+ 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
1264+ should return non-zero exit status if it fails, so mutt knows
1265+ something's wrong.
1266+
1267+ Example:
1268+
1269+ append-hook \\.gz$ "gzip -c %t >> %f"
1270+
1271+ When ``append-hook'' is used, the folder is not opened, which saves
1272+ time, but this means that we can not find out what the folder type is.
1273+ Thus the default (``$mbox_type'') type is always supposed (i.e. this
1274+ is the format used for the temporary folder).
1275+
1276+ If the file does not exist when you save to it, ``close-hook'' is
1277+ called, and not ``append-hook''. ``append-hook'' is only for appending
1278+ to existing folders.
1279+
1280+ If the _\bc_\bo_\bm_\bm_\ba_\bn_\bd is empty, this operation is disabled for this file
1281+ type. In this case, the folder will be open and closed again (using
1282+ ``open-hook'' and ``close-hook''respectively) each time you will add
1283+ to it.
1284+
1285+ 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
1286+
1287+ The compressed folders support can also be used to handle encrypted
1288+ folders. If you want to encrypt a folder with PGP, you may want to use
1289+ the following hooks:
1290+
1291+ open-hook \\.pgp$ "pgp -f < %f > %t"
1292+ close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
1293+
1294+ Please note, that PGP does not support appending to an encrypted
1295+ folder, so there is no append-hook defined.
1296+
1297+ If you are using GnuPG instead of PGP, you may use the following hooks
1298+ instead:
1299+
1300+ open-hook \\.gpg$ "gpg --decrypt < %f > %t"
1301+ close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
1302+
1303+ N\bNo\bot\bte\be:\b: the folder is temporary stored decrypted in the /tmp directory,
1304+ where it can be read by your system administrator. So think about the
1305+ security aspects of this.
1306+
1307 5\b5.\b. M\bMu\but\btt\bt'\b's\bs M\bMI\bIM\bME\bE S\bSu\bup\bpp\bpo\bor\brt\bt
1308
1309 Quite a bit of effort has been made to make Mutt the premier text-mode
1310@@ -3148,6 +3303,8 @@
1311
1312