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