3 * mhparse.h -- definitions for parsing/building of MIME content
4 * -- (mhparse.c/mhbuildsbr.c)
14 * Abstract type for header fields
16 typedef struct hfield *HF;
19 * Abstract types for MIME parsing/building
21 typedef struct cefile *CE;
22 typedef struct CTinfo *CI;
23 typedef struct Content *CT;
26 * type for Init function (both type and transfer encoding)
28 typedef int (*InitFunc) (CT);
31 * types for various transfer encoding access functions
33 typedef int (*OpenCEFunc) (CT, char **);
34 typedef void (*CloseCEFunc) (CT);
35 typedef unsigned long (*SizeCEFunc) (CT);
38 * Structure for storing/encoding/decoding
39 * a header field and its value.
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 */
49 * Structure for storing parsed elements
50 * of the Content-Type component.
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 */
62 * Structure for storing decoded contents after
63 * removing Content-Transfer-Encoding.
66 char *ce_file; /* decoded content (file) */
67 FILE *ce_fp; /* decoded content (stream) */
68 int ce_unlink; /* remove file when done? */
72 * Primary structure for handling Content (Entity)
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? */
80 long c_begin; /* where content body starts in file */
81 long c_end; /* where content body ends in file */
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 */
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 */
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 */
101 /* Content-Transfer-Encoding info (decoded contents) */
102 CE c_cefile; /* structure holding decoded content */
103 int c_encoding; /* internal flag for encoding type */
105 /* Content-MD5 info */
106 int c_digested; /* have we seen this header before? */
107 unsigned char c_digest[16]; /* decoded MD5 checksum */
109 /* pointers to content-specific structures */
110 void *c_ctparams; /* content type specific data */
111 struct exbody *c_ctexbody; /* data for type message/external */
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 */
119 int c_umask; /* associated umask */
120 pid_t c_pid; /* process doing display */
121 int c_rfc934; /* rfc934 compatibility flag */
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 */
127 char *c_storage; /* write contents (file) */
128 char *c_folder; /* write contents (folder) */
132 * Flags for Content-Type (Content->c_type)
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
141 #define CT_VIDEO 0x07
142 #define CT_EXTENSION 0x08
145 * Flags for Content-Transfer-Encoding (Content->c_encoding)
147 #define CE_UNKNOWN 0x00
148 #define CE_BASE64 0x01
149 #define CE_QUOTED 0x02
152 #define CE_BINARY 0x05
153 #define CE_EXTENSION 0x06
154 #define CE_EXTERNAL 0x07 /* for external-body */
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
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
172 /* Structure for text content */
174 int tx_charset; /* flag for character set */
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
188 /* Structure for subparts of a multipart content */
190 CT mp_part; /* Content structure for subpart */
191 struct part *mp_next; /* pointer to next subpart structure */
194 /* Main structure for multipart content */
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 */
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
211 /* Structure for message/partial */
220 /* Structure for message/external */
222 CT eb_parent; /* pointer to controlling content structure */
223 CT eb_content; /* pointer to internal content structure */
232 unsigned long eb_size;
239 * APPLICATION content
242 /* Flags for subtype of APPLICATION */
243 #define APPLICATION_UNKNOWN 0x00
244 #define APPLICATION_OCTETS 0x01
245 #define APPLICATION_POSTSCRIPT 0x02
249 * Structures for mapping types to their internal flags
255 extern struct k2v SubText[];
256 extern struct k2v Charset[];
257 extern struct k2v SubMultiPart[];
258 extern struct k2v SubMessage[];
259 extern struct k2v SubApplication[];
262 * Structures for mapping (content) types to
263 * the functions to handle them.
270 extern struct str2init str2cts[];
271 extern struct str2init str2ces[];
272 extern struct str2init str2methods[];
278 CT parse_mime (char *);
279 int add_header (CT, char *, char *);
280 int get_ctinfo (unsigned char *, CT, int);
281 int params_external (CT, int);
282 int open7Bit (CT, char **);
283 void close_encoding (CT);
285 extern int checksw; /* Add Content-MD5 field */