Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / camel-mime-filter.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 /* Abstract class for non-copying filters */
23
24 #ifndef _CAMEL_MIME_FILTER_H
25 #define _CAMEL_MIME_FILTER_H
26
27 #include <sys/types.h>
28 #include <camel/camel-object.h>
29
30 #define CAMEL_MIME_FILTER_TYPE         (camel_mime_filter_get_type ())
31 #define CAMEL_MIME_FILTER(obj)         CAMEL_CHECK_CAST (obj, camel_mime_filter_get_type (), CamelMimeFilter)
32 #define CAMEL_MIME_FILTER_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_mime_filter_get_type (), CamelMimeFilterClass)
33 #define CAMEL_IS_MIME_FILTER(obj)      CAMEL_CHECK_TYPE (obj, camel_mime_filter_get_type ())
34
35 G_BEGIN_DECLS
36
37 typedef struct _CamelMimeFilterClass CamelMimeFilterClass;
38
39 struct _CamelMimeFilter {
40         CamelObject parent;
41
42         struct _CamelMimeFilterPrivate *priv;
43
44         char *outreal;          /* real malloc'd buffer */
45         char *outbuf;           /* first 'writable' position allowed (outreal + outpre) */
46         char *outptr;
47         size_t outsize;
48         size_t outpre;          /* prespace of this buffer */
49
50         char *backbuf;
51         size_t backsize;
52         size_t backlen;         /* significant data there */
53 };
54
55 struct _CamelMimeFilterClass {
56         CamelObjectClass parent_class;
57
58         /* virtual functions */
59         void (*filter)(CamelMimeFilter *f,
60                        char *in, size_t len, size_t prespace,
61                        char **out, size_t *outlen, size_t *outprespace);
62         void (*complete)(CamelMimeFilter *f,
63                          char *in, size_t len, size_t prespace,
64                          char **out, size_t *outlen, size_t *outprespace);
65         void (*reset)(CamelMimeFilter *f);
66 };
67
68 CamelType             camel_mime_filter_get_type        (void);
69 CamelMimeFilter      *camel_mime_filter_new     (void);
70
71 void camel_mime_filter_filter(CamelMimeFilter *filter,
72                               char *in, size_t len, size_t prespace,
73                               char **out, size_t *outlen, size_t *outprespace);
74
75 void camel_mime_filter_complete(CamelMimeFilter *filter,
76                                 char *in, size_t len, size_t prespace,
77                                 char **out, size_t *outlen, size_t *outprespace);
78
79 void camel_mime_filter_reset(CamelMimeFilter *filter);
80
81 /* sets/returns number of bytes backed up on the input */
82 void camel_mime_filter_backup(CamelMimeFilter *filter, const char *data, size_t length);
83
84 /* ensure this much size available for filter output */
85 void camel_mime_filter_set_size(CamelMimeFilter *filter, size_t size, int keep);
86
87 G_END_DECLS
88
89 #endif /* ! _CAMEL_MIME_FILTER_H */