Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / camel-stream-mem.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-stream-mem.h: stream based on memory buffer */
3
4 /*
5  * Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
6  *          Michael Zucchi <notzed@ximian.com>
7  *
8  * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of version 2 of the GNU Lesser General Public
12  * License as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24
25
26 #ifndef CAMEL_STREAM_MEM_H
27 #define CAMEL_STREAM_MEM_H 1
28
29 #include <sys/types.h>
30 #include <camel/camel-seekable-stream.h>
31
32 #define CAMEL_STREAM_MEM_TYPE     (camel_stream_mem_get_type ())
33 #define CAMEL_STREAM_MEM(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_STREAM_MEM_TYPE, CamelStreamMem))
34 #define CAMEL_STREAM_MEM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_STREAM_MEM_TYPE, CamelStreamMemClass))
35 #define CAMEL_IS_STREAM_MEM(o)    (CAMEL_CHECK_TYPE((o), CAMEL_STREAM_MEM_TYPE))
36
37 G_BEGIN_DECLS
38
39 typedef struct _CamelStreamMemClass CamelStreamMemClass;
40
41 struct _CamelStreamMem {
42         CamelSeekableStream parent_object;
43
44         unsigned int owner:1;   /* do we own the buffer? */
45         unsigned int secure:1;  /* do we clear the buffer on finalise (if we own it) */
46         GByteArray *buffer;
47 };
48
49 struct _CamelStreamMemClass {
50         CamelSeekableStreamClass parent_class;
51
52         /* Virtual methods */
53 };
54
55 /* Standard Camel function */
56 CamelType camel_stream_mem_get_type (void);
57
58 /* public methods */
59 CamelStream *camel_stream_mem_new(void);
60 CamelStream *camel_stream_mem_new_with_byte_array(GByteArray *buffer);
61 CamelStream *camel_stream_mem_new_with_buffer(const char *buffer, size_t len);
62
63 /* 'secure' data, currently just clears memory on finalise */
64 void camel_stream_mem_set_secure(CamelStreamMem *mem);
65
66 /* these are really only here for implementing classes */
67 void camel_stream_mem_set_byte_array(CamelStreamMem *mem, GByteArray *buffer);
68 void camel_stream_mem_set_buffer(CamelStreamMem *mem, const char *buffer, size_t len);
69
70 G_END_DECLS
71
72 #endif /* CAMEL_STREAM_MEM_H */