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