1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*- */
2 /* camel-stream.h : class for an abstract stream */
6 * Bertrand Guiheneuf <bertrand@helixcode.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_H
27 #define CAMEL_STREAM_H 1
31 #include <camel/camel-object.h>
33 #define CAMEL_STREAM_TYPE (camel_stream_get_type ())
34 #define CAMEL_STREAM(obj) (CAMEL_CHECK_CAST((obj), CAMEL_STREAM_TYPE, CamelStream))
35 #define CAMEL_STREAM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_STREAM_TYPE, CamelStreamClass))
36 #define CAMEL_IS_STREAM(o) (CAMEL_CHECK_TYPE((o), CAMEL_STREAM_TYPE))
42 CamelObject parent_object;
48 CamelObjectClass parent_class;
52 ssize_t (*read) (CamelStream *stream, char *buffer, size_t n);
53 ssize_t (*write) (CamelStream *stream, const char *buffer, size_t n);
54 int (*close) (CamelStream *stream);
55 int (*flush) (CamelStream *stream);
56 gboolean (*eos) (CamelStream *stream);
57 int (*reset) (CamelStream *stream);
61 /* Standard Camel function */
62 CamelType camel_stream_get_type (void);
65 ssize_t camel_stream_read (CamelStream *stream, char *buffer, size_t n);
66 ssize_t camel_stream_write (CamelStream *stream, const char *buffer, size_t n);
67 int camel_stream_flush (CamelStream *stream);
68 int camel_stream_close (CamelStream *stream);
69 gboolean camel_stream_eos (CamelStream *stream);
70 int camel_stream_reset (CamelStream *stream);
72 /* utility macros and funcs */
73 ssize_t camel_stream_write_string (CamelStream *stream, const char *string);
74 ssize_t camel_stream_printf (CamelStream *stream, const char *fmt, ... ) G_GNUC_PRINTF (2, 3);
75 ssize_t camel_stream_vprintf (CamelStream *stream, const char *fmt, va_list ap);
77 /* Write a whole stream to another stream, until eof or error on
80 ssize_t camel_stream_write_to_stream (CamelStream *stream, CamelStream *output_stream);
84 #endif /* CAMEL_STREAM_H */