9d4d70e9efb8ecc0c54db570e4dff3fb08d9f7a7
[apps/madmutt.git] / lib-mime / mime-types.h
1 /*
2  *  This program is free software; you can redistribute it and/or modify
3  *  it under the terms of the GNU General Public License as published by
4  *  the Free Software Foundation; either version 2 of the License, or (at
5  *  your option) any later version.
6  *
7  *  This program is distributed in the hope that it will be useful, but
8  *  WITHOUT ANY WARRANTY; without even the implied warranty of
9  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10  *  General Public License for more details.
11  *
12  *  You should have received a copy of the GNU General Public License
13  *  along with this program; if not, write to the Free Software
14  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
15  *  MA 02110-1301, USA.
16  *
17  *  Copyright © 2006 Pierre Habouzit
18  */
19
20 /*
21  * Copyright notice from original mutt:
22  * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
23  * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
24  *
25  * This file is part of mutt-ng, see http://www.muttng.org/.
26  * It's licensed under the GNU General Public License,
27  * please see the file GPL in the top level source directory.
28  */
29
30 #ifndef MUTT_LIB_MIME_MIME_TYPES_H
31 #define MUTT_LIB_MIME_MIME_TYPES_H
32
33 #if HAVE_CONFIG_H
34 # include "config.h"
35 #endif
36
37 #include <lib-lib/mem.h>
38 #include <lib-lib/buffer.h>
39 #include <lib-lib/list.h>
40
41 /* Content-Type */
42 enum {
43     TYPEOTHER,
44     TYPEAUDIO,
45     TYPEAPPLICATION,
46     TYPEIMAGE,
47     TYPEMESSAGE,
48     TYPEMODEL,
49     TYPEMULTIPART,
50     TYPETEXT,
51     TYPEVIDEO,
52     TYPEANY
53 };
54
55 /* Content-Transfer-Encoding */
56 enum {
57     ENCOTHER,
58     ENC7BIT,
59     ENC8BIT,
60     ENCQUOTEDPRINTABLE,
61     ENCBASE64,
62     ENCBINARY,
63     ENCUUENCODED
64 };
65
66 /* Content-Disposition values */
67 enum {
68     DISPINLINE,
69     DISPATTACH,
70     DISPFORMDATA
71 };
72
73 /****************************************************************************/
74 /* rfc822 addresses                                                         */
75 /****************************************************************************/
76
77 typedef struct address_t {
78     char *personal;               /* real name of address */
79     char *mailbox;                /* mailbox and host address */
80     int group;                    /* group mailbox? */
81     struct address_t *next;
82 } address_t;
83
84 DO_INIT(address_t, address);
85 void address_wipe(address_t *);
86
87 DO_NEW(address_t, address);
88 DO_DELETE(address_t, address);
89 DO_SLIST(address_t, address);
90
91
92 /****************************************************************************/
93 /* rfc822 header parameters                                                 */
94 /****************************************************************************/
95
96 typedef struct parameter {
97     char *attribute;
98     char *value;
99     struct parameter *next;
100 } PARAMETER;
101
102
103 /****************************************************************************/
104 /* rfc822 envelopes                                                         */
105 /****************************************************************************/
106
107 typedef struct envelope_t {
108     address_t *return_path;
109     address_t *from;
110     address_t *to;
111     address_t *cc;
112     address_t *bcc;
113     address_t *sender;
114     address_t *reply_to;
115     address_t *mail_followup_to;
116     char *list_post;              /* this stores a mailto URL, or nothing */
117     char *subject;
118     char *real_subj;              /* offset of the real subject */
119     char *message_id;
120     char *supersedes;
121     char *date;
122     char *x_label;
123     char *organization;
124 #ifdef USE_NNTP
125     char *newsgroups;
126     char *xref;
127     char *followup_to;
128     char *x_comment_to;
129 #endif
130     BUFFER *spam;
131     LIST *references;             /* message references (in reverse order) */
132     LIST *in_reply_to;            /* in-reply-to header content */
133     LIST *userhdrs;               /* user defined headers */
134     unsigned int irt_changed:1;   /* In-Reply-To changed to link/break threads */
135     unsigned int refs_changed:1;  /* References changed to break thread */
136 } ENVELOPE;
137
138
139 /****************************************************************************/
140 /* rfc822 content-*                                                         */
141 /****************************************************************************/
142
143 /* Information that helps in determing the Content-* of an attachment */
144 typedef struct content {
145     long hibin;                   /* 8-bit characters */
146     long lobin;                   /* unprintable 7-bit chars (eg., control chars) */
147     long crlf;                    /* '\r' and '\n' characters */
148     long ascii;                   /* number of ascii chars */
149     long linemax;                 /* length of the longest line in the file */
150     unsigned int space:1;         /* whitespace at the end of lines? */
151     unsigned int binary:1;        /* long lines, or CR not in CRLF pair */
152     unsigned int from:1;          /* has a line beginning with "From "? */
153     unsigned int dot:1;           /* has a line consisting of a single dot? */
154     unsigned int cr:1;            /* has CR, even when in a CRLF pair */
155 } CONTENT;
156
157
158 /****************************************************************************/
159 /* rfc822 Bodies                                                            */
160 /****************************************************************************/
161
162 typedef struct body {
163     char *xtype;                  /* content-type if x-unknown */
164     char *subtype;                /* content-type subtype */
165     PARAMETER *parameter;         /* parameters of the content-type */
166     char *description;            /* content-description */
167     char *form_name;              /* Content-Disposition form-data name param */
168     off_t hdr_offset;             /* offset in stream where the headers begin.
169                                    * this info is used when invoking metamail,
170                                    * where we need to send the headers of the
171                                    * attachment
172                                    */
173     off_t offset;                 /* offset where the actual data begins */
174     off_t length;                 /* length (in bytes) of attachment */
175     char *filename;               /* when sending a message, this is the file
176                                    * to which this structure refers
177                                    */
178     char *d_filename;             /* filename to be used for the 
179                                    * content-disposition header.
180                                    * If NULL, filename is used 
181                                    * instead.
182                                    */
183     char *file_charset;           /* charset of attached file */
184     CONTENT *content;             /* structure used to store detailed info about
185                                    * the content of the attachment.  this is used
186                                    * to determine what content-transfer-encoding
187                                    * is required when sending mail.
188                                    */
189     struct body *next;            /* next attachment in the list */
190     struct body *parts;           /* parts of a multipart or message/rfc822 */
191     struct header *hdr;           /* header information for message/rfc822 */
192
193     struct attachptr *aptr;       /* Menu information, used in recvattach.c */
194
195     signed short attach_count;
196
197     time_t stamp;                 /* time stamp of last
198                                    * encoding update.
199                                    */
200
201     unsigned int type:4;          /* content-type primary type */
202     unsigned int encoding:3;      /* content-transfer-encoding */
203     unsigned int disposition:2;   /* content-disposition */
204     unsigned int use_disp:1;      /* Content-Disposition uses filename= ? */
205     unsigned int unlink:1;        /* flag to indicate the the file named by
206                                    * "filename" should be unlink()ed before
207                                    * free()ing this structure
208                                    */
209     unsigned int tagged:1;
210     unsigned int deleted:1;       /* attachment marked for deletion */
211
212     unsigned int noconv:1;        /* don't do character set conversion */
213     unsigned int force_charset:1; /* send mode: don't adjust the character set
214                                      when in send-mode. */
215     unsigned int is_signed_data:1; /* A lot of MUAs don't indicate S/MIME
216                                       signed-data correctly, e.g. they use
217                                       foo.p7m even for the name of signed
218                                       data.  This flag is used to keep track
219                                       of the actual message type.  It gets set
220                                       during the verification (which is done
221                                       if the encryption try failed) and check
222                                       by the function to figure the type of
223                                       the message. */
224
225     unsigned int goodsig:1;       /* good cryptographic signature */
226     unsigned int warnsig:1;       /* maybe good signature */
227     unsigned int badsig:1;        /* bad cryptographic signature (needed to check encrypted s/mime-signatures) */
228
229     unsigned int collapsed:1;     /* used by recvattach */
230     unsigned int attach_qualifies:1;
231 } BODY;
232
233
234 /****************************************************************************/
235 /* rfc822 Headers                                                           */
236 /****************************************************************************/
237
238 typedef struct header {
239     unsigned int security:11;     /* bit 0-6: flags, bit 7,8: application.
240 see: crypt.h pgplib.h, smime.h */
241
242     unsigned int mime:1;          /* has a MIME-Version header? */
243     unsigned int flagged:1;       /* marked important? */
244     unsigned int tagged:1;
245     unsigned int appended:1;      /* has been saved */
246     unsigned int purged:1;        /* bypassing the trash folder */
247     unsigned int deleted:1;
248     unsigned int changed:1;
249     unsigned int attach_del:1;    /* has an attachment marked for deletion */
250     unsigned int old:1;
251     unsigned int read:1;
252     unsigned int expired:1;       /* already expired? */
253     unsigned int superseded:1;    /* got superseded? */
254     unsigned int replied:1;
255     unsigned int subject_changed:1;       /* used for threading */
256     unsigned int threaded:1;      /* used for threading */
257     unsigned int display_subject:1;       /* used for threading */
258     unsigned int recip_valid:1;   /* is_recipient is valid */
259     unsigned int active:1;        /* message is not to be removed */
260     unsigned int trash:1;         /* message is marked as trashed on disk.
261                                    * This flag is used by the maildir_trash
262                                    * option.
263                                    */
264
265     /* timezone of the sender of this message */
266     unsigned int zhours:5;
267     unsigned int zminutes:6;
268     unsigned int zoccident:1;
269
270     /* bits used for caching when searching */
271     unsigned int searched:1;
272     unsigned int matched:1;
273
274     /* tells whether the attach count is valid */
275     unsigned int attach_valid:1;
276
277     /* the following are used to support collapsing threads  */
278     unsigned int collapsed:1;     /* is this message part of a collapsed thread? */
279     unsigned int limited:1;       /* is this message in a limited view?  */
280     size_t num_hidden;            /* number of hidden messages in this view */
281
282     short recipient;              /* user_is_recipient()'s return value, cached */
283
284     int pair;                     /* color-pair to use when displaying in the index */
285
286     time_t date_sent;             /* time when the message was sent (UTC) */
287     time_t received;              /* time when the message was placed in the mailbox */
288     off_t offset;                 /* where in the stream does this message begin? */
289     int lines;                    /* how many lines in the body of this message? */
290     int index;                    /* the absolute (unsorted) message number */
291     int msgno;                    /* number displayed to the user */
292     int virtual;                  /* virtual message number */
293     int score;
294     ENVELOPE *env;                /* envelope information */
295     BODY *content;                /* list of MIME parts */
296     char *path;
297 #ifdef USE_NNTP
298     int article_num;
299 #endif
300
301     char *tree;                   /* character string to print thread tree */
302     struct thread *thread;
303
304     short attach_total;
305
306 #ifdef MIXMASTER
307     LIST *chain;
308 #endif
309
310     int refno;                    /* message number on server */
311     void *data;                   /* driver-specific data */
312
313     char *maildir_flags;          /* unknown maildir flags */
314 } HEADER;
315
316 #endif /* MUTT_LIB_MIME_MIME_TYPES_H */