index-mail.h revision 147a788fea2a88f7125b27226451271d55cf5b01
#ifndef INDEX_MAIL_H
#define INDEX_MAIL_H
#include "message-size.h"
#include "mail-cache.h"
#include "mail-storage-private.h"
enum index_cache_field {
/* fixed size fields */
MAIL_CACHE_FLAGS = 0,
/* variable sized field */
};
extern struct mail_cache_field
#define IMAP_BODY_PLAIN_7BIT_ASCII \
"\"text\" \"plain\" (\"charset\" \"us-ascii\") NIL NIL \"7bit\""
enum mail_cache_record_flag {
/* If binary flags are set, it's not checked whether mail is
missing CRs. So this flag may be set as an optimization for
regular non-binary mails as well if it's known that it contains
valid CR+LF line breaks. */
MAIL_CACHE_FLAG_BINARY_HEADER = 0x0001,
MAIL_CACHE_FLAG_BINARY_BODY = 0x0002,
/* Mail header or body is known to contain NUL characters. */
MAIL_CACHE_FLAG_HAS_NULS = 0x0004,
/* Mail header or body is known to not contain NUL characters. */
MAIL_CACHE_FLAG_HAS_NO_NULS = 0x0008,
/* BODY is IMAP_BODY_PLAIN_7BIT_ASCII and rest of BODYSTRUCTURE
fields are NIL */
};
enum index_mail_access_part {
READ_HDR = 0x01,
READ_BODY = 0x02,
PARSE_HDR = 0x04,
PARSE_BODY = 0x08
};
struct mail_sent_date {
};
struct index_mail_line {
unsigned int field_idx;
};
struct message_header_line;
struct index_mail_data {
struct mail_sent_date sent_date;
struct index_mail_line parse_line;
struct message_part *parts;
struct message_binary_part *bin_parts;
const char *from_envelope;
struct message_part_envelope_data *envelope_data;
/* dont_cache_fields overrides cache_fields */
unsigned int dont_cache_field_idx;
struct mailbox_header_lookup_ctx *wanted_headers;
struct tee_istream *tee_stream;
struct istream *parser_input;
struct message_parser_ctx *parser_ctx;
int parsing_count;
unsigned int initialized:1;
unsigned int save_sent_date:1;
unsigned int sent_date_parsed:1;
unsigned int save_envelope:1;
unsigned int save_bodystructure_header:1;
unsigned int save_bodystructure_body:1;
unsigned int save_message_parts:1;
unsigned int stream_has_only_header:1;
unsigned int parsed_bodystructure:1;
unsigned int hdr_size_set:1;
unsigned int body_size_set:1;
unsigned int messageparts_saved_to_cache:1;
unsigned int header_parsed:1;
unsigned int no_caching:1;
unsigned int forced_no_caching:1;
unsigned int destroying_stream:1;
unsigned int initialized_wrapper_stream:1;
unsigned int destroy_callback_set:1;
unsigned int prefetch_sent:1;
};
struct index_mail {
struct mail_private mail;
struct index_mail_data data;
struct index_mailbox_context *ibox;
int pop3_state;
/* per-mail variables, here for performance reasons: */
#define HEADER_MATCH_FLAG_FOUND 1
#define HEADER_MATCH_SKIP_COUNT 2
ARRAY(unsigned int) header_match_lines;
unsigned int pop3_state_set:1;
/* mail created by mailbox_search_*() */
unsigned int search_mail:1;
/* close() is being called from mail_free() */
unsigned int freeing:1;
};
struct mail *
index_mail_alloc(struct mailbox_transaction_context *t,
struct mailbox_header_lookup_ctx *wanted_headers);
struct mailbox_transaction_context *_t,
struct mailbox_header_lookup_ctx *_wanted_headers);
enum mail_fetch_field fields,
struct mailbox_header_lookup_ctx *headers);
struct mailbox_header_lookup_ctx *headers)
ATTR_NULL(2);
struct message_header_line *hdr,
struct mailbox_header_lookup_ctx *headers)
ATTR_NULL(2);
bool decode_to_utf8, const char **value_r);
bool decode_to_utf8, const char *const **value_r);
struct mailbox_header_lookup_ctx *headers,
const ARRAY_TYPE(keyword_indexes) *
struct message_size *hdr_size,
struct message_size *body_size,
const struct message_part *part,
unsigned int *body_lines_r, bool *binary_r,
const char **value_r);
enum mail_flags flags);
struct mail_keywords *keywords);
enum mail_fetch_field field);
bool success);
unsigned int field_idx);
#endif