Whitespace cleanups.
[platform/upstream/evolution-data-server.git] / camel / camel-imapx-stream.h
1 /*
2  *  Copyright (C) 2000 Ximian Inc.
3  *
4  *  Authors: Michael Zucchi <notzed@ximian.com>
5  *
6  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of version 2 of the GNU Lesser General Public
10  * License as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 #if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
24 #error "Only <camel/camel.h> can be included directly."
25 #endif
26
27 #ifndef CAMEL_IMAPX_STREAM_H
28 #define CAMEL_IMAPX_STREAM_H
29
30 #include <camel/camel-stream.h>
31
32 /* Standard GObject macros */
33 #define CAMEL_TYPE_IMAPX_STREAM \
34         (camel_imapx_stream_get_type ())
35 #define CAMEL_IMAPX_STREAM(obj) \
36         (G_TYPE_CHECK_INSTANCE_CAST \
37         ((obj), CAMEL_TYPE_IMAPX_STREAM, CamelIMAPXStream))
38 #define CAMEL_IMAPX_STREAM_CLASS(cls) \
39         (G_TYPE_CHECK_CLASS_CAST \
40         ((cls), CAMEL_TYPE_IMAPX_STREAM, CamelIMAPXStreamClass))
41 #define CAMEL_IS_IMAPX_STREAM(obj) \
42         (G_TYPE_CHECK_INSTANCE_TYPE \
43         ((obj), CAMEL_TYPE_IMAPX_STREAM))
44 #define CAMEL_IS_IMAPX_STREAM_CLASS(cls) \
45         (G_TYPE_CHECK_CLASS_TYPE \
46         ((cls), CAMEL_TYPE_IMAPX_STREAM))
47 #define CAMEL_IMAPX_STREAM_GET_CLASS(obj) \
48         (G_TYPE_INSTANCE_GET_CLASS \
49         ((obj), CAMEL_TYPE_IMAPX_STREAM, CamelIMAPXStreamClass))
50
51 #define CAMEL_IMAPX_ERROR \
52         (camel_imapx_error_quark ())
53
54 G_BEGIN_DECLS
55
56 typedef struct _CamelIMAPXStream CamelIMAPXStream;
57 typedef struct _CamelIMAPXStreamClass CamelIMAPXStreamClass;
58
59 typedef enum {
60         IMAPX_TOK_PROTOCOL = -2,
61         IMAPX_TOK_ERROR = -1,
62         IMAPX_TOK_TOKEN = 256,
63         IMAPX_TOK_STRING,
64         IMAPX_TOK_INT,
65         IMAPX_TOK_LITERAL,
66 } camel_imapx_token_t;
67
68 struct _CamelIMAPXStream {
69         CamelStream parent;
70
71         CamelStream *source;
72         gchar tagprefix; /* For debugging output */
73
74         /*int state;*/
75         guchar *buf, *ptr, *end;
76         guint literal;
77
78         guint unget;
79         camel_imapx_token_t unget_tok;
80         guchar *unget_token;
81         guint unget_len;
82
83         guchar *tokenbuf;
84         guint bufsize;
85 };
86
87 struct _CamelIMAPXStreamClass {
88         CamelStreamClass parent_class;
89 };
90
91 GType           camel_imapx_stream_get_type     (void);
92 GQuark          camel_imapx_error_quark         (void) G_GNUC_CONST;
93 CamelStream *   camel_imapx_stream_new          (CamelStream *source);
94 gint            camel_imapx_stream_buffered     (CamelIMAPXStream *is);
95
96 /* throws IO,PARSE exception */
97 camel_imapx_token_t
98                 camel_imapx_stream_token        (CamelIMAPXStream *is,
99                                                  guchar **start,
100                                                  guint *len,
101                                                  GCancellable *cancellable,
102                                                  GError **error);
103
104 void            camel_imapx_stream_ungettoken   (CamelIMAPXStream *is,
105                                                  camel_imapx_token_t tok,
106                                                  guchar *token,
107                                                  guint len);
108 void            camel_imapx_stream_set_literal  (CamelIMAPXStream *is,
109                                                  guint literal);
110 gint            camel_imapx_stream_gets         (CamelIMAPXStream *is,
111                                                  guchar **start,
112                                                  guint *len,
113                                                  GCancellable *cancellable,
114                                                  GError **error);
115 gint             camel_imapx_stream_getl        (CamelIMAPXStream *is,
116                                                  guchar **start,
117                                                  guint *len,
118                                                  GCancellable *cancellable,
119                                                  GError **error);
120
121 /* all throw IO,PARSE exceptions */
122
123 /* gets an atom, upper-cases */
124 gint            camel_imapx_stream_atom         (CamelIMAPXStream *is,
125                                                  guchar **start,
126                                                  guint *len,
127                                                  GCancellable *cancellable,
128                                                  GError **error);
129 /* gets an atom or string */
130 gint            camel_imapx_stream_astring      (CamelIMAPXStream *is,
131                                                  guchar **start,
132                                                  GCancellable *cancellable,
133                                                  GError **error);
134 /* gets a NIL or a string, start==NULL if NIL */
135 gint            camel_imapx_stream_nstring      (CamelIMAPXStream *is,
136                                                  guchar **start,
137                                                  GCancellable *cancellable,
138                                                  GError **error);
139 /* gets a NIL or string into a stream, stream==NULL if NIL */
140 gint            camel_imapx_stream_nstring_stream
141                                                 (CamelIMAPXStream *is,
142                                                  CamelStream **stream,
143                                                  GCancellable *cancellable,
144                                                  GError **error);
145 /* gets 'text' */
146 gint            camel_imapx_stream_text         (CamelIMAPXStream *is,
147                                                  guchar **text,
148                                                  GCancellable *cancellable,
149                                                  GError **error);
150
151 /* gets a 'number' */
152 guint64          camel_imapx_stream_number      (CamelIMAPXStream *is,
153                                                  GCancellable *cancellable,
154                                                  GError **error);
155
156 /* skips the rest of a line, including literals, etc */
157 gint            camel_imapx_stream_skip         (CamelIMAPXStream *is,
158                                                  GCancellable *cancellable,
159                                                  GError **error);
160
161 G_END_DECLS
162
163 #endif /* CAMEL_IMAPX_STREAM_H */