message-header-search.c revision d8e43743157d05e416eb5d3b45cddb3b3122dc07
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "base64.h"
#include "hex-binary.h"
#include "charset-utf8.h"
#include "rfc822-tokenize.h"
#include "message-header-search.h"
#include <ctype.h>
struct _HeaderSearchContext {
const unsigned char *key;
unsigned int last_newline:1;
unsigned int submatch:1;
unsigned int eoh:1;
unsigned int unknown_charset:1;
};
int *unknown_charset)
{
/* get the key uppercased */
return NULL;
return ctx;
}
unsigned char *dest)
{
const unsigned char *end;
unsigned char *dest_start;
char hexbuf[3];
dest_start = dest;
if (*src == '_') {
*dest++ = ' ';
continue;
}
dest++;
src += 2;
continue;
}
}
}
}
{
int ret;
if (ctx->unknown_charset) {
/* we don't know the source charset, so assume we want to
match using same charsets */
}
/* unknown character set, or invalid data */
return FALSE;
}
return ret;
}
{
const char *charset;
unsigned char *buf;
/* first split the string =?charset?encoding?text?= */
if (*p == '?') {
encoding = p+1;
if (p != encoding+1)
encoding = "?";
encoding = "Q";
encoding = "B";
else
encoding = "?";
text = p+1;
} else {
new_end = p;
p++;
if (p != end && *p == '=')
p++;
*start = p-1;
break;
}
}
}
t_push();
if (*encoding == 'Q')
else
if (size >= 0) {
/* non-corrupted encoding */
t_pop();
return ret;
}
t_pop();
}
/* non-supported encoding, we can't match it */
ctx->match_count = 0;
return FALSE;
}
int message_header_search(const unsigned char *header_block,
{
const unsigned char *p, *end;
unsigned char chr;
ssize_t i;
int found;
return FALSE;
for (p = header_block; p != end; p++) {
/* encoded string. read it. */
p += 2;
break;
}
continue;
}
/* newline */
if (!IS_LWSP(*p)) {
/* not a long header, reset matches */
ctx->match_count = 0;
/* and see if we're at end of header */
if (*p == '\n') {
p++;
break;
}
if (*p == '\r' && p[1] == '\n') {
p += 2;
break;
}
}
chr = ' ';
}
if (*p == '\r' || *p == '\n')
continue;
/* full match */
p++;
break;
}
} else {
/* non-match */
ctx->match_count--;
if (i != ctx->match_count) {
ctx->match_count - i);
}
}
}
if (found)
break;
/* only one character in search key */
p++;
break;
}
}
}
return found;
}
{
ctx->match_count = 0;
}