498473cb395892eb31e76b58a8c4ae124365e19e
[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 "mime-types.h"
36
37 extern const char MimeSpecials[];
38 extern const char *BodyTypes[];
39 extern const char *BodyEncodings[];
40
41 /* MIME encoding/decoding global vars */
42
43 #define is_multipart(x) \
44     ((x)->type == TYPEMULTIPART \
45      || ((x)->type == TYPEMESSAGE && (!strcasecmp((x)->subtype, "rfc822") \
46                                       || !strcasecmp((x)->subtype, "news"))))
47 #define TYPE(X) ((X->type == TYPEOTHER) && (X->xtype != NULL) ? X->xtype : BodyTypes[(X->type)])
48 #define ENCODING(X) BodyEncodings[(X)]
49
50 /****************************************************************************/
51 /* RFC 822                                                                  */
52 /*                Standard for ARPA Internet Text Messages                  */
53 /****************************************************************************/
54
55 address_t *address_dup(address_t *addr);
56 address_t *address_list_dup(address_t *addr);
57 void rfc822_qualify(address_t *, const char *);
58
59 address_t *rfc822_parse_adrlist(address_t *, const char *s);
60
61 ssize_t rfc822_write_address(char *, ssize_t, address_t *, int);
62 ssize_t rfc822_write_address_single(char *, ssize_t, address_t *, int);
63 ssize_t rfc822_strcpy(char *, ssize_t, const char *, const char *);
64
65 extern const char RFC822Specials[];
66
67 /****************************************************************************/
68 /* RFC 2047                                                                 */
69 /*       MIME (Multipurpose Internet Mail Extensions) Part Three:           */
70 /*             Message Header Extensions for Non-ASCII Text                 */
71 /****************************************************************************/
72
73 char *mutt_choose_charset(const char *fromcode, const char *charsets,
74                           char *u, ssize_t ulen, char **d, ssize_t *dlen);
75
76 void rfc2047_encode_string(char **);
77 void rfc2047_encode_adrlist(address_t *, const char *);
78
79 void rfc2047_decode(char **);
80 void rfc2047_decode_adrlist(address_t *);
81 void rfc2047_decode_envelope(ENVELOPE* e);
82
83 /****************************************************************************/
84 /* RFC 2231                                                                 */
85 /*             MIME Parameter Value and Encoded Word Extensions:            */
86 /*               Character Sets, Languages, and Continuations               */
87 /****************************************************************************/
88
89 int  rfc2231_encode_string(char **);
90 void rfc2231_decode_parameters(PARAMETER **);
91
92 #endif /* MUTT_LIB_MIME_MIME_H */