1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-stream-mem.h: stream based on memory buffer */
5 * Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
6 * Michael Zucchi <notzed@ximian.com>
8 * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
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.
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.
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
26 #ifndef CAMEL_STREAM_MEM_H
27 #define CAMEL_STREAM_MEM_H 1
29 #include <sys/types.h>
30 #include <camel/camel-seekable-stream.h>
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))
39 typedef struct _CamelStreamMemClass CamelStreamMemClass;
41 struct _CamelStreamMem {
42 CamelSeekableStream parent_object;
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) */
49 struct _CamelStreamMemClass {
50 CamelSeekableStreamClass parent_class;
55 /* Standard Camel function */
56 CamelType camel_stream_mem_get_type (void);
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);
63 /* 'secure' data, currently just clears memory on finalise */
64 void camel_stream_mem_set_secure(CamelStreamMem *mem);
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);
72 #endif /* CAMEL_STREAM_MEM_H */