1 /* $NetBSD: mime_state.h,v 1.2 2026/05/09 18:49:16 christos 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 int mime_state_status(MIME_STATE *); 38 extern MIME_STATE *mime_state_free(MIME_STATE *); 39 40 /* 41 * Processing options. 42 */ 43 #define MIME_OPT_NONE (0) 44 #define MIME_OPT_DOWNGRADE (1<<0) 45 #define MIME_OPT_REPORT_8BIT_IN_7BIT_BODY (1<<1) 46 #define MIME_OPT_REPORT_8BIT_IN_HEADER (1<<2) 47 #define MIME_OPT_REPORT_ENCODING_DOMAIN (1<<3) 48 #define MIME_OPT_RECURSE_ALL_MESSAGE (1<<4) 49 #define MIME_OPT_REPORT_TRUNC_HEADER (1<<5) 50 #define MIME_OPT_DISABLE_MIME (1<<6) 51 #define MIME_OPT_REPORT_NESTING (1<<7) 52 #define MIME_OPT_REPORT_NON_EMPTY_EOH (1<<8) 53 54 /* 55 * Body encoding domains. 56 */ 57 #define MIME_ENC_7BIT (7) 58 #define MIME_ENC_8BIT (8) 59 #define MIME_ENC_BINARY (9) 60 61 /* 62 * Processing errors, not necessarily lethal. 63 */ 64 typedef struct { 65 const int code; /* internal error code */ 66 const char *dsn; /* RFC 3463 */ 67 const char *text; /* descriptive text */ 68 } MIME_STATE_DETAIL; 69 70 #define MIME_ERR_NESTING (1<<0) 71 #define MIME_ERR_TRUNC_HEADER (1<<1) 72 #define MIME_ERR_8BIT_IN_HEADER (1<<2) 73 #define MIME_ERR_8BIT_IN_7BIT_BODY (1<<3) 74 #define MIME_ERR_ENCODING_DOMAIN (1<<4) 75 #define MIME_ERR_NON_EMPTY_EOH (1<<5) 76 77 extern const MIME_STATE_DETAIL *mime_state_detail(int); 78 extern 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