initial message templates support
[claws.git] / src / procmime.h
blobe99aba648b5c5fe84c7c163e68886fae218d7e11
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_QUOTED_PRINTABLE,
40 ENC_BASE64,
41 ENC_X_UUENCODE,
42 ENC_UNKNOWN
43 } EncodingType;
45 typedef enum
47 MIME_TEXT,
48 MIME_TEXT_HTML,
49 MIME_MESSAGE_RFC822,
50 MIME_APPLICATION,
51 MIME_APPLICATION_OCTET_STREAM,
52 MIME_MULTIPART,
53 MIME_IMAGE,
54 MIME_AUDIO,
55 MIME_UNKNOWN
56 } ContentType;
58 struct _MimeType
60 gchar *type;
61 gchar *sub_type;
63 gchar *extension;
66 struct _MimeInfo
68 gchar *encoding;
70 EncodingType encoding_type;
71 ContentType mime_type;
73 gchar *content_type;
74 gchar *charset;
75 gchar *name;
76 gchar *boundary;
78 gchar *content_disposition;
79 gchar *filename;
81 glong fpos;
82 guint size;
84 MimeInfo *main;
85 MimeInfo *sub;
87 MimeInfo *next;
88 MimeInfo *parent;
89 MimeInfo *children;
91 #if USE_GPGME
92 MimeInfo *plaintext;
93 gchar *plaintextfile;
94 gchar *sigstatus;
95 gchar *sigstatus_full;
96 #endif
98 gint level;
101 #define IS_BOUNDARY(s, bnd, len) \
102 (bnd && s[0] == '-' && s[1] == '-' && !strncmp(s + 2, bnd, len))
104 /* MimeInfo handling */
106 MimeInfo *procmime_mimeinfo_new (void);
107 void procmime_mimeinfo_free (MimeInfo *mimeinfo);
108 void procmime_mimeinfo_free_all (MimeInfo *mimeinfo);
110 MimeInfo *procmime_mimeinfo_insert (MimeInfo *parent,
111 MimeInfo *mimeinfo);
113 MimeInfo *procmime_scan_message (MsgInfo *msginfo);
114 void procmime_scan_multipart_message (MimeInfo *mimeinfo,
115 FILE *fp);
117 /* scan headers */
119 void procmime_scan_encoding (MimeInfo *mimeinfo,
120 const gchar *encoding);
121 void procmime_scan_content_type (MimeInfo *mimeinfo,
122 const gchar *content_type);
123 void procmime_scan_content_disposition (MimeInfo *mimeinfo,
124 const gchar *content_disposition);
125 MimeInfo *procmime_scan_mime_header (FILE *fp);
127 FILE *procmime_decode_content (FILE *outfp,
128 FILE *infp,
129 MimeInfo *mimeinfo);
130 gint procmime_get_part (const gchar *outfile,
131 const gchar *infile,
132 MimeInfo *mimeinfo);
133 FILE *procmime_get_text_part (MsgInfo *msginfo);
135 gchar *procmime_get_tmp_file_name (MimeInfo *mimeinfo);
137 ContentType procmime_scan_mime_type (const gchar *mime_type);
138 gchar *procmime_get_mime_type (const gchar *filename);
140 GList *procmime_get_mime_type_list (void);
142 EncodingType procmime_get_encoding_for_charset (const gchar *charset);
143 const gchar *procmime_get_encoding_str (EncodingType encoding);
145 #endif /* __PROCMIME_H__ */