1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2000-2012 Jeffrey Stedfast
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1
8 * of the License, or (at your option) any later version.
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.
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
17 * Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
22 #ifndef __GMIME_FILTER_H__
23 #define __GMIME_FILTER_H__
26 #include <glib-object.h>
27 #include <sys/types.h>
31 #define GMIME_TYPE_FILTER (g_mime_filter_get_type ())
32 #define GMIME_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMIME_TYPE_FILTER, GMimeFilter))
33 #define GMIME_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMIME_TYPE_FILTER, GMimeFilterClass))
34 #define GMIME_IS_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMIME_TYPE_FILTER))
35 #define GMIME_IS_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GMIME_TYPE_FILTER))
36 #define GMIME_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMIME_TYPE_FILTER, GMimeFilterClass))
38 typedef struct _GMimeFilter GMimeFilter;
39 typedef struct _GMimeFilterClass GMimeFilterClass;
43 * @parent_object: parent #GObject
44 * @priv: private state data
45 * @outreal: real malloc'd buffer
46 * @outbuf: first writable position allowed (outreal + outpre)
47 * @outptr: current writale position
48 * @outsize: current bytes in @outbuf
49 * @outpre: current prespace of @outbuf
50 * @backbuf: backup buffer
51 * @backsize: backup buffer size
52 * @backlen: number of bytes backed-up in @backbuf
54 * Base class for filters used by #GMimeStreamFilter.
57 GObject parent_object;
59 struct _GMimeFilterPrivate *priv;
62 char *outreal; /* real malloc'd buffer */
63 char *outbuf; /* first 'writable' position allowed (outreal + outpre) */
66 size_t outpre; /* prespace of this buffer */
70 size_t backlen; /* significant data there */
73 struct _GMimeFilterClass {
74 GObjectClass parent_class;
76 /* virtual functions */
77 GMimeFilter * (* copy) (GMimeFilter *filter);
79 void (* filter) (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
80 char **outbuf, size_t *outlen, size_t *outprespace);
82 void (* complete) (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
83 char **outbuf, size_t *outlen, size_t *outprespace);
85 void (* reset) (GMimeFilter *filter);
89 GType g_mime_filter_get_type (void);
92 GMimeFilter *g_mime_filter_copy (GMimeFilter *filter);
94 void g_mime_filter_filter (GMimeFilter *filter,
95 char *inbuf, size_t inlen, size_t prespace,
96 char **outbuf, size_t *outlen, size_t *outprespace);
98 void g_mime_filter_complete (GMimeFilter *filter,
99 char *inbuf, size_t inlen, size_t prespace,
100 char **outbuf, size_t *outlen, size_t *outprespace);
102 void g_mime_filter_reset (GMimeFilter *filter);
105 /* sets/returns number of bytes backed up on the input */
106 void g_mime_filter_backup (GMimeFilter *filter, const char *data, size_t length);
108 /* ensure this much size available for filter output */
109 void g_mime_filter_set_size (GMimeFilter *filter, size_t size, gboolean keep);
113 #endif /* __GMIME_FILTER_H__ */