imap-bodystructure.c revision 76b43e4417bab52e913da39b5f5bc2a130d3f149
/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "buffer.h"
#include "istream.h"
#include "str.h"
#include "message-parser.h"
#include "rfc822-parser.h"
#include "imap-parser.h"
#include "imap-quote.h"
#include "imap-envelope.h"
#include "imap-bodystructure.h"
#define DEFAULT_CHARSET \
"\"charset\" \"us-ascii\""
#define EMPTY_BODYSTRUCTURE \
struct message_part_body_data {
const char *content_type, *content_subtype;
const char *content_type_params;
const char *content_transfer_encoding;
const char *content_id;
const char *content_description;
const char *content_disposition;
const char *content_disposition_params;
const char *content_md5;
const char *content_language;
struct message_part_envelope_data *envelope;
};
struct message_header_line *hdr)
{
struct rfc822_parser_context parser;
unsigned int i;
bool charset_found = FALSE;
(void)rfc822_skip_lwsp(&parser);
return;
/* Save content type and subtype */
for (i = 0; value[i] != '\0'; i++) {
if (value[i] == '/') {
break;
}
}
data->content_type =
/* parse parameters and save them */
str_truncate(str, 0);
}
if (!charset_found &&
/* set a default charset */
}
}
}
struct message_header_line *hdr)
{
struct rfc822_parser_context parser;
(void)rfc822_skip_lwsp(&parser);
}
}
struct message_header_line *hdr)
{
struct rfc822_parser_context parser;
(void)rfc822_skip_lwsp(&parser);
return;
/* parse parameters and save them */
str_truncate(str, 0);
}
}
}
struct message_part_body_data *data)
{
struct rfc822_parser_context parser;
/* Language-Header = "Content-Language" ":" 1#Language-tag
Language-Tag = Primary-tag *( "-" Subtag )
Primary-tag = 1*8ALPHA
Subtag = 1*8ALPHA */
(void)rfc822_skip_lwsp(&parser);
break;
(void)rfc822_skip_lwsp(&parser);
}
}
}
static void parse_content_header(struct message_part_body_data *d,
struct message_header_line *hdr,
{
const unsigned char *value;
return;
}
switch (*name) {
case 'i':
case 'I':
break;
case 'm':
case 'M':
break;
case 't':
case 'T':
parse_content_type(d, hdr);
d->content_transfer_encoding == NULL)
break;
case 'l':
case 'L':
d->content_language == NULL)
break;
case 'd':
case 'D':
d->content_description == NULL) {
d->content_description =
}
d->content_disposition_params == NULL) {
}
break;
}
}
struct message_header_line *hdr)
{
struct message_part_body_data *part_data;
struct message_part_envelope_data *envelope;
bool parent_rfc822;
/* no Content-* headers. add an empty context
structure anyway. */
/* If there was no Mime-Version, forget all
the Content-stuff */
}
return;
}
return;
return;
/* initialize message part data */
}
);
}
if (parent_rfc822) {
}
}
{
else {
/* no parts in multipart message,
that's not allowed. write a single
}
else
if (!extended)
return;
/* BODYSTRUCTURE data */
else {
}
else {
else {
}
}
else {
}
}
{
bool text;
} else {
/* "content type" "subtype" */
else {
if (text)
else
}
}
/* ("content type param key" "value" ...) */
if (!text)
else
} else {
}
if (text) {
/* text/.. contains line count */
struct message_part_body_data *child_data;
struct message_part_envelope_data *env_data;
}
if (!extended)
return;
/* BODYSTRUCTURE data */
/* "md5" ("content disposition" ("disposition" "params"))
("body" "language" "params") */
else {
else {
}
}
else {
}
}
{
multipart stuff */
return FALSE;
return FALSE; /* shouldn't happen normally.. */
return FALSE;
/* only allowed parameter is charset=us-ascii, which is also default */
return FALSE;
return FALSE;
return FALSE;
/* BODYSTRUCTURE checks: */
return FALSE;
return TRUE;
}
{
else
}
}
{
case IMAP_ARG_NIL:
break;
case IMAP_ARG_ATOM:
break;
case IMAP_ARG_STRING:
break;
case IMAP_ARG_LITERAL: {
break;
}
default:
return FALSE;
}
return TRUE;
}
{
/* don't do any typechecking, just write it out */
return FALSE;
return FALSE;
}
args++;
}
return TRUE;
}
{
int i;
return FALSE;
args++;
}
if (multipart) {
/* next is subtype of Content-Type. rest is skipped. */
}
/* "content type" "subtype" */
return FALSE;
return FALSE;
return FALSE;
args += 2;
/* ("content type param key" "value" ...) | NIL */
return FALSE;
return FALSE;
subargs += 2;
break;
}
} else {
return FALSE;
}
args++;
/* "content id" "content description" "transfer encoding" size */
for (i = 0; i < 4; i++, args++) {
return FALSE;
}
if (text) {
return FALSE;
} else if (message_rfc822) {
return FALSE;
return FALSE;
return FALSE;
}
return TRUE;
}
bool imap_body_parse_from_bodystructure(const char *bodystructure,
{
struct imap_parser *parser;
int ret;
(void)i_stream_read(input);
if (!ret)
return ret;
}