diff options
| author | Simeon Simeonov | 2018-02-26 11:23:00 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2018-02-26 11:23:00 +0100 |
| commit | 0b3cbf57875fd692e4ba0b336fefa4bee1ed00dc (patch) | |
| tree | af916a30553c78ce9d4f2d8658656a175c5b6921 /libsylph/procmime.h | |
Initial commit for sylpheed 3.7.0
Diffstat (limited to 'libsylph/procmime.h')
| -rw-r--r-- | libsylph/procmime.h | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/libsylph/procmime.h b/libsylph/procmime.h new file mode 100644 index 0000000..0242d34 --- /dev/null +++ b/libsylph/procmime.h | |||
| @@ -0,0 +1,213 @@ | |||
| 1 | /* | ||
| 2 | * LibSylph -- E-Mail client library | ||
| 3 | * Copyright (C) 1999-2010 Hiroyuki Yamamoto | ||
| 4 | * | ||
| 5 | * This library is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU Lesser General Public | ||
| 7 | * License as published by the Free Software Foundation; either | ||
| 8 | * version 2.1 of the License, or (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This library 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 GNU | ||
| 13 | * Lesser General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU Lesser General Public | ||
| 16 | * License along with this library; if not, write to the Free Software | ||
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 18 | */ | ||
| 19 | |||
| 20 | #ifndef __PROCMIME_H__ | ||
| 21 | #define __PROCMIME_H__ | ||
| 22 | |||
| 23 | #ifdef HAVE_CONFIG_H | ||
| 24 | # include "config.h" | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #include <glib.h> | ||
| 28 | #include <stdio.h> | ||
| 29 | |||
| 30 | typedef struct _MimeType MimeType; | ||
| 31 | typedef struct _MailCap MailCap; | ||
| 32 | typedef struct _MimeInfo MimeInfo; | ||
| 33 | |||
| 34 | #include "procmsg.h" | ||
| 35 | #include "utils.h" | ||
| 36 | |||
| 37 | typedef enum | ||
| 38 | { | ||
| 39 | ENC_7BIT, | ||
| 40 | ENC_8BIT, | ||
| 41 | ENC_QUOTED_PRINTABLE, | ||
| 42 | ENC_BASE64, | ||
| 43 | ENC_X_UUENCODE, | ||
| 44 | ENC_UNKNOWN | ||
| 45 | } EncodingType; | ||
| 46 | |||
| 47 | typedef enum | ||
| 48 | { | ||
| 49 | MIME_TEXT, | ||
| 50 | MIME_TEXT_HTML, | ||
| 51 | MIME_MESSAGE_RFC822, | ||
| 52 | MIME_APPLICATION, | ||
| 53 | MIME_APPLICATION_OCTET_STREAM, | ||
| 54 | MIME_MULTIPART, | ||
| 55 | MIME_IMAGE, | ||
| 56 | MIME_AUDIO, | ||
| 57 | MIME_VIDEO, | ||
| 58 | MIME_UNKNOWN | ||
| 59 | } ContentType; | ||
| 60 | |||
| 61 | struct _MimeType | ||
| 62 | { | ||
| 63 | gchar *type; | ||
| 64 | gchar *sub_type; | ||
| 65 | |||
| 66 | gchar *extension; | ||
| 67 | }; | ||
| 68 | |||
| 69 | struct _MailCap | ||
| 70 | { | ||
| 71 | gchar *mime_type; | ||
| 72 | gchar *cmdline_fmt; | ||
| 73 | gboolean needs_terminal; | ||
| 74 | }; | ||
| 75 | |||
| 76 | /* | ||
| 77 | * An example of MimeInfo structure: | ||
| 78 | * | ||
| 79 | * multipart/mixed root <-+ parent | ||
| 80 | * | | ||
| 81 | * multipart/alternative children <-+ parent | ||
| 82 | * | | ||
| 83 | * text/plain children --+ | ||
| 84 | * | | ||
| 85 | * text/html next <-+ | ||
| 86 | * | ||
| 87 | * message/rfc822 next <-+ main | ||
| 88 | * | | ||
| 89 | * sub (capsulated message) | ||
| 90 | * | ||
| 91 | * image/jpeg next | ||
| 92 | */ | ||
| 93 | |||
| 94 | struct _MimeInfo | ||
| 95 | { | ||
| 96 | gchar *encoding; | ||
| 97 | |||
| 98 | EncodingType encoding_type; | ||
| 99 | ContentType mime_type; | ||
| 100 | |||
| 101 | gchar *content_type; | ||
| 102 | gchar *charset; | ||
| 103 | gchar *name; | ||
| 104 | gchar *boundary; | ||
| 105 | |||
| 106 | gchar *content_disposition; | ||
| 107 | gchar *filename; | ||
| 108 | |||
| 109 | glong fpos; | ||
| 110 | guint size; | ||
| 111 | guint content_size; | ||
| 112 | |||
| 113 | MimeInfo *main; | ||
| 114 | MimeInfo *sub; | ||
| 115 | |||
| 116 | MimeInfo *next; | ||
| 117 | MimeInfo *parent; | ||
| 118 | MimeInfo *children; | ||
| 119 | |||
| 120 | MimeInfo *plaintext; | ||
| 121 | gchar *sigstatus; | ||
| 122 | gchar *sigstatus_full; | ||
| 123 | |||
| 124 | gint level; | ||
| 125 | }; | ||
| 126 | |||
| 127 | #define IS_BOUNDARY(s, bnd, len) \ | ||
| 128 | (bnd && s[0] == '-' && s[1] == '-' && !strncmp(s + 2, bnd, len)) | ||
| 129 | |||
| 130 | /* MimeInfo handling */ | ||
| 131 | |||
| 132 | MimeInfo *procmime_mimeinfo_new (void); | ||
| 133 | void procmime_mimeinfo_free_all (MimeInfo *mimeinfo); | ||
| 134 | |||
| 135 | MimeInfo *procmime_mimeinfo_insert (MimeInfo *parent, | ||
| 136 | MimeInfo *mimeinfo); | ||
| 137 | #if 0 | ||
| 138 | void procmime_mimeinfo_replace (MimeInfo *old, | ||
| 139 | MimeInfo *new); | ||
| 140 | #endif | ||
| 141 | |||
| 142 | MimeInfo *procmime_mimeinfo_next (MimeInfo *mimeinfo); | ||
| 143 | |||
| 144 | MimeInfo *procmime_scan_message (MsgInfo *msginfo); | ||
| 145 | MimeInfo *procmime_scan_message_stream (FILE *fp); | ||
| 146 | void procmime_scan_multipart_message (MimeInfo *mimeinfo, | ||
| 147 | FILE *fp); | ||
| 148 | |||
| 149 | /* scan headers */ | ||
| 150 | |||
| 151 | void procmime_scan_encoding (MimeInfo *mimeinfo, | ||
| 152 | const gchar *encoding); | ||
| 153 | void procmime_scan_content_type (MimeInfo *mimeinfo, | ||
| 154 | const gchar *content_type); | ||
| 155 | void procmime_scan_content_type_str (const gchar *content_type, | ||
| 156 | gchar **mime_type, | ||
| 157 | gchar **charset, | ||
| 158 | gchar **name, | ||
| 159 | gchar **boundary); | ||
| 160 | void procmime_scan_content_type_partial (const gchar *content_type, | ||
| 161 | gint *total, | ||
| 162 | gchar **part_id, | ||
| 163 | gint *number); | ||
| 164 | void procmime_scan_content_disposition (MimeInfo *mimeinfo, | ||
| 165 | const gchar *content_disposition); | ||
| 166 | MimeInfo *procmime_scan_mime_header (FILE *fp); | ||
| 167 | |||
| 168 | FILE *procmime_decode_content (FILE *outfp, | ||
| 169 | FILE *infp, | ||
| 170 | MimeInfo *mimeinfo); | ||
| 171 | gint procmime_get_part (const gchar *outfile, | ||
| 172 | const gchar *infile, | ||
| 173 | MimeInfo *mimeinfo); | ||
| 174 | gint procmime_get_part_fp (const gchar *outfile, | ||
| 175 | FILE *infp, | ||
| 176 | MimeInfo *mimeinfo); | ||
| 177 | FILE *procmime_get_part_fp_fp (FILE *outfp, | ||
| 178 | FILE *infp, | ||
| 179 | MimeInfo *mimeinfo); | ||
| 180 | gint procmime_get_all_parts (const gchar *dir, | ||
| 181 | const gchar *infile, | ||
| 182 | MimeInfo *mimeinfo); | ||
| 183 | FILE *procmime_get_text_content (MimeInfo *mimeinfo, | ||
| 184 | FILE *infp, | ||
| 185 | const gchar *encoding); | ||
| 186 | FILE *procmime_get_first_text_content (MsgInfo *msginfo, | ||
| 187 | const gchar *encoding); | ||
| 188 | |||
| 189 | gboolean procmime_find_string_part (MimeInfo *mimeinfo, | ||
| 190 | const gchar *filename, | ||
| 191 | const gchar *str, | ||
| 192 | StrFindFunc find_func); | ||
| 193 | gboolean procmime_find_string (MsgInfo *msginfo, | ||
| 194 | const gchar *str, | ||
| 195 | StrFindFunc find_func); | ||
| 196 | |||
| 197 | gchar *procmime_get_part_file_name (MimeInfo *mimeinfo); | ||
| 198 | gchar *procmime_get_tmp_file_name (MimeInfo *mimeinfo); | ||
| 199 | gchar *procmime_get_tmp_file_name_for_user | ||
| 200 | (MimeInfo *mimeinfo); | ||
| 201 | |||
| 202 | ContentType procmime_scan_mime_type (const gchar *mime_type); | ||
| 203 | gchar *procmime_get_mime_type (const gchar *filename); | ||
| 204 | |||
| 205 | gint procmime_execute_open_file (const gchar *file, | ||
| 206 | const gchar *mime_type); | ||
| 207 | |||
| 208 | EncodingType procmime_get_encoding_for_charset (const gchar *charset); | ||
| 209 | EncodingType procmime_get_encoding_for_text_file(const gchar *file); | ||
| 210 | EncodingType procmime_get_encoding_for_str (const gchar *str); | ||
| 211 | const gchar *procmime_get_encoding_str (EncodingType encoding); | ||
| 212 | |||
| 213 | #endif /* __PROCMIME_H__ */ | ||
