/* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "buffer.h"
#include "str.h"
#include "istream.h"
#include "mail-html2text.h"
#include "message-parser.h"
#include "message-decoder.h"
#include "message-snippet.h"
enum snippet_state {
/* beginning of the line */
/* within normal text */
/* within quoted text - skip until EOL */
};
struct snippet_context {
unsigned int chars_left;
bool add_whitespace;
};
{
ctx->plain_output);
}
/* message-decoder should feed us only valid and complete
UTF-8 input */
count = 1;
case SNIPPET_STATE_NEWLINE:
break;
}
/* fallthrough */
case SNIPPET_STATE_NORMAL:
if (size-i >= 3 &&
break;
}
/* skip any leading whitespace */
if (data[i] == '\n')
break;
}
if (ctx->add_whitespace) {
if (ctx->chars_left-- == 0)
return FALSE;
}
if (ctx->chars_left == 0)
return FALSE;
ctx->chars_left--;
break;
case SNIPPET_STATE_QUOTED:
if (data[i] == '\n')
break;
}
}
return TRUE;
}
unsigned int max_snippet_chars,
{
int ret;
continue;
const char *ct;
continue;
/* end of headers - verify that we can use this
Content-Type. we get here only once, because we
always handle only one non-multipart MIME part. */
else if (mail_html2text_content_type_match(ct)) {
break;
continue;
}
break;
}
pool_unref(&pool);
}