]> git.pld-linux.org Git - packages/mutt.git/blob - mutt-rr.compressed.patch
- fixed applying of send_charset patch (Muttrc is regenerated by
[packages/mutt.git] / mutt-rr.compressed.patch
1 diff -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 \
25 diff -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 \
55 diff -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,15 @@
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 +# open-hook \\.bz2$ "bzip2 -cd %f > %t"
68 +# close-hook \\.bz2$ "bzip2 -c %t > %f"
69 +# append-hook \\.bz2$ "bzip2 -c %t >> %f"
70 +
71  # If Mutt is unable to determine your site's domain name correctly, you can
72  # set the default here.
73  #
74 diff -Nur mutt-1.3.27.orig/Muttrc.head mutt-1.3.27/Muttrc.head
75 --- mutt-1.3.27.orig/Muttrc.head        Tue Jan  1 21:18:02 2002
76 +++ mutt-1.3.27/Muttrc.head     Fri Feb  1 22:51:32 2002
77 @@ -19,6 +19,15 @@
78  macro index   <f1> "!less /usr/local/doc/mutt/manual.txt\n" "Show Mutt documentation"
79  macro pager   <f1> "!less /usr/local/doc/mutt/manual.txt\n" "Show Mutt documentation"
80  
81 +# Use folders which match on \\.gz$ as gzipped folders:
82 +# open-hook \\.gz$ "gzip -cd %f > %t"
83 +# close-hook \\.gz$ "gzip -c %t > %f"
84 +# append-hook \\.gz$ "gzip -c %t >> %f"
85 +
86 +# open-hook \\.bz2$ "bzip2 -cd %f > %t"
87 +# close-hook \\.bz2$ "bzip2 -c %t > %f"
88 +# append-hook \\.bz2$ "bzip2 -c %t >> %f"
89 +
90  # If Mutt is unable to determine your site's domain name correctly, you can
91  # set the default here.
92  #
93 diff -Nur mutt-1.3.27.orig/Muttrc.head.in mutt-1.3.27/Muttrc.head.in
94 --- mutt-1.3.27.orig/Muttrc.head.in     Mon Mar 20 11:25:49 2000
95 +++ mutt-1.3.27/Muttrc.head.in  Fri Feb  1 22:51:32 2002
96 @@ -19,6 +19,15 @@
97  macro index   <f1> "!less @docdir@/manual.txt\n" "Show Mutt documentation"
98  macro pager   <f1> "!less @docdir@/manual.txt\n" "Show Mutt documentation"
99  
100 +# Use folders which match on \\.gz$ as gzipped folders:
101 +# open-hook \\.gz$ "gzip -cd %f > %t"
102 +# close-hook \\.gz$ "gzip -c %t > %f"
103 +# append-hook \\.gz$ "gzip -c %t >> %f"
104 +
105 +# open-hook \\.bz2$ "bzip2 -cd %f > %t"
106 +# close-hook \\.bz2$ "bzip2 -c %t > %f"
107 +# append-hook \\.bz2$ "bzip2 -c %t >> %f"
108 +
109  # If Mutt is unable to determine your site's domain name correctly, you can
110  # set the default here.
111  #
112 diff -Nur mutt-1.3.27.orig/PATCHES mutt-1.3.27/PATCHES
113 --- mutt-1.3.27.orig/PATCHES    Mon Nov 26 20:16:22 2001
114 +++ mutt-1.3.27/PATCHES Fri Feb  1 22:51:32 2002
115 @@ -0,0 +1 @@
116 +patch-1.3.27.rr.compressed.1
117 diff -Nur mutt-1.3.27.orig/compress.c mutt-1.3.27/compress.c
118 --- mutt-1.3.27.orig/compress.c Thu Jan  1 01:00:00 1970
119 +++ mutt-1.3.27/compress.c      Fri Feb  1 22:51:32 2002
120 @@ -0,0 +1,483 @@
121 +/*
122 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
123 + *
124 + *     This program is free software; you can redistribute it and/or modify
125 + *     it under the terms of the GNU General Public License as published by
126 + *     the Free Software Foundation; either version 2 of the License, or
127 + *     (at your option) any later version.
128 + *
129 + *     This program is distributed in the hope that it will be useful,
130 + *     but WITHOUT ANY WARRANTY; without even the implied warranty of
131 + *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
132 + *     GNU General Public License for more details.
133 + *
134 + *     You should have received a copy of the GNU General Public License
135 + *     along with this program; if not, write to the Free Software
136 + *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
137 + */
138 +
139 +#include "mutt.h"
140 +
141 +#ifdef USE_COMPRESSED
142 +
143 +#include "mx.h"
144 +#include "mailbox.h"
145 +#include "mutt_curses.h"
146 +
147 +#include <errno.h>
148 +#include <string.h>
149 +#include <unistd.h>
150 +#include <sys/stat.h>
151 +
152 +typedef struct
153 +{
154 +  const char *close;   /* close-hook  command */
155 +  const char *open;    /* open-hook   command */
156 +  const char *append;  /* append-hook command */
157 +  off_t size;          /* size of real folder */
158 +} COMPRESS_INFO;
159 +
160 +
161 +/*
162 + * ctx - context to lock
163 + * excl - exclusive lock?
164 + * retry - should retry if unable to lock?
165 + */
166 +int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
167 +{
168 +  int r;
169 +
170 +  if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
171 +    ctx->locked = 1;
172 +  else if (retry && !excl)
173 +  {
174 +    ctx->readonly = 1;
175 +    return 0;
176 +  }
177 +
178 +  return (r);
179 +}
180 +
181 +void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
182 +{
183 +  if (ctx->locked)
184 +  {
185 +    fflush (fp);
186 +
187 +    mx_unlock_file (ctx->realpath, fileno (fp), 1);
188 +    ctx->locked = 0;
189 +  }
190 +}
191 +
192 +static int is_new (const char *path)
193 +{
194 +  return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
195 +}
196 +
197 +static const char* find_compress_hook (int type, const char *path)
198 +{
199 +  const char* c = mutt_find_hook (type, path);
200 +  return (!c || !*c) ? NULL : c;
201 +}
202 +
203 +int mutt_can_read_compressed (const char *path)
204 +{
205 +  return find_compress_hook (M_OPENHOOK, path) ? 1 : 0;
206 +}
207 +
208 +/*
209 + * if the file is new, we really do not append, but create, and so use
210 + * close-hook, and not append-hook
211 + */
212 +static const char* get_append_command (const char *path, const CONTEXT* ctx)
213 +{
214 +  COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
215 +  return (is_new (path)) ? ci->close : ci->append;
216 +}
217 +
218 +int mutt_can_append_compressed (const char *path)
219 +{
220 +  int magic;
221 +
222 +  if (is_new (path))
223 +    return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
224 +
225 +  magic = mx_get_magic (path);
226 +
227 +  if (magic != 0 && magic != M_COMPRESSED)
228 +    return 0;
229 +
230 +  return (find_compress_hook (M_APPENDHOOK, path)
231 +         || (find_compress_hook (M_OPENHOOK, path)
232 +             && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
233 +}
234 +
235 +/* open a compressed mailbox */
236 +static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
237 +{
238 +  COMPRESS_INFO *ci;
239 +
240 +  /* Now lets uncompress this thing */
241 +  ci = safe_malloc (sizeof (COMPRESS_INFO));
242 +  ctx->compressinfo = (void*) ci;
243 +  ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
244 +  ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
245 +  ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
246 +  return ci;
247 +}
248 +
249 +static void set_path (CONTEXT* ctx)
250 +{
251 +  char tmppath[_POSIX_PATH_MAX];
252 +
253 +  /* Setup the right paths */
254 +  ctx->realpath = ctx->path;
255 +
256 +  /* Uncompress to /tmp */
257 +  mutt_mktemp (tmppath);
258 +  ctx->path = safe_malloc (strlen (tmppath) + 1);
259 +  strcpy (ctx->path, tmppath);
260 +}
261 +
262 +static int get_size (const char* path)
263 +{
264 +  struct stat sb;
265 +  if (stat (path, &sb) != 0)
266 +    return 0;
267 +  return (sb.st_size);
268 +}
269 +
270 +static void store_size (CONTEXT* ctx)
271 +{
272 +  COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
273 +  ci->size = get_size (ctx->realpath);
274 +}
275 +
276 +static const char *
277 +compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
278 +                        const char *fmt, const char *ifstring,
279 +                        const char *elsestring, unsigned long data,
280 +                        format_flag flags)
281 +{
282 +  char tmp[SHORT_STRING];
283 +
284 +  CONTEXT *ctx = (CONTEXT *) data;
285 +  switch (op)
286 +  {
287 +  case 'f':
288 +    snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
289 +    snprintf (dest, destlen, tmp, ctx->realpath);
290 +    break;
291 +  case 't':
292 +    snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
293 +    snprintf (dest, destlen, tmp, ctx->path);
294 +    break;
295 +  }
296 +  return (src);
297 +}
298 +
299 +/*
300 + * check that the command has both %f and %t
301 + * 0 means OK, -1 means error
302 + */
303 +int mutt_test_compress_command (const char* cmd)
304 +{
305 +  return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
306 +}
307 +
308 +static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
309 +{
310 +  char expanded[_POSIX_PATH_MAX];
311 +  mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str,
312 +                    (unsigned long) ctx, 0);
313 +  return safe_strdup (expanded);
314 +}
315 +
316 +int mutt_check_mailbox_compressed (CONTEXT* ctx)
317 +{
318 +  COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
319 +  if (ci->size != get_size (ctx->realpath))
320 +  {
321 +    safe_free ((void**)&ctx->compressinfo);
322 +    safe_free ((void**)&ctx->realpath);
323 +    mutt_error _("Mailbox was corrupted!");
324 +    return (-1);
325 +  }
326 +  return (0);
327 +}
328 +
329 +int mutt_open_read_compressed (CONTEXT *ctx)
330 +{
331 +  char *cmd;
332 +  FILE *fp;
333 +  int rc;
334 +
335 +  COMPRESS_INFO *ci = set_compress_info (ctx);
336 +  if (!ci->open) {
337 +    ctx->magic = 0;
338 +    safe_free ((void**)ctx->compressinfo);
339 +    return (-1);
340 +  }
341 +  if (!ci->close || access (ctx->path, W_OK) != 0)
342 +    ctx->readonly = 1;
343 +
344 +  set_path (ctx);
345 +  store_size (ctx);
346 +
347 +  if (!ctx->quiet)
348 +    mutt_message (_("Decompressing %s..."), ctx->realpath);
349 +
350 +  cmd = get_compression_cmd (ci->open, ctx);
351 +  if (cmd == NULL)
352 +    return (-1);
353 +  dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
354 +
355 +  if ((fp = fopen (ctx->realpath, "r")) == NULL)
356 +  {
357 +    mutt_perror (ctx->realpath);
358 +    safe_free ((void **)&cmd);
359 +    return (-1);
360 +  }
361 +  mutt_block_signals ();
362 +  if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
363 +  {
364 +    fclose (fp);
365 +    mutt_unblock_signals ();
366 +    mutt_error _("Unable to lock mailbox!");
367 +    safe_free ((void **)&cmd);
368 +    return (-1);
369 +  }
370 +
371 +  endwin ();
372 +  fflush (stdout);
373 +  fprintf (stderr, _("Decompressing %s...\n"),ctx->realpath);
374 +  rc = mutt_system (cmd);
375 +  mbox_unlock_compressed (ctx, fp);
376 +  mutt_unblock_signals ();
377 +  fclose (fp);
378 +
379 +  if (rc)
380 +  {
381 +    mutt_any_key_to_continue (NULL);
382 +    ctx->magic = 0;
383 +    safe_free ((void**)ctx->compressinfo);
384 +    mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
385 +  }
386 +  safe_free ((void **)&cmd);
387 +  if (rc)
388 +    return (-1);
389 +
390 +  if (mutt_check_mailbox_compressed (ctx))
391 +    return (-1);
392 +
393 +  ctx->magic = mx_get_magic (ctx->path);
394 +
395 +  return (0);
396 +}
397 +
398 +void restore_path (CONTEXT* ctx)
399 +{
400 +  safe_free ((void **)&ctx->path);
401 +  ctx->path = ctx->realpath;
402 +}
403 +
404 +/* remove the temporary mailbox */
405 +void remove_file (CONTEXT* ctx)
406 +{
407 +  if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
408 +    remove (ctx->path);
409 +}
410 +
411 +int mutt_open_append_compressed (CONTEXT *ctx)
412 +{
413 +  FILE *fh;
414 +  COMPRESS_INFO *ci = set_compress_info (ctx);
415 +
416 +  if (!get_append_command (ctx->path, ctx))
417 +  {
418 +    if (ci->open && ci->close)
419 +      return (mutt_open_read_compressed (ctx));
420 +
421 +    ctx->magic = 0;
422 +    safe_free ((void**)&ctx->compressinfo);
423 +    return (-1);
424 +  }
425 +
426 +  set_path (ctx);
427 +
428 +  ctx->magic = DefaultMagic;
429 +
430 +  if (!is_new (ctx->realpath))
431 +    if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
432 +      if ((fh = fopen (ctx->path, "w")))
433 +       fclose (fh);
434 +  /* No error checking - the parent function will catch it */
435 +
436 +  return (0);
437 +}
438 +
439 +/* close a compressed mailbox */
440 +void mutt_fast_close_compressed (CONTEXT *ctx)
441 +{
442 +  dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
443 +             ctx->path));
444 +
445 +  if (ctx->compressinfo)
446 +  {
447 +    if (ctx->fp)
448 +      fclose (ctx->fp);
449 +    ctx->fp = NULL;
450 +    /* if the folder was removed, remove the gzipped folder too */
451 +    if ((ctx->magic > 0) 
452 +       && (access (ctx->path, F_OK) != 0) 
453 +       && ! option (OPTSAVEEMPTY))
454 +      remove (ctx->realpath);
455 +    else
456 +      remove_file (ctx);
457 +
458 +    restore_path (ctx);
459 +    safe_free ((void**)&ctx->compressinfo);
460 +  }
461 +}
462 +
463 +/* return 0 on success, -1 on failure */
464 +int mutt_sync_compressed (CONTEXT* ctx)
465 +{
466 +  char *cmd;
467 +  int rc = 0;
468 +  FILE *fp;
469 +  COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
470 +
471 +  if (!ctx->quiet)
472 +    mutt_message (_("Compressing %s..."), ctx->realpath);
473 +
474 +  cmd = get_compression_cmd (ci->close, ctx);
475 +  if (cmd == NULL)
476 +    return (-1);
477 +
478 +  if ((fp = fopen (ctx->realpath, "a")) == NULL)
479 +  {
480 +    mutt_perror (ctx->realpath);
481 +    safe_free ((void **)&cmd);
482 +    return (-1);
483 +  }
484 +  mutt_block_signals ();
485 +  if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
486 +  {
487 +    fclose (fp);
488 +    mutt_unblock_signals ();
489 +    mutt_error _("Unable to lock mailbox!");
490 +    store_size (ctx);
491 +    safe_free ((void **)&cmd);
492 +    return (-1);
493 +  }
494 +
495 +  dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
496 +
497 +  endwin ();
498 +  fflush (stdout);
499 +  fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
500 +  if (mutt_system (cmd))
501 +  {
502 +    mutt_any_key_to_continue (NULL);
503 +    mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
504 +    rc = -1;
505 +  }
506 +
507 +  mbox_unlock_compressed (ctx, fp);
508 +  mutt_unblock_signals ();
509 +  fclose (fp);
510 +
511 +  safe_free ((void **)&cmd);
512 +
513 +  store_size (ctx);
514 +
515 +  return (rc);
516 +}
517 +
518 +int mutt_slow_close_compressed (CONTEXT *ctx)
519 +{
520 +  FILE *fp;
521 +  const char *append;
522 +  char *cmd;
523 +  COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
524 +
525 +  dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
526 +             ctx->path));
527 +
528 +  if (! (ctx->append
529 +        && ((append = get_append_command (ctx->realpath, ctx))
530 +            || (append = ci->close))))
531 +  { 
532 +    /* if we can not or should not append, we only have to remove the */
533 +    /* compressed info, because sync was already called               */
534 +    mutt_fast_close_compressed (ctx);
535 +    return (0);
536 +  }
537 +
538 +  if (ctx->fp)
539 +    fclose (ctx->fp);
540 +  ctx->fp = NULL;
541 +
542 +  if (!ctx->quiet)
543 +  {
544 +    if (append == ci->close)
545 +      mutt_message (_("Compressing %s..."), ctx->realpath);
546 +    else
547 +      mutt_message (_("Compressed-appending to %s..."), ctx->realpath);
548 +  }
549 +
550 +  cmd = get_compression_cmd (append, ctx);
551 +  if (cmd == NULL)
552 +    return (-1);
553 +
554 +  if ((fp = fopen (ctx->realpath, "a")) == NULL)
555 +  {
556 +    mutt_perror (ctx->realpath);
557 +    safe_free ((void **)&cmd);
558 +    return (-1);
559 +  }
560 +  mutt_block_signals ();
561 +  if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
562 +  {
563 +    fclose (fp);
564 +    mutt_unblock_signals ();
565 +    mutt_error _("Unable to lock mailbox!");
566 +    safe_free ((void **)&cmd);
567 +    return (-1);
568 +  }
569 +
570 +  dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
571 +
572 +  endwin ();
573 +  fflush (stdout);
574 +
575 +  if (append == ci->close)
576 +    fprintf (stderr, _("Compressing %s...\n"), ctx->realpath);
577 +  else
578 +    fprintf (stderr, _("Compressed-appending to %s...\n"), ctx->realpath);
579 +
580 +  if (mutt_system (cmd))
581 +  {
582 +    mutt_any_key_to_continue (NULL);
583 +    mutt_error (_(" %s: Error compressing mailbox!  Uncompressed one kept!\n"),
584 +               ctx->path);
585 +    safe_free ((void **)&cmd);
586 +    mbox_unlock_compressed (ctx, fp);
587 +    mutt_unblock_signals ();
588 +    fclose (fp);
589 +    return (-1);
590 +  }
591 +
592 +  mbox_unlock_compressed (ctx, fp);
593 +  mutt_unblock_signals ();
594 +  fclose (fp);
595 +  remove_file (ctx);
596 +  restore_path (ctx);
597 +  safe_free ((void **)&cmd);
598 +  safe_free ((void **)&ctx->compressinfo);
599 +
600 +  return (0);
601 +}
602 +
603 +#endif /* USE_COMPRESSED */
604 diff -Nur mutt-1.3.27.orig/compress.h mutt-1.3.27/compress.h
605 --- mutt-1.3.27.orig/compress.h Thu Jan  1 01:00:00 1970
606 +++ mutt-1.3.27/compress.h      Fri Feb  1 22:51:32 2002
607 @@ -0,0 +1,27 @@
608 +/*
609 + * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com>
610 + *
611 + *     This program is free software; you can redistribute it and/or modify
612 + *     it under the terms of the GNU General Public License as published by
613 + *     the Free Software Foundation; either version 2 of the License, or
614 + *     (at your option) any later version.
615 + *
616 + *     This program is distributed in the hope that it will be useful,
617 + *     but WITHOUT ANY WARRANTY; without even the implied warranty of
618 + *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
619 + *     GNU General Public License for more details.
620 + *
621 + *     You should have received a copy of the GNU General Public License
622 + *     along with this program; if not, write to the Free Software
623 + *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
624 + */
625 +
626 +int mutt_can_read_compressed (const char *);
627 +int mutt_can_append_compressed (const char *);
628 +int mutt_open_read_compressed (CONTEXT *);
629 +int mutt_open_append_compressed (CONTEXT *);
630 +int mutt_slow_close_compressed (CONTEXT *);
631 +int mutt_sync_compressed (CONTEXT *);
632 +int mutt_test_compress_command (const char *);
633 +int mutt_check_mailbox_compressed (CONTEXT *);
634 +void mutt_fast_close_compressed (CONTEXT *);
635 diff -Nur mutt-1.3.27.orig/config.h.in mutt-1.3.27/config.h.in
636 --- mutt-1.3.27.orig/config.h.in        Fri Aug  3 18:52:17 2001
637 +++ mutt-1.3.27/config.h.in     Fri Feb  1 22:52:59 2002
638 @@ -151,6 +151,9 @@
639  /*  Define to enable Sun mailtool attachments support.  */
640  #undef SUN_ATTACHMENT
641  
642 +/* Define to enable compressed mailboxes support */
643 +#undef USE_COMPRESSED
644 +
645  /*  Define if the result of isprint() is unreliable.  */
646  #undef LOCALES_HACK
647  
648 diff -Nur mutt-1.3.27.orig/configure mutt-1.3.27/configure
649 --- mutt-1.3.27.orig/configure  Tue Jan  1 21:17:56 2002
650 +++ mutt-1.3.27/configure       Fri Feb  1 22:51:32 2002
651 @@ -60,6 +60,8 @@
652  ac_help="$ac_help
653    --enable-locales-fix       The result of isprint() is unreliable "
654  ac_help="$ac_help
655 +  --enable-compressed        Enable compressed folders support "
656 +ac_help="$ac_help
657    --with-exec-shell=SHELL    Specify alternate shell (ONLY if /bin/sh is broken)"
658  ac_help="$ac_help
659    --enable-exact-address     Enable regeneration of email addresses"
660 @@ -5793,6 +5795,18 @@
661  EOF
662  
663          fi
664 +fi
665 +
666 +
667 +# Check whether --enable-compressed or --disable-compressed was given.
668 +if test "${enable_compressed+set}" = set; then
669 +  enableval="$enable_compressed"
670 +  if test x$enableval = xyes; then
671 +                cat >> confdefs.h <<\EOF
672 +#define USE_COMPRESSED 1
673 +EOF
674 +
675 +        fi
676  fi
677  
678  
679 diff -Nur mutt-1.3.27.orig/configure.in mutt-1.3.27/configure.in
680 --- mutt-1.3.27.orig/configure.in       Fri Feb  1 22:51:17 2002
681 +++ mutt-1.3.27/configure.in    Fri Feb  1 22:51:32 2002
682 @@ -644,6 +644,11 @@
683                  AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
684          fi])
685  
686 +AC_ARG_ENABLE(compressed, [  --enable-compressed        Enable compressed folders support ],
687 +       [if test x$enableval = xyes; then
688 +                AC_DEFINE(USE_COMPRESSED,1, [ Define to support compressed folders. ])
689 +        fi])
690 +
691  AC_ARG_WITH(exec-shell, [  --with-exec-shell=SHELL    Specify alternate shell (ONLY if /bin/sh is broken)],
692          [if test $withval != yes; then
693                  AC_DEFINE_UNQUOTED(EXECSHELL, "$withval")
694 diff -Nur mutt-1.3.27.orig/curs_main.c mutt-1.3.27/curs_main.c
695 --- mutt-1.3.27.orig/curs_main.c        Wed Jan 23 00:42:01 2002
696 +++ mutt-1.3.27/curs_main.c     Fri Feb  1 22:51:32 2002
697 @@ -1010,6 +1010,11 @@
698          {
699           int check;
700  
701 +#ifdef USE_COMPRESSED
702 +         if (Context->compressinfo && Context->realpath)
703 +           mutt_str_replace (&LastFolder, Context->realpath);
704 +         else
705 +#endif
706           mutt_str_replace (&LastFolder, Context->path);
707           oldcount = Context ? Context->msgcount : 0;
708  
709 diff -Nur mutt-1.3.27.orig/doc/manual-6.html mutt-1.3.27/doc/manual-6.html
710 --- mutt-1.3.27.orig/doc/manual-6.html  Tue Jan  1 21:18:13 2002
711 +++ mutt-1.3.27/doc/manual-6.html       Fri Feb  1 22:51:32 2002
712 @@ -70,12 +70,16 @@
713  <LI><CODE>
714  <A HREF="manual-5.html#alternative_order">alternative_order</A></CODE> <EM>mimetype</EM> [ <EM>mimetype</EM> ... ]</LI>
715  <LI><CODE>
716 +<A HREF="manual-4.html#append-hook">append-hook</A></CODE> <EM>regexp</EM> &quot;<EM>command</EM>&quot;</LI>
717 +<LI><CODE>
718  <A HREF="manual-5.html#auto_view">auto_view</A></CODE> <EM>mimetype</EM> [ <EM>mimetype</EM> ... ]</LI>
719  <LI><CODE>
720  <A HREF="manual-3.html#bind">bind</A></CODE> <EM>map</EM> <EM>key</EM> <EM>function</EM></LI>
721  <LI><CODE>
722  <A HREF="manual-3.html#charset-hook">charset-hook</A></CODE> <EM>alias</EM> <EM>charset</EM></LI>
723  <LI><CODE>
724 +<A HREF="manual-4.html#close-hook">close-hook</A></CODE> <EM>regexp</EM> &quot;<EM>command</EM>&quot;</LI>
725 +<LI><CODE>
726  <A HREF="manual-3.html#color">color</A></CODE> <EM>object</EM> <EM>foreground</EM> <EM>background</EM> [ <EM>regexp</EM> ]</LI>
727  <LI><CODE>
728  <A HREF="manual-3.html#color">uncolor</A></CODE> <EM>index</EM> <EM>pattern</EM> [ <EM>pattern</EM> ... ]</LI>
729 @@ -118,6 +122,8 @@
730  <LI><CODE>
731  <A HREF="manual-3.html#my_hdr">unmy_hdr</A></CODE> <EM>field</EM> [ <EM>field</EM> ... ]</LI>
732  <LI><CODE>
733 +<A HREF="manual-4.html#open-hook">open-hook</A></CODE> <EM>regexp</EM> &quot;<EM>command</EM>&quot;</LI>
734 +<LI><CODE>
735  <A HREF="manual-3.html#pgp-hook">pgp-hook</A></CODE> <EM>pattern</EM> <EM>key-id</EM></LI>
736  <LI><CODE>
737  <A HREF="manual-3.html#push">push</A></CODE> <EM>string</EM></LI>
738 diff -Nur mutt-1.3.27.orig/doc/manual.sgml mutt-1.3.27/doc/manual.sgml
739 --- mutt-1.3.27.orig/doc/manual.sgml    Tue Jan  1 21:18:05 2002
740 +++ mutt-1.3.27/doc/manual.sgml Fri Feb  1 22:51:32 2002
741 @@ -2318,6 +2318,176 @@
742  macro pager \cb |urlview\n
743  </verb></tscreen>
744  
745 +<sect1>Compressed folders Support (OPTIONAL)
746 +<p>
747 +
748 +If Mutt was compiled with compressed folders support (by running the
749 +<em/configure/ script with the <em/--enable-compressed/ flag), Mutt
750 +can open folders stored in an arbitrary format, provided that the user
751 +has a script to convert from/to this format to one of the accepted.
752 +
753 +The most common use is to open compressed archived folders e.g. with
754 +gzip.
755 +
756 +In addition, the user can provide a script that gets a folder in an
757 +accepted format and appends its context to the folder in the
758 +user-defined format, which may be faster than converting the entire
759 +folder to the accepted format, appending to it and converting back to
760 +the user-defined format.
761 +
762 +There are three hooks defined (<ref id="open-hook" name="open-hook">,
763 +<ref id="close-hook" name="close-hook"> and <ref id="append-hook"
764 +name="append-hook">) which define commands to uncompress and compress
765 +a folder and to append messages to an existing compressed folder 
766 +respectively.
767 +
768 +For example:
769 +
770 +<tscreen><verb>
771 +open-hook \\.gz$ "gzip -cd %f &gt; %t" 
772 +close-hook \\.gz$ "gzip -c %t &gt; %f"
773 +append-hook \\.gz$ "gzip -c %t &gt;&gt; %f" 
774 +</verb></tscreen>
775 +
776 +You do not have to specify all of the commands. If you omit <ref
777 +id="append-hook" name="append-hook">, the folder will be open and
778 +closed again each time you will add to it. If you omit <ref
779 +id="close-hook" name="close-hook"> (or give empty command) , the
780 +folder will be open in the  mode. If you specify <ref
781 +id="append-hook" name="append-hook"> though you'll be able to append
782 +to the folder.
783 +
784 +Note that Mutt will only try to use hooks if the file is not in one of
785 +the accepted formats. In particular, if the file is empty, mutt
786 +supposes it is not compressed. This is important because it allows the
787 +use of programs that do not have well defined extensions. Just use
788 +&dquot;.&dquot; as a regexp. But this may be surprising if your
789 +compressing script produces empty files. In this situation, unset <ref
790 +id="save_empty" name="&dollar;save&lowbar;empty">, so that the compressed file
791 +will be removed if you delete all of the messages.
792 +
793 +<sect2>Open a compressed mailbox for reading<label id="open-hook">
794 +<p>
795 +Usage: <tt/open-hook/ <em/regexp/ &dquot;<em/command/&dquot;
796 +
797 +The <em/command/ is the command that can be used for opening the
798 +folders whose names match <em/regexp/.
799 +
800 +The <em/command/ string is the printf-like format string, and it
801 +should accept two parameters: &percnt;f, which is replaced with the
802 +(compressed) folder name, and &percnt;t which is replaced with the
803 +name of the temporary folder to which to write.
804 +
805 +&percnt;f and &percnt;t can be repeated any number of times in the
806 +command string, and all of the entries are replaced with the
807 +appropriate folder name. In addition, &percnt;&percnt; is replaced by
808 +&percnt;, as in printf, and any other &percnt;anything is left as is.
809 +
810 +The <em/command/ should <bf/not/ remove the original compressed file.
811 +The <em/command/ should return non-zero exit status if it fails, so
812 +mutt knows something's wrong.
813 +
814 +Example:
815 +
816 +<tscreen><verb>
817 +open-hook \\.gz$ "gzip -cd %f &gt; %t" 
818 +</verb></tscreen>
819 +
820 +If the <em/command/ is empty, this operation is disabled for this file
821 +type.
822 +
823 +<sect2>Write a compressed mailbox<label id="close-hook">
824 +<p>
825 +Usage: <tt/close-hook/ <em/regexp/ &dquot;<em/command/&dquot;
826 +
827 +This is used to close the folder that was open with the <ref id="open-hook" 
828 +name="open-hook"> command after some changes were made to it.
829 +
830 +The <em/command/ string is the command that can be used for closing the
831 +folders whose names match <em/regexp/. It has the same format as in 
832 +the <ref id="open-hook" name="open-hook"> command. Temporary folder
833 +in this case is the folder previously produced by the <ref id="open-hook"
834 +name="open-hook"> command.
835 +
836 +The <em/command/ should <bf/not/ remove the decompressed file. The
837 +<em/command/ should return non-zero exit status if it fails, so mutt
838 +knows something's wrong.
839 +
840 +Example:
841 +
842 +<tscreen><verb>
843 +close-hook \\.gz$ "gzip -c %t &gt; %f"
844 +</verb></tscreen>
845 +
846 +If the <em/command/ is empty, this operation is disabled for this file
847 +type, and the file can only be open in the read-only mode.
848 +
849 +<ref id="close-hook" name ="close-hook"> is not called when you exit
850 +from the folder if the folder was not changed.
851 +
852 +<sect2>Append a message to a compressed mailbox<label id="append-hook">
853 +<p>
854 +Usage: <tt/append-hook/ <em/regexp/ &dquot;<em/command/&dquot;
855 +
856 +This command is used for saving to an existing compressed folder.
857 +The <em/command/ is the command that can be used for appending to the
858 +folders whose names match <em/regexp/. It has the same format as in 
859 + the <ref id="open-hook" name="open-hook"> command.
860 +The temporary folder in this case contains the messages that are being
861 +appended. 
862 +
863 +The <em/command/ should <bf/not/ remove the decompressed file. The
864 +<em/command/ should return non-zero exit status if it fails, so mutt
865 +knows something's wrong.
866 +
867 +Example:
868 +
869 +<tscreen><verb>
870 +append-hook \\.gz$ "gzip -c %t &gt;&gt; %f" 
871 +</verb></tscreen>
872 +
873 +When <ref id="append-hook" name="append-hook"> is used, the folder is
874 +not opened, which saves time, but this means that we can not find out
875 +what the folder type is. Thus the default (<ref id="mbox_type"
876 +name="&dollar;mbox&lowbar;type">) type is always supposed (i.e.
877 +this is the format used for the temporary folder).
878 +
879 +If the file does not exist when you save to it, <ref id="close-hook"
880 +name="close-hook"> is called, and not <ref id="append-hook"
881 +name="append-hook">. <ref id="append-hook" name="append-hook"> is only
882 +for appending to existing folders.
883 +
884 +If the <em/command/ is empty, this operation is disabled for this file
885 +type. In this case, the folder will be open and closed again (using
886 +<ref id="open-hook" name="open-hook"> and <ref id="close-hook" 
887 +name="close-hook">respectively) each time you will add to it.
888 +
889 +<sect2>Encrypted folders
890 +<p>
891 +The compressed folders support can also be used to handle encrypted
892 +folders. If you want to encrypt a folder with PGP, you may want to use
893 +the following hooks:
894 +
895 +<tscreen><verb>
896 +open-hook  \\.pgp$ "pgp -f &lt; %f &gt; %t"
897 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId &lt; %t &gt; %f"
898 +</verb></tscreen>
899 +
900 +Please note, that PGP does not support appending to an encrypted
901 +folder, so there is no append-hook defined.
902 +
903 +If you are using GnuPG instead of PGP, you may use the following hooks
904 +instead:
905 +
906 +<tscreen><verb>
907 +open-hook  \\.gpg$ "gpg --decrypt &lt; %f &gt; %t"
908 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId &lt; %t &gt; %f"
909 +</verb></tscreen>
910 +
911 +<bf/Note:/ the folder is temporary stored decrypted in the /tmp
912 +directory, where it can be read by your system administrator. So think
913 +about the security aspects of this.
914 +
915  <sect>Mutt's MIME Support
916  <p>
917  Quite a bit of effort has been made to make Mutt the premier text-mode
918 @@ -2868,12 +3038,16 @@
919  <item>
920  <tt><ref id="alternative_order" name="alternative&lowbar;order"></tt> <em/mimetype/ &lsqb; <em/mimetype/ ... &rsqb;
921  <item>
922 +<tt><ref id="append-hook" name="append-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
923 +<item>
924  <tt><ref id="auto_view" name="auto&lowbar;view"></tt> <em/mimetype/ &lsqb; <em/mimetype/ ... &rsqb;
925  <item>
926  <tt><ref id="bind" name="bind"></tt> <em/map/ <em/key/ <em/function/
927  <item>
928  <tt><ref id="charset-hook" name="charset-hook"></tt> <em/alias/ <em/charset/
929  <item>
930 +<tt><ref id="close-hook" name="close-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
931 +<item>
932  <tt><ref id="color" name="color"></tt> <em/object/ <em/foreground/ <em/background/ &lsqb; <em/regexp/ &rsqb;
933  <item>
934  <tt><ref id="color" name="uncolor"></tt> <em/index/ <em/pattern/ &lsqb; <em/pattern/ ... &rsqb;
935 @@ -2916,6 +3090,8 @@
936  <item>
937  <tt><ref id="my_hdr" name="unmy&lowbar;hdr"></tt> <em/field/ &lsqb; <em/field/ ... &rsqb;
938  <item>
939 +<tt><ref id="open-hook" name="open-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
940 +<item>
941  <tt><ref id="pgp-hook" name="pgp-hook"></tt> <em/pattern/ <em/key-id/
942  <item>
943  <tt><ref id="push" name="push"></tt> <em/string/
944 diff -Nur mutt-1.3.27.orig/doc/manual.sgml.head mutt-1.3.27/doc/manual.sgml.head
945 --- mutt-1.3.27.orig/doc/manual.sgml.head       Wed Jan 23 00:42:01 2002
946 +++ mutt-1.3.27/doc/manual.sgml.head    Fri Feb  1 22:51:32 2002
947 @@ -2319,6 +2319,176 @@
948  macro pager \cb |urlview\n
949  </verb></tscreen>
950  
951 +<sect1>Compressed folders Support (OPTIONAL)
952 +<p>
953 +
954 +If Mutt was compiled with compressed folders support (by running the
955 +<em/configure/ script with the <em/--enable-compressed/ flag), Mutt
956 +can open folders stored in an arbitrary format, provided that the user
957 +has a script to convert from/to this format to one of the accepted.
958 +
959 +The most common use is to open compressed archived folders e.g. with
960 +gzip.
961 +
962 +In addition, the user can provide a script that gets a folder in an
963 +accepted format and appends its context to the folder in the
964 +user-defined format, which may be faster than converting the entire
965 +folder to the accepted format, appending to it and converting back to
966 +the user-defined format.
967 +
968 +There are three hooks defined (<ref id="open-hook" name="open-hook">,
969 +<ref id="close-hook" name="close-hook"> and <ref id="append-hook"
970 +name="append-hook">) which define commands to uncompress and compress
971 +a folder and to append messages to an existing compressed folder 
972 +respectively.
973 +
974 +For example:
975 +
976 +<tscreen><verb>
977 +open-hook \\.gz$ "gzip -cd %f &gt; %t" 
978 +close-hook \\.gz$ "gzip -c %t &gt; %f"
979 +append-hook \\.gz$ "gzip -c %t &gt;&gt; %f" 
980 +</verb></tscreen>
981 +
982 +You do not have to specify all of the commands. If you omit <ref
983 +id="append-hook" name="append-hook">, the folder will be open and
984 +closed again each time you will add to it. If you omit <ref
985 +id="close-hook" name="close-hook"> (or give empty command) , the
986 +folder will be open in the  mode. If you specify <ref
987 +id="append-hook" name="append-hook"> though you'll be able to append
988 +to the folder.
989 +
990 +Note that Mutt will only try to use hooks if the file is not in one of
991 +the accepted formats. In particular, if the file is empty, mutt
992 +supposes it is not compressed. This is important because it allows the
993 +use of programs that do not have well defined extensions. Just use
994 +&dquot;.&dquot; as a regexp. But this may be surprising if your
995 +compressing script produces empty files. In this situation, unset <ref
996 +id="save_empty" name="&dollar;save&lowbar;empty">, so that the compressed file
997 +will be removed if you delete all of the messages.
998 +
999 +<sect2>Open a compressed mailbox for reading<label id="open-hook">
1000 +<p>
1001 +Usage: <tt/open-hook/ <em/regexp/ &dquot;<em/command/&dquot;
1002 +
1003 +The <em/command/ is the command that can be used for opening the
1004 +folders whose names match <em/regexp/.
1005 +
1006 +The <em/command/ string is the printf-like format string, and it
1007 +should accept two parameters: &percnt;f, which is replaced with the
1008 +(compressed) folder name, and &percnt;t which is replaced with the
1009 +name of the temporary folder to which to write.
1010 +
1011 +&percnt;f and &percnt;t can be repeated any number of times in the
1012 +command string, and all of the entries are replaced with the
1013 +appropriate folder name. In addition, &percnt;&percnt; is replaced by
1014 +&percnt;, as in printf, and any other &percnt;anything is left as is.
1015 +
1016 +The <em/command/ should <bf/not/ remove the original compressed file.
1017 +The <em/command/ should return non-zero exit status if it fails, so
1018 +mutt knows something's wrong.
1019 +
1020 +Example:
1021 +
1022 +<tscreen><verb>
1023 +open-hook \\.gz$ "gzip -cd %f &gt; %t" 
1024 +</verb></tscreen>
1025 +
1026 +If the <em/command/ is empty, this operation is disabled for this file
1027 +type.
1028 +
1029 +<sect2>Write a compressed mailbox<label id="close-hook">
1030 +<p>
1031 +Usage: <tt/close-hook/ <em/regexp/ &dquot;<em/command/&dquot;
1032 +
1033 +This is used to close the folder that was open with the <ref id="open-hook" 
1034 +name="open-hook"> command after some changes were made to it.
1035 +
1036 +The <em/command/ string is the command that can be used for closing the
1037 +folders whose names match <em/regexp/. It has the same format as in 
1038 +the <ref id="open-hook" name="open-hook"> command. Temporary folder
1039 +in this case is the folder previously produced by the <ref id="open-hook"
1040 +name="open-hook"> command.
1041 +
1042 +The <em/command/ should <bf/not/ remove the decompressed file. The
1043 +<em/command/ should return non-zero exit status if it fails, so mutt
1044 +knows something's wrong.
1045 +
1046 +Example:
1047 +
1048 +<tscreen><verb>
1049 +close-hook \\.gz$ "gzip -c %t &gt; %f"
1050 +</verb></tscreen>
1051 +
1052 +If the <em/command/ is empty, this operation is disabled for this file
1053 +type, and the file can only be open in the read-only mode.
1054 +
1055 +<ref id="close-hook" name ="close-hook"> is not called when you exit
1056 +from the folder if the folder was not changed.
1057 +
1058 +<sect2>Append a message to a compressed mailbox<label id="append-hook">
1059 +<p>
1060 +Usage: <tt/append-hook/ <em/regexp/ &dquot;<em/command/&dquot;
1061 +
1062 +This command is used for saving to an existing compressed folder.
1063 +The <em/command/ is the command that can be used for appending to the
1064 +folders whose names match <em/regexp/. It has the same format as in 
1065 + the <ref id="open-hook" name="open-hook"> command.
1066 +The temporary folder in this case contains the messages that are being
1067 +appended. 
1068 +
1069 +The <em/command/ should <bf/not/ remove the decompressed file. The
1070 +<em/command/ should return non-zero exit status if it fails, so mutt
1071 +knows something's wrong.
1072 +
1073 +Example:
1074 +
1075 +<tscreen><verb>
1076 +append-hook \\.gz$ "gzip -c %t &gt;&gt; %f" 
1077 +</verb></tscreen>
1078 +
1079 +When <ref id="append-hook" name="append-hook"> is used, the folder is
1080 +not opened, which saves time, but this means that we can not find out
1081 +what the folder type is. Thus the default (<ref id="mbox_type"
1082 +name="&dollar;mbox&lowbar;type">) type is always supposed (i.e.
1083 +this is the format used for the temporary folder).
1084 +
1085 +If the file does not exist when you save to it, <ref id="close-hook"
1086 +name="close-hook"> is called, and not <ref id="append-hook"
1087 +name="append-hook">. <ref id="append-hook" name="append-hook"> is only
1088 +for appending to existing folders.
1089 +
1090 +If the <em/command/ is empty, this operation is disabled for this file
1091 +type. In this case, the folder will be open and closed again (using
1092 +<ref id="open-hook" name="open-hook"> and <ref id="close-hook" 
1093 +name="close-hook">respectively) each time you will add to it.
1094 +
1095 +<sect2>Encrypted folders
1096 +<p>
1097 +The compressed folders support can also be used to handle encrypted
1098 +folders. If you want to encrypt a folder with PGP, you may want to use
1099 +the following hooks:
1100 +
1101 +<tscreen><verb>
1102 +open-hook  \\.pgp$ "pgp -f &lt; %f &gt; %t"
1103 +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId &lt; %t &gt; %f"
1104 +</verb></tscreen>
1105 +
1106 +Please note, that PGP does not support appending to an encrypted
1107 +folder, so there is no append-hook defined.
1108 +
1109 +If you are using GnuPG instead of PGP, you may use the following hooks
1110 +instead:
1111 +
1112 +<tscreen><verb>
1113 +open-hook  \\.gpg$ "gpg --decrypt &lt; %f &gt; %t"
1114 +close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId &lt; %t &gt; %f"
1115 +</verb></tscreen>
1116 +
1117 +<bf/Note:/ the folder is temporary stored decrypted in the /tmp
1118 +directory, where it can be read by your system administrator. So think
1119 +about the security aspects of this.
1120 +
1121  <sect>Mutt's MIME Support
1122  <p>
1123  Quite a bit of effort has been made to make Mutt the premier text-mode
1124 @@ -2869,12 +3039,16 @@
1125  <item>
1126  <tt><ref id="alternative_order" name="alternative&lowbar;order"></tt> <em/mimetype/ &lsqb; <em/mimetype/ ... &rsqb;
1127  <item>
1128 +<tt><ref id="append-hook" name="append-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
1129 +<item>
1130  <tt><ref id="auto_view" name="auto&lowbar;view"></tt> <em/mimetype/ &lsqb; <em/mimetype/ ... &rsqb;
1131  <item>
1132  <tt><ref id="bind" name="bind"></tt> <em/map/ <em/key/ <em/function/
1133  <item>
1134  <tt><ref id="charset-hook" name="charset-hook"></tt> <em/alias/ <em/charset/
1135  <item>
1136 +<tt><ref id="close-hook" name="close-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
1137 +<item>
1138  <tt><ref id="color" name="color"></tt> <em/object/ <em/foreground/ <em/background/ &lsqb; <em/regexp/ &rsqb;
1139  <item>
1140  <tt><ref id="color" name="uncolor"></tt> <em/index/ <em/pattern/ &lsqb; <em/pattern/ ... &rsqb;
1141 @@ -2917,6 +3091,8 @@
1142  <item>
1143  <tt><ref id="my_hdr" name="unmy&lowbar;hdr"></tt> <em/field/ &lsqb; <em/field/ ... &rsqb;
1144  <item>
1145 +<tt><ref id="open-hook" name="open-hook"></tt> <em/regexp/ &dquot;<em/command/&dquot;
1146 +<item>
1147  <tt><ref id="pgp-hook" name="pgp-hook"></tt> <em/pattern/ <em/key-id/
1148  <item>
1149  <tt><ref id="push" name="push"></tt> <em/string/
1150 diff -Nur mutt-1.3.27.orig/doc/manual.txt mutt-1.3.27/doc/manual.txt
1151 --- mutt-1.3.27.orig/doc/manual.txt     Tue Jan  1 21:18:08 2002
1152 +++ mutt-1.3.27/doc/manual.txt  Fri Feb  1 22:51:32 2002
1153 @@ -78,6 +78,11 @@
1154          4.11.2 Authentication
1155       4.12 Managing multiple IMAP/POP accounts (OPTIONAL)
1156       4.13 Start a WWW Browser on URLs (EXTERNAL)
1157 +     4.14 Compressed folders Support (OPTIONAL)
1158 +        4.14.1 Open a compressed mailbox for reading
1159 +        4.14.2 Write a compressed mailbox
1160 +        4.14.3 Append a message to a compressed mailbox
1161 +        4.14.4 Encrypted folders
1162  
1163    5. Mutt's MIME Support
1164       5.1 Using MIME in Mutt
1165 @@ -2554,6 +2559,156 @@
1166         macro index \cb |urlview\n
1167         macro pager \cb |urlview\n
1168  
1169 +  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)
1170 +
1171 +  If Mutt was compiled with compressed folders support (by running the
1172 +  _\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
1173 +  folders stored in an arbitrary format, provided that the user has a
1174 +  script to convert from/to this format to one of the accepted.
1175 +
1176 +  The most common use is to open compressed archived folders e.g. with
1177 +  gzip.
1178 +
1179 +  In addition, the user can provide a script that gets a folder in an
1180 +  accepted format and appends its context to the folder in the user-
1181 +  defined format, which may be faster than converting the entire folder
1182 +  to the accepted format, appending to it and converting back to the
1183 +  user-defined format.
1184 +
1185 +  There are three hooks defined (``open-hook'', ``close-hook'' and
1186 +  ``append-hook'') which define commands to uncompress and compress a
1187 +  folder and to append messages to an existing compressed folder
1188 +  respectively.
1189 +
1190 +  For example:
1191 +
1192 +       open-hook \\.gz$ "gzip -cd %f > %t"
1193 +       close-hook \\.gz$ "gzip -c %t > %f"
1194 +       append-hook \\.gz$ "gzip -c %t >> %f"
1195 +
1196 +  You do not have to specify all of the commands. If you omit ``append-
1197 +  hook'', the folder will be open and closed again each time you will
1198 +  add to it. If you omit ``close-hook'' (or give empty command) , the
1199 +  folder will be open in the  mode. If you specify ``append-hook''
1200 +  though you'll be able to append to the folder.
1201 +
1202 +  Note that Mutt will only try to use hooks if the file is not in one of
1203 +  the accepted formats. In particular, if the file is empty, mutt
1204 +  supposes it is not compressed. This is important because it allows the
1205 +  use of programs that do not have well defined extensions. Just use "."
1206 +  as a regexp. But this may be surprising if your compressing script
1207 +  produces empty files. In this situation, unset ``$save_empty'', so
1208 +  that the compressed file will be removed if you delete all of the
1209 +  messages.
1210 +
1211 +  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
1212 +
1213 +  Usage: open-hook _\br_\be_\bg_\be_\bx_\bp "_\bc_\bo_\bm_\bm_\ba_\bn_\bd"
1214 +
1215 +  The _\bc_\bo_\bm_\bm_\ba_\bn_\bd is the command that can be used for opening the folders
1216 +  whose names match _\br_\be_\bg_\be_\bx_\bp.
1217 +
1218 +  The _\bc_\bo_\bm_\bm_\ba_\bn_\bd string is the printf-like format string, and it should
1219 +  accept two parameters: %f, which is replaced with the (compressed)
1220 +  folder name, and %t which is replaced with the name of the temporary
1221 +  folder to which to write.
1222 +
1223 +  %f and %t can be repeated any number of times in the command string,
1224 +  and all of the entries are replaced with the appropriate folder name.
1225 +  In addition, %% is replaced by %, as in printf, and any other
1226 +  %anything is left as is.
1227 +
1228 +  The _\bc_\bo_\bm_\bm_\ba_\bn_\bd should n\bno\bot\bt remove the original compressed file.  The
1229 +  _\bc_\bo_\bm_\bm_\ba_\bn_\bd should return non-zero exit status if it fails, so mutt knows
1230 +  something's wrong.
1231 +
1232 +  Example:
1233 +
1234 +       open-hook \\.gz$ "gzip -cd %f > %t"
1235 +
1236 +  If the _\bc_\bo_\bm_\bm_\ba_\bn_\bd is empty, this operation is disabled for this file
1237 +  type.
1238 +
1239 +  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
1240 +
1241 +  Usage: close-hook _\br_\be_\bg_\be_\bx_\bp "_\bc_\bo_\bm_\bm_\ba_\bn_\bd"
1242 +
1243 +  This is used to close the folder that was open with the ``open-hook''
1244 +  command after some changes were made to it.
1245 +
1246 +  The _\bc_\bo_\bm_\bm_\ba_\bn_\bd string is the command that can be used for closing the
1247 +  folders whose names match _\br_\be_\bg_\be_\bx_\bp. It has the same format as in the
1248 +  ``open-hook'' command. Temporary folder in this case is the folder
1249 +  previously produced by the ``open-hook'' command.
1250 +
1251 +  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
1252 +  should return non-zero exit status if it fails, so mutt knows
1253 +  something's wrong.
1254 +
1255 +  Example:
1256 +
1257 +       close-hook \\.gz$ "gzip -c %t > %f"
1258 +
1259 +  If the _\bc_\bo_\bm_\bm_\ba_\bn_\bd is empty, this operation is disabled for this file
1260 +  type, and the file can only be open in the read-only mode.
1261 +
1262 +  ``close-hook'' is not called when you exit from the folder if the
1263 +  folder was not changed.
1264 +
1265 +  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
1266 +
1267 +  Usage: append-hook _\br_\be_\bg_\be_\bx_\bp "_\bc_\bo_\bm_\bm_\ba_\bn_\bd"
1268 +
1269 +  This command is used for saving to an existing compressed folder.  The
1270 +  _\bc_\bo_\bm_\bm_\ba_\bn_\bd is the command that can be used for appending to the folders
1271 +  whose names match _\br_\be_\bg_\be_\bx_\bp. It has the same format as in the ``open-
1272 +  hook'' command.  The temporary folder in this case contains the
1273 +  messages that are being appended.
1274 +
1275 +  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
1276 +  should return non-zero exit status if it fails, so mutt knows
1277 +  something's wrong.
1278 +
1279 +  Example:
1280 +
1281 +       append-hook \\.gz$ "gzip -c %t >> %f"
1282 +
1283 +  When ``append-hook'' is used, the folder is not opened, which saves
1284 +  time, but this means that we can not find out what the folder type is.
1285 +  Thus the default (``$mbox_type'') type is always supposed (i.e.  this
1286 +  is the format used for the temporary folder).
1287 +
1288 +  If the file does not exist when you save to it, ``close-hook'' is
1289 +  called, and not ``append-hook''. ``append-hook'' is only for appending
1290 +  to existing folders.
1291 +
1292 +  If the _\bc_\bo_\bm_\bm_\ba_\bn_\bd is empty, this operation is disabled for this file
1293 +  type. In this case, the folder will be open and closed again (using
1294 +  ``open-hook'' and ``close-hook''respectively) each time you will add
1295 +  to it.
1296 +
1297 +  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
1298 +
1299 +  The compressed folders support can also be used to handle encrypted
1300 +  folders. If you want to encrypt a folder with PGP, you may want to use
1301 +  the following hooks:
1302 +
1303 +       open-hook  \\.pgp$ "pgp -f < %f > %t"
1304 +       close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f"
1305 +
1306 +  Please note, that PGP does not support appending to an encrypted
1307 +  folder, so there is no append-hook defined.
1308 +
1309 +  If you are using GnuPG instead of PGP, you may use the following hooks
1310 +  instead:
1311 +
1312 +       open-hook  \\.gpg$ "gpg --decrypt < %f > %t"
1313 +       close-hook \\.gpg$ "gpg --encrypt --recipient YourGpgUserIdOrKeyId < %t > %f"
1314 +
1315 +  N\bNo\bot\bte\be:\b: the folder is temporary stored decrypted in the /tmp directory,
1316 +  where it can be read by your system administrator. So think about the
1317 +  security aspects of this.
1318 +
1319    5\b5.\b.  M\bMu\but\btt\bt'\b's\bs M\bMI\bIM\bME\bE S\bSu\bup\bpp\bpo\bor\brt\bt
1320  
1321    Quite a bit of effort has been made to make Mutt the premier text-mode
1322 @@ -3148,6 +3303,8 @@
1323  
1324    ·  ``unmy_hdr'' _\bf_\bi_\be_\bl_\bd [ _\bf_\bi_\be_\bl_\bd ... ]
1325  
1326 +  ·  ``open-hook'' _\br_\be_\bg_\be_\bx_\bp "_\bc_\bo_\bm_\bm_\ba_\bn_\bd"
1327 +
1328    ·  ``pgp-hook'' _\bp_\ba_\bt_\bt_\be_\br_\bn _\bk_\be_\by_\b-_\bi_\bd
1329  
1330    ·  ``push'' _\bs_\bt_\br_\bi_\bn_\bg
1331 diff -Nur mutt-1.3.27.orig/doc/muttrc.man mutt-1.3.27/doc/muttrc.man
1332 --- mutt-1.3.27.orig/doc/muttrc.man     Fri Dec 28 18:14:28 2001
1333 +++ mutt-1.3.27/doc/muttrc.man  Fri Feb  1 22:51:32 2002
1334 @@ -258,6 +258,24 @@
1335  The pgp-hook command provides a method by which you can
1336  specify the ID of the public key to be used when encrypting messages
1337  to a certain recipient.
1338 +.PP
1339 +.nf
1340 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
1341 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
1342 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
1343 +.fi
1344 +.IP
1345 +These commands provide a way to handle compressed folders. The given
1346 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
1347 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
1348 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
1349 +compressed mail to a compressed folder (\fBappend-hook\fP). The
1350 +\fIcommand\fP string is the 
1351 +.BR printf (3)
1352 +like format string, and it should accept two parameters: \fB%f\fP,
1353 +which is replaced with the (compressed) folder name, and \fB%t\fP
1354 +which is replaced with the name of the temporary folder to which to
1355 +write.
1356  .TP
1357  \fBpush\fP \fIstring\fP
1358  This command adds the named \fIstring\fP to the keyboard buffer.
1359 diff -Nur mutt-1.3.27.orig/doc/muttrc.man.head mutt-1.3.27/doc/muttrc.man.head
1360 --- mutt-1.3.27.orig/doc/muttrc.man.head        Wed Jan 23 00:42:01 2002
1361 +++ mutt-1.3.27/doc/muttrc.man.head     Fri Feb  1 22:51:32 2002
1362 @@ -258,6 +258,24 @@
1363  The pgp-hook command provides a method by which you can
1364  specify the ID of the public key to be used when encrypting messages
1365  to a certain recipient.
1366 +.PP
1367 +.nf
1368 +\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
1369 +\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP"
1370 +\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP"
1371 +.fi
1372 +.IP
1373 +These commands provide a way to handle compressed folders. The given
1374 +\fBregexp\fP specifies which folders are taken as compressed (e.g.
1375 +"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder
1376 +(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a
1377 +compressed mail to a compressed folder (\fBappend-hook\fP). The
1378 +\fIcommand\fP string is the 
1379 +.BR printf (3)
1380 +like format string, and it should accept two parameters: \fB%f\fP,
1381 +which is replaced with the (compressed) folder name, and \fB%t\fP
1382 +which is replaced with the name of the temporary folder to which to
1383 +write.
1384  .TP
1385  \fBpush\fP \fIstring\fP
1386  This command adds the named \fIstring\fP to the keyboard buffer.
1387 diff -Nur mutt-1.3.27.orig/hook.c mutt-1.3.27/hook.c
1388 --- mutt-1.3.27.orig/hook.c     Fri Jun 29 12:05:50 2001
1389 +++ mutt-1.3.27/hook.c  Fri Feb  1 22:51:32 2002
1390 @@ -19,6 +19,10 @@
1391  #include "mutt.h"
1392  #include "mailbox.h"
1393  
1394 +#ifdef USE_COMPRESSED
1395 +#include "compress.h"
1396 +#endif
1397 +
1398  #include <limits.h>
1399  #include <string.h>
1400  #include <stdlib.h>
1401 @@ -87,6 +91,16 @@
1402      memset (&pattern, 0, sizeof (pattern));
1403      pattern.data = safe_strdup (path);
1404    }
1405 +#ifdef USE_COMPRESSED
1406 +  else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
1407 +  {
1408 +    if (mutt_test_compress_command (command.data))
1409 +    {
1410 +      strfcpy (err->data, _("bad formatted command string"), err->dsize);
1411 +      return (-1);
1412 +    }
1413 +  }
1414 +#endif
1415    else if (DefaultHook && (data & (M_FOLDERHOOK | M_MBOXHOOK | M_SENDHOOK |
1416                                    M_FCCHOOK | M_SAVEHOOK | M_MESSAGEHOOK)))
1417    {
1418 diff -Nur mutt-1.3.27.orig/init.h mutt-1.3.27/init.h
1419 --- mutt-1.3.27.orig/init.h     Mon Dec 10 11:09:03 2001
1420 +++ mutt-1.3.27/init.h  Fri Feb  1 22:51:32 2002
1421 @@ -2447,6 +2447,11 @@
1422    { "fcc-hook",                mutt_parse_hook,        M_FCCHOOK },
1423    { "fcc-save-hook",   mutt_parse_hook,        M_FCCHOOK | M_SAVEHOOK },
1424    { "folder-hook",     mutt_parse_hook,        M_FOLDERHOOK },
1425 +#ifdef USE_COMPRESSED
1426 +  { "open-hook",       mutt_parse_hook,        M_OPENHOOK },
1427 +  { "close-hook",      mutt_parse_hook,        M_CLOSEHOOK },
1428 +  { "append-hook",     mutt_parse_hook,        M_APPENDHOOK },
1429 +#endif
1430    { "hdr_order",       parse_list,             UL &HeaderOrderList },
1431    { "iconv-hook",      mutt_parse_hook,        M_ICONVHOOK }, 
1432    { "ignore",          parse_ignore,           0 },
1433 diff -Nur mutt-1.3.27.orig/main.c mutt-1.3.27/main.c
1434 --- mutt-1.3.27.orig/main.c     Wed Nov  7 11:40:26 2001
1435 +++ mutt-1.3.27/main.c  Fri Feb  1 22:51:32 2002
1436 @@ -328,6 +328,12 @@
1437  #else
1438         "-LOCALES_HACK  "
1439  #endif
1440 +
1441 +#ifdef USE_COMPRESSED
1442 +       "+COMPRESSED  "
1443 +#else
1444 +       "-COMPRESSED  "
1445 +#endif
1446               
1447  #ifdef HAVE_WC_FUNCS
1448         "+HAVE_WC_FUNCS  "
1449 diff -Nur mutt-1.3.27.orig/mbox.c mutt-1.3.27/mbox.c
1450 --- mutt-1.3.27.orig/mbox.c     Wed Oct 31 10:40:05 2001
1451 +++ mutt-1.3.27/mbox.c  Fri Feb  1 22:51:32 2002
1452 @@ -28,6 +28,10 @@
1453  #include "sort.h"
1454  #include "copy.h"
1455  
1456 +#ifdef USE_COMPRESSED
1457 +#include "compress.h"
1458 +#endif
1459 +
1460  #include <sys/stat.h>
1461  #include <dirent.h>
1462  #include <string.h>
1463 @@ -1045,6 +1049,12 @@
1464  int mbox_close_mailbox (CONTEXT *ctx)
1465  {
1466    mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
1467 +
1468 +#ifdef USE_COMPRESSED
1469 +  if (ctx->compressinfo)
1470 +    mutt_slow_close_compressed (ctx);
1471 +#endif
1472 +
1473    mutt_unblock_signals ();
1474    mx_fastclose_mailbox (ctx);
1475    return 0;
1476 diff -Nur mutt-1.3.27.orig/mutt.h mutt-1.3.27/mutt.h
1477 --- mutt-1.3.27.orig/mutt.h     Wed Jan 23 00:42:01 2002
1478 +++ mutt-1.3.27/mutt.h  Fri Feb  1 22:51:32 2002
1479 @@ -143,6 +143,11 @@
1480  #define M_PGPHOOK      (1<<8)
1481  #endif
1482  #define M_ACCOUNTHOOK  (1<<9)
1483 +#ifdef USE_COMPRESSED
1484 +#define M_OPENHOOK     (1<<10)
1485 +#define M_APPENDHOOK   (1<<11)
1486 +#define M_CLOSEHOOK    (1<<12)
1487 +#endif
1488  
1489  /* tree characters for linearize_tree and print_enriched_string */
1490  #define M_TREE_LLCORNER                1
1491 @@ -745,6 +750,11 @@
1492    void *data;                  /* driver specific data */
1493  #endif /* USE_IMAP */
1494  
1495 +#ifdef USE_COMPRESSED
1496 +  void *compressinfo;          /* compressed mbox module private data */
1497 +  char *realpath;              /* path to compressed mailbox */
1498 +#endif /* USE_COMPRESSED */
1499 +
1500    short magic;                 /* mailbox type */
1501  
1502    unsigned int locked : 1;     /* is the mailbox locked? */
1503 diff -Nur mutt-1.3.27.orig/mx.c mutt-1.3.27/mx.c
1504 --- mutt-1.3.27.orig/mx.c       Wed Jan 23 00:42:01 2002
1505 +++ mutt-1.3.27/mx.c    Fri Feb  1 22:51:32 2002
1506 @@ -26,6 +26,10 @@
1507  #include "keymap.h"
1508  #include "url.h"
1509  
1510 +#ifdef USE_COMPRESSED
1511 +#include "compress.h"
1512 +#endif
1513 +
1514  #ifdef HAVE_PGP
1515  #include "pgp.h"
1516  #endif
1517 @@ -448,6 +452,10 @@
1518      return (-1);
1519    }
1520  
1521 +#ifdef USE_COMPRESSED
1522 +  if (magic == 0 && mutt_can_read_compressed (path))
1523 +    return M_COMPRESSED;
1524 +#endif
1525    return (magic);
1526  }
1527  
1528 @@ -489,6 +497,13 @@
1529  {
1530    struct stat sb;
1531  
1532 +#ifdef USE_COMPRESSED
1533 +  /* special case for appending to compressed folders -
1534 +   * even if we can not open them for reading */
1535 +  if (mutt_can_append_compressed (ctx->path))
1536 +    mutt_open_append_compressed (ctx);
1537 +#endif
1538 +
1539    ctx->append = 1;
1540  
1541  #ifdef USE_IMAP
1542 @@ -649,7 +664,12 @@
1543    }
1544  
1545    ctx->magic = mx_get_magic (path);
1546 -  
1547 +
1548 +#ifdef USE_COMPRESSED
1549 +  if (ctx->magic == M_COMPRESSED)
1550 +    mutt_open_read_compressed (ctx);
1551 +#endif
1552 +
1553    if(ctx->magic == 0)
1554      mutt_error (_("%s is not a mailbox."), path);
1555  
1556 @@ -755,6 +775,10 @@
1557      mutt_free_header (&ctx->hdrs[i]);
1558    safe_free ((void **) &ctx->hdrs);
1559    safe_free ((void **) &ctx->v2r);
1560 +#ifdef USE_COMPRESSED
1561 +  if (ctx->compressinfo)
1562 +    mutt_fast_close_compressed (ctx);
1563 +#endif
1564    safe_free ((void **) &ctx->path);
1565    safe_free ((void **) &ctx->pattern);
1566    if (ctx->limit_pattern) 
1567 @@ -812,6 +836,12 @@
1568    if (tmp && tmp->new == 0)
1569      mutt_update_mailbox (tmp);
1570  #endif
1571 +
1572 +#ifdef USE_COMPRESSED
1573 +  if (rc == 0 && ctx->compressinfo)
1574 +    return mutt_sync_compressed (ctx);
1575 +#endif
1576 +
1577    return rc;
1578  }
1579  
1580 @@ -1018,6 +1048,11 @@
1581        !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
1582      mx_unlink_empty (ctx->path);
1583  
1584 +#ifdef USE_COMPRESSED
1585 +  if (ctx->compressinfo && mutt_slow_close_compressed (ctx))
1586 +    return (-1);
1587 +#endif
1588 +
1589    mx_fastclose_mailbox (ctx);
1590  
1591    return 0;
1592 @@ -1325,6 +1360,11 @@
1593  {
1594    int rc;
1595  
1596 +#ifdef USE_COMPRESSED
1597 +  if (ctx->compressinfo)
1598 +    return mutt_check_mailbox_compressed (ctx);
1599 +#endif
1600 +
1601    if (ctx)
1602    {
1603      if (ctx->locked) lock = 0;
1604 diff -Nur mutt-1.3.27.orig/mx.h mutt-1.3.27/mx.h
1605 --- mutt-1.3.27.orig/mx.h       Wed Oct 31 10:40:05 2001
1606 +++ mutt-1.3.27/mx.h    Fri Feb  1 22:51:32 2002
1607 @@ -41,6 +41,9 @@
1608  #ifdef USE_POP
1609    , M_POP
1610  #endif
1611 +#ifdef USE_COMPRESSED
1612 +  , M_COMPRESSED
1613 +#endif
1614  };
1615  
1616  WHERE short DefaultMagic INITVAL (M_MBOX);
1617 diff -Nur mutt-1.3.27.orig/po/POTFILES.in mutt-1.3.27/po/POTFILES.in
1618 --- mutt-1.3.27.orig/po/POTFILES.in     Tue Oct 10 21:18:37 2000
1619 +++ mutt-1.3.27/po/POTFILES.in  Fri Feb  1 22:51:32 2002
1620 @@ -8,6 +8,7 @@
1621  color.c
1622  commands.c
1623  compose.c
1624 +compress.c
1625  curs_lib.c
1626  curs_main.c
1627  edit.c
1628 diff -Nur mutt-1.3.27.orig/po/de.po mutt-1.3.27/po/de.po
1629 --- mutt-1.3.27.orig/po/de.po   Wed Jan 23 00:43:05 2002
1630 +++ mutt-1.3.27/po/de.po        Fri Feb  1 22:51:32 2002
1631 @@ -654,6 +654,48 @@
1632  msgid "Message written."
1633  msgstr "Nachricht geschrieben."
1634  
1635 +#: compress.c:203 mbox.c:661
1636 +msgid "Mailbox was corrupted!"
1637 +msgstr "Mailbox wurde zerstört!"
1638 +
1639 +#: compress.c:228 compress.c:253
1640 +#, c-format
1641 +msgid "Decompressing %s...\n"
1642 +msgstr "Entpacke %s...\n"
1643 +
1644 +#: compress.c:246 compress.c:367 compress.c:443 mbox.c:706
1645 +msgid "Unable to lock mailbox!"
1646 +msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1647 +
1648 +#: compress.c:264
1649 +#, c-format
1650 +msgid "Error executing: %s : unable to open the mailbox!\n"
1651 +msgstr "Fehler beim Ausführen von %s : Kann die Mailbox nicht öffnen!\n"
1652 +
1653 +#: compress.c:350 compress.c:377 compress.c:423 compress.c:454
1654 +#, c-format
1655 +msgid "Compressing %s...\n"
1656 +msgstr "Komprimiere %s...\n"
1657 +
1658 +#: compress.c:381
1659 +#, c-format
1660 +msgid ""
1661 +"%s: Error compressing mailbox! Original mailbox deleted, uncompressed one "
1662 +"kept!\n"
1663 +msgstr ""
1664 +"%s: Fehler beim Komprimieren der Mailbox! Ursprüngliche Mailbox gelöscht, "
1665 +"entpackte gespeichert!\n"
1666 +
1667 +#: compress.c:425 compress.c:456
1668 +#, c-format
1669 +msgid "Compressed-appending to %s...\n"
1670 +msgstr "Hänge komprimiert an %s... an\n"
1671 +
1672 +#: compress.c:461
1673 +#, c-format
1674 +msgid " %s: Error compressing mailbox!  Uncompressed one kept!\n"
1675 +msgstr " %s: Fehler beim packen der Mailbox! Entpackte Mailbox gespeichert!\n"
1676 +
1677  #: curs_lib.c:153
1678  msgid "yes"
1679  msgstr "ja"
1680 @@ -1137,6 +1179,10 @@
1681  msgid "Help for %s"
1682  msgstr "Hilfe für %s"
1683  
1684 +#: hook.c:96
1685 +msgid "bad formatted command string"
1686 +msgstr "Hook enthält nicht die Muster %f und %t"
1687 +
1688  #: hook.c:240
1689  msgid "unhook: Can't do unhook * from within a hook."
1690  msgstr "unhook: Innerhalb eines hook kann kein unhook * aufgerufen werden."
1691 @@ -2459,18 +2505,10 @@
1692  msgid "Mailbox is corrupt!"
1693  msgstr "Mailbox fehlerhaft!"
1694  
1695 -#: mbox.c:665
1696 -msgid "Mailbox was corrupted!"
1697 -msgstr "Mailbox wurde zerstört!"
1698 -
1699  #: mbox.c:702 mbox.c:978
1700  msgid "Fatal error!  Could not reopen mailbox!"
1701  msgstr "Fataler Fehler, konnte Mailbox nicht erneut öffnen!"
1702  
1703 -#: mbox.c:711
1704 -msgid "Unable to lock mailbox!"
1705 -msgstr "Kann Mailbox nicht für exklusiven Zugriff sperren!"
1706 -
1707  #. this means ctx->changed or ctx->deleted was set, but no
1708  #. * messages were found to be changed or deleted.  This should
1709  #. * never happen, is we presume it is a bug in mutt.
1710 diff -Nur mutt-1.3.27.orig/status.c mutt-1.3.27/status.c
1711 --- mutt-1.3.27.orig/status.c   Fri Mar  3 11:10:14 2000
1712 +++ mutt-1.3.27/status.c        Fri Feb  1 22:51:32 2002
1713 @@ -93,6 +93,14 @@
1714  
1715      case 'f':
1716        snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
1717 +#ifdef USE_COMPRESSED
1718 +      if (Context && Context->compressinfo && Context->realpath)
1719 +      {
1720 +        strfcpy (tmp, Context->realpath, sizeof (tmp));
1721 +        mutt_pretty_mailbox (tmp);
1722 +      }
1723 +      else
1724 +#endif
1725        if (Context && Context->path)
1726        {
1727         strfcpy (tmp, Context->path, sizeof (tmp));
1728 --- mutt-1.3.99/doc/manual-4.html~      Tue May 21 22:14:04 2002
1729 +++ mutt-1.3.99/doc/manual-4.html       Tue May 21 22:15:56 2002
1730 @@ -815,7 +815,57 @@
1731  </CODE></BLOCKQUOTE>
1732  </P>
1733  
1734 -<HR>
1735 +<H2><A NAME="ss4.14">4.14 Compressed folders Support (OPTIONAL)</A>
1736 +</H2>
1737 +
1738 +
1739 +<P>If Mutt was compiled with compressed folders support (by running the
1740 +<EM>configure</EM> script with the <EM>--enable-compressed</EM> flag), Mutt
1741 +can open folders stored in an arbitrary format, provided that the user
1742 +has a script to convert from/to this format to one of the accepted.</P>
1743 +<P>The most common use is to open compressed archived folders e.g. with
1744 +gzip.</P>
1745 +<P>In addition, the user can provide a script that gets a folder in an
1746 +accepted format and appends its context to the folder in the
1747 +user-defined format, which may be faster than converting the entire
1748 +folder to the accepted format, appending to it and converting back to
1749 +the user-defined format.</P>
1750 +<P>There are three hooks defined (
1751 +<A HREF="#open-hook">open-hook</A>,
1752 +<A HREF="#close-hook">close-hook</A> and 
1753 +<A HREF="#append-hook">append-hook</A>) which define commands to uncompress and compress
1754 +a folder and to append messages to an existing compressed folder 
1755 +respectively.</P>
1756 +<P>For example:</P>
1757 +<P>
1758 +<BLOCKQUOTE><CODE>
1759 +<PRE>
1760 +open-hook \\.gz$ "gzip -cd %f &gt; %t" 
1761 +close-hook \\.gz$ "gzip -c %t &gt; %f"
1762 +append-hook \\.gz$ "gzip -c %t &gt;&gt; %f" 
1763 +</PRE>
1764 +</CODE></BLOCKQUOTE>
1765 +</P>
1766 +<P>You do not have to specify all of the commands. If you omit 
1767 +<A HREF="#append-hook">append-hook</A>, the folder will be open and
1768 +closed again each time you will add to it. If you omit 
1769 +<A HREF="#close-hook">close-hook</A> (or give empty command) , the
1770 +folder will be open in the  mode. If you specify 
1771 +<A HREF="#append-hook">append-hook</A> though you'll be able to append
1772 +to the folder.</P>
1773 +<P>Note that Mutt will only try to use hooks if the file is not in one of
1774 +the accepted formats. In particular, if the file is empty, mutt
1775 +supposes it is not compressed. This is important because it allows the
1776 +use of programs that do not have well defined extensions. Just use
1777 +&quot;.&quot; as a regexp. But this may be surprising if your
1778 +compressing script produces empty files. In this situation, unset 
1779 +<A HREF="manual-6.html#save_empty">$save_empty</A>, so that the compressed file
1780 +will be removed if you delete all of the messages.</P>
1781 +
1782 +<H3><A NAME="open-hook"></A> Open a compressed mailbox for reading</H3>
1783 +
1784 +<P>Usage: <CODE>open-hook</CODE> <EM>regexp</EM> &quot;<EM>command</EM>&quot;</P><HR>
1785 +
1786  <A HREF="manual-5.html">Next</A>
1787  <A HREF="manual-3.html">Previous</A>
1788  <A HREF="manual.html#toc4">Contents</A>
This page took 0.368294 seconds and 3 git commands to generate.