Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/lib-imap/imap-message-cache.c @ 22:a946ce1f09b7 HEAD
mbox fixes, not fully working yet but almost :)
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 24 Aug 2002 05:04:45 +0300 |
parents | 82b7de533f98 |
children | d493b9cc265e |
comparison
equal
deleted
inserted
replaced
21:163675942b83 | 22:a946ce1f09b7 |
---|---|
43 CachedMessage *messages; | 43 CachedMessage *messages; |
44 int messages_count; | 44 int messages_count; |
45 | 45 |
46 CachedMessage *open_msg; | 46 CachedMessage *open_msg; |
47 IOBuffer *open_inbuf; | 47 IOBuffer *open_inbuf; |
48 size_t open_size, open_virtual_size; | 48 off_t open_virtual_size; |
49 | 49 |
50 IOBuffer *(*inbuf_rewind)(IOBuffer *inbuf, void *context); | 50 IOBuffer *(*inbuf_rewind)(IOBuffer *inbuf, void *context); |
51 void *context; | 51 void *context; |
52 }; | 52 }; |
53 | 53 |
290 body size from it and the total virtual size */ | 290 body size from it and the total virtual size */ |
291 imap_msgcache_get_inbuf(cache, 0); | 291 imap_msgcache_get_inbuf(cache, 0); |
292 message_get_header_size(cache->open_inbuf, | 292 message_get_header_size(cache->open_inbuf, |
293 msg->hdr_size); | 293 msg->hdr_size); |
294 | 294 |
295 i_assert((off_t)msg->hdr_size->physical_size < | |
296 cache->open_inbuf->size); | |
297 i_assert((off_t)msg->hdr_size->virtual_size < | |
298 cache->open_virtual_size); | |
299 | |
295 msg->body_size->lines = 0; | 300 msg->body_size->lines = 0; |
296 msg->body_size->physical_size = cache->open_size - | 301 msg->body_size->physical_size = |
302 cache->open_inbuf->size - | |
297 msg->hdr_size->physical_size; | 303 msg->hdr_size->physical_size; |
298 msg->body_size->virtual_size = | 304 msg->body_size->virtual_size = |
299 cache->open_virtual_size - | 305 cache->open_virtual_size - |
300 msg->hdr_size->virtual_size; | 306 msg->hdr_size->virtual_size; |
301 } | 307 } |
318 | 324 |
319 t_pop(); | 325 t_pop(); |
320 } | 326 } |
321 | 327 |
322 void imap_msgcache_message(ImapMessageCache *cache, unsigned int uid, | 328 void imap_msgcache_message(ImapMessageCache *cache, unsigned int uid, |
323 ImapCacheField fields, size_t virtual_size, | 329 ImapCacheField fields, off_t virtual_size, |
324 size_t pv_headers_size, size_t pv_body_size, | 330 off_t pv_headers_size, off_t pv_body_size, |
325 IOBuffer *inbuf, | 331 IOBuffer *inbuf, |
326 IOBuffer *(*inbuf_rewind)(IOBuffer *inbuf, | 332 IOBuffer *(*inbuf_rewind)(IOBuffer *inbuf, |
327 void *context), | 333 void *context), |
328 void *context) | 334 void *context) |
329 { | 335 { |
333 if (cache->open_msg != msg) { | 339 if (cache->open_msg != msg) { |
334 imap_msgcache_close(cache); | 340 imap_msgcache_close(cache); |
335 | 341 |
336 cache->open_msg = msg; | 342 cache->open_msg = msg; |
337 cache->open_inbuf = inbuf; | 343 cache->open_inbuf = inbuf; |
338 cache->open_size = cache->open_inbuf->stop_offset - | |
339 cache->open_inbuf->offset; | |
340 cache->open_virtual_size = virtual_size; | 344 cache->open_virtual_size = virtual_size; |
341 | 345 |
342 cache->inbuf_rewind = inbuf_rewind; | 346 cache->inbuf_rewind = inbuf_rewind; |
343 cache->context = context; | 347 cache->context = context; |
344 } | 348 } |
367 io_buffer_destroy(cache->open_inbuf); | 371 io_buffer_destroy(cache->open_inbuf); |
368 cache->open_inbuf = NULL; | 372 cache->open_inbuf = NULL; |
369 } | 373 } |
370 | 374 |
371 cache->open_msg = NULL; | 375 cache->open_msg = NULL; |
372 cache->open_size = cache->open_virtual_size = 0; | 376 cache->open_virtual_size = 0; |
373 } | 377 } |
374 | 378 |
375 void imap_msgcache_set(ImapMessageCache *cache, unsigned int uid, | 379 void imap_msgcache_set(ImapMessageCache *cache, unsigned int uid, |
376 ImapCacheField field, const char *value) | 380 ImapCacheField field, const char *value) |
377 { | 381 { |
536 /* see if we can do this easily */ | 540 /* see if we can do this easily */ |
537 size_got = FALSE; | 541 size_got = FALSE; |
538 if (virtual_skip == 0) { | 542 if (virtual_skip == 0) { |
539 if (max_virtual_size < 0 && msg->body_size == NULL) { | 543 if (max_virtual_size < 0 && msg->body_size == NULL) { |
540 msg->body_size = p_new(msg->pool, MessageSize, 1); | 544 msg->body_size = p_new(msg->pool, MessageSize, 1); |
541 msg->body_size->physical_size = cache->open_size - | 545 msg->body_size->physical_size = |
546 cache->open_inbuf->size - | |
542 msg->hdr_size->physical_size; | 547 msg->hdr_size->physical_size; |
543 msg->body_size->virtual_size = | 548 msg->body_size->virtual_size = |
544 cache->open_virtual_size - | 549 cache->open_virtual_size - |
545 msg->hdr_size->virtual_size; | 550 msg->hdr_size->virtual_size; |
546 } | 551 } |