mail-cache-fields.c revision e015e2f7e7f48874495f9df8b0dd192b7ffcb5cc
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Copyright (C) 2004 Timo Sirainen */
beb6125ee872e7fed57745ab33e6de99639180f3Timo Sirainenstatic const unsigned char *null4[] = { 0, 0, 0, 0 };
beb6125ee872e7fed57745ab33e6de99639180f3Timo Sirainenvoid mail_cache_register_fields(struct mail_cache *cache,
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen unsigned int new_idx;
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen for (i = 0; i < fields_count; i++) {
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen if (hash_lookup_full(cache->field_name_hash, fields[i].name,
ae8817f05005f57bba32479a610b52d083e2b6ebTimo Sirainen /* @UNSAFE */
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainen cache->fields = p_realloc(cache->field_pool, cache->fields,
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainen p_realloc(cache->field_pool, cache->field_file_map,
c251a38df327599a62d341bf5c2282f31352faa5Timo Sirainen cache->fields_count * sizeof(*cache->field_file_map),
aa38d1a0945f0bc13a225d043f53fad2eec666b1Timo Sirainen for (i = 0; i < fields_count; i++) {
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainen /* new index - save it */
46c31f64b9f0949f00b7819f45b22f2d64b2ea27Timo Sirainen cache->fields[idx].field_size = (unsigned int)-1;
a022088674a5ae72ed29ae001834cbad62a4f19fTimo Sirainenmail_cache_register_lookup(struct mail_cache *cache, const char *name)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (hash_lookup_full(cache->field_name_hash, name,
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen return POINTER_CAST_TO(orig_value, unsigned int);
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen return (unsigned int)-1;
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainenstatic int mail_cache_header_fields_get_offset(struct mail_cache *cache,
09c3a491f4f6ccebe290c7709bdc0d79a187610bTimo Sirainen const struct mail_cache_header_fields *field_hdr;
offset = 0;
while (next_offset != 0) {
if (offset == 0) {
if (p == end) {
if (!locked) {
if (!locked)
unsigned int field;
const char *name;
if (*offset_r == 0) {