160a7c9a6d7f2485b9793f54c7bc3b0e084868d5
[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 #include <stdio.h>
35
36 #include "mime-types.h"
37
38 extern const char MimeSpecials[];
39 extern const char *BodyTypes[];
40 extern const char *BodyEncodings[];
41
42 /* MIME encoding/decoding global vars */
43
44 #define is_multipart(x) \
45     ((x)->type == TYPEMULTIPART \
46      || ((x)->type == TYPEMESSAGE && (!strcasecmp((x)->subtype, "rfc822") \
47                                       || !strcasecmp((x)->subtype, "news"))))
48 #define TYPE(X) ((X->type == TYPEOTHER) && (X->xtype != NULL) ? X->xtype : BodyTypes[(X->type)])
49 #define ENCODING(X) BodyEncodings[(X)]
50
51 /****************************************************************************/
52 /* RFC 822                                                                  */
53 /*                Standard for ARPA Internet Text Messages                  */
54 /****************************************************************************/
55
56 extern const char RFC822Specials[];
57
58 ssize_t mutt_read_rfc822_line(FILE*, char**, ssize_t*);
59 LIST *mutt_parse_references(char *, int);
60 int mutt_check_encoding(const char *);
61 int mutt_check_mime_type(const char *);
62 void mutt_parse_content_type(char *, BODY *);
63 BODY *mutt_read_mime_header (FILE *, int);
64 void mutt_parse_part(FILE *, BODY *);
65 BODY *mutt_parse_messageRFC822(FILE *, BODY *);
66 BODY *mutt_parse_multipart(FILE *, const char *, off_t, int);
67 void mutt_parse_rfc822_line(ENVELOPE *, HEADER *, char *line, char *p,
68                            short user_hdrs, short weed, short do_2047,
69                            LIST **);
70
71 /*** addresses ***/
72
73 address_t *address_dup(address_t *addr);
74 address_t *address_list_dup(address_t *addr);
75 void rfc822_qualify(address_t *, const char *);
76
77 address_t *rfc822_parse_adrlist(address_t *, const char *s);
78
79 ssize_t rfc822_write_address(char *, ssize_t, address_t *, int);
80 ssize_t rfc822_write_address_single(char *, ssize_t, address_t *, int);
81 ssize_t rfc822_strcpy(char *, ssize_t, const char *, const char *);
82
83 /****************************************************************************/
84 /* RFC 2047                                                                 */
85 /*       MIME (Multipurpose Internet Mail Extensions) Part Three:           */
86 /*             Message Header Extensions for Non-ASCII Text                 */
87 /****************************************************************************/
88
89 char *mutt_choose_charset(const char *fromcode, const char *charsets,
90                           char *u, ssize_t ulen, char **d, ssize_t *dlen);
91
92 void rfc2047_encode_string(char **);
93 void rfc2047_encode_adrlist(address_t *, const char *);
94
95 void rfc2047_decode(char **);
96 void rfc2047_decode_adrlist(address_t *);
97 void rfc2047_decode_envelope(ENVELOPE* e);
98
99 /****************************************************************************/
100 /* RFC 2231                                                                 */
101 /*             MIME Parameter Value and Encoded Word Extensions:            */
102 /*               Character Sets, Languages, and Continuations               */
103 /****************************************************************************/
104
105 int  rfc2231_encode_string(char **);
106 void rfc2231_decode_parameters(PARAMETER **);
107
108 #endif /* MUTT_LIB_MIME_MIME_H */