3744cbccbe7cf45df55b815e5977584f5f23e41c
[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 typedef struct parameter {
74     char *attribute;
75     char *value;
76     struct parameter *next;
77 } PARAMETER;
78
79 typedef struct address_t {
80     char *personal;               /* real name of address */
81     char *mailbox;                /* mailbox and host address */
82     int group;                    /* group mailbox? */
83     struct address_t *next;
84 } address_t;
85
86 typedef struct envelope_t {
87     address_t *return_path;
88     address_t *from;
89     address_t *to;
90     address_t *cc;
91     address_t *bcc;
92     address_t *sender;
93     address_t *reply_to;
94     address_t *mail_followup_to;
95     char *list_post;              /* this stores a mailto URL, or nothing */
96     char *subject;
97     char *real_subj;              /* offset of the real subject */
98     char *message_id;
99     char *supersedes;
100     char *date;
101     char *x_label;
102     char *organization;
103 #ifdef USE_NNTP
104     char *newsgroups;
105     char *xref;
106     char *followup_to;
107     char *x_comment_to;
108 #endif
109     BUFFER *spam;
110     LIST *references;             /* message references (in reverse order) */
111     LIST *in_reply_to;            /* in-reply-to header content */
112     LIST *userhdrs;               /* user defined headers */
113     unsigned int irt_changed:1;   /* In-Reply-To changed to link/break threads */
114     unsigned int refs_changed:1;  /* References changed to break thread */
115 } ENVELOPE;
116
117 /* Information that helps in determing the Content-* of an attachment */
118 typedef struct content {
119     long hibin;                   /* 8-bit characters */
120     long lobin;                   /* unprintable 7-bit chars (eg., control chars) */
121     long crlf;                    /* '\r' and '\n' characters */
122     long ascii;                   /* number of ascii chars */
123     long linemax;                 /* length of the longest line in the file */
124     unsigned int space:1;         /* whitespace at the end of lines? */
125     unsigned int binary:1;        /* long lines, or CR not in CRLF pair */
126     unsigned int from:1;          /* has a line beginning with "From "? */
127     unsigned int dot:1;           /* has a line consisting of a single dot? */
128     unsigned int cr:1;            /* has CR, even when in a CRLF pair */
129 } CONTENT;
130
131 typedef struct body {
132     char *xtype;                  /* content-type if x-unknown */
133     char *subtype;                /* content-type subtype */
134     PARAMETER *parameter;         /* parameters of the content-type */
135     char *description;            /* content-description */
136     char *form_name;              /* Content-Disposition form-data name param */
137     off_t hdr_offset;             /* offset in stream where the headers begin.
138                                    * this info is used when invoking metamail,
139                                    * where we need to send the headers of the
140                                    * attachment
141                                    */
142     off_t offset;                 /* offset where the actual data begins */
143     off_t length;                 /* length (in bytes) of attachment */
144     char *filename;               /* when sending a message, this is the file
145                                    * to which this structure refers
146                                    */
147     char *d_filename;             /* filename to be used for the 
148                                    * content-disposition header.
149                                    * If NULL, filename is used 
150                                    * instead.
151                                    */
152     char *file_charset;           /* charset of attached file */
153     CONTENT *content;             /* structure used to store detailed info about
154                                    * the content of the attachment.  this is used
155                                    * to determine what content-transfer-encoding
156                                    * is required when sending mail.
157                                    */
158     struct body *next;            /* next attachment in the list */
159     struct body *parts;           /* parts of a multipart or message/rfc822 */
160     struct header *hdr;           /* header information for message/rfc822 */
161
162     struct attachptr *aptr;       /* Menu information, used in recvattach.c */
163
164     signed short attach_count;
165
166     time_t stamp;                 /* time stamp of last
167                                    * encoding update.
168                                    */
169
170     unsigned int type:4;          /* content-type primary type */
171     unsigned int encoding:3;      /* content-transfer-encoding */
172     unsigned int disposition:2;   /* content-disposition */
173     unsigned int use_disp:1;      /* Content-Disposition uses filename= ? */
174     unsigned int unlink:1;        /* flag to indicate the the file named by
175                                    * "filename" should be unlink()ed before
176                                    * free()ing this structure
177                                    */
178     unsigned int tagged:1;
179     unsigned int deleted:1;       /* attachment marked for deletion */
180
181     unsigned int noconv:1;        /* don't do character set conversion */
182     unsigned int force_charset:1; /* send mode: don't adjust the character set
183                                      when in send-mode. */
184     unsigned int is_signed_data:1; /* A lot of MUAs don't indicate S/MIME
185                                       signed-data correctly, e.g. they use
186                                       foo.p7m even for the name of signed
187                                       data.  This flag is used to keep track
188                                       of the actual message type.  It gets set
189                                       during the verification (which is done
190                                       if the encryption try failed) and check
191                                       by the function to figure the type of
192                                       the message. */
193
194     unsigned int goodsig:1;       /* good cryptographic signature */
195     unsigned int warnsig:1;       /* maybe good signature */
196     unsigned int badsig:1;        /* bad cryptographic signature (needed to check encrypted s/mime-signatures) */
197
198     unsigned int collapsed:1;     /* used by recvattach */
199     unsigned int attach_qualifies:1;
200
201 } BODY;
202
203 typedef struct header {
204     unsigned int security:11;     /* bit 0-6: flags, bit 7,8: application.
205 see: crypt.h pgplib.h, smime.h */
206
207     unsigned int mime:1;          /* has a MIME-Version header? */
208     unsigned int flagged:1;       /* marked important? */
209     unsigned int tagged:1;
210     unsigned int appended:1;      /* has been saved */
211     unsigned int purged:1;        /* bypassing the trash folder */
212     unsigned int deleted:1;
213     unsigned int changed:1;
214     unsigned int attach_del:1;    /* has an attachment marked for deletion */
215     unsigned int old:1;
216     unsigned int read:1;
217     unsigned int expired:1;       /* already expired? */
218     unsigned int superseded:1;    /* got superseded? */
219     unsigned int replied:1;
220     unsigned int subject_changed:1;       /* used for threading */
221     unsigned int threaded:1;      /* used for threading */
222     unsigned int display_subject:1;       /* used for threading */
223     unsigned int recip_valid:1;   /* is_recipient is valid */
224     unsigned int active:1;        /* message is not to be removed */
225     unsigned int trash:1;         /* message is marked as trashed on disk.
226                                    * This flag is used by the maildir_trash
227                                    * option.
228                                    */
229
230     /* timezone of the sender of this message */
231     unsigned int zhours:5;
232     unsigned int zminutes:6;
233     unsigned int zoccident:1;
234
235     /* bits used for caching when searching */
236     unsigned int searched:1;
237     unsigned int matched:1;
238
239     /* tells whether the attach count is valid */
240     unsigned int attach_valid:1;
241
242     /* the following are used to support collapsing threads  */
243     unsigned int collapsed:1;     /* is this message part of a collapsed thread? */
244     unsigned int limited:1;       /* is this message in a limited view?  */
245     size_t num_hidden;            /* number of hidden messages in this view */
246
247     short recipient;              /* user_is_recipient()'s return value, cached */
248
249     int pair;                     /* color-pair to use when displaying in the index */
250
251     time_t date_sent;             /* time when the message was sent (UTC) */
252     time_t received;              /* time when the message was placed in the mailbox */
253     off_t offset;                 /* where in the stream does this message begin? */
254     int lines;                    /* how many lines in the body of this message? */
255     int index;                    /* the absolute (unsorted) message number */
256     int msgno;                    /* number displayed to the user */
257     int virtual;                  /* virtual message number */
258     int score;
259     ENVELOPE *env;                /* envelope information */
260     BODY *content;                /* list of MIME parts */
261     char *path;
262 #ifdef USE_NNTP
263     int article_num;
264 #endif
265
266     char *tree;                   /* character string to print thread tree */
267     struct thread *thread;
268
269     short attach_total;
270
271 #ifdef MIXMASTER
272     LIST *chain;
273 #endif
274
275     int refno;                    /* message number on server */
276     void *data;                   /* driver-specific data */
277
278     char *maildir_flags;          /* unknown maildir flags */
279 } HEADER;
280
281 DO_INIT(address_t, address);
282 void address_wipe(address_t *);
283
284 DO_NEW(address_t, address);
285 DO_DELETE(address_t, address);
286 DO_SLIST(address_t, address);
287
288
289 #endif /* MUTT_LIB_MIME_MIME_TYPES_H */