ooops, make it compile again.
[apps/madmutt.git] / lib-mime / mime.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_H
31 #define MUTT_LIB_MIME_MIME_H
32
33 #include <stdlib.h>
34
35 #include <lib-lib/mem.h>
36 #include <lib-lib/buffer.h>
37 #include <lib-lib/list.h>
38
39 /* Content-Type */
40 enum {
41     TYPEOTHER,
42     TYPEAUDIO,
43     TYPEAPPLICATION,
44     TYPEIMAGE,
45     TYPEMESSAGE,
46     TYPEMODEL,
47     TYPEMULTIPART,
48     TYPETEXT,
49     TYPEVIDEO,
50     TYPEANY
51 };
52
53 /* Content-Transfer-Encoding */
54 enum {
55     ENCOTHER,
56     ENC7BIT,
57     ENC8BIT,
58     ENCQUOTEDPRINTABLE,
59     ENCBASE64,
60     ENCBINARY,
61     ENCUUENCODED
62 };
63
64 /* Content-Disposition values */
65 enum {
66     DISPINLINE,
67     DISPATTACH,
68     DISPFORMDATA
69 };
70
71 typedef struct parameter {
72     char *attribute;
73     char *value;
74     struct parameter *next;
75 } PARAMETER;
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 typedef struct envelope_t {
85     address_t *return_path;
86     address_t *from;
87     address_t *to;
88     address_t *cc;
89     address_t *bcc;
90     address_t *sender;
91     address_t *reply_to;
92     address_t *mail_followup_to;
93     char *list_post;              /* this stores a mailto URL, or nothing */
94     char *subject;
95     char *real_subj;              /* offset of the real subject */
96     char *message_id;
97     char *supersedes;
98     char *date;
99     char *x_label;
100     char *organization;
101 #ifdef USE_NNTP
102     char *newsgroups;
103     char *xref;
104     char *followup_to;
105     char *x_comment_to;
106 #endif
107     BUFFER *spam;
108     LIST *references;             /* message references (in reverse order) */
109     LIST *in_reply_to;            /* in-reply-to header content */
110     LIST *userhdrs;               /* user defined headers */
111     unsigned int irt_changed:1;   /* In-Reply-To changed to link/break threads */
112     unsigned int refs_changed:1;  /* References changed to break thread */
113 } ENVELOPE;
114
115
116 DO_INIT(address_t, address);
117 void address_wipe(address_t *);
118
119 DO_NEW(address_t, address);
120 DO_DELETE(address_t, address);
121 DO_SLIST(address_t, address);
122
123
124 extern const char MimeSpecials[];
125 extern const char *BodyTypes[];
126 extern const char *BodyEncodings[];
127
128 /* MIME encoding/decoding global vars */
129
130 #define is_multipart(x) \
131     ((x)->type == TYPEMULTIPART \
132      || ((x)->type == TYPEMESSAGE && (!strcasecmp((x)->subtype, "rfc822") \
133                                       || !strcasecmp((x)->subtype, "news"))))
134 #define TYPE(X) ((X->type == TYPEOTHER) && (X->xtype != NULL) ? X->xtype : BodyTypes[(X->type)])
135 #define ENCODING(X) BodyEncodings[(X)]
136
137 /****************************************************************************/
138 /* RFC 822                                                                  */
139 /*                Standard for ARPA Internet Text Messages                  */
140 /****************************************************************************/
141
142 address_t *address_dup(address_t *addr);
143 address_t *address_list_dup(address_t *addr);
144 void rfc822_qualify(address_t *, const char *);
145
146 address_t *rfc822_parse_adrlist(address_t *, const char *s);
147
148 ssize_t rfc822_write_address(char *, ssize_t, address_t *, int);
149 ssize_t rfc822_write_address_single(char *, ssize_t, address_t *, int);
150 ssize_t rfc822_strcpy(char *, ssize_t, const char *, const char *);
151
152 extern const char RFC822Specials[];
153
154 /****************************************************************************/
155 /* RFC 2047                                                                 */
156 /*       MIME (Multipurpose Internet Mail Extensions) Part Three:           */
157 /*             Message Header Extensions for Non-ASCII Text                 */
158 /****************************************************************************/
159
160 char *mutt_choose_charset(const char *fromcode, const char *charsets,
161                           char *u, size_t ulen, char **d, size_t *dlen);
162
163 void rfc2047_encode_string(char **);
164 void rfc2047_encode_adrlist(address_t *, const char *);
165
166 void rfc2047_decode(char **);
167 void rfc2047_decode_adrlist(address_t *);
168 void rfc2047_decode_envelope(ENVELOPE* e);
169
170 /****************************************************************************/
171 /* RFC 2231                                                                 */
172 /*             MIME Parameter Value and Encoded Word Extensions:            */
173 /*               Character Sets, Languages, and Continuations               */
174 /****************************************************************************/
175
176 int  rfc2231_encode_string(char **);
177 void rfc2231_decode_parameters(PARAMETER **);
178
179 #endif /* MUTT_LIB_MIME_MIME_H */