source: trunk/third/nmh/h/mhparse.h @ 12455

Revision 12455, 6.6 KB checked in by danw, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12454, which included commits to RCS files with non-trunk default branches.
Line 
1
2/*
3 * mhparse.h -- definitions for parsing/building of MIME content
4 *           -- (mhparse.c/mhbuildsbr.c)
5 *
6 * $Id: mhparse.h,v 1.1.1.1 1999-02-07 18:14:06 danw Exp $
7 */
8
9#define NPARTS  50
10#define NTYPES  20
11#define NPARMS  10
12
13/*
14 * Abstract type for header fields
15 */
16typedef struct hfield *HF;
17
18/*
19 * Abstract types for MIME parsing/building
20 */
21typedef struct cefile  *CE;
22typedef struct CTinfo  *CI;
23typedef struct Content *CT;
24
25/*
26 * type for Init function (both type and transfer encoding)
27 */
28typedef int (*InitFunc) (CT);
29
30/*
31 * types for various transfer encoding access functions
32 */
33typedef int (*OpenCEFunc) (CT, char **);
34typedef void (*CloseCEFunc) (CT);
35typedef unsigned long (*SizeCEFunc) (CT);
36
37/*
38 * Structure for storing/encoding/decoding
39 * a header field and its value.
40 */
41struct hfield {
42    char *name;         /* field name */
43    char *value;        /* field body */
44    int hf_encoding;    /* internal flag for transfer encoding to use */
45    HF next;            /* link to next header field */
46};
47
48/*
49 * Structure for storing parsed elements
50 * of the Content-Type component.
51 */
52struct CTinfo {
53    char *ci_type;              /* content type     */
54    char *ci_subtype;           /* content subtype  */
55    char *ci_attrs[NPARMS + 2]; /* attribute names  */
56    char *ci_values[NPARMS];    /* attribute values */
57    char *ci_comment;           /* RFC-822 comments */
58    char *ci_magic;
59};
60
61/*
62 * Structure for storing decoded contents after
63 * removing Content-Transfer-Encoding.
64 */
65struct cefile {
66    char *ce_file;      /* decoded content (file)   */
67    FILE *ce_fp;        /* decoded content (stream) */
68    int   ce_unlink;    /* remove file when done?   */
69};
70
71/*
72 * Primary structure for handling Content (Entity)
73 */
74struct Content {
75    /* source (read) file */
76    char *c_file;               /* read contents (file)              */
77    FILE *c_fp;                 /* read contents (stream)            */
78    int c_unlink;               /* remove file when done?            */
79
80    long c_begin;               /* where content body starts in file */
81    long c_end;                 /* where content body ends in file   */
82
83    /* linked list of header fields */
84    HF c_first_hf;              /* pointer to first header field     */
85    HF c_last_hf;               /* pointer to last header field      */
86
87    /* copies of MIME related header fields */
88    char *c_vrsn;               /* MIME-Version:                     */
89    char *c_ctline;             /* Content-Type:                     */
90    char *c_celine;             /* Content-Transfer-Encoding:        */
91    char *c_id;                 /* Content-ID:                       */
92    char *c_descr;              /* Content-Description:              */
93    char *c_partno;             /* within multipart content          */
94
95    /* Content-Type info */
96    struct CTinfo c_ctinfo;     /* parsed elements of Content-Type   */
97    int c_type;                 /* internal flag for content type    */
98    int c_subtype;              /* internal flag for content subtype */
99
100    /* Content-Transfer-Encoding info (decoded contents) */
101    CE c_cefile;                /* structure holding decoded content */
102    int c_encoding;             /* internal flag for encoding type   */
103
104    /* Content-MD5 info */
105    int c_digested;             /* have we seen this header before?  */
106    unsigned char c_digest[16]; /* decoded MD5 checksum              */
107
108    /* pointers to content-specific structures */
109    void *c_ctparams;           /* content type specific data        */
110    struct exbody *c_ctexbody;  /* data for type message/external    */
111
112    /* function pointers */
113    InitFunc    c_ctinitfnx;    /* parse content body                */
114    OpenCEFunc  c_ceopenfnx;    /* get a stream to decoded contents  */
115    CloseCEFunc c_ceclosefnx;   /* release stream                    */
116    SizeCEFunc  c_cesizefnx;    /* size of decoded contents          */
117
118    int c_umask;                /* associated umask                  */
119    pid_t c_pid;                /* process doing display             */
120    int c_rfc934;               /* rfc934 compatibility flag         */
121
122    char *c_showproc;           /* default, if not in profile        */
123    char *c_termproc;           /* for charset madness...            */
124    char *c_storeproc;          /* overrides profile entry, if any   */
125
126    char *c_storage;            /* write contents (file)             */
127    char *c_folder;             /* write contents (folder)           */
128};
129
130/*
131 * Flags for Content-Type (Content->c_type)
132 */
133#define CT_UNKNOWN      0x00
134#define CT_APPLICATION  0x01
135#define CT_AUDIO        0x02
136#define CT_IMAGE        0x03
137#define CT_MESSAGE      0x04
138#define CT_MULTIPART    0x05
139#define CT_TEXT         0x06
140#define CT_VIDEO        0x07
141#define CT_EXTENSION    0x08
142
143/*
144 * Flags for Content-Transfer-Encoding (Content->c_encoding)
145 */
146#define CE_UNKNOWN      0x00
147#define CE_BASE64       0x01
148#define CE_QUOTED       0x02
149#define CE_8BIT         0x03
150#define CE_7BIT         0x04
151#define CE_BINARY       0x05
152#define CE_EXTENSION    0x06
153#define CE_EXTERNAL     0x07    /* for external-body */
154
155/*
156 * TEXT content
157 */
158
159/* Flags for subtypes of TEXT */
160#define TEXT_UNKNOWN    0x00
161#define TEXT_PLAIN      0x01
162#define TEXT_RICHTEXT   0x02
163#define TEXT_ENRICHED   0x03
164
165/* Flags for character sets */
166#define CHARSET_UNKNOWN     0x00
167#define CHARSET_UNSPECIFIED 0x01  /* only needed when building drafts */
168#define CHARSET_USASCII     0x01
169#define CHARSET_LATIN       0x02
170
171/* Structure for text content */
172struct text {
173    int tx_charset;             /* flag for character set */
174};
175
176/*
177 * MULTIPART content
178 */
179
180/* Flags for subtypes of MULTIPART */
181#define MULTI_UNKNOWN   0x00
182#define MULTI_MIXED     0x01
183#define MULTI_ALTERNATE 0x02
184#define MULTI_DIGEST    0x03
185#define MULTI_PARALLEL  0x04
186
187/* Structure for subparts of a multipart content */
188struct part {
189    CT mp_part;                 /* Content structure for subpart     */
190    struct part *mp_next;       /* pointer to next subpart structure */
191};
192
193/* Main structure for multipart content */
194struct multipart {
195    char *mp_start;             /* boundary string separating parts   */
196    char *mp_stop;              /* terminating boundary string        */
197    struct part *mp_parts;      /* pointer to first subpart structure */
198};
199
200/*
201 * MESSAGE content
202 */
203
204/* Flags for subtypes of MESSAGE */
205#define MESSAGE_UNKNOWN  0x00
206#define MESSAGE_RFC822   0x01
207#define MESSAGE_PARTIAL  0x02
208#define MESSAGE_EXTERNAL 0x03
209
210/* Structure for message/partial */
211struct partial {
212    char *pm_partid;
213    int pm_partno;
214    int pm_maxno;
215    int pm_marked;
216    int pm_stored;
217};
218
219/* Structure for message/external */
220struct exbody {
221    CT eb_parent;       /* pointer to controlling content structure */
222    CT eb_content;      /* pointer to internal content structure    */
223    char *eb_partno;
224    char *eb_access;
225    int eb_flags;
226    char *eb_name;
227    char *eb_permission;
228    char *eb_site;
229    char *eb_dir;
230    char *eb_mode;
231    unsigned long eb_size;
232    char *eb_server;
233    char *eb_subject;
234    char *eb_body;
235};
236
237/*
238 * APPLICATION content
239 */
240
241/* Flags for subtype of APPLICATION */
242#define APPLICATION_UNKNOWN     0x00
243#define APPLICATION_OCTETS      0x01
244#define APPLICATION_POSTSCRIPT  0x02
245
Note: See TracBrowser for help on using the repository browser.