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