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