turn charset into a lua package as well.
[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  * Copyright notice from original mutt:
21  * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
22  * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
23  *
24  * This file is part of mutt-ng, see http://www.muttng.org/.
25  * It's licensed under the GNU General Public License,
26  * please see the file GPL in the top level source directory.
27  */
28
29 #ifndef MUTT_LIB_MIME_MIME_H
30 #define MUTT_LIB_MIME_MIME_H
31
32 #include "mime-types.h"
33 #include "mime-token.h"
34
35 extern const char MimeSpecials[];
36 extern const char *BodyTypes[];
37 extern const char *BodyEncodings[];
38
39 /* MIME encoding/decoding global vars */
40
41 #define is_multipart(x) \
42     ((x)->type == TYPEMULTIPART \
43      || ((x)->type == TYPEMESSAGE && \
44          ((!mime_which_token((x)->subtype, -1) == MIME_RFC822) \
45          || !mime_which_token((x)->subtype, -1) == MIME_NEWS)))
46
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 1524                                                                 */
52 /*                   A User Agent Configuration Mechanism                   */
53 /*                  For Multimedia Mail Format Information                  */
54 /****************************************************************************/
55
56 typedef struct rfc1524_entry {
57     char *command;
58     char *testcommand;
59     char *composecommand;
60     char *composetypecommand;
61     char *editcommand;
62     char *printcommand;
63     char *nametemplate;
64     char *convert;
65
66     unsigned needsterminal:1; /* endwin() and system */
67     unsigned copiousoutput:1; /* needs pager, basically */
68 } rfc1524_entry;
69
70 DO_INIT(rfc1524_entry, rfc1524_entry);
71 void rfc1524_entry_wipe(rfc1524_entry *);
72
73 DO_NEW(rfc1524_entry, rfc1524_entry);
74 DO_DELETE(rfc1524_entry, rfc1524_entry);
75
76 int rfc1524_expand_command(BODY *, const char *, const char *, char *, int);
77 int rfc1524_expand_filename(char *, char *, char *, ssize_t);
78 int rfc1524_mailcap_lookup(BODY *, char *, rfc1524_entry *, int);
79 int rfc1524_mailcap_isneeded(BODY *);
80
81 /****************************************************************************/
82 /* RFC 822                                                                  */
83 /*                Standard for ARPA Internet Text Messages                  */
84 /****************************************************************************/
85
86 extern const char RFC822Specials[];
87
88 ssize_t mutt_read_rfc822_line(FILE*, char**, ssize_t*);
89 string_list_t *mutt_parse_references(char *, int);
90 int mutt_check_encoding(const char *);
91 int mutt_check_mime_type(const char *);
92 void mutt_parse_content_type(char *, BODY *);
93 BODY *mutt_read_mime_header (FILE *, int);
94 void mutt_parse_part(FILE *, BODY *);
95 BODY *mutt_parse_messageRFC822(FILE *, BODY *);
96 BODY *mutt_parse_multipart(FILE *, const char *, off_t, int);
97 string_list_t **mutt_parse_rfc822_line(ENVELOPE *, HEADER *, char *line, char *p,
98                                        short weed, short do_2047, string_list_t **);
99 ENVELOPE *mutt_read_rfc822_header(FILE *, HEADER *, short, short);
100 int mutt_count_body_parts (HEADER *hdr, int flags);
101
102 int mutt_is_message_type(BODY *);
103 int mutt_is_multipart_encrypted(BODY *);
104 int mutt_is_multipart_signed(BODY *);
105 int mutt_is_application_pgp(BODY *);
106 int mutt_is_application_smime(BODY *);
107 int mutt_is_text_part(BODY *);
108 time_t mutt_parse_date(const char *, HEADER *);
109
110 /*** addresses ***/
111
112 address_t *mutt_parse_adrlist(address_t *, const char *);
113 address_t *address_dup(const address_t *addr);
114 address_t *address_list_dup(const address_t *addr);
115
116 void address_list_uniq(address_t *);
117 void rfc822_qualify(address_t *, const char *);
118
119 address_t *rfc822_parse_adrlist(address_t *, const char *s);
120
121 ssize_t rfc822_addrcat(char *, ssize_t, address_t *, int);
122 ssize_t rfc822_addrcpy(char *, ssize_t, address_t *, int);
123 ssize_t rfc822_strcpy(char *, ssize_t, const char *, const char *);
124
125 /****************************************************************************/
126 /* RFC 2047                                                                 */
127 /*       MIME (Multipurpose Internet Mail Extensions) Part Three:           */
128 /*             Message Header Extensions for Non-ASCII Text                 */
129 /****************************************************************************/
130
131 char *mutt_choose_charset(const char *fromcode, const char *charsets,
132                           char *u, ssize_t ulen, char **d, ssize_t *dlen);
133
134 void rfc2047_encode_string(char **);
135 void rfc2047_encode_adrlist(address_t *, const char *);
136
137 void rfc2047_decode(char **);
138 void rfc2047_decode_adrlist(address_t *);
139 void rfc2047_decode_envelope(ENVELOPE* e);
140
141 /****************************************************************************/
142 /* RFC 2231                                                                 */
143 /*             MIME Parameter Value and Encoded Word Extensions:            */
144 /*               Character Sets, Languages, and Continuations               */
145 /****************************************************************************/
146
147 int  rfc2231_encode_string(char **);
148 void rfc2231_decode_parameters(parameter_t **);
149
150 #endif /* MUTT_LIB_MIME_MIME_H */