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 /* Abstract class for non-copying filters */
24 #ifndef _CAMEL_MIME_FILTER_H
25 #define _CAMEL_MIME_FILTER_H
27 #include <sys/types.h>
28 #include <camel/camel-object.h>
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 ())
37 typedef struct _CamelMimeFilterClass CamelMimeFilterClass;
39 struct _CamelMimeFilter {
42 struct _CamelMimeFilterPrivate *priv;
44 char *outreal; /* real malloc'd buffer */
45 char *outbuf; /* first 'writable' position allowed (outreal + outpre) */
48 size_t outpre; /* prespace of this buffer */
52 size_t backlen; /* significant data there */
55 struct _CamelMimeFilterClass {
56 CamelObjectClass parent_class;
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);
68 CamelType camel_mime_filter_get_type (void);
69 CamelMimeFilter *camel_mime_filter_new (void);
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);
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);
79 void camel_mime_filter_reset(CamelMimeFilter *filter);
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);
84 /* ensure this much size available for filter output */
85 void camel_mime_filter_set_size(CamelMimeFilter *filter, size_t size, int keep);
89 #endif /* ! _CAMEL_MIME_FILTER_H */