1#ifndef _MIME_STATE_H_INCLUDED_
2#define _MIME_STATE_H_INCLUDED_
3
4/*++
5/* NAME
6/*	mime_state 3h
7/* SUMMARY
8/*	MIME parser state engine
9/* SYNOPSIS
10/*	#include "mime_state.h"
11 DESCRIPTION
12 .nf
13
14 /*
15  * Utility library.
16  */
17#include <vstring.h>
18
19 /*
20  * Global library.
21  */
22#include <header_opts.h>
23
24 /*
25  * External interface. All MIME_STATE structure members are private.
26  */
27typedef struct MIME_STATE MIME_STATE;
28typedef void (*MIME_STATE_HEAD_OUT) (void *, int, const HEADER_OPTS *, VSTRING *, off_t);
29typedef void (*MIME_STATE_BODY_OUT) (void *, int, const char *, ssize_t, off_t);
30typedef void (*MIME_STATE_ANY_END) (void *);
31typedef void (*MIME_STATE_ERR_PRINT) (void *, int, const char *, ssize_t);
32
33extern MIME_STATE *mime_state_alloc(int, MIME_STATE_HEAD_OUT, MIME_STATE_ANY_END, MIME_STATE_BODY_OUT, MIME_STATE_ANY_END, MIME_STATE_ERR_PRINT, void *);
34extern int mime_state_update(MIME_STATE *, int, const char *, ssize_t);
35extern int mime_state_flush(MIME_STATE *);	    /* APPLE - RFC 3030 */
36extern MIME_STATE *mime_state_free(MIME_STATE *);
37
38 /*
39  * Processing options.
40  */
41#define MIME_OPT_NONE				(0)
42#define MIME_OPT_DOWNGRADE			(1<<0)
43#define MIME_OPT_REPORT_8BIT_IN_7BIT_BODY	(1<<1)
44#define MIME_OPT_REPORT_8BIT_IN_HEADER		(1<<2)
45#define MIME_OPT_REPORT_ENCODING_DOMAIN		(1<<3)
46#define MIME_OPT_RECURSE_ALL_MESSAGE		(1<<4)
47#define MIME_OPT_REPORT_TRUNC_HEADER		(1<<5)
48#define MIME_OPT_DISABLE_MIME			(1<<6)
49#define MIME_OPT_REPORT_NESTING			(1<<7)
50#define MIME_OPT_DOWNGRADE_BASE64		(1<<8)	/* APPLE - RFC 3030 */
51
52 /*
53  * Body encoding domains.
54  */
55#define MIME_ENC_7BIT	(7)
56#define MIME_ENC_8BIT	(8)
57#define MIME_ENC_BINARY	(9)
58
59 /*
60  * Processing errors, not necessarily lethal.
61  */
62typedef struct {
63    const int code;			/* internal error code */
64    const char *dsn;			/* RFC 3463 */
65    const char *text;			/* descriptive text */
66} MIME_STATE_DETAIL;
67
68#define MIME_ERR_NESTING		(1<<0)
69#define MIME_ERR_TRUNC_HEADER		(1<<1)
70#define MIME_ERR_8BIT_IN_HEADER		(1<<2)
71#define MIME_ERR_8BIT_IN_7BIT_BODY	(1<<3)
72#define MIME_ERR_ENCODING_DOMAIN	(1<<4)
73#ifdef __APPLE_OS_X_SERVER__
74#define MIME_ERR_BODY_TOO_LARGE		(1<<5)
75#endif
76
77extern const MIME_STATE_DETAIL *mime_state_detail(int);
78extern const char *mime_state_error(int);
79
80 /*
81  * With header classes, look at the header_opts argument to recognize MIME
82  * headers in primary or nested sections.
83  */
84#define MIME_HDR_FIRST		(1)	/* first class */
85#define MIME_HDR_PRIMARY	(1)	/* initial headers */
86#define MIME_HDR_MULTIPART	(2)	/* headers after multipart boundary */
87#define MIME_HDR_NESTED		(3)	/* attached message initial headers */
88#define MIME_HDR_LAST		(3)	/* last class */
89
90/* LICENSE
91/* .ad
92/* .fi
93/*	The Secure Mailer license must be distributed with this software.
94/* AUTHOR(S)
95/*	Wietse Venema
96/*	IBM T.J. Watson Research
97/*	P.O. Box 704
98/*	Yorktown Heights, NY 10598, USA
99/*--*/
100
101#endif
102