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