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 MIME_STATE *mime_state_free(MIME_STATE *); 36 37 /* 38 * Processing options. 39 */ 40#define MIME_OPT_NONE (0) 41#define MIME_OPT_DOWNGRADE (1<<0) 42#define MIME_OPT_REPORT_8BIT_IN_7BIT_BODY (1<<1) 43#define MIME_OPT_REPORT_8BIT_IN_HEADER (1<<2) 44#define MIME_OPT_REPORT_ENCODING_DOMAIN (1<<3) 45#define MIME_OPT_RECURSE_ALL_MESSAGE (1<<4) 46#define MIME_OPT_REPORT_TRUNC_HEADER (1<<5) 47#define MIME_OPT_DISABLE_MIME (1<<6) 48#define MIME_OPT_REPORT_NESTING (1<<7) 49 50 /* 51 * Body encoding domains. 52 */ 53#define MIME_ENC_7BIT (7) 54#define MIME_ENC_8BIT (8) 55#define MIME_ENC_BINARY (9) 56 57 /* 58 * Processing errors, not necessarily lethal. 59 */ 60typedef struct { 61 const int code; /* internal error code */ 62 const char *dsn; /* RFC 3463 */ 63 const char *text; /* descriptive text */ 64} MIME_STATE_DETAIL; 65 66#define MIME_ERR_NESTING (1<<0) 67#define MIME_ERR_TRUNC_HEADER (1<<1) 68#define MIME_ERR_8BIT_IN_HEADER (1<<2) 69#define MIME_ERR_8BIT_IN_7BIT_BODY (1<<3) 70#define MIME_ERR_ENCODING_DOMAIN (1<<4) 71 72extern const MIME_STATE_DETAIL *mime_state_detail(int); 73extern const char *mime_state_error(int); 74 75 /* 76 * With header classes, look at the header_opts argument to recognize MIME 77 * headers in primary or nested sections. 78 */ 79#define MIME_HDR_FIRST (1) /* first class */ 80#define MIME_HDR_PRIMARY (1) /* initial headers */ 81#define MIME_HDR_MULTIPART (2) /* headers after multipart boundary */ 82#define MIME_HDR_NESTED (3) /* attached message initial headers */ 83#define MIME_HDR_LAST (3) /* last class */ 84 85/* LICENSE 86/* .ad 87/* .fi 88/* The Secure Mailer license must be distributed with this software. 89/* AUTHOR(S) 90/* Wietse Venema 91/* IBM T.J. Watson Research 92/* P.O. Box 704 93/* Yorktown Heights, NY 10598, USA 94/*--*/ 95 96#endif 97