Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / camel-stream.h
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 */
3
4 /*
5  * Author:
6  *  Bertrand Guiheneuf <bertrand@helixcode.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_H
27 #define CAMEL_STREAM_H 1
28
29 #include <stdarg.h>
30 #include <unistd.h>
31 #include <camel/camel-object.h>
32
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))
37
38 G_BEGIN_DECLS
39
40 struct _CamelStream
41 {
42         CamelObject parent_object;
43
44         gboolean eos;
45 };
46
47 typedef struct {
48         CamelObjectClass parent_class;
49
50         /* Virtual methods */
51
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);
58
59 } CamelStreamClass;
60
61 /* Standard Camel function */
62 CamelType camel_stream_get_type (void);
63
64 /* public methods */
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);
71
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);
76
77 /* Write a whole stream to another stream, until eof or error on
78  * either stream.
79  */
80 ssize_t camel_stream_write_to_stream (CamelStream *stream, CamelStream *output_stream);
81
82 G_END_DECLS
83
84 #endif /* CAMEL_STREAM_H */