message-body-search.c revision 2b217e691440aaa45649ab310b28e5f95be28cae
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "base64.h"
#include "buffer.h"
#include "istream.h"
#include "charset-utf8.h"
#include "rfc822-tokenize.h"
#include "quoted-printable.h"
#include "message-parser.h"
#include "message-content-parser.h"
#include "message-header-search.h"
#include "message-body-search.h"
#define DECODE_BLOCK_SIZE 8192
typedef struct {
const char *key;
const char *charset;
unsigned int unknown_charset:1;
unsigned int search_header:1;
typedef struct {
char *content_type;
char *content_charset;
unsigned int content_qp:1;
unsigned int content_base64:1;
unsigned int content_unknown:1;
unsigned int ignore_header:1;
unsigned int found:1;
void *context)
{
ctx->content_type =
}
}
const Rfc822Token *value,
int value_count, void *context)
{
return;
}
}
{
return;
case 4:
break;
case 6:
break;
case 16:
else
break;
default:
break;
}
}
{
return;
if (!ctx->ignore_header) {
}
t_push();
ctx);
} else if (name_len == 25 &&
}
t_pop();
}
{
NULL);
/* we default to text content-type */
}
{
ssize_t i;
end = p + block_size;
for (; p != end; p++) {
/* full match */
p++;
return TRUE;
}
} else {
/* non-match */
ctx->match_count--;
if (i != ctx->match_count) {
ctx->match_count - i);
}
}
}
if (*p == key[0]) {
if (key_len == 1) {
/* only one character in search key */
p++;
return TRUE;
}
}
}
return FALSE;
}
/* returns 1 = found, 0 = not found, -1 = error in input data */
{
const unsigned char *inbuf;
/* we can use the buffer directly without copying */
} else {
/* some characters already in buffer, ie. last
conversion contained partial data */
(size_t)-1);
}
inbuf_left -= inbuf_size;
switch (result) {
case CHARSET_RET_OUTPUT_FULL:
/* we should have copied the incomplete sequence.. */
/* fall through */
case CHARSET_RET_OK:
block_pos -= inbuf_left;
break;
/* save the partial sequence to buffer */
break;
return -1;
}
return 1;
}
return 0;
}
{
const unsigned char *data;
int found;
if (ctx->content_unknown) {
/* unknown content-encoding-type, ignore */
return FALSE;
}
if (!ctx->content_type_text) {
/* non-text content, ignore - FIXME: should be configurable? */
return FALSE;
}
ctx->match_count = 0;
/* limit the size of t_malloc()s */
if (data_size > DECODE_BLOCK_SIZE)
t_push();
if (ctx->content_qp) {
} else if (ctx->content_base64) {
size);
/* corrupted base64 data, don't bother with
the rest of it */
t_pop();
break;
}
} else {
}
t_pop();
if (ret != 0) {
break;
}
}
return found;
}
const char *charset, int *unknown_charset,
int search_header)
{
/* get the key uppercased */
return FALSE;
return TRUE;
}
{
int found;
t_push();
} else {
}
t_pop();
}
return found;
}
{
return -1;
}