move mutt_get_parameter -> parameter_getval into mime.c
[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 <stdlib.h>
33 #include <stdio.h>
34
35 #include "mime-types.h"
36 #include "mime-token.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 && \
47          ((!mime_which_token((x)->subtype, -1) == MIME_RFC822) \
48          || !mime_which_token((x)->subtype, -1) == MIME_NEWS)))
49
50 #define TYPE(X) ((X->type == TYPEOTHER) && (X->xtype != NULL) ? X->xtype : BodyTypes[(X->type)])
51 #define ENCODING(X) BodyEncodings[(X)]
52
53 int url_parse_mailto(ENVELOPE *e, char **body, const char *src);
54
55 /****************************************************************************/
56 /* RFC 1524                                                                 */
57 /*                   A User Agent Configuration Mechanism                   */
58 /*                  For Multimedia Mail Format Information                  */
59 /****************************************************************************/
60
61 typedef struct rfc1524_entry {
62     char *command;
63     char *testcommand;
64     char *composecommand;
65     char *composetypecommand;
66     char *editcommand;
67     char *printcommand;
68     char *nametemplate;
69     char *convert;
70
71     unsigned needsterminal:1; /* endwin() and system */
72     unsigned copiousoutput:1; /* needs pager, basically */
73 } rfc1524_entry;
74
75 DO_INIT(rfc1524_entry, rfc1524_entry);
76 void rfc1524_entry_wipe(rfc1524_entry *);
77
78 DO_NEW(rfc1524_entry, rfc1524_entry);
79 DO_DELETE(rfc1524_entry, rfc1524_entry);
80
81 int rfc1524_expand_command(BODY *, const char *, const char *, char *, int);
82 int rfc1524_expand_filename(char *, char *, char *, ssize_t);
83 int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
84
85 /****************************************************************************/
86 /* RFC 822                                                                  */
87 /*                Standard for ARPA Internet Text Messages                  */
88 /****************************************************************************/
89
90 extern const char RFC822Specials[];
91
92 ssize_t mutt_read_rfc822_line(FILE*, char**, ssize_t*);
93 string_list_t *mutt_parse_references(char *, int);
94 int mutt_check_encoding(const char *);
95 int mutt_check_mime_type(const char *);
96 void mutt_parse_content_type(char *, BODY *);
97 BODY *mutt_read_mime_header (FILE *, int);
98 void mutt_parse_part(FILE *, BODY *);
99 BODY *mutt_parse_messageRFC822(FILE *, BODY *);
100 BODY *mutt_parse_multipart(FILE *, const char *, off_t, int);
101 string_list_t **mutt_parse_rfc822_line(ENVELOPE *, HEADER *, char *line, char *p,
102                                        short weed, short do_2047, string_list_t **);
103 ENVELOPE *mutt_read_rfc822_header(FILE *, HEADER *, short, short);
104 int mutt_count_body_parts (HEADER *hdr, int flags);
105
106 /*** addresses ***/
107
108 address_t *mutt_parse_adrlist(address_t *, const char *);
109 address_t *address_dup(const address_t *addr);
110 address_t *address_list_dup(const address_t *addr);
111 void rfc822_qualify(address_t *, const char *);
112
113 address_t *rfc822_parse_adrlist(address_t *, const char *s);
114
115 ssize_t rfc822_write_address(char *, ssize_t, address_t *, int);
116 ssize_t rfc822_write_address_single(char *, ssize_t, address_t *, int);
117 ssize_t rfc822_strcpy(char *, ssize_t, const char *, const char *);
118
119 /****************************************************************************/
120 /* RFC 2047                                                                 */
121 /*       MIME (Multipurpose Internet Mail Extensions) Part Three:           */
122 /*             Message Header Extensions for Non-ASCII Text                 */
123 /****************************************************************************/
124
125 char *mutt_choose_charset(const char *fromcode, const char *charsets,
126                           char *u, ssize_t ulen, char **d, ssize_t *dlen);
127
128 void rfc2047_encode_string(char **);
129 void rfc2047_encode_adrlist(address_t *, const char *);
130
131 void rfc2047_decode(char **);
132 void rfc2047_decode_adrlist(address_t *);
133 void rfc2047_decode_envelope(ENVELOPE* e);
134
135 /****************************************************************************/
136 /* RFC 2231                                                                 */
137 /*             MIME Parameter Value and Encoded Word Extensions:            */
138 /*               Character Sets, Languages, and Continuations               */
139 /****************************************************************************/
140
141 int  rfc2231_encode_string(char **);
142 void rfc2231_decode_parameters(PARAMETER **);
143
144 #endif /* MUTT_LIB_MIME_MIME_H */