mail-index.c revision bc1d1497d715cc5c820ff518f070f78c39ef6cdc
52N/A/* Copyright (C) 2003-2004 Timo Sirainen */ 6N/A /* see if it's already there */ 44N/A /* keywords_hash keeps a name => index mapping of keywords. 44N/A Keywords are never removed from it, so the index values are valid 6N/A for the lifetime of the mail_index. */ 15N/A /* Extension header contains: 15N/A - struct mail_index_keyword_header 15N/A - struct mail_index_keyword_header_rec * keywords_count 15N/A - const char names[] * keywords_count 6N/A /* Keywords can only be added into same mapping. Removing requires a 6N/A new mapping (recreating the index file) */ 6N/A /* nothing changed */ 6N/A /* make sure the header is valid */ 6N/A "Keywords removed unexpectedly",
6N/A "keywords_count larger than header size",
6N/A "name_offset points outside allocated header",
63N/A "Keyword header doesn't end with NUL",
63N/A /* create file -> index mapping */ 164N/A /* Check that existing headers are still the same. It's behind DEBUG 164N/A since it's pretty useless waste of CPU normally. */ 164N/A "Keywords changed unexpectedly",
63N/A /* Register the newly seen keywords */ 6N/A /* Make sure all the keywords are in index->keywords. It's quick to do 32N/A if nothing has changed. */ 32N/A /* Note that our caller must close index->fd by itself. */ 32N/A /* have to create it */ 6N/A /* it's corrupted - recreate it */ /* doesn't exist / corrupted */ /* open/create failed, fallback to in-memory indexes */ /* corrupted, reopen files */ /* doesn't exist and create flag not used */ /* completely broken, reopen */ /* new file, new locks. the old fd can keep its locks, they don't matter anymore as no-one's going to modify the file. */ /* we have index exclusively locked, nothing could return ret <= 0 ? -
1 : 0;
/* set the index as being into memory */ /* index was never even opened. just mark it as being in memory and let the caller re-open the index. */ /* move index map to memory */ /* move transaction log to memory */ /* close the index file. */ /* FIXME: Unfortunately these functions were originally written to use endian-specific code and we can't avoid that without breaking backwards compatibility. When we do break it, just select one of these. */ return 0x00000080 | ((
offset &
0x0000007f)) |
0x00008000 | ((
offset &
0x00003f80) >>
7 <<
8) |
0x00800000 | ((
offset &
0x001fc000) >>
14 <<
16) |
0x80000000 | ((
offset &
0x0fe00000) >>
21 <<
24);
if ((
offset &
0x80808080) !=
0x80808080)
return (((
offset &
0x0000007f)) |
((
offset &
0x00007f00) >>
8 <<
7) |
((
offset &
0x007f0000) >>
16 <<
14) |
((
offset &
0x7f000000) >>
24 <<
21)) <<
2;
return 0x80000000 | ((
offset &
0x0000007f) <<
24) |
0x00800000 | ((
offset &
0x00003f80) >>
7 <<
16) |
0x00008000 | ((
offset &
0x001fc000) >>
14 <<
8) |
0x00000080 | ((
offset &
0x0fe00000) >>
21);
if ((
offset &
0x80808080) !=
0x80808080)
return (((
offset &
0x0000007f) <<
21) |
((
offset &
0x00007f00) >>
8 <<
14) |
((
offset &
0x007f0000) >>
16 <<
7) |
((
offset &
0x7f000000) >>
24)) <<
2;