This commit was manufactured by cvs2svn to create tag 'LAST_STABLE'.
[claws.git] / src / procmime.h
blobededf13fe3c5927d0ac3804d8565cf1b234d58e8
1 /*
2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2001 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef __PROCMIME_H__
21 #define __PROCMIME_H__
23 #ifdef HAVE_CONFIG_H
24 # include "config.h"
25 #endif
27 #include <glib.h>
28 #include <stdio.h>
30 typedef struct _MimeType MimeType;
31 typedef struct _MimeInfo MimeInfo;
33 #include "procmsg.h"
35 typedef enum
37 ENC_7BIT,
38 ENC_8BIT,
39 ENC_BINARY,
40 ENC_QUOTED_PRINTABLE,
41 ENC_BASE64,
42 ENC_X_UUENCODE,
43 ENC_UNKNOWN
44 } EncodingType;
46 typedef enum
48 MIME_TEXT,
49 MIME_TEXT_HTML,
50 MIME_MESSAGE_RFC822,
51 MIME_APPLICATION,
52 MIME_APPLICATION_OCTET_STREAM,
53 MIME_MULTIPART,
54 MIME_IMAGE,
55 MIME_AUDIO,
56 MIME_TEXT_ENRICHED,
57 MIME_UNKNOWN
58 } ContentType;
60 struct _MimeType
62 gchar *type;
63 gchar *sub_type;
65 gchar *extension;
69 * An example of MimeInfo structure:
71 * multipart/mixed root <-+ parent
72 * |
73 * multipart/alternative children <-+ parent
74 * |
75 * text/plain children --+
76 * |
77 * text/html next <-+
79 * message/rfc822 next <-+ main
80 * |
81 * sub (capsulated message)
83 * image/jpeg next
86 struct _MimeInfo
88 gchar *encoding;
90 EncodingType encoding_type;
91 ContentType mime_type;
93 gchar *content_type;
94 gchar *charset;
95 gchar *name;
96 gchar *boundary;
98 gchar *content_disposition;
99 gchar *filename;
101 glong fpos;
102 guint size;
104 MimeInfo *main;
105 MimeInfo *sub;
107 MimeInfo *next;
108 MimeInfo *parent;
109 MimeInfo *children;
111 #if USE_GPGME
112 MimeInfo *plaintext;
113 gchar *plaintextfile;
114 gchar *sigstatus;
115 gchar *sigstatus_full;
116 #endif
118 gint level;
121 #define IS_BOUNDARY(s, bnd, len) \
122 (bnd && s[0] == '-' && s[1] == '-' && !strncmp(s + 2, bnd, len))
124 /* MimeInfo handling */
126 MimeInfo *procmime_mimeinfo_new (void);
127 void procmime_mimeinfo_free_all (MimeInfo *mimeinfo);
129 MimeInfo *procmime_mimeinfo_insert (MimeInfo *parent,
130 MimeInfo *mimeinfo);
131 void procmime_mimeinfo_replace (MimeInfo *old,
132 MimeInfo *new);
134 MimeInfo *procmime_mimeinfo_next (MimeInfo *mimeinfo);
136 MimeInfo *procmime_scan_message (MsgInfo *msginfo);
137 void procmime_scan_multipart_message (MimeInfo *mimeinfo,
138 FILE *fp);
140 /* scan headers */
142 void procmime_scan_encoding (MimeInfo *mimeinfo,
143 const gchar *encoding);
144 void procmime_scan_content_type (MimeInfo *mimeinfo,
145 const gchar *content_type);
146 void procmime_scan_content_disposition (MimeInfo *mimeinfo,
147 const gchar *content_disposition);
148 void procmime_scan_content_description (MimeInfo *mimeinfo,
149 const gchar *content_description);
150 void procmime_scan_subject (MimeInfo *mimeinfo,
151 const gchar *subject);
152 MimeInfo *procmime_scan_mime_header (FILE *fp);
154 FILE *procmime_decode_content (FILE *outfp,
155 FILE *infp,
156 MimeInfo *mimeinfo);
157 gint procmime_get_part (const gchar *outfile,
158 const gchar *infile,
159 MimeInfo *mimeinfo);
160 FILE *procmime_get_text_content (MimeInfo *mimeinfo,
161 FILE *infp);
162 FILE *procmime_get_first_text_content (MsgInfo *msginfo);
164 gboolean procmime_find_string_part (MimeInfo *mimeinfo,
165 const gchar *filename,
166 const gchar *str,
167 gboolean case_sens);
168 gboolean procmime_find_string (MsgInfo *msginfo,
169 const gchar *str,
170 gboolean case_sens);
172 gchar *procmime_get_tmp_file_name (MimeInfo *mimeinfo);
174 ContentType procmime_scan_mime_type (const gchar *mime_type);
175 gchar *procmime_get_mime_type (const gchar *filename);
177 GList *procmime_get_mime_type_list (void);
179 EncodingType procmime_get_encoding_for_charset (const gchar *charset);
180 EncodingType procmime_get_encoding_for_file (const gchar *file);
181 const gchar *procmime_get_encoding_str (EncodingType encoding);
183 void renderer_read_config(void);
184 void renderer_write_config(void);
186 #endif /* __PROCMIME_H__ */