imap-bodystructure.c revision c0435c854a0e7246373b9752d163095cc4fbe985
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "istream.h"
#include "str.h"
#include "message-parser.h"
#include "message-content-parser.h"
#include "message-tokenize.h"
#include "imap-parser.h"
#include "imap-quote.h"
#include "imap-envelope.h"
#include "imap-bodystructure.h"
#define EMPTY_BODYSTRUCTURE \
"(\"text\" \"plain\" (\"charset\" \"us-ascii\") NIL NIL \"7bit\" 0 0)"
struct message_part_body_data {
char *content_type, *content_subtype;
char *content_type_params;
char *content_transfer_encoding;
char *content_id;
char *content_description;
char *content_disposition;
char *content_disposition_params;
char *content_md5;
char *content_language;
struct message_part_envelope_data *envelope;
};
void *context)
{
size_t i;
for (i = 0; i < value_len; i++) {
if (value[i] == '/')
break;
}
if (i == value_len) {
data->content_type =
} else {
data->content_type =
i++;
}
}
void *context)
{
}
static void parse_content_transfer_encoding(const unsigned char *value,
{
}
static void parse_content_disposition(const unsigned char *value,
{
}
struct message_part_body_data *data)
{
struct message_tokenizer *tok;
enum message_token token;
int quoted;
/* Content-Language: en-US, az-arabic (comments allowed) */
t_push();
if (token == ',') {
/* list separator */
if (quoted) {
}
} else {
/* anything else goes as-is. only alphabetic characters
and '-' is allowed, so anything else is error
which we can deal with however we want. */
if (!quoted) {
}
if (!IS_TOKEN_STRING(token))
else {
&value_len);
}
}
}
if (quoted)
t_pop();
}
void *context)
{
struct message_part_body_data *part_data;
int parent_rfc822;
return;
/* initialize message part data */
}
t_push();
switch (name_len) {
case 10:
}
break;
case 11:
}
break;
case 12:
break;
break;
case 16:
break;
case 19:
}
}
break;
case 25:
break;
break;
}
if (parent_rfc822) {
}
t_pop();
}
{
/* note that we want to parse the header of all
the message parts, multiparts too. */
start_offset, pool);
}
}
}
{
/* there was no content headers, use an empty structure */
}
else {
/* no parts in multipart message,
that's not allowed. write a single
}
else
if (!extended)
return;
/* BODYSTRUCTURE data */
else {
}
else {
else {
}
}
else {
}
}
{
/* there was no content headers, use an empty structure */
}
/* "content type" "subtype" */
/* ("content type param key" "value" ...) */
else {
}
/* text/.. contains line count */
struct message_part_body_data *child_data;
str);
} else {
/* buggy message */
}
}
if (!extended)
return;
/* BODYSTRUCTURE data */
/* "md5" ("content disposition" ("disposition" "params"))
("body" "language" "params") */
else {
else {
}
}
else {
}
}
{
else
}
}
int extended)
{
}
{
else {
}
}
{
/* don't do any typechecking, just write it out */
case IMAP_ARG_NIL:
break;
case IMAP_ARG_ATOM:
break;
case IMAP_ARG_STRING:
break;
case IMAP_ARG_LIST:
return FALSE;
break;
default:
return FALSE;
}
args++;
}
return TRUE;
}
{
struct imap_arg_list *list;
return FALSE;
args++;
}
if (multipart) {
/* next is subtype of Content-Type. rest is skipped. */
return FALSE;
return TRUE;
}
/* "content type" "subtype" */
return FALSE;
args += 2;
/* ("content type param key" "value" ...) | NIL */
return FALSE;
IMAP_ARG_STR(&subargs[0]),
subargs += 2;
break;
}
} else {
return FALSE;
}
args++;
/* "content id" "content description" "transfer encoding" size */
for (i = 0; i < 4; i++, args++) {
} else {
return FALSE;
}
}
if (text) {
return FALSE;
} else if (message_rfc822) {
return FALSE;
return FALSE;
return FALSE;
}
return TRUE;
}
const char *imap_body_parse_from_bodystructure(const char *bodystructure)
{
struct imap_parser *parser;
const char *value;
int ret;
(void)i_stream_read(input);
&args);
else
return value;
}