imap-quote.c revision 33ca6b017b6ebbd048651b5e3d16915001dbc291
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "str.h"
#include "imap-quote.h"
#define IS_BREAK_CHAR(c) \
((c) == ' ' || (c) == '\t' || \
(c) == ',' || (c) == ':' || (c) == ';' || (c) == '@' || \
(c) == '<' || (c) == '>' || (c) == '(' || (c) == ')' || \
(c) == '[' || (c) == ']' || (c) == '=')
#define IS_BREAK_OR_CRLF_CHAR(c) \
{
size_t i;
if ((unsigned char)value[i] & 0x80)
i++;
break;
}
}
return i;
}
{
size_t i = 0;
if (qp_on) {
/* skip spaces, so we don't end up QP'ing word at a time */
for (i = 0; i < len; i++) {
if (value[i] != ' ')
break;
}
if (i == len)
return i;
}
if (IS_BREAK_OR_CRLF_CHAR(value[i])) {
/* return all break-chars in one token */
for (i++; i < len; i++) {
if (!IS_BREAK_CHAR(value[i]))
break;
}
return i;
}
/* then stop at break-char */
for (; i < len; i++) {
if ((unsigned char)value[i] & 0x80)
if (IS_BREAK_OR_CRLF_CHAR(value[i]))
break;
}
return i;
}
{
size_t i;
unsigned char c;
/* do this the easy way, it's already broken behaviour to leave the
8bit text in mailbox, so we shouldn't need to try too hard to make
it readable. Keep 'A'..'Z', 'a'..'z' and '0'..'9', QP rest */
for (i = 0; i < len; i++) {
if (value[i] == ' ')
} else {
c = (unsigned char)value[i] >> 4;
c = (unsigned char)value[i] & 0x0f;
}
}
}
{
size_t i;
for (i = 0; i < len; i++) {
}
}
/* does two things: 1) escape '\' and '"' characters, 2) 8bit text -> QP */
{
while (value_len > 0) {
/* header may be split to multiple lines, we don't want them */
value[0] == '\n')) {
value++;
token_len--;
value_len--;
}
}
if (need_qp)
else
}
return str;
}
const char *imap_quote_str_nil(const char *value)
{
}
{
}