f2e7b6afb264da12957b2bcc1cb93377938e6843
[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) 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
34 /* Content-Type */
35 enum {
36     TYPEOTHER,
37     TYPEAUDIO,
38     TYPEAPPLICATION,
39     TYPEIMAGE,
40     TYPEMESSAGE,
41     TYPEMODEL,
42     TYPEMULTIPART,
43     TYPETEXT,
44     TYPEVIDEO,
45     TYPEANY
46 };
47
48 /* Content-Transfer-Encoding */
49 enum {
50     ENCOTHER,
51     ENC7BIT,
52     ENC8BIT,
53     ENCQUOTEDPRINTABLE,
54     ENCBASE64,
55     ENCBINARY,
56     ENCUUENCODED
57 };
58
59 /* Content-Disposition values */
60 enum {
61     DISPINLINE,
62     DISPATTACH,
63     DISPFORMDATA
64 };
65
66 typedef struct parameter {
67     char *attribute;
68     char *value;
69     struct parameter *next;
70 } PARAMETER;
71
72 extern const char MimeSpecials[];
73 extern const char *BodyTypes[];
74 extern const char *BodyEncodings[];
75
76 /* MIME encoding/decoding global vars */
77
78 #define is_multipart(x) \
79     ((x)->type == TYPEMULTIPART \
80      || ((x)->type == TYPEMESSAGE && (!strcasecmp((x)->subtype, "rfc822") \
81                                       || !strcasecmp((x)->subtype, "news"))))
82 #define TYPE(X) ((X->type == TYPEOTHER) && (X->xtype != NULL) ? X->xtype : BodyTypes[(X->type)])
83 #define ENCODING(X) BodyEncodings[(X)]
84
85 /****************************************************************************/
86 /* RFC 822                                                                  */
87 /*                Standard for ARPA Internet Text Messages                  */
88 /****************************************************************************/
89
90 /* possible values for RFC822Error */
91 enum {
92     ERR_MEMORY = 1,
93     ERR_MISMATCH_PAREN,
94     ERR_MISMATCH_QUOTE,
95     ERR_BAD_ROUTE,
96     ERR_BAD_ROUTE_ADDR,
97     ERR_BAD_ADDR_SPEC
98 };
99
100 typedef struct address_t {
101     char *personal;               /* real name of address */
102     char *mailbox;                /* mailbox and host address */
103     int group;                    /* group mailbox? */
104     struct address_t *next;
105 } address_t;
106
107 void rfc822_free_address(address_t **);
108 void rfc822_qualify(address_t *, const char *);
109 address_t *rfc822_parse_adrlist(address_t *, const char *s);
110 address_t *rfc822_cpy_adr(address_t * addr);
111 address_t *rfc822_cpy_adr_real(address_t * addr);
112 address_t *rfc822_append(address_t ** a, address_t * b);
113 void rfc822_write_address(char *, size_t, address_t *, int);
114 void rfc822_write_address_single(char *, size_t, address_t *, int);
115 void rfc822_cat(char *, size_t, const char *, const char *);
116
117 extern int RFC822Error;
118 extern const char *RFC822Errors[];
119 extern const char RFC822Specials[];
120
121 #define rfc822_error(x) RFC822Errors[x]
122 #define rfc822_new_address() calloc(1,sizeof(address_t))
123
124 /****************************************************************************/
125 /* RFC 2231                                                                 */
126 /*             MIME Parameter Value and Encoded Word Extensions:            */
127 /*               Character Sets, Languages, and Continuations               */
128 /****************************************************************************/
129
130 int  rfc2231_encode_string(char **);
131 void rfc2231_decode_parameters(PARAMETER **);
132
133 #endif /* MUTT_LIB_MIME_MIME_H */