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.
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.
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,
17 * Copyright © 2006 Pierre Habouzit
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>
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.
29 #ifndef MUTT_LIB_MIME_MIME_H
30 #define MUTT_LIB_MIME_MIME_H
32 #include "mime-types.h"
33 #include "mime-token.h"
35 #include <lib-lua/lib-lua.h>
38 extern const char MimeSpecials[];
39 extern const char *BodyTypes[];
40 extern const char *BodyEncodings[];
41 extern rx_t *SpamList, *NoSpamList;
43 extern string_list_t *AlternativeOrderList;
44 extern string_list_t *AutoViewList;
45 extern string_list_t *HeaderOrderList;
46 extern string_list_t *Ignore;
47 extern string_list_t *MimeLookupList;
48 extern string_list_t *UnIgnore;
50 /* MIME encoding/decoding global vars */
52 #define is_multipart(x) \
53 ((x)->type == TYPEMULTIPART \
54 || ((x)->type == TYPEMESSAGE && \
55 ((!mime_which_token((x)->subtype, -1) == MIME_RFC822) \
56 || !mime_which_token((x)->subtype, -1) == MIME_NEWS)))
58 #define TYPE(X) ((X->type == TYPEOTHER) && (X->xtype != NULL) ? X->xtype : BodyTypes[(X->type)])
59 #define ENCODING(X) BodyEncodings[(X)]
61 /****************************************************************************/
63 /* A User Agent Configuration Mechanism */
64 /* For Multimedia Mail Format Information */
65 /****************************************************************************/
67 typedef struct rfc1524_entry {
71 char *composetypecommand;
77 unsigned needsterminal:1; /* endwin() and system */
78 unsigned copiousoutput:1; /* needs pager, basically */
81 DO_INIT(rfc1524_entry, rfc1524_entry);
82 void rfc1524_entry_wipe(rfc1524_entry *);
84 DO_NEW(rfc1524_entry, rfc1524_entry);
85 DO_DELETE(rfc1524_entry, rfc1524_entry);
87 int rfc1524_expand_command(BODY *, const char *, const char *, char *, int);
88 int rfc1524_expand_filename(char *, char *, char *, ssize_t);
89 int rfc1524_mailcap_lookup(BODY *, char *, rfc1524_entry *, int);
90 int rfc1524_mailcap_isneeded(BODY *);
92 /****************************************************************************/
94 /* Standard for ARPA Internet Text Messages */
95 /****************************************************************************/
97 extern const char RFC822Specials[];
99 ssize_t mutt_read_rfc822_line(FILE*, char**, ssize_t*);
100 string_list_t *mutt_parse_references(char *, int);
101 int mutt_check_encoding(const char *);
102 int mutt_check_mime_type(const char *);
103 void mutt_parse_content_type(char *, BODY *);
104 BODY *mutt_read_mime_header (FILE *, int);
105 void mutt_parse_part(FILE *, BODY *);
106 BODY *mutt_parse_messageRFC822(FILE *, BODY *);
107 BODY *mutt_parse_multipart(FILE *, const char *, off_t, int);
108 string_list_t **mutt_parse_rfc822_line(ENVELOPE *, HEADER *, char *line, char *p,
109 short weed, short do_2047, string_list_t **);
110 ENVELOPE *mutt_read_rfc822_header(FILE *, HEADER *, short, short);
111 int mutt_count_body_parts (HEADER *hdr, int flags);
113 int mutt_is_message_type(BODY *);
114 int mutt_is_multipart_encrypted(BODY *);
115 int mutt_is_multipart_signed(BODY *);
116 int mutt_is_application_pgp(BODY *);
117 int mutt_is_application_smime(BODY *);
118 int mutt_is_text_part(BODY *);
119 time_t mutt_parse_date(const char *, HEADER *);
123 address_t *mutt_parse_adrlist(address_t *, const char *);
124 address_t *address_dup(const address_t *addr);
125 address_t *address_list_dup(const address_t *addr);
127 void address_list_uniq(address_t *);
128 void rfc822_qualify(address_t *, const char *);
130 address_t *rfc822_parse_adrlist(address_t *, const char *s);
132 ssize_t rfc822_addrcat(char *, ssize_t, address_t *, int);
133 ssize_t rfc822_addrcpy(char *, ssize_t, address_t *, int);
134 ssize_t rfc822_strcpy(char *, ssize_t, const char *, const char *);
136 /****************************************************************************/
138 /* MIME (Multipurpose Internet Mail Extensions) Part Three: */
139 /* Message Header Extensions for Non-ASCII Text */
140 /****************************************************************************/
142 char *mutt_choose_charset(const char *fromcode, const char *charsets,
143 char *u, ssize_t ulen, char **d, ssize_t *dlen);
145 void rfc2047_encode_string(char **);
146 void rfc2047_encode_adrlist(address_t *, const char *);
148 void rfc2047_decode(char **);
149 void rfc2047_decode_adrlist(address_t *);
150 void rfc2047_decode_envelope(ENVELOPE* e);
152 /****************************************************************************/
154 /* MIME Parameter Value and Encoded Word Extensions: */
155 /* Character Sets, Languages, and Continuations */
156 /****************************************************************************/
158 int rfc2231_encode_string(char **);
159 void rfc2231_decode_parameters(parameter_t **);
161 #endif /* MUTT_LIB_MIME_MIME_H */