imap-bodystructure.c revision 12f73f226ce94805b765b2458ead3d0669028543
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "istream.h"
#include "str.h"
#include "rfc822-tokenize.h"
#include "message-parser.h"
#include "message-content-parser.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)"
typedef struct {
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;
int extended);
{
const char *value;
int i;
/* find the content type separator */
for (i = 0; i < count; i++) {
break;
}
}
void *context)
{
const char *str;
}
{
const char *value;
}
{
const char *value;
}
{
int quoted;
/* Content-Language: en-US, az-arabic (comments allowed) */
if (count <= 0)
return;
case '(':
/* ignore comment */
break;
case ',':
/* list separator */
if (quoted) {
}
break;
default:
/* 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) {
}
else
break;
}
}
if (quoted)
}
void *context)
{
int parent_rfc822;
return;
/* initialize message part data */
}
t_push();
/* fix the name to be \0-terminated */
} else if (parent_rfc822) {
}
t_pop();
}
{
/* note that we want to parse the header of all
the message parts, multiparts too. */
start_offset, pool);
}
}
}
int extended)
{
/* 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 */
str);
} else {
/* buggy message */
}
}
if (!extended)
return;
/* BODYSTRUCTURE data */
/* "md5" ("content disposition" ("disposition" "params"))
("body" "language" "params") */
else {
else {
}
}
else {
}
}
int extended)
{
else
}
}
{
}
{
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;
}
{
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;
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;
str))
return FALSE;
}
return TRUE;
}
const char *imap_body_parse_from_bodystructure(const char *bodystructure)
{
const char *value;
int ret;
(void)i_stream_read(input);
&args);
else
return value;
}