]> diplodocus.org Git - nmh/blob - h/mhparse.h
Cope with sasl_decode64() returning SASL_CONTINUE as well as SASL_OK.
[nmh] / h / mhparse.h
1
2 /*
3 * mhparse.h -- definitions for parsing/building of MIME content
4 * -- (mhparse.c/mhbuildsbr.c)
5 *
6 * $Id$
7 */
8
9 #define NPARTS 50
10 #define NTYPES 20
11 #define NPARMS 10
12
13 /*
14 * Abstract type for header fields
15 */
16 typedef struct hfield *HF;
17
18 /*
19 * Abstract types for MIME parsing/building
20 */
21 typedef struct cefile *CE;
22 typedef struct CTinfo *CI;
23 typedef struct Content *CT;
24
25 /*
26 * type for Init function (both type and transfer encoding)
27 */
28 typedef int (*InitFunc) (CT);
29
30 /*
31 * types for various transfer encoding access functions
32 */
33 typedef int (*OpenCEFunc) (CT, char **);
34 typedef void (*CloseCEFunc) (CT);
35 typedef unsigned long (*SizeCEFunc) (CT);
36
37 /*
38 * Structure for storing/encoding/decoding
39 * a header field and its value.
40 */
41 struct hfield {
42 char *name; /* field name */
43 char *value; /* field body */
44 int hf_encoding; /* internal flag for transfer encoding to use */
45 HF next; /* link to next header field */
46 };
47
48 /*
49 * Structure for storing parsed elements
50 * of the Content-Type component.
51 */
52 struct CTinfo {
53 char *ci_type; /* content type */
54 char *ci_subtype; /* content subtype */
55 char *ci_attrs[NPARMS + 2]; /* attribute names */
56 char *ci_values[NPARMS]; /* attribute values */
57 char *ci_comment; /* RFC-822 comments */
58 char *ci_magic;
59 };
60
61 /*
62 * Structure for storing decoded contents after
63 * removing Content-Transfer-Encoding.
64 */
65 struct cefile {
66 char *ce_file; /* decoded content (file) */
67 FILE *ce_fp; /* decoded content (stream) */
68 int ce_unlink; /* remove file when done? */
69 };
70
71 /*
72 * Primary structure for handling Content (Entity)
73 */
74 struct Content {
75 /* source (read) file */
76 char *c_file; /* read contents (file) */
77 FILE *c_fp; /* read contents (stream) */
78 int c_unlink; /* remove file when done? */
79
80 long c_begin; /* where content body starts in file */
81 long c_end; /* where content body ends in file */
82
83 /* linked list of header fields */
84 HF c_first_hf; /* pointer to first header field */
85 HF c_last_hf; /* pointer to last header field */
86
87 /* copies of MIME related header fields */
88 char *c_vrsn; /* MIME-Version: */
89 char *c_ctline; /* Content-Type: */
90 char *c_celine; /* Content-Transfer-Encoding: */
91 char *c_id; /* Content-ID: */
92 char *c_descr; /* Content-Description: */
93 char *c_dispo; /* Content-Disposition: */
94 char *c_partno; /* within multipart content */
95
96 /* Content-Type info */
97 struct CTinfo c_ctinfo; /* parsed elements of Content-Type */
98 int c_type; /* internal flag for content type */
99 int c_subtype; /* internal flag for content subtype */
100
101 /* Content-Transfer-Encoding info (decoded contents) */
102 CE c_cefile; /* structure holding decoded content */
103 int c_encoding; /* internal flag for encoding type */
104
105 /* Content-MD5 info */
106 int c_digested; /* have we seen this header before? */
107 unsigned char c_digest[16]; /* decoded MD5 checksum */
108
109 /* pointers to content-specific structures */
110 void *c_ctparams; /* content type specific data */
111 struct exbody *c_ctexbody; /* data for type message/external */
112
113 /* function pointers */
114 InitFunc c_ctinitfnx; /* parse content body */
115 OpenCEFunc c_ceopenfnx; /* get a stream to decoded contents */
116 CloseCEFunc c_ceclosefnx; /* release stream */
117 SizeCEFunc c_cesizefnx; /* size of decoded contents */
118
119 int c_umask; /* associated umask */
120 pid_t c_pid; /* process doing display */
121 int c_rfc934; /* rfc934 compatibility flag */
122
123 char *c_showproc; /* default, if not in profile */
124 char *c_termproc; /* for charset madness... */
125 char *c_storeproc; /* overrides profile entry, if any */
126
127 char *c_storage; /* write contents (file) */
128 char *c_folder; /* write contents (folder) */
129 };
130
131 /*
132 * Flags for Content-Type (Content->c_type)
133 */
134 #define CT_UNKNOWN 0x00
135 #define CT_APPLICATION 0x01
136 #define CT_AUDIO 0x02
137 #define CT_IMAGE 0x03
138 #define CT_MESSAGE 0x04
139 #define CT_MULTIPART 0x05
140 #define CT_TEXT 0x06
141 #define CT_VIDEO 0x07
142 #define CT_EXTENSION 0x08
143
144 /*
145 * Flags for Content-Transfer-Encoding (Content->c_encoding)
146 */
147 #define CE_UNKNOWN 0x00
148 #define CE_BASE64 0x01
149 #define CE_QUOTED 0x02
150 #define CE_8BIT 0x03
151 #define CE_7BIT 0x04
152 #define CE_BINARY 0x05
153 #define CE_EXTENSION 0x06
154 #define CE_EXTERNAL 0x07 /* for external-body */
155
156 /*
157 * TEXT content
158 */
159
160 /* Flags for subtypes of TEXT */
161 #define TEXT_UNKNOWN 0x00
162 #define TEXT_PLAIN 0x01
163 #define TEXT_RICHTEXT 0x02
164 #define TEXT_ENRICHED 0x03
165
166 /* Flags for character sets */
167 #define CHARSET_UNKNOWN 0x00
168 #define CHARSET_UNSPECIFIED 0x01 /* only needed when building drafts */
169 #define CHARSET_USASCII 0x01
170 #define CHARSET_LATIN 0x02
171
172 /* Structure for text content */
173 struct text {
174 int tx_charset; /* flag for character set */
175 };
176
177 /*
178 * MULTIPART content
179 */
180
181 /* Flags for subtypes of MULTIPART */
182 #define MULTI_UNKNOWN 0x00
183 #define MULTI_MIXED 0x01
184 #define MULTI_ALTERNATE 0x02
185 #define MULTI_DIGEST 0x03
186 #define MULTI_PARALLEL 0x04
187
188 /* Structure for subparts of a multipart content */
189 struct part {
190 CT mp_part; /* Content structure for subpart */
191 struct part *mp_next; /* pointer to next subpart structure */
192 };
193
194 /* Main structure for multipart content */
195 struct multipart {
196 char *mp_start; /* boundary string separating parts */
197 char *mp_stop; /* terminating boundary string */
198 struct part *mp_parts; /* pointer to first subpart structure */
199 };
200
201 /*
202 * MESSAGE content
203 */
204
205 /* Flags for subtypes of MESSAGE */
206 #define MESSAGE_UNKNOWN 0x00
207 #define MESSAGE_RFC822 0x01
208 #define MESSAGE_PARTIAL 0x02
209 #define MESSAGE_EXTERNAL 0x03
210
211 /* Structure for message/partial */
212 struct partial {
213 char *pm_partid;
214 int pm_partno;
215 int pm_maxno;
216 int pm_marked;
217 int pm_stored;
218 };
219
220 /* Structure for message/external */
221 struct exbody {
222 CT eb_parent; /* pointer to controlling content structure */
223 CT eb_content; /* pointer to internal content structure */
224 char *eb_partno;
225 char *eb_access;
226 int eb_flags;
227 char *eb_name;
228 char *eb_permission;
229 char *eb_site;
230 char *eb_dir;
231 char *eb_mode;
232 unsigned long eb_size;
233 char *eb_server;
234 char *eb_subject;
235 char *eb_body;
236 };
237
238 /*
239 * APPLICATION content
240 */
241
242 /* Flags for subtype of APPLICATION */
243 #define APPLICATION_UNKNOWN 0x00
244 #define APPLICATION_OCTETS 0x01
245 #define APPLICATION_POSTSCRIPT 0x02
246