index-fetch-section.c revision 1d5740f09a1f09f528acb7bc42048e2a0d2852ef
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce/* Copyright (C) 2002 Timo Sirainen */
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo SorceImapCacheField index_fetch_body_get_cache(const char *section)
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce return IMAP_CACHE_MESSAGE_PART | IMAP_CACHE_MESSAGE_OPEN;
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce if (*section == '\0' || strcasecmp(section, "TEXT") == 0) {
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce /* no IMAP_CACHE_MESSAGE_BODY_SIZE, so that we don't
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce uselessly check it when we want to read partial data */
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce return IMAP_CACHE_MESSAGE_HDR_SIZE | IMAP_CACHE_MESSAGE_OPEN;
75d66aea7accc842e68c88f085f9053112b20eccPavel Březina/* fetch BODY[] or BODY[TEXT] */
c1058e96679c7ed1372825bf5226ce7d28a8e6ffPavel Březinastatic int fetch_body(MailIndexRecord *rec, MailFetchBodyData *sect,
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce const char *str;
22a21e910fd216ec1468fe769dcc29f1621a52a4Ondrej Kos if (!imap_msgcache_get_rfc822_partial(ctx->cache, rec->uid,
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce i_error("Couldn't get BODY[] for UID %u (index %s)",
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce str = t_strdup_printf("{%lu}\r\n", (unsigned long) size.virtual_size);
233a3c6c48972b177e60d6ef4cecfacd3cf31659Simo Sorce (void)io_buffer_send(ctx->outbuf, str, strlen(str));
7c69221077c780e62f6c536e78675f2dc1c131bcMichal Zidek (void)message_send(ctx->outbuf, inbuf, &size, 0, sect->max_size);
f9961e5f82e0ef474d6492371bfdf9e74e208a99Pavel Březinastatic char *const *get_fields_array(const char *fields)
2a96981a0ac781d01e5bba473409ed2bdf4cd4e0Jakub Hrozek field_list = (char **) t_strsplit(fields, " )");
4dd38025efda88f123eac672f87d3cda12f050c8Jakub Hrozek /* array ends at ")" element */
4dd38025efda88f123eac672f87d3cda12f050c8Jakub Hrozek for (field = field_list; *field != NULL; field++) {
f3a25949de81f80c136bb073e4a8f504b080c20cJakub Hrozekstatic int header_match(char *const *fields, const char *name,
78a08d30b5fbf6e1e3b589e0cf67022e0c1faa33Michal Židek unsigned int size)
b5825c74b6bf7a99ae2172392dbecb51179013a6Jakub Hrozek for (name = name_start; name != name_end; name++) {
19e44537c28f6d5f011cd7ac885c74c1e892605fSimo Sorce /* field has been uppercased long time ago while
5f7cd30c865046a7ea69944f7e07c85b4c43465aSumit Bose parsing FETCH command */
b9c563c29243291f40489bb0dcbf3946fca72d58Jakub Hrozekstatic int header_match_not(char *const *fields, const char *name,
b9c563c29243291f40489bb0dcbf3946fca72d58Jakub Hrozek unsigned int size)
300b9e9217ee1ed8d845ed2370c5ccf5c87afb36Pavel Březinastatic int header_match_mime(char *const *fields __attr_unused__,
c0f9f5a0f6d71a1596ee3cef549b4b02295313c3Jakub Hrozek if (size > 8 && strncasecmp(name, "Content-", 8) == 0)
ccd349f0274217e1f0cc118e3a6045e2235ce420Fabiano Fidêncio if (size == 12 && strncasecmp(name, "Mime-Version", 13) == 0)
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorcetypedef struct {
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce char *const *fields;
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce int (*match_func) (char *const *, const char *, unsigned int);
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorcestatic void fetch_header_field(MessagePart *part __attr_unused__,
void *context)
unsigned int len;
int (*match_func) (char *const *, const char *,
const char *str;
char *dest;
unsigned int len;
t_push();
len = 0;
len = 0;
t_pop();
return FALSE;
return TRUE;
const char *path;
int num;
num = 0;
return NULL;
path++;
path++;
return NULL;
return part;
const char *str;
return FALSE;
return TRUE;
return FALSE;
return TRUE;
const char *section;
return FALSE;
return FALSE;
const char *str;
int fetch_ok;
if (!fetch_ok) {