Merge from EXISCAN branch.
[exim.git] / src / src / mime.h
1 /* $Cambridge: exim/src/src/mime.h,v 1.2 2004/12/16 15:11:47 tom Exp $ */
2
3 /*************************************************
4 *     Exim - an Internet mail transport agent    *
5 *************************************************/
6
7 /* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2004 */
8 /* License: GPL */
9
10 #ifdef WITH_CONTENT_SCAN
11
12 #define MIME_MAX_HEADER_SIZE 8192
13 #define MIME_MAX_LINE_LENGTH 32768
14
15 #define MBC_ATTACHMENT            0
16 #define MBC_COVERLETTER_ONESHOT   1
17 #define MBC_COVERLETTER_ALL       2
18
19 struct mime_boundary_context
20 {
21   struct mime_boundary_context *parent;
22   unsigned char *boundary;
23   int context;
24 };
25
26 typedef struct mime_header {
27   uschar *name;
28   int    namelen;
29   void   *value;
30 } mime_header;
31
32 static mime_header mime_header_list[] = {
33   { US"content-type:", 13, &mime_content_type },
34   { US"content-disposition:", 20, &mime_content_disposition },
35   { US"content-transfer-encoding:", 26, &mime_content_transfer_encoding },
36   { US"content-id:", 11, &mime_content_id },
37   { US"content-description:", 20 , &mime_content_description }
38 };
39
40 static int mime_header_list_size = sizeof(mime_header_list)/sizeof(mime_header);
41
42
43
44 typedef struct mime_parameter {
45   uschar *name;
46   int    namelen;
47   void   *value;
48 } mime_parameter;
49
50 static mime_parameter mime_parameter_list[] = {
51   { US"name=", 5, &mime_filename },
52   { US"filename=", 9, &mime_filename },
53   { US"charset=", 8, &mime_charset },
54   { US"boundary=", 9, &mime_boundary }
55 };
56
57 static int mime_parameter_list_size = sizeof(mime_parameter_list)/sizeof(mime_parameter);
58
59
60 /* MIME Anomaly list */
61 #define MIME_ANOMALY_BROKEN_BASE64    2, "Broken BASE64 encoding detected"
62 #define MIME_ANOMALY_BROKEN_QP        1, "Broken Quoted-Printable encoding detected"
63
64
65 /* BASE64 decoder matrix */
66 static unsigned char mime_b64[256]={
67 /*   0 */  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,
68 /*  16 */  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128, 
69 /*  32 */  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,   62,  128,  128,  128,   63,
70 /*  48 */   52,   53,   54,   55,   56,   57,   58,   59,   60,   61,  128,  128,  128,  255,  128,  128,
71 /*  64 */  128,    0,    1,    2,    3,    4,    5,    6,    7,    8,    9,   10,   11,   12,   13,   14,
72 /*  80 */   15,   16,   17,   18,   19,   20,   21,   22,   23,   24,   25,  128,  128,  128,  128,  128,
73 /*  96 */  128,   26,   27,   28,   29,   30,   31,   32,   33,   34,   35,   36,   37,   38,   39,   40,
74 /* 112 */   41,   42,   43,   44,   45,   46,   47,   48,   49,   50,   51,  128,  128,  128,  128,  128,
75 /* 128 */  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,
76 /* 144 */  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,
77 /* 160 */  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,
78 /* 176 */  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,
79 /* 192 */  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,
80 /* 208 */  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,
81 /* 224 */  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,
82 /* 240 */  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128,  128 
83 };
84
85 #endif