]>
diplodocus.org Git - nmh/blob - h/mhparse.h
3 * mhparse.h -- definitions for parsing/building of MIME content
4 * -- (mhparse.c/mhbuildsbr.c)
12 * Abstract type for header fields
14 typedef struct hfield
*HF
;
17 * Abstract types for MIME parsing/building
19 typedef struct cefile
*CE
;
20 typedef struct CTinfo
*CI
;
21 typedef struct Content
*CT
;
24 * type for Init function (both type and transfer encoding)
26 typedef int (*InitFunc
) (CT
);
29 * types for various transfer encoding access functions
31 typedef int (*OpenCEFunc
) (CT
, char **);
32 typedef void (*CloseCEFunc
) (CT
);
33 typedef unsigned long (*SizeCEFunc
) (CT
);
36 * Structure for storing/encoding/decoding
37 * a header field and its value.
40 char *name
; /* field name */
41 char *value
; /* field body */
42 int hf_encoding
; /* internal flag for transfer encoding to use */
43 HF next
; /* link to next header field */
47 * Structure for storing parsed elements
48 * of the Content-Type component.
51 char *ci_type
; /* content type */
52 char *ci_subtype
; /* content subtype */
53 char *ci_attrs
[NPARMS
+ 2]; /* attribute names */
54 char *ci_values
[NPARMS
]; /* attribute values */
55 char *ci_comment
; /* RFC-822 comments */
60 * Structure for storing decoded contents after
61 * removing Content-Transfer-Encoding.
64 char *ce_file
; /* decoded content (file) */
65 FILE *ce_fp
; /* decoded content (stream) */
66 int ce_unlink
; /* remove file when done? */
70 * Primary structure for handling Content (Entity)
73 /* source (read) file */
74 char *c_file
; /* read contents (file) */
75 FILE *c_fp
; /* read contents (stream) */
76 int c_unlink
; /* remove file when done? */
78 long c_begin
; /* where content body starts in file */
79 long c_end
; /* where content body ends in file */
81 /* linked list of header fields */
82 HF c_first_hf
; /* pointer to first header field */
83 HF c_last_hf
; /* pointer to last header field */
85 /* copies of MIME related header fields */
86 char *c_vrsn
; /* MIME-Version: */
87 char *c_ctline
; /* Content-Type: */
88 char *c_celine
; /* Content-Transfer-Encoding: */
89 char *c_id
; /* Content-ID: */
90 char *c_descr
; /* Content-Description: */
91 char *c_dispo
; /* Content-Disposition: */
92 char *c_partno
; /* within multipart content */
94 /* Content-Type info */
95 struct CTinfo c_ctinfo
; /* parsed elements of Content-Type */
96 int c_type
; /* internal flag for content type */
97 int c_subtype
; /* internal flag for content subtype */
99 /* Content-Transfer-Encoding info (decoded contents) */
100 struct cefile c_cefile
; /* structure holding decoded content */
101 int c_encoding
; /* internal flag for encoding type */
103 /* Content-MD5 info */
104 int c_digested
; /* have we seen this header before? */
105 unsigned char c_digest
[16]; /* decoded MD5 checksum */
107 /* pointers to content-specific structures */
108 void *c_ctparams
; /* content type specific data */
109 struct exbody
*c_ctexbody
; /* data for type message/external */
111 /* function pointers */
112 InitFunc c_ctinitfnx
; /* parse content body */
113 OpenCEFunc c_ceopenfnx
; /* get a stream to decoded contents */
114 CloseCEFunc c_ceclosefnx
; /* release stream */
115 SizeCEFunc c_cesizefnx
; /* size of decoded contents */
117 int c_umask
; /* associated umask */
118 pid_t c_pid
; /* process doing display */
119 int c_rfc934
; /* rfc934 compatibility flag */
121 char *c_showproc
; /* default, if not in profile */
122 char *c_termproc
; /* for charset madness... */
123 char *c_storeproc
; /* overrides profile entry, if any */
125 char *c_storage
; /* write contents (file) */
126 char *c_folder
; /* write contents (folder) */
130 * Flags for Content-Type (Content->c_type)
132 #define CT_UNKNOWN 0x00
133 #define CT_APPLICATION 0x01
134 #define CT_AUDIO 0x02
135 #define CT_IMAGE 0x03
136 #define CT_MESSAGE 0x04
137 #define CT_MULTIPART 0x05
139 #define CT_VIDEO 0x07
140 #define CT_EXTENSION 0x08
143 * Flags for Content-Transfer-Encoding (Content->c_encoding)
145 #define CE_UNKNOWN 0x00
146 #define CE_BASE64 0x01
147 #define CE_QUOTED 0x02
150 #define CE_BINARY 0x05
151 #define CE_EXTENSION 0x06
152 #define CE_EXTERNAL 0x07 /* for external-body */
158 /* Flags for subtypes of TEXT */
159 #define TEXT_UNKNOWN 0x00
160 #define TEXT_PLAIN 0x01
161 #define TEXT_RICHTEXT 0x02
162 #define TEXT_ENRICHED 0x03
164 /* Flags for character sets */
165 #define CHARSET_SPECIFIED 0x00
166 #define CHARSET_UNSPECIFIED 0x01 /* only needed when building drafts */
168 /* Structure for text content */
170 int tx_charset
; /* flag for character set */
177 /* Flags for subtypes of MULTIPART */
178 #define MULTI_UNKNOWN 0x00
179 #define MULTI_MIXED 0x01
180 #define MULTI_ALTERNATE 0x02
181 #define MULTI_DIGEST 0x03
182 #define MULTI_PARALLEL 0x04
184 /* Structure for subparts of a multipart content */
186 CT mp_part
; /* Content structure for subpart */
187 struct part
*mp_next
; /* pointer to next subpart structure */
190 /* Main structure for multipart content */
192 char *mp_start
; /* boundary string separating parts */
193 char *mp_stop
; /* terminating boundary string */
194 char *mp_content_before
; /* any content before the first subpart */
195 char *mp_content_after
; /* any content after the last subpart */
196 struct part
*mp_parts
; /* pointer to first subpart structure */
203 /* Flags for subtypes of MESSAGE */
204 #define MESSAGE_UNKNOWN 0x00
205 #define MESSAGE_RFC822 0x01
206 #define MESSAGE_PARTIAL 0x02
207 #define MESSAGE_EXTERNAL 0x03
209 /* Structure for message/partial */
218 /* Structure for message/external */
220 CT eb_parent
; /* pointer to controlling content structure */
221 CT eb_content
; /* pointer to internal content structure */
230 unsigned long eb_size
;
238 * APPLICATION content
241 /* Flags for subtype of APPLICATION */
242 #define APPLICATION_UNKNOWN 0x00
243 #define APPLICATION_OCTETS 0x01
244 #define APPLICATION_POSTSCRIPT 0x02
248 * Structures for mapping types to their internal flags
254 extern struct k2v SubText
[];
255 extern struct k2v Charset
[];
256 extern struct k2v SubMultiPart
[];
257 extern struct k2v SubMessage
[];
258 extern struct k2v SubApplication
[];
261 * Structures for mapping (content) types to
262 * the functions to handle them.
269 extern struct str2init str2cts
[];
270 extern struct str2init str2ces
[];
271 extern struct str2init str2methods
[];
277 CT
parse_mime (char *);
278 int add_header (CT
, char *, char *);
279 int get_ctinfo (char *, CT
, int);
280 int params_external (CT
, int);
281 int open7Bit (CT
, char **);
282 void close_encoding (CT
);
283 void free_content (CT
);
284 char *ct_type_str (int);
285 char *ct_subtype_str (int, int);
286 const struct str2init
*get_ct_init (int);
287 const char *ce_str (int);
288 const struct str2init
*get_ce_method (const char *);
289 int parse_header_attrs (const char *, int, char **, CI
, int *);
291 extern int checksw
; /* Add Content-MD5 field */