1 /*        $NetBSD: mime_state.h,v 1.1.1.1 2009/06/23 10:08:47 tron Exp $        */
2 
3 #ifndef _MIME_STATE_H_INCLUDED_
4 #define _MIME_STATE_H_INCLUDED_
5 
6 /*++
7 /* NAME
8 /*        mime_state 3h
9 /* SUMMARY
10 /*        MIME parser state engine
11 /* SYNOPSIS
12 /*        #include "mime_state.h"
13  DESCRIPTION
14  .nf
15 
16  /*
17   * Utility library.
18   */
19 #include <vstring.h>
20 
21  /*
22   * Global library.
23   */
24 #include <header_opts.h>
25 
26  /*
27   * External interface. All MIME_STATE structure members are private.
28   */
29 typedef struct MIME_STATE MIME_STATE;
30 typedef void (*MIME_STATE_HEAD_OUT) (void *, int, const HEADER_OPTS *, VSTRING *, off_t);
31 typedef void (*MIME_STATE_BODY_OUT) (void *, int, const char *, ssize_t, off_t);
32 typedef void (*MIME_STATE_ANY_END) (void *);
33 typedef void (*MIME_STATE_ERR_PRINT) (void *, int, const char *, ssize_t);
34 
35 extern 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 *);
36 extern int mime_state_update(MIME_STATE *, int, const char *, ssize_t);
37 extern MIME_STATE *mime_state_free(MIME_STATE *);
38 
39  /*
40   * Processing options.
41   */
42 #define MIME_OPT_NONE                                       (0)
43 #define MIME_OPT_DOWNGRADE                        (1<<0)
44 #define MIME_OPT_REPORT_8BIT_IN_7BIT_BODY         (1<<1)
45 #define MIME_OPT_REPORT_8BIT_IN_HEADER            (1<<2)
46 #define MIME_OPT_REPORT_ENCODING_DOMAIN           (1<<3)
47 #define MIME_OPT_RECURSE_ALL_MESSAGE              (1<<4)
48 #define MIME_OPT_REPORT_TRUNC_HEADER              (1<<5)
49 #define MIME_OPT_DISABLE_MIME                     (1<<6)
50 #define MIME_OPT_REPORT_NESTING                             (1<<7)
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   */
62 typedef 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 
74 extern const MIME_STATE_DETAIL *mime_state_detail(int);
75 extern const char *mime_state_error(int);
76 
77  /*
78   * With header classes, look at the header_opts argument to recognize MIME
79   * headers in primary or nested sections.
80   */
81 #define MIME_HDR_FIRST                  (1)       /* first class */
82 #define MIME_HDR_PRIMARY      (1)       /* initial headers */
83 #define MIME_HDR_MULTIPART    (2)       /* headers after multipart boundary */
84 #define MIME_HDR_NESTED                 (3)       /* attached message initial headers */
85 #define MIME_HDR_LAST                   (3)       /* last class */
86 
87 /* LICENSE
88 /* .ad
89 /* .fi
90 /*        The Secure Mailer license must be distributed with this software.
91 /* AUTHOR(S)
92 /*        Wietse Venema
93 /*        IBM T.J. Watson Research
94 /*        P.O. Box 704
95 /*        Yorktown Heights, NY 10598, USA
96 /*--*/
97 
98 #endif
99