summaryrefslogtreecommitdiff
path: root/mailnews/mime/src/mimeunty.h
blob: 9661f68bc9290ab3e6b63fd061e2b73fa2f8cd56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef _MIMEUNTY_H_
#define _MIMEUNTY_H_

#include "mimecont.h"

/* The MimeUntypedText class is used for untyped message contents, that is,
   it is the class used for the body of a message/rfc822 object which had
   *no* Content-Type header, as opposed to an unrecognized content-type.
   Such a message, technically, does not contain MIME data (it follows only
   RFC 822, not RFC 1521.)

   This is a container class, and the reason for that is that it loosely
   parses the body of the message looking for ``sub-parts'' and then
   creates appropriate containers for them.

   More specifically, it looks for uuencoded data.  It may do more than that
   some day.

   Basically, the algorithm followed is:

     if line is "begin 644 foo.gif"
       if there is an open sub-part, close it
     add a sub-part with type: image/gif; encoding: x-uue
     hand this line to it
     and hand subsequent lines to that subpart
   else if there is an open uuencoded sub-part, and line is "end"
     hand this line to it
     close off the uuencoded sub-part
     else if there is an open sub-part
     hand this line to it
     else
       open a text/plain subpart
     hand this line to it

   Adding other types than uuencode to this (for example, PGP) would be
   pretty straightforward.
 */

typedef struct MimeUntypedTextClass MimeUntypedTextClass;
typedef struct MimeUntypedText      MimeUntypedText;

struct MimeUntypedTextClass {
  MimeContainerClass container;
};

extern MimeUntypedTextClass mimeUntypedTextClass;

typedef enum {
  MimeUntypedTextSubpartTypeText,  /* text/plain */
  MimeUntypedTextSubpartTypeUUE,  /* uuencoded data */
  MimeUntypedTextSubpartTypeYEnc,  /* yencoded data */
  MimeUntypedTextSubpartTypeBinhex  /* Mac BinHex data */
} MimeUntypedTextSubpartType;

struct MimeUntypedText {
  MimeContainer container;      /* superclass variables */
  MimeObject *open_subpart;      /* The part still-being-parsed */
  MimeUntypedTextSubpartType type;  /* What kind of type it is */
  MimeHeaders *open_hdrs;      /* The faked-up headers describing it */
};

#define MimeUntypedTextClassInitializer(ITYPE,CSUPER) \
  { MimeContainerClassInitializer(ITYPE,CSUPER) }

#endif /* _MIMEUNTY_H_ */