Link Here
|
5 |
+ hcache.c \ |
5 |
+ hcache.c \ |
6 |
addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \ |
6 |
addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \ |
7 |
diff -Nru a/configure.in b/configure.in |
7 |
diff -Nru a/configure.in b/configure.in |
8 |
--- configure.in Sat Feb 28 11:16:57 2004 |
8 |
--- configure.in.orig Sat Jun 12 09:49:17 2004 |
9 |
+++ configure.in Sat Feb 28 11:16:57 2004 |
9 |
+++ configure.in Sat Jun 12 09:50:18 2004 |
10 |
@@ -768,6 +767,21 @@ |
10 |
@@ -773,6 +773,80 @@ |
11 |
|
11 |
|
12 |
fi]) |
12 |
fi]) |
13 |
|
13 |
|
14 |
+dnl -- start cache -- |
14 |
+dnl -- start cache -- |
15 |
+AC_ARG_ENABLE(hcache, [ --enable-hcache Enable header caching for Maildir folders], |
15 |
+AC_ARG_ENABLE(hcache, [ --enable-hcache Enable header caching for Maildir folders], |
16 |
+[if test x$enableval = xyes; then |
16 |
+[if test x$enableval = xyes; then |
17 |
+ AC_DEFINE(USE_HCACHE, 1, [Enable header caching for Maildir style mailboxes]) |
17 |
+ AC_DEFINE(USE_HCACHE, 1, [Enable header caching for Maildir style mailboxes]) |
18 |
+ LIBS="$LIBS -lgdbm" |
18 |
+ |
19 |
+ AC_CACHE_CHECK(for gdbm_open, ac_cv_gdbmopen, |
19 |
+ OLDCPPFLAGS="$CPPFLAGS" |
20 |
+ [ac_cv_gdbmopen=no |
20 |
+ OLDLIBS="$LIBS" |
21 |
+ AC_TRY_LINK([#include <gdbm.h>],[gdbm_open(0,0,0,0,0);],[ac_cv_gdbmopen=yes])]) |
21 |
+ |
22 |
+ |
22 |
+ BDB_VERSIONS="db-4 db4 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db" |
23 |
+ if test $ac_cv_gdbmopen = no; then |
23 |
+ |
24 |
+ AC_MSG_ERROR(You must install libgdbm with --enable-hcache) |
24 |
+ AC_MSG_CHECKING([for BerkeleyDB > 4.0]) |
25 |
+ fi |
25 |
+ |
|
|
26 |
+ for d in /opt/csw/bdb4 /opt /usr/local /usr; do |
27 |
+ for v in `echo $BDB_VERSIONS .`; do |
28 |
+ if test -r "$d/include/$v/db.h"; then |
29 |
+ BDB_INCLUDE_DIR="$d/include/$v" |
30 |
+ break |
31 |
+ fi |
32 |
+ done |
33 |
+ for v in `echo $BDB_VERSIONS .`; do |
34 |
+ if test -d "$d/lib/$v"; then |
35 |
+ BDB_LIB_DIR="$d/lib/$v" |
36 |
+ break |
37 |
+ fi |
38 |
+ done |
39 |
+ for v in BerkeleyDB.4.3 BerkeleyDB.4.2 BerkeleyDB.4.1; do |
40 |
+ test -r "$d/$v/include/db.h" && BDB_INCLUDE_DIR="$d/$v/include" |
41 |
+ test -d "$d/$v/lib" && BDB_LIB_DIR="$d/$v/lib" |
42 |
+ done |
43 |
+ test x$BDB_INCLUDE_DIR = x -o x$BDB_LIB_DIR = x && continue |
44 |
+ for v in `echo $BDB_VERSIONS`; do |
45 |
+ CPPFLAGS="$OLDCPPFLAGS -I$BDB_INCLUDE_DIR" |
46 |
+ LIBS="$OLDLIBS -L$BDB_LIB_DIR -l$v" |
47 |
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
48 |
+ #include <stdlib.h> |
49 |
+ #include <db.h> |
50 |
+ ]],[[ |
51 |
+ DB *db = NULL; |
52 |
+ db->open(db,NULL,NULL,NULL,0,0,0); |
53 |
+ ]])],[ |
54 |
+ ac_cv_dbcreate=yes |
55 |
+ BDB_LIB="$v" |
56 |
+ break |
57 |
+ ]) |
58 |
+ done |
59 |
+ test x$BDB_LIB != x && break |
60 |
+ done |
61 |
+ |
62 |
+ if test x$ac_cv_dbcreate = xyes; then |
63 |
+ AC_MSG_RESULT(yes) |
64 |
+ else |
65 |
+ AC_MSG_RESULT(no) |
66 |
+ fi |
67 |
+ |
68 |
+ CPPFLAGS="$OLDCPPFLAGS" |
69 |
+ LIBS="$OLDLIBS -lgdbm"; |
70 |
+ AC_CACHE_CHECK(for gdbm_open, ac_cv_gdbmopen, |
71 |
+ [ac_cv_gdbmopen=no |
72 |
+ AC_TRY_LINK([#include <gdbm.h>],[gdbm_open(0,0,0,0,0);],[ac_cv_gdbmopen=yes])]) |
73 |
+ |
74 |
+ if test x$ac_cv_dbcreate = xyes; then |
75 |
+ CPPFLAGS="$OLDCPPFLAGS -I$BDB_INCLUDE_DIR" |
76 |
+ LIBS="$OLDLIBS -L$BDB_LIB_DIR -l$BDB_LIB" |
77 |
+ AC_DEFINE(HAVE_DB4, 1, [Sleepycat DB4 Support]) |
78 |
+ elif test x$ac_cv_gdbmopen = xyes; then |
79 |
+ CPPFLAGS="$OLDCPPFLAGS" |
80 |
+ LIBS="$OLDLIBS -lgdbm"; |
81 |
+ AC_DEFINE(HAVE_GDBM, 1, [GDBM Support]) |
82 |
+ else |
83 |
+ AC_MSG_ERROR(You need Sleepycat DB4 or GDBM for --enable-hcache) |
84 |
+ fi |
26 |
+fi]) |
85 |
+fi]) |
27 |
+dnl -- end cache -- |
86 |
+dnl -- end cache -- |
28 |
+ |
87 |
+ |
Link Here
|
30 |
AC_SUBST(MUTT_LIB_OBJECTS) |
89 |
AC_SUBST(MUTT_LIB_OBJECTS) |
31 |
AC_SUBST(LIBIMAP) |
90 |
AC_SUBST(LIBIMAP) |
32 |
diff -Nru a/globals.h b/globals.h |
91 |
diff -Nru a/globals.h b/globals.h |
33 |
--- globals.h Sat Feb 28 11:16:57 2004 |
92 |
--- globals.h 2004-06-10 14:03:44 +02:00 |
34 |
+++ globals.h Sat Feb 28 11:16:57 2004 |
93 |
+++ globals.h 2004-06-10 14:03:44 +02:00 |
35 |
@@ -63,6 +63,9 @@ |
94 |
@@ -63,6 +63,10 @@ |
36 |
WHERE char *Locale; |
95 |
WHERE char *Locale; |
37 |
WHERE char *MailcapPath; |
96 |
WHERE char *MailcapPath; |
38 |
WHERE char *Maildir; |
97 |
WHERE char *Maildir; |
39 |
+#if USE_HCACHE |
98 |
+#if USE_HCACHE |
40 |
+WHERE char *MaildirCache; |
99 |
+WHERE char *MaildirCache; |
|
|
100 |
+WHERE short MaildirCachePageSize; |
41 |
+#endif |
101 |
+#endif |
42 |
WHERE char *MhFlagged; |
102 |
WHERE char *MhFlagged; |
43 |
WHERE char *MhReplied; |
103 |
WHERE char *MhReplied; |
44 |
WHERE char *MhUnseen; |
104 |
WHERE char *MhUnseen; |
45 |
diff -Nru a/hcache.c b/hcache.c |
105 |
diff -Nru a/hcache.c b/hcache.c |
46 |
--- /dev/null Wed Dec 31 16:00:00 1969 |
106 |
--- hcache.c.orig Sat Jun 12 09:52:31 2004 |
47 |
+++ hcache.c Sat Feb 28 11:16:57 2004 |
107 |
+++ hcache.c Sat Jun 12 09:52:56 2004 |
48 |
@@ -0,0 +1,420 @@ |
108 |
@@ -0,0 +1,676 @@ |
49 |
+/* |
109 |
+/* |
50 |
+ * Copyright (C) 2004 Thomas Glanzmann <sithglan@stud.uni-erlangen.de> |
110 |
+ * Copyright (C) 2004 Thomas Glanzmann <sithglan@stud.uni-erlangen.de> |
|
|
111 |
+ * Copyright (C) 2004 Brian Fundakowski Feldman <green@FreeBSD.org> |
51 |
+ * |
112 |
+ * |
52 |
+ * This program is free software; you can redistribute it and/or modify |
113 |
+ * This program is free software; you can redistribute it and/or modify |
53 |
+ * it under the terms of the GNU General Public License as published by |
114 |
+ * it under the terms of the GNU General Public License as published by |
Link Here
|
68 |
+#include "config.h" |
129 |
+#include "config.h" |
69 |
+#endif /* HAVE_CONFIG_H */ |
130 |
+#endif /* HAVE_CONFIG_H */ |
70 |
+ |
131 |
+ |
|
|
132 |
+#if HAVE_GDBM |
71 |
+#include <gdbm.h> |
133 |
+#include <gdbm.h> |
|
|
134 |
+#elif HAVE_DB4 |
135 |
+#include <db42/db.h> |
136 |
+#endif |
137 |
+ |
138 |
+#include <errno.h> |
72 |
+#include <fcntl.h> |
139 |
+#include <fcntl.h> |
73 |
+#include "mutt.h" |
140 |
+#include "mutt.h" |
74 |
+#include "mime.h" |
141 |
+#include "mime.h" |
Link Here
|
76 |
+#include "lib.h" |
143 |
+#include "lib.h" |
77 |
+ |
144 |
+ |
78 |
+static unsigned char * |
145 |
+static unsigned char * |
79 |
+dump_int(unsigned int i, unsigned char *d, unsigned int *off) |
146 |
+dump_int(unsigned int i, unsigned char *d, int *off) |
80 |
+{ |
147 |
+{ |
81 |
+ safe_realloc(&d, *off + sizeof(int)); |
148 |
+ safe_realloc(&d, *off + sizeof(int)); |
82 |
+ memcpy(d + *off, &i, sizeof(int)); |
149 |
+ memcpy(d + *off, &i, sizeof(int)); |
Link Here
|
86 |
+} |
153 |
+} |
87 |
+ |
154 |
+ |
88 |
+static void |
155 |
+static void |
89 |
+restore_int(unsigned int *i, unsigned char *d, unsigned int *off) |
156 |
+restore_int(unsigned int *i, const unsigned char *d, int *off) |
90 |
+{ |
157 |
+{ |
91 |
+ memcpy(i, d + *off, sizeof(int)); |
158 |
+ memcpy(i, d + *off, sizeof(int)); |
92 |
+ (*off) += sizeof(int); |
159 |
+ (*off) += sizeof(int); |
93 |
+} |
160 |
+} |
94 |
+ |
161 |
+ |
95 |
+static unsigned char * |
162 |
+static unsigned char * |
96 |
+dump_char(char *c, unsigned char *d, unsigned int *off) |
163 |
+dump_char(char *c, unsigned char *d, int *off) |
97 |
+{ |
164 |
+{ |
98 |
+ unsigned int size; |
165 |
+ unsigned int size; |
99 |
+ |
166 |
+ |
Link Here
|
113 |
+} |
180 |
+} |
114 |
+ |
181 |
+ |
115 |
+static void |
182 |
+static void |
116 |
+restore_char(char **c, unsigned char *d, unsigned int *off) |
183 |
+restore_char(char **c, const unsigned char *d, int *off) |
117 |
+{ |
184 |
+{ |
118 |
+ unsigned int size; |
185 |
+ unsigned int size; |
119 |
+ restore_int(&size, d, off); |
186 |
+ restore_int(&size, d, off); |
Link Here
|
129 |
+} |
196 |
+} |
130 |
+ |
197 |
+ |
131 |
+static void |
198 |
+static void |
132 |
+skip_char(unsigned char *d, unsigned int *off) |
199 |
+skip_char(const unsigned char *d, int *off) |
133 |
+{ |
200 |
+{ |
134 |
+ unsigned int size; |
201 |
+ unsigned int size; |
135 |
+ restore_int(&size, d, off); |
202 |
+ restore_int(&size, d, off); |
Link Here
|
137 |
+} |
204 |
+} |
138 |
+ |
205 |
+ |
139 |
+static unsigned char * |
206 |
+static unsigned char * |
140 |
+dump_address(ADDRESS *a, unsigned char *d, unsigned int *off) |
207 |
+dump_address(ADDRESS *a, unsigned char *d, int *off) |
141 |
+{ |
208 |
+{ |
142 |
+ unsigned int counter = 0; |
209 |
+ unsigned int counter = 0; |
143 |
+ unsigned int start_off = *off; |
210 |
+ unsigned int start_off = *off; |
144 |
+ |
211 |
+ |
145 |
+ d = dump_int(0xdeadbeaf, d, off); |
212 |
+ d = dump_int(0xdeadbeef, d, off); |
146 |
+ |
213 |
+ |
147 |
+ while (a) { |
214 |
+ while (a) { |
148 |
+#ifdef EXACT_ADDRESS |
215 |
+#ifdef EXACT_ADDRESS |
Link Here
|
161 |
+} |
228 |
+} |
162 |
+ |
229 |
+ |
163 |
+static void |
230 |
+static void |
164 |
+restore_address(ADDRESS **a, unsigned char *d, unsigned int *off) |
231 |
+restore_address(ADDRESS **a, const unsigned char *d, int *off) |
165 |
+{ |
232 |
+{ |
166 |
+ unsigned int counter; |
233 |
+ unsigned int counter; |
167 |
+ |
234 |
+ |
Link Here
|
184 |
+} |
251 |
+} |
185 |
+ |
252 |
+ |
186 |
+static unsigned char * |
253 |
+static unsigned char * |
187 |
+dump_list(LIST *l, unsigned char *d, unsigned int *off) |
254 |
+dump_list(LIST *l, unsigned char *d, int *off) |
188 |
+{ |
255 |
+{ |
189 |
+ unsigned int counter = 0; |
256 |
+ unsigned int counter = 0; |
190 |
+ unsigned int start_off = *off; |
257 |
+ unsigned int start_off = *off; |
191 |
+ |
258 |
+ |
192 |
+ d = dump_int(0xdeadbeaf, d, off); |
259 |
+ d = dump_int(0xdeadbeef, d, off); |
193 |
+ |
260 |
+ |
194 |
+ while (l) { |
261 |
+ while (l) { |
195 |
+ d = dump_char(l->data, d, off); |
262 |
+ d = dump_char(l->data, d, off); |
Link Here
|
203 |
+} |
270 |
+} |
204 |
+ |
271 |
+ |
205 |
+static void |
272 |
+static void |
206 |
+restore_list(LIST **l, unsigned char *d, unsigned int *off) |
273 |
+restore_list(LIST **l, const unsigned char *d, int *off) |
207 |
+{ |
274 |
+{ |
208 |
+ unsigned int counter; |
275 |
+ unsigned int counter; |
209 |
+ |
276 |
+ |
Link Here
|
221 |
+} |
288 |
+} |
222 |
+ |
289 |
+ |
223 |
+static unsigned char * |
290 |
+static unsigned char * |
224 |
+dump_parameter(PARAMETER *p, unsigned char *d, unsigned int *off) |
291 |
+dump_parameter(PARAMETER *p, unsigned char *d, int *off) |
225 |
+{ |
292 |
+{ |
226 |
+ unsigned int counter = 0; |
293 |
+ unsigned int counter = 0; |
227 |
+ unsigned int start_off = *off; |
294 |
+ unsigned int start_off = *off; |
228 |
+ |
295 |
+ |
229 |
+ d = dump_int(0xdeadbeaf, d, off); |
296 |
+ d = dump_int(0xdeadbeef, d, off); |
230 |
+ |
297 |
+ |
231 |
+ while (p) { |
298 |
+ while (p) { |
232 |
+ d = dump_char(p->attribute, d, off); |
299 |
+ d = dump_char(p->attribute, d, off); |
Link Here
|
241 |
+} |
308 |
+} |
242 |
+ |
309 |
+ |
243 |
+static void |
310 |
+static void |
244 |
+restore_parameter(PARAMETER **p, unsigned char *d, unsigned int *off) |
311 |
+restore_parameter(PARAMETER **p, const unsigned char *d, int *off) |
245 |
+{ |
312 |
+{ |
246 |
+ unsigned int counter; |
313 |
+ unsigned int counter; |
247 |
+ |
314 |
+ |
Link Here
|
260 |
+} |
327 |
+} |
261 |
+ |
328 |
+ |
262 |
+static unsigned char * |
329 |
+static unsigned char * |
263 |
+dump_body(BODY *c, unsigned char *d, unsigned int *off) |
330 |
+dump_body(BODY *c, unsigned char *d, int *off) |
264 |
+{ |
331 |
+{ |
265 |
+ safe_realloc(&d, *off + sizeof(BODY)); |
332 |
+ safe_realloc(&d, *off + sizeof(BODY)); |
266 |
+ memcpy(d + *off, c, sizeof(BODY)); |
333 |
+ memcpy(d + *off, c, sizeof(BODY)); |
Link Here
|
280 |
+} |
347 |
+} |
281 |
+ |
348 |
+ |
282 |
+static void |
349 |
+static void |
283 |
+restore_body(BODY *c, unsigned char *d, unsigned int *off) |
350 |
+restore_body(BODY *c, const unsigned char *d, int *off) |
284 |
+{ |
351 |
+{ |
285 |
+ memcpy(c, d + *off, sizeof(BODY)); |
352 |
+ memcpy(c, d + *off, sizeof(BODY)); |
286 |
+ *off += sizeof(BODY); |
353 |
+ *off += sizeof(BODY); |
Link Here
|
297 |
+} |
364 |
+} |
298 |
+ |
365 |
+ |
299 |
+static unsigned char * |
366 |
+static unsigned char * |
300 |
+dump_envelope(ENVELOPE *e, unsigned char *d, unsigned int *off) |
367 |
+dump_envelope(ENVELOPE *e, unsigned char *d, int *off) |
301 |
+{ |
368 |
+{ |
302 |
+ d = dump_address(e->return_path, d, off); |
369 |
+ d = dump_address(e->return_path, d, off); |
303 |
+ d = dump_address(e->from, d, off); |
370 |
+ d = dump_address(e->from, d, off); |
Link Here
|
309 |
+ d = dump_address(e->mail_followup_to, d, off); |
376 |
+ d = dump_address(e->mail_followup_to, d, off); |
310 |
+ |
377 |
+ |
311 |
+ d = dump_char(e->subject, d, off); |
378 |
+ d = dump_char(e->subject, d, off); |
312 |
+ d = dump_char(e->real_subj, d, off); |
379 |
+ if (e->real_subj) { |
|
|
380 |
+ d = dump_int(e->real_subj - e->subject, d, off); |
381 |
+ } else { |
382 |
+ d = dump_int(-1, d, off); |
383 |
+ } |
313 |
+ d = dump_char(e->message_id, d, off); |
384 |
+ d = dump_char(e->message_id, d, off); |
314 |
+ d = dump_char(e->supersedes, d, off); |
385 |
+ d = dump_char(e->supersedes, d, off); |
315 |
+ d = dump_char(e->date, d, off); |
386 |
+ d = dump_char(e->date, d, off); |
Link Here
|
323 |
+} |
394 |
+} |
324 |
+ |
395 |
+ |
325 |
+static void |
396 |
+static void |
326 |
+restore_envelope(ENVELOPE *e, unsigned char *d, unsigned int *off) |
397 |
+restore_envelope(ENVELOPE *e, const unsigned char *d, int *off) |
327 |
+{ |
398 |
+{ |
|
|
399 |
+ int real_subj_off; |
400 |
+ |
328 |
+ restore_address(& e->return_path, d, off); |
401 |
+ restore_address(& e->return_path, d, off); |
329 |
+ restore_address(& e->from, d, off); |
402 |
+ restore_address(& e->from, d, off); |
330 |
+ restore_address(& e->to, d, off); |
403 |
+ restore_address(& e->to, d, off); |
Link Here
|
335 |
+ restore_address(& e->mail_followup_to, d, off); |
408 |
+ restore_address(& e->mail_followup_to, d, off); |
336 |
+ |
409 |
+ |
337 |
+ restore_char(& e->subject, d, off); |
410 |
+ restore_char(& e->subject, d, off); |
338 |
+ restore_char(& e->real_subj, d, off); |
411 |
+ restore_int(& real_subj_off, d, off); |
|
|
412 |
+ if (0 <= real_subj_off) { |
413 |
+ e->real_subj = e->subject + real_subj_off; |
414 |
+ } else { |
415 |
+ e->real_subj = NULL; |
416 |
+ } |
339 |
+ restore_char(& e->message_id, d, off); |
417 |
+ restore_char(& e->message_id, d, off); |
340 |
+ restore_char(& e->supersedes, d, off); |
418 |
+ restore_char(& e->supersedes, d, off); |
341 |
+ restore_char(& e->date, d, off); |
419 |
+ restore_char(& e->date, d, off); |
Link Here
|
352 |
+ |
430 |
+ |
353 |
+#if HAVE_LANGINFO_CODESET |
431 |
+#if HAVE_LANGINFO_CODESET |
354 |
+int |
432 |
+int |
355 |
+mutt_hcache_charset_matches(char *d) |
433 |
+mutt_hcache_charset_matches(const char *d) |
356 |
+{ |
434 |
+{ |
357 |
+ unsigned int off = sizeof(struct timeval); |
435 |
+ int matches; |
|
|
436 |
+ int off = sizeof(struct timeval); |
358 |
+ char *charset = NULL; |
437 |
+ char *charset = NULL; |
359 |
+ |
438 |
+ |
360 |
+ restore_char(&charset, (unsigned char *) d, &off); |
439 |
+ restore_char(&charset, (unsigned char *) d, &off); |
|
|
440 |
+ matches = (0 == mutt_strcmp(charset, Charset)); |
441 |
+ FREE(&charset); |
361 |
+ |
442 |
+ |
362 |
+ return (0 == mutt_strcmp(charset, Charset)); |
443 |
+ return (matches); |
363 |
+} |
444 |
+} |
364 |
+#endif /* HAVE_LANGINFO_CODESET */ |
445 |
+#endif /* HAVE_LANGINFO_CODESET */ |
365 |
+ |
446 |
+ |
366 |
+void * |
447 |
+static void * |
367 |
+mutt_hcache_dump(HEADER *h, unsigned int *off) |
448 |
+mutt_hcache_dump(HEADER *h, int *off) |
368 |
+{ |
449 |
+{ |
369 |
+ unsigned char *d = NULL; |
450 |
+ unsigned char *d = NULL; |
370 |
+ struct timeval now; |
451 |
+ struct timeval now; |
Link Here
|
392 |
+} |
473 |
+} |
393 |
+ |
474 |
+ |
394 |
+HEADER * |
475 |
+HEADER * |
395 |
+mutt_hcache_restore(unsigned char *d, HEADER **oh) |
476 |
+mutt_hcache_restore(const unsigned char *d, HEADER **oh) |
396 |
+{ |
477 |
+{ |
397 |
+ unsigned int off = 0; |
478 |
+ int off = 0; |
398 |
+ HEADER *h = mutt_new_header(); |
479 |
+ HEADER *h = mutt_new_header(); |
399 |
+ |
480 |
+ |
400 |
+ /* skip timeval */ |
481 |
+ /* skip timeval */ |
Link Here
|
422 |
+ return h; |
503 |
+ return h; |
423 |
+} |
504 |
+} |
424 |
+ |
505 |
+ |
425 |
+GDBM_FILE |
506 |
+static size_t mutt_hcache_keylen (const char *fn) |
426 |
+mutt_hcache_open(char *path) |
|
|
427 |
+{ |
507 |
+{ |
428 |
+ GDBM_FILE db = NULL; |
508 |
+ const char * p = strchr (fn, ':'); |
|
|
509 |
+ return p ? (size_t) (p - fn) : strlen (fn); |
510 |
+} |
511 |
+ |
512 |
+#if HAVE_GDBM |
513 |
+static struct |
514 |
+header_cache |
515 |
+{ |
516 |
+ GDBM_FILE db; |
517 |
+ char *folder; |
518 |
+} HEADER_CACHE; |
519 |
+ |
520 |
+void * |
521 |
+mutt_hcache_open(const char *path, const char *folder) |
522 |
+{ |
523 |
+ struct header_cache *h = malloc(sizeof(HEADER_CACHE)); |
524 |
+ h->db = NULL; |
525 |
+ h->folder = safe_strdup (folder); |
429 |
+ |
526 |
+ |
430 |
+ if (! path || path[0] == '\0') { |
527 |
+ if (! path || path[0] == '\0') { |
431 |
+ return NULL; |
528 |
+ return NULL; |
432 |
+ } |
529 |
+ } |
433 |
+ |
530 |
+ |
434 |
+ db = gdbm_open(path, 0, GDBM_WRCREAT, 00600, NULL); |
531 |
+ h->db = gdbm_open((char *) path, (int) MaildirCachePageSize, GDBM_WRCREAT, 00600, NULL); |
435 |
+ if (db) { |
532 |
+ if (h->db) { |
436 |
+ return db; |
533 |
+ return h; |
437 |
+ } |
534 |
+ } |
438 |
+ |
535 |
+ |
439 |
+ /* if rw failed try ro */ |
536 |
+ /* if rw failed try ro */ |
440 |
+ return gdbm_open(path, 0, GDBM_READER, 00600, NULL); |
537 |
+ h->db = gdbm_open((char *) path, (int) MaildirCachePageSize, GDBM_READER, 00600, NULL); |
|
|
538 |
+ if(h->db) { |
539 |
+ return h; |
540 |
+ } else { |
541 |
+ FREE(& h->folder); |
542 |
+ FREE(& h); |
543 |
+ |
544 |
+ return NULL; |
545 |
+ } |
546 |
+} |
547 |
+ |
548 |
+void |
549 |
+mutt_hcache_close(void *db) |
550 |
+{ |
551 |
+ struct header_cache *h = db; |
552 |
+ |
553 |
+ if (! h) { |
554 |
+ return; |
555 |
+ } |
556 |
+ |
557 |
+ gdbm_close(h->db); |
558 |
+ FREE(& h->folder); |
559 |
+ FREE(& h); |
560 |
+} |
561 |
+ |
562 |
+void * |
563 |
+mutt_hcache_fetch(void *db, const char *filename) |
564 |
+{ |
565 |
+ struct header_cache *h = db; |
566 |
+ datum key; |
567 |
+ datum data; |
568 |
+ char path[_POSIX_PATH_MAX]; |
569 |
+ |
570 |
+ if (! h) { |
571 |
+ return NULL; |
572 |
+ } |
573 |
+ |
574 |
+ strncpy(path, h->folder, sizeof(path)); |
575 |
+ strncat(path, filename, sizeof(path) - strlen(path)); |
576 |
+ |
577 |
+ key.dptr = path; |
578 |
+ key.dsize = mutt_hcache_keylen(path); |
579 |
+ |
580 |
+ data = gdbm_fetch(h->db, key); |
581 |
+ |
582 |
+ return data.dptr; |
583 |
+} |
584 |
+ |
585 |
+int |
586 |
+mutt_hcache_store(void *db, const char *filename, HEADER *header) |
587 |
+{ |
588 |
+ struct header_cache *h = db; |
589 |
+ datum key; |
590 |
+ datum data; |
591 |
+ char path[_POSIX_PATH_MAX]; |
592 |
+ int ret; |
593 |
+ |
594 |
+ if (! h) { |
595 |
+ return -1; |
596 |
+ } |
597 |
+ |
598 |
+ strncpy(path, h->folder, sizeof(path)); |
599 |
+ strncat(path, filename, sizeof(path) - strlen(path)); |
600 |
+ |
601 |
+ key.dptr = path; |
602 |
+ key.dsize = mutt_hcache_keylen(path); |
603 |
+ |
604 |
+ data.dptr = mutt_hcache_dump(header, &data.dsize); |
605 |
+ |
606 |
+ ret = gdbm_store(h->db, key, data, GDBM_REPLACE); |
607 |
+ |
608 |
+ FREE(& data.dptr); |
609 |
+ |
610 |
+ return ret; |
611 |
+} |
612 |
+ |
613 |
+int |
614 |
+mutt_hcache_delete(void *db, const char *filename) |
615 |
+{ |
616 |
+ datum key; |
617 |
+ struct header_cache *h = db; |
618 |
+ char path[_POSIX_PATH_MAX]; |
619 |
+ |
620 |
+ if (! h) { |
621 |
+ return -1; |
622 |
+ } |
623 |
+ |
624 |
+ strncpy(path, h->folder, sizeof(path)); |
625 |
+ strncat(path, filename, sizeof(path) - strlen(path)); |
626 |
+ |
627 |
+ key.dptr = path; |
628 |
+ key.dsize = mutt_hcache_keylen(path); |
629 |
+ |
630 |
+ return gdbm_delete(h->db, key); |
631 |
+} |
632 |
+#elif HAVE_DB4 |
633 |
+ |
634 |
+static struct |
635 |
+header_cache |
636 |
+{ |
637 |
+ DB_ENV *env; |
638 |
+ DB *db; |
639 |
+} HEADER_CACHE; |
640 |
+ |
641 |
+static void |
642 |
+mutt_hcache_dbt_init(DBT *dbt, void *data, size_t len) |
643 |
+{ |
644 |
+ dbt->data = data; |
645 |
+ dbt->size = dbt->ulen = len; |
646 |
+ dbt->dlen = dbt->doff = 0; |
647 |
+ dbt->flags = DB_DBT_USERMEM; |
648 |
+} |
649 |
+ |
650 |
+static void |
651 |
+mutt_hcache_dbt_empty_init(DBT *dbt) |
652 |
+{ |
653 |
+ dbt->data = NULL; |
654 |
+ dbt->size = dbt->ulen = dbt->dlen = dbt->doff = 0; |
655 |
+ dbt->flags = 0; |
656 |
+} |
657 |
+ |
658 |
+void * |
659 |
+mutt_hcache_open(const char *path, const char *folder) |
660 |
+{ |
661 |
+ struct stat sb; |
662 |
+ u_int32_t createflags = DB_CREATE; |
663 |
+ int ret; |
664 |
+ struct header_cache *h = malloc(sizeof(HEADER_CACHE)); |
665 |
+ |
666 |
+ if (! path || path[0] == '\0') { |
667 |
+ FREE(& h); |
668 |
+ return NULL; |
669 |
+ } |
670 |
+ |
671 |
+ ret = db_env_create(&h->env, 0); |
672 |
+ if (ret) { |
673 |
+ FREE(& h); |
674 |
+ return NULL; |
675 |
+ } |
676 |
+ |
677 |
+ ret = h->env->open(h->env, NULL, DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE, 0600); |
678 |
+ if (! ret) { |
679 |
+ ret = db_create(&h->db, h->env, 0); |
680 |
+ if (ret) { |
681 |
+ h->env->close(h->env, 0); |
682 |
+ FREE(& h); |
683 |
+ return NULL; |
684 |
+ } |
685 |
+ } |
686 |
+ |
687 |
+ if (stat(path, &sb) != 0 && errno == ENOENT) { |
688 |
+ createflags |= DB_EXCL; |
689 |
+ h->db->set_pagesize(h->db, (int) MaildirCachePageSize); |
690 |
+ } |
691 |
+ |
692 |
+ ret = h->db->open(h->db, NULL, path, folder, DB_BTREE, createflags, 0600); |
693 |
+ if (ret) { |
694 |
+ h->db->close(h->db, 0); |
695 |
+ h->env->close(h->env, 0); |
696 |
+ FREE(& h); |
697 |
+ return NULL; |
698 |
+ } |
699 |
+ |
700 |
+ return h; |
441 |
+} |
701 |
+} |
442 |
+ |
702 |
+ |
443 |
+void |
703 |
+void |
444 |
+mutt_hcache_close(GDBM_FILE db) |
704 |
+mutt_hcache_close(void *db) |
445 |
+{ |
705 |
+{ |
446 |
+ if (db) { |
706 |
+ struct header_cache *h = db; |
447 |
+ gdbm_close(db); |
707 |
+ int ret; |
|
|
708 |
+ |
709 |
+ if (! h) { |
710 |
+ return; |
448 |
+ } |
711 |
+ } |
|
|
712 |
+ |
713 |
+ h->db->close(h->db, 0); |
714 |
+ h->env->close(h->env, 0); |
715 |
+ |
716 |
+ FREE(& h); |
449 |
+} |
717 |
+} |
450 |
+ |
718 |
+ |
451 |
+datum |
719 |
+void * |
452 |
+mutt_hcache_fetch(GDBM_FILE db, datum key) |
720 |
+mutt_hcache_fetch(void *db, const char *filename) |
453 |
+{ |
721 |
+{ |
454 |
+ if (! db) { |
722 |
+ DBT key; |
455 |
+ datum ret = {NULL, 0}; |
723 |
+ DBT data; |
456 |
+ return ret; |
724 |
+ struct header_cache *h = db; |
|
|
725 |
+ |
726 |
+ if (! h) { |
727 |
+ return NULL; |
457 |
+ } |
728 |
+ } |
458 |
+ return gdbm_fetch(db, key); |
729 |
+ |
|
|
730 |
+ filename++; /* skip '/' */ |
731 |
+ |
732 |
+ mutt_hcache_dbt_init(&key, (void *) filename, mutt_hcache_keylen(filename)); |
733 |
+ mutt_hcache_dbt_empty_init(&data); |
734 |
+ data.flags = DB_DBT_MALLOC; |
735 |
+ |
736 |
+ h->db->get(h->db, NULL, &key, &data, 0); |
737 |
+ |
738 |
+ return data.data; |
459 |
+} |
739 |
+} |
460 |
+ |
740 |
+ |
461 |
+int |
741 |
+int |
462 |
+mutt_hcache_store(GDBM_FILE db, datum key, datum data) |
742 |
+mutt_hcache_store(void *db, const char *filename, HEADER *header) |
463 |
+{ |
743 |
+{ |
464 |
+ if (! db) { |
744 |
+ DBT key; |
|
|
745 |
+ DBT data; |
746 |
+ int ret; |
747 |
+ struct header_cache *h = db; |
748 |
+ |
749 |
+ if (! h) { |
465 |
+ return -1; |
750 |
+ return -1; |
466 |
+ } |
751 |
+ } |
467 |
+ return gdbm_store(db, key, data, GDBM_REPLACE); |
752 |
+ |
|
|
753 |
+ filename++; /* skip '/' */ |
754 |
+ |
755 |
+ mutt_hcache_dbt_init(&key, (void *) filename, mutt_hcache_keylen(filename)); |
756 |
+ |
757 |
+ mutt_hcache_dbt_empty_init(&data); |
758 |
+ data.flags = DB_DBT_USERMEM; |
759 |
+ data.data = mutt_hcache_dump(header, (signed int *) &data.size); |
760 |
+ data.ulen = data.size; |
761 |
+ |
762 |
+ ret = h->db->put(h->db, NULL, &key, &data, 0); |
763 |
+ |
764 |
+ FREE(& data.data); |
765 |
+ |
766 |
+ return ret; |
767 |
+} |
768 |
+ |
769 |
+int |
770 |
+mutt_hcache_delete(void *db, const char *filename) |
771 |
+{ |
772 |
+ DBT key; |
773 |
+ struct header_cache *h = db; |
774 |
+ |
775 |
+ if (! h) { |
776 |
+ return -1; |
777 |
+ } |
778 |
+ |
779 |
+ filename++; /* skip '/' */ |
780 |
+ |
781 |
+ mutt_hcache_dbt_init(&key, (void *) filename, mutt_hcache_keylen(filename)); |
782 |
+ return h->db->del(h->db, NULL, &key, 0); |
468 |
+} |
783 |
+} |
|
|
784 |
+#endif |
469 |
diff -Nru a/init.h b/init.h |
785 |
diff -Nru a/init.h b/init.h |
470 |
--- init.h Sat Feb 28 11:16:57 2004 |
786 |
--- init.h 2004-06-10 14:03:44 +02:00 |
471 |
+++ init.h Sat Feb 28 11:16:57 2004 |
787 |
+++ init.h 2004-06-10 14:03:44 +02:00 |
472 |
@@ -981,6 +981,13 @@ |
788 |
@@ -981,6 +981,28 @@ |
473 |
** \fBDON'T CHANGE THIS SETTING UNLESS YOU ARE REALLY SURE WHAT YOU ARE |
789 |
** \fBDON'T CHANGE THIS SETTING UNLESS YOU ARE REALLY SURE WHAT YOU ARE |
474 |
** DOING!\fP |
790 |
** DOING!\fP |
475 |
*/ |
791 |
*/ |
Link Here
|
479 |
+ ** .pp |
795 |
+ ** .pp |
480 |
+ ** Path to the maildir cache file. If unset no cache will be used. |
796 |
+ ** Path to the maildir cache file. If unset no cache will be used. |
481 |
+ */ |
797 |
+ */ |
|
|
798 |
+ { "maildir_cache_verify", DT_BOOL, R_NONE, OPTHCACHEVERIFY, 1 }, |
799 |
+ /* |
800 |
+ ** .pp |
801 |
+ ** Check for programs other than mutt having modified maildir |
802 |
+ ** files when the header cache is in use. This incurs one stat(2) |
803 |
+ ** per message every time the folder is opened. |
804 |
+ */ |
805 |
+ { "maildir_cache_page_size", DT_NUM, R_NONE, UL &MaildirCachePageSize, 2048 }, |
806 |
+ /* |
807 |
+ ** .pp |
808 |
+ ** Change the maildir header cache database page size. Too large |
809 |
+ ** or too small of a page size for the common header can waste |
810 |
+ ** space, memory effectiveness, or CPU time. You can use the |
811 |
+ ** db_dump utility to determine the optimal page size. |
812 |
+ */ |
482 |
+#endif /* USE_HCACHE */ |
813 |
+#endif /* USE_HCACHE */ |
483 |
{ "maildir_trash", DT_BOOL, R_NONE, OPTMAILDIRTRASH, 0 }, |
814 |
{ "maildir_trash", DT_BOOL, R_NONE, OPTMAILDIRTRASH, 0 }, |
484 |
/* |
815 |
/* |
485 |
** .pp |
816 |
** .pp |
486 |
diff -Nru a/main.c b/main.c |
817 |
diff -Nru a/main.c b/main.c |
487 |
--- main.c Sat Feb 28 11:16:57 2004 |
818 |
--- main.c 2004-06-10 14:03:44 +02:00 |
488 |
+++ main.c Sat Feb 28 11:16:57 2004 |
819 |
+++ main.c 2004-06-10 14:03:44 +02:00 |
489 |
@@ -411,6 +411,12 @@ |
820 |
@@ -411,6 +411,12 @@ |
490 |
"-HAVE_GETADDRINFO " |
821 |
"-HAVE_GETADDRINFO " |
491 |
#endif |
822 |
#endif |
Link Here
|
500 |
|
831 |
|
501 |
#ifdef ISPELL |
832 |
#ifdef ISPELL |
502 |
diff -Nru a/mh.c b/mh.c |
833 |
diff -Nru a/mh.c b/mh.c |
503 |
--- mh.c Sat Feb 28 11:16:57 2004 |
834 |
--- mh.c 2004-06-10 14:03:44 +02:00 |
504 |
+++ mh.c Sat Feb 28 11:16:57 2004 |
835 |
+++ mh.c 2004-06-10 14:03:44 +02:00 |
505 |
@@ -42,6 +42,10 @@ |
836 |
@@ -779,11 +779,65 @@ |
506 |
#include <string.h> |
|
|
507 |
#include <utime.h> |
508 |
|
509 |
+#if USE_HCACHE |
510 |
+#include <gdbm.h> |
511 |
+#endif /* USE_HCACHE */ |
512 |
+ |
513 |
struct maildir |
514 |
{ |
515 |
HEADER *h; |
516 |
@@ -779,11 +783,82 @@ |
517 |
return r; |
837 |
return r; |
518 |
} |
838 |
} |
519 |
|
839 |
|
520 |
+#if USE_HCACHE |
840 |
+#if USE_HCACHE |
521 |
+ |
|
|
522 |
+static ssize_t |
523 |
+maildir_cache_keylen(const char *fn) |
524 |
+{ |
525 |
+ char *lastcolon = strrchr(fn, ':'); |
526 |
+ |
527 |
+ if (lastcolon) { |
528 |
+ *lastcolon = '\0'; |
529 |
+ } |
530 |
+ |
531 |
+ return strlen(fn) + 1; |
532 |
+} |
533 |
|
841 |
|
534 |
/* |
842 |
/* |
535 |
* This function does the second parsing pass for a maildir-style |
843 |
* This function does the second parsing pass for a maildir-style |
Link Here
|
538 |
+void maildir_delayed_parsing (CONTEXT * ctx, struct maildir *md) |
846 |
+void maildir_delayed_parsing (CONTEXT * ctx, struct maildir *md) |
539 |
+{ |
847 |
+{ |
540 |
+ struct maildir *p; |
848 |
+ struct maildir *p; |
541 |
+ GDBM_FILE db = NULL; |
849 |
+ void *hc = NULL; |
542 |
+ char fn[_POSIX_PATH_MAX]; |
850 |
+ char fn[_POSIX_PATH_MAX]; |
543 |
+ char key_fn[_POSIX_PATH_MAX]; |
851 |
+ void *data; |
544 |
+ datum key; |
|
|
545 |
+ datum data; |
546 |
+ unsigned int size; |
852 |
+ unsigned int size; |
547 |
+ struct timeval *when = NULL; |
853 |
+ struct timeval *when = NULL; |
548 |
+ struct stat lastchanged; |
854 |
+ struct stat lastchanged; |
549 |
+ int ret; |
855 |
+ int ret; |
550 |
+ |
856 |
+ |
551 |
+ db = mutt_hcache_open(MaildirCache); |
857 |
+ hc = mutt_hcache_open (MaildirCache, ctx->path); |
552 |
+ |
858 |
+ |
553 |
+ for (p = md; p; p = p->next) { |
859 |
+ for (p = md; p; p = p->next) { |
554 |
+ if (! (p && p->h && !p->header_parsed)) { |
860 |
+ if (! (p && p->h && !p->header_parsed)) { |
555 |
+ continue; |
861 |
+ continue; |
556 |
+ } |
862 |
+ } |
557 |
+ |
863 |
+ |
558 |
+ snprintf(key_fn, sizeof(key_fn), "%s/%s", ctx->path, p->h->path + 4); |
864 |
+ data = mutt_hcache_fetch (hc, p->h->path + 3); |
559 |
+ key.dptr = key_fn; |
865 |
+ when = (struct timeval *) data; |
560 |
+ key.dsize = maildir_cache_keylen(key_fn); |
|
|
561 |
+ data = mutt_hcache_fetch(db, key); |
562 |
+ when = (struct timeval *) data.dptr; |
563 |
+ |
866 |
+ |
564 |
+ snprintf(fn, sizeof (fn), "%s/%s", ctx->path, p->h->path); |
867 |
+ snprintf(fn, sizeof (fn), "%s/%s", ctx->path, p->h->path); |
565 |
+ ret = stat(fn, &lastchanged); |
|
|
566 |
+ |
868 |
+ |
567 |
+ if (data.dptr != NULL |
869 |
+ if (option(OPTHCACHEVERIFY)) { |
|
|
870 |
+ ret = stat(fn, &lastchanged); |
871 |
+ } else { |
872 |
+ lastchanged.st_mtime = 0; |
873 |
+ ret = 0; |
874 |
+ } |
875 |
+ |
876 |
+ if (data != NULL |
568 |
+ && ret == 0 |
877 |
+ && ret == 0 |
569 |
+ && lastchanged.st_mtime <= when->tv_sec |
878 |
+ && lastchanged.st_mtime <= when->tv_sec |
570 |
+#if HAVE_LANGINFO_CODESET |
879 |
+#if HAVE_LANGINFO_CODESET |
571 |
+ && mutt_hcache_charset_matches(data.dptr) |
880 |
+ && mutt_hcache_charset_matches (data) |
572 |
+#endif /* HAVE_LANGINFO_CODESET */ |
881 |
+#endif /* HAVE_LANGINFO_CODESET */ |
573 |
+ ) { |
882 |
+ ) { |
574 |
+ p->h = mutt_hcache_restore((unsigned char *)data.dptr, &p->h); |
883 |
+ p->h = mutt_hcache_restore ((unsigned char *)data, &p->h); |
575 |
+ FREE(& data.dptr); |
884 |
+ maildir_parse_flags (p->h, fn); |
576 |
+ maildir_parse_flags(p->h, fn); |
|
|
577 |
+ |
885 |
+ |
578 |
+ } else if (maildir_parse_message (ctx->magic, fn, p->h->old, p->h)) { |
886 |
+ } else if (maildir_parse_message (ctx->magic, fn, p->h->old, p->h)) { |
579 |
+ maildir_parse_flags(p->h, fn); |
887 |
+ maildir_parse_flags(p->h, fn); |
580 |
+ p->header_parsed = 1; |
888 |
+ p->header_parsed = 1; |
581 |
+ if (db) { |
889 |
+ mutt_hcache_store (hc, p->h->path + 3, p->h); |
582 |
+ /* only try this if db connection is available */ |
|
|
583 |
+ data.dptr = mutt_hcache_dump(p->h, &size); |
584 |
+ data.dsize = size; |
585 |
+ mutt_hcache_store(db, key, data); |
586 |
+ FREE(& data.dptr); |
587 |
+ } |
588 |
+ } else { |
890 |
+ } else { |
589 |
+ mutt_free_header (&p->h); |
891 |
+ mutt_free_header (&p->h); |
590 |
+ } |
892 |
+ } |
|
|
893 |
+ FREE(&data); |
591 |
+ } |
894 |
+ } |
592 |
+ mutt_hcache_close(db); |
895 |
+ mutt_hcache_close (hc); |
593 |
+} |
896 |
+} |
594 |
+ |
897 |
+ |
595 |
+#else /* USE_HCACHE */ |
898 |
+#else /* USE_HCACHE */ |
596 |
|
899 |
|
597 |
void maildir_delayed_parsing (CONTEXT * ctx, struct maildir *md) |
900 |
void maildir_delayed_parsing (CONTEXT * ctx, struct maildir *md) |
598 |
{ |
901 |
{ |
599 |
@@ -801,7 +876,7 @@ |
902 |
@@ -801,7 +855,7 @@ |
600 |
} |
903 |
} |
601 |
} |
904 |
} |
602 |
|
905 |
|
Link Here
|
605 |
|
908 |
|
606 |
/* Read a MH/maildir style mailbox. |
909 |
/* Read a MH/maildir style mailbox. |
607 |
* |
910 |
* |
|
|
911 |
@@ -1293,6 +1347,9 @@ |
912 |
{ |
913 |
char path[_POSIX_PATH_MAX], tmp[_POSIX_PATH_MAX]; |
914 |
int i, j; |
915 |
+#if USE_HCACHE |
916 |
+ void *hc = NULL; |
917 |
+#endif /* USE_HCACHE */ |
918 |
|
919 |
if (ctx->magic == M_MH) |
920 |
i = mh_check_mailbox (ctx, index_hint); |
921 |
@@ -1302,6 +1359,11 @@ |
922 |
if (i != 0) |
923 |
return i; |
924 |
|
925 |
+#if USE_HCACHE |
926 |
+ if (ctx->magic == M_MAILDIR) |
927 |
+ hc = mutt_hcache_open(MaildirCache, ctx->path); |
928 |
+#endif /* USE_HCACHE */ |
929 |
+ |
930 |
for (i = 0; i < ctx->msgcount; i++) |
931 |
{ |
932 |
if (ctx->hdrs[i]->deleted |
933 |
@@ -1310,7 +1372,13 @@ |
934 |
snprintf (path, sizeof (path), "%s/%s", ctx->path, ctx->hdrs[i]->path); |
935 |
if (ctx->magic == M_MAILDIR |
936 |
|| (option (OPTMHPURGE) && ctx->magic == M_MH)) |
937 |
+ { |
938 |
+#if USE_HCACHE |
939 |
+ if (ctx->magic == M_MAILDIR) |
940 |
+ mutt_hcache_delete (hc, ctx->hdrs[i]->path + 3); |
941 |
+#endif /* USE_HCACHE */ |
942 |
unlink (path); |
943 |
+ } |
944 |
else if (ctx->magic == M_MH) |
945 |
{ |
946 |
/* MH just moves files out of the way when you delete them */ |
947 |
@@ -1332,16 +1400,21 @@ |
948 |
if (ctx->magic == M_MAILDIR) |
949 |
{ |
950 |
if (maildir_sync_message (ctx, i) == -1) |
951 |
- return -1; |
952 |
+ goto err; |
953 |
} |
954 |
else |
955 |
{ |
956 |
if (mh_sync_message (ctx, i) == -1) |
957 |
- return -1; |
958 |
+ goto err; |
959 |
} |
960 |
} |
961 |
} |
962 |
|
963 |
+#if USE_HCACHE |
964 |
+ if (ctx->magic == M_MAILDIR) |
965 |
+ mutt_hcache_close (hc); |
966 |
+#endif /* USE_HCACHE */ |
967 |
+ |
968 |
if (ctx->magic == M_MH) |
969 |
mh_update_sequences (ctx); |
970 |
|
971 |
@@ -1362,6 +1435,13 @@ |
972 |
} |
973 |
|
974 |
return 0; |
975 |
+ |
976 |
+err: |
977 |
+#if USE_HCACHE |
978 |
+ if (ctx->magic == M_MAILDIR) |
979 |
+ mutt_hcache_close (hc); |
980 |
+#endif /* USE_HCACHE */ |
981 |
+ return -1; |
982 |
} |
983 |
|
984 |
static char *maildir_canon_filename (char *dest, const char *src, size_t l) |
985 |
diff -Nru a/mutt.h b/mutt.h |
986 |
--- mutt.h 2004-06-10 14:03:44 +02:00 |
987 |
+++ mutt.h 2004-06-10 14:03:44 +02:00 |
988 |
@@ -345,6 +345,9 @@ |
989 |
OPTFORCENAME, |
990 |
OPTFORWDECODE, |
991 |
OPTFORWQUOTE, |
992 |
+#if USE_HCACHE |
993 |
+ OPTHCACHEVERIFY, |
994 |
+#endif |
995 |
OPTHDRS, |
996 |
OPTHEADER, |
997 |
OPTHELP, |
608 |
diff -Nru a/protos.h b/protos.h |
998 |
diff -Nru a/protos.h b/protos.h |
609 |
--- protos.h Sat Feb 28 11:16:57 2004 |
999 |
--- protos.h 2004-06-10 14:03:44 +02:00 |
610 |
+++ protos.h Sat Feb 28 11:16:57 2004 |
1000 |
+++ protos.h 2004-06-10 14:03:44 +02:00 |
611 |
@@ -99,6 +99,18 @@ |
1001 |
@@ -99,6 +99,19 @@ |
612 |
ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short); |
1002 |
ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short); |
613 |
HEADER *mutt_dup_header (HEADER *); |
1003 |
HEADER *mutt_dup_header (HEADER *); |
614 |
|
1004 |
|
615 |
+#if USE_HCACHE |
1005 |
+#if USE_HCACHE |
616 |
+#include <gdbm.h> |
1006 |
+void *mutt_hcache_open(const char *path, const char *folder); |
617 |
+GDBM_FILE mutt_hcache_open(char *path); |
1007 |
+void mutt_hcache_close(void *db); |
618 |
+void mutt_hcache_close(GDBM_FILE db); |
1008 |
+HEADER *mutt_hcache_restore(const unsigned char *d, HEADER **oh); |
619 |
+void * mutt_hcache_dump(HEADER *h, unsigned int *off); |
1009 |
+void *mutt_hcache_fetch(void *db, const char *filename); |
620 |
+HEADER * mutt_hcache_restore(unsigned char *d, HEADER **oh); |
1010 |
+int mutt_hcache_store(void *db, const char *filename, HEADER *h); |
621 |
+datum mutt_hcache_fetch(GDBM_FILE db, datum key); |
1011 |
+int mutt_hcache_delete(void *db, const char *filename); |
622 |
+int mutt_hcache_store(GDBM_FILE db, datum key, datum data); |
1012 |
+#if HAVE_LANGINFO_CODESET |
623 |
+int mutt_hcache_charset_matches(char *d); |
1013 |
+int mutt_hcache_charset_matches(const char *d); |
|
|
1014 |
+#endif /* HAVE_LANGINFO_CODESET */ |
624 |
+#endif /* USE_HCACHE */ |
1015 |
+#endif /* USE_HCACHE */ |
625 |
+ |
1016 |
+ |
626 |
+ |
1017 |
+ |
627 |
ATTACHPTR **mutt_gen_attach_list (BODY *, int, ATTACHPTR **, short *, short *, int, int); |
1018 |
ATTACHPTR **mutt_gen_attach_list (BODY *, int, ATTACHPTR **, short *, short *, int, int); |
628 |
|
1019 |
|
629 |
time_t mutt_decrease_mtime (const char *, struct stat *); |
1020 |
time_t mutt_decrease_mtime (const char *, struct stat *); |
|
|
1021 |
--- PATCHES.orig Tue Nov 6 19:59:33 2001 |
1022 |
+++ PATCHES Tue Nov 6 19:59:42 2001 |
1023 |
@@ -1,0 +1 @@ |
1024 |
+maildir-header-cache.18 |