imap-fetch-body.c revision 6816955a9254b43bff782175ee6762fdc5448b86
/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */
#include "imap-common.h"
#include "buffer.h"
#include "str.h"
#include "strescape.h"
#include "istream.h"
#include "ostream.h"
#include "istream-header-filter.h"
#include "message-parser.h"
#include "message-send.h"
#include "mail-storage-private.h"
#include "imap-quote.h"
#include "imap-parser.h"
#include "imap-msgpart.h"
#include "imap-fetch.h"
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
struct imap_fetch_body_data {
const char *section; /* NOTE: always uppercased */
struct imap_msgpart *msgpart;
unsigned int partial:1;
unsigned int peek:1;
};
{
"read(%s) failed: %m (FETCH for mailbox %s UID %u)",
}
{
}
}
const struct imap_fetch_body_data *body,
{
else
else
return str;
}
{
if (ret > 0)
/* unfinished */
return -1;
}
/* Input stream gave less data than expected */
i_error("FETCH %s for mailbox %s UID %u "
"got too little data: "
return -1;
}
if (ret < 0) {
/* client probably disconnected */
return -1;
}
return 0;
}
return 1;
}
const struct imap_fetch_body_data *body)
{
struct imap_msgpart_open_result result;
return -1;
return -1;
}
/* Parse next digits in string into integer. Returns -1 if the integer
becomes too big and wraps. */
{
*value = 0;
while (**p >= '0' && **p <= '9') {
return -1;
(*p)++;
}
return 0;
}
static int
{
const char *value;
size_t i;
for (i = 0; i < args_count; i++) {
"Header list contains non-strings";
return -1;
}
if (i != 0)
else {
}
}
return 0;
}
const char *p, const char **error_r)
{
if (*p == '\0')
return 0;
/* <start.end> */
if (*p != '<') {
*error_r = "Unexpected data after ']'";
return -1;
}
p++;
/* wrapped */
*error_r = "Too big partial start";
return -1;
}
if (*p == '.') {
p++;
/* wrapped */
*error_r = "Too big partial end";
return -1;
}
}
if (*p != '>') {
*error_r = "Missing '>' in partial";
return -1;
}
if (p[1] != '\0') {
*error_r = "Unexpected data after '>'";
return -1;
}
return 0;
}
{
struct imap_fetch_body_data *body;
unsigned int list_count;
p += 5;
} else {
}
if (*p != '[') {
return FALSE;
}
/* BODY[HEADER.FIELDS.. (headers list)] */
str[0] != ']') {
return FALSE;
}
list_args, list_count) < 0)
return FALSE;
p = str+1;
} else {
/* no headers list */
if (p == NULL) {
return FALSE;
}
p++;
}
return -1;
}
"Invalid BODY[..] parameter: %s", error);
return FALSE;
}
/* update the section name for the imap_fetch_add_handler() */
return TRUE;
}
void *context ATTR_UNUSED)
{
return -1;
return 1;
}
static int
{
struct imap_msgpart_open_result result;
int ret;
if (ret < 0)
return -1;
return 0;
}
void *context ATTR_UNUSED)
{
struct imap_msgpart *msgpart;
const char *str;
msgpart = imap_msgpart_full();
}
return -1;
}
{
struct imap_msgpart *msgpart;
const char *str;
}
return -1;
}
void *context ATTR_UNUSED)
{
struct imap_msgpart *msgpart;
const char *str;
msgpart = imap_msgpart_body();
}
return -1;
}
{
return TRUE;
}
return TRUE;
}
return TRUE;
}
return TRUE;
}
return FALSE;
}