Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / camel-mime-filter-bestenc.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  *  Copyright (C) 2000 Ximian Inc.
4  *
5  *  Authors: Michael Zucchi <notzed@ximian.com>
6  *
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.
10  *
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.
15  *
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.
20  */
21
22 #ifndef _CAMEL_MIME_FILTER_BESTENC_H
23 #define _CAMEL_MIME_FILTER_BESTENC_H
24
25 #include <camel/camel-mime-filter.h>
26 #include <camel/camel-mime-part.h>
27 #include <camel/camel-charset-map.h>
28
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 ())
32
33 G_BEGIN_DECLS
34
35 typedef struct _CamelMimeFilterBestencClass CamelMimeFilterBestencClass;
36
37 typedef enum _CamelBestencRequired {
38         CAMEL_BESTENC_GET_ENCODING = 1<<0,
39         CAMEL_BESTENC_GET_CHARSET = 1<<1,
40
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;
46
47 typedef enum _CamelBestencEncoding {
48         CAMEL_BESTENC_7BIT,
49         CAMEL_BESTENC_8BIT,
50         CAMEL_BESTENC_BINARY,
51         
52         /* is the content stream to be treated as text? */
53         CAMEL_BESTENC_TEXT = 1<<8,
54 } CamelBestencEncoding;
55
56 struct _CamelMimeFilterBestenc {
57         CamelMimeFilter parent;
58
59         unsigned int flags;     /* our creation flags, see above */
60
61         unsigned int count0;    /* count of NUL characters */
62         unsigned int count8;    /* count of 8 bit characters */
63         unsigned int total;     /* total characters read */
64
65         unsigned int lastc;     /* the last character read */
66         int crlfnoorder;        /* if crlf's occured where they shouldn't have */
67
68         int startofline;        /* are we at the start of a new line? */
69
70         int fromcount;
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? */
73
74         unsigned int countline; /* current count of characters on a given line */
75         unsigned int maxline;   /* max length of any line */
76
77         CamelCharset charset;   /* used to determine the best charset to use */
78 };
79
80 struct _CamelMimeFilterBestencClass {
81         CamelMimeFilterClass parent_class;
82 };
83
84 CamelType               camel_mime_filter_bestenc_get_type      (void);
85 CamelMimeFilterBestenc      *camel_mime_filter_bestenc_new      (unsigned int flags);
86
87
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);
91
92 G_END_DECLS
93
94 #endif /* ! _CAMEL_MIME_FILTER_BESTENC_H */