1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2000 Ximian Inc.
5 * Authors: Michael Zucchi <notzed@ximian.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of version 2 of the GNU Lesser General Public
9 * License as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #ifndef _CAMEL_MIME_FILTER_BESTENC_H
23 #define _CAMEL_MIME_FILTER_BESTENC_H
25 #include <camel/camel-mime-filter.h>
26 #include <camel/camel-mime-part.h>
27 #include <camel/camel-charset-map.h>
29 #define CAMEL_MIME_FILTER_BESTENC(obj) CAMEL_CHECK_CAST (obj, camel_mime_filter_bestenc_get_type (), CamelMimeFilterBestenc)
30 #define CAMEL_MIME_FILTER_BESTENC_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_mime_filter_bestenc_get_type (), CamelMimeFilterBestencClass)
31 #define CAMEL_IS_MIME_FILTER_BESTENC(obj) CAMEL_CHECK_TYPE (obj, camel_mime_filter_bestenc_get_type ())
35 typedef struct _CamelMimeFilterBestencClass CamelMimeFilterBestencClass;
37 typedef enum _CamelBestencRequired {
38 CAMEL_BESTENC_GET_ENCODING = 1<<0,
39 CAMEL_BESTENC_GET_CHARSET = 1<<1,
41 /* do we treat 'lf' as if it were crlf? */
42 CAMEL_BESTENC_LF_IS_CRLF = 1<<8,
43 /* do we not allow "From " to appear at the start of a line in any part? */
44 CAMEL_BESTENC_NO_FROM = 1<<9,
45 } CamelBestencRequired;
47 typedef enum _CamelBestencEncoding {
52 /* is the content stream to be treated as text? */
53 CAMEL_BESTENC_TEXT = 1<<8,
54 } CamelBestencEncoding;
56 struct _CamelMimeFilterBestenc {
57 CamelMimeFilter parent;
59 unsigned int flags; /* our creation flags, see above */
61 unsigned int count0; /* count of NUL characters */
62 unsigned int count8; /* count of 8 bit characters */
63 unsigned int total; /* total characters read */
65 unsigned int lastc; /* the last character read */
66 int crlfnoorder; /* if crlf's occured where they shouldn't have */
68 int startofline; /* are we at the start of a new line? */
71 char fromsave[6]; /* save a few characters if we found an \n near the end of the buffer */
72 int hadfrom; /* did we encounter a "\nFrom " in the data? */
74 unsigned int countline; /* current count of characters on a given line */
75 unsigned int maxline; /* max length of any line */
77 CamelCharset charset; /* used to determine the best charset to use */
80 struct _CamelMimeFilterBestencClass {
81 CamelMimeFilterClass parent_class;
84 CamelType camel_mime_filter_bestenc_get_type (void);
85 CamelMimeFilterBestenc *camel_mime_filter_bestenc_new (unsigned int flags);
88 CamelTransferEncoding camel_mime_filter_bestenc_get_best_encoding(CamelMimeFilterBestenc *filter, CamelBestencEncoding required);
89 const char * camel_mime_filter_bestenc_get_best_charset(CamelMimeFilterBestenc *filter);
90 void camel_mime_filter_bestenc_set_flags(CamelMimeFilterBestenc *filter, unsigned int flags);
94 #endif /* ! _CAMEL_MIME_FILTER_BESTENC_H */