mail-cache-lookup.c revision 58816241cbaf79e3f8dd7d831b7c6f02c6c38ee6
2ronwalf/* Copyright (c) 2003-2011 Dovecot authors, see the included COPYING file */ 2ronwalf /* records are always 32-bit aligned */ 2ronwalf /* we don't know yet how large the record is, so just guess */ 2ronwalf /* larger than we guessed. map the rest of the record. */ 2ronwalf /* reset_id must match file_seq or the offset is for a different cache 2ronwalf file. if this happens, try if reopening the cache helps. if not, 2ronwalf it was probably for an old cache file that's already lost by now. */ 2ronwalf /* we're probably compressing */ 2ronwalf /* error / we already have the latest file open */ 2ronwalf /* looping happens only in rare error conditions, so it's enough if we 2ronwalf just catch it eventually. we do this by checking if we've seen 2ronwalf more record data than possible in the accessed file area. */ 2ronwalf /* end of this record list. check newly appended data. */ "record has invalid size");
/* return the next field */ /* new field, have to re-read fields header to figure out its size. don't do this if we're compressing. */ "field index too large (%u >= %u)",
/* field reading might have re-mmaped the file and caused rec pointer to break. need to get it again. */ /* variable size field. get its size from the file. */ "record continues outside its allocated size");
/* each record begins from 32bit aligned position */ /* wrapped, we'll have to clear the buffer */ /* FIXME: we should discard the cache if view has been synced */ const unsigned char *
src;
/* make sure all bits are cleared first */ /* the field should exist */ /* return the first one that's found. if there are multiple they're all identical. */ /* data = { line_nums[], 0, "headers" } */ /* update the decision state regardless of whether the fields actually exist or not. */ /* mark all the fields we want to find. */ /* a) don't want it, b) duplicate */ /* check that all fields were found */ /* we need to return headers in the order they existed originally. we can do this by sorting the messages by their line numbers. */ /* then start filling dest buffer from the headers */ for (i = 0; i <
count; i++) {
/* find the end of the (multiline) header */ (p+
1 ==
end || (p[
1] !=
' ' && p[
1] !=
'\t'))) {
/* if there are more lines for this header, the following lines continue after this one. so skip this line. */