Bug #606181 - Accepting bad SSL certificate applies to any hostname
[platform/upstream/evolution-data-server.git] / camel / providers / imapx / 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 #ifndef CAMEL_IMAPX_STREAM_H
24 #define CAMEL_IMAPX_STREAM_H
25
26 #include <camel/camel.h>
27
28 /* Standard GObject macros */
29 #define CAMEL_TYPE_IMAPX_STREAM \
30         (camel_imapx_stream_get_type ())
31 #define CAMEL_IMAPX_STREAM(obj) \
32         (G_TYPE_CHECK_INSTANCE_CAST \
33         ((obj), CAMEL_TYPE_IMAPX_STREAM, CamelIMAPXStream))
34 #define CAMEL_IMAPX_STREAM_CLASS(cls) \
35         (G_TYPE_CHECK_CLASS_CAST \
36         ((cls), CAMEL_TYPE_IMAPX_STREAM, CamelIMAPXStreamClass))
37 #define CAMEL_IS_IMAPX_STREAM(obj) \
38         (G_TYPE_CHECK_INSTANCE_TYPE \
39         ((obj), CAMEL_TYPE_IMAPX_STREAM))
40 #define CAMEL_IS_IMAPX_STREAM_CLASS(cls) \
41         (G_TYPE_CHECK_CLASS_TYPE \
42         ((cls), CAMEL_TYPE_IMAPX_STREAM))
43 #define CAMEL_IMAPX_STREAM_GET_CLASS(obj) \
44         (G_TYPE_INSTANCE_GET_CLASS \
45         ((obj), CAMEL_TYPE_IMAPX_STREAM, CamelIMAPXStreamClass))
46
47 #define CAMEL_IMAPX_ERROR \
48         (camel_imapx_error_quark ())
49
50 G_BEGIN_DECLS
51
52 typedef struct _CamelIMAPXStream CamelIMAPXStream;
53 typedef struct _CamelIMAPXStreamClass CamelIMAPXStreamClass;
54
55 typedef enum {
56         IMAPX_TOK_PROTOCOL = -2,
57         IMAPX_TOK_ERROR = -1,
58         IMAPX_TOK_TOKEN = 256,
59         IMAPX_TOK_STRING,
60         IMAPX_TOK_INT,
61         IMAPX_TOK_LITERAL,
62 } camel_imapx_token_t;
63
64 struct _CamelIMAPXStream {
65         CamelStream parent;
66
67         CamelStream *source;
68         gchar tagprefix; /* For debugging output */
69
70         /*int state;*/
71         guchar *buf, *ptr, *end;
72         guint literal;
73
74         guint unget;
75         camel_imapx_token_t unget_tok;
76         guchar *unget_token;
77         guint unget_len;
78
79         guchar *tokenbuf;
80         guint bufsize;
81 };
82
83 struct _CamelIMAPXStreamClass {
84         CamelStreamClass parent_class;
85 };
86
87 GType           camel_imapx_stream_get_type     (void);
88 GQuark          camel_imapx_error_quark         (void) G_GNUC_CONST;
89 CamelStream *   camel_imapx_stream_new          (CamelStream *source);
90 gint            camel_imapx_stream_buffered     (CamelIMAPXStream *is);
91
92 /* throws IO,PARSE exception */
93 camel_imapx_token_t
94                 camel_imapx_stream_token        (CamelIMAPXStream *is,
95                                                  guchar **start,
96                                                  guint *len,
97                                                  GCancellable *cancellable,
98                                                  GError **error);
99
100 void            camel_imapx_stream_ungettoken   (CamelIMAPXStream *is,
101                                                  camel_imapx_token_t tok,
102                                                  guchar *token,
103                                                  guint len);
104 void            camel_imapx_stream_set_literal  (CamelIMAPXStream *is,
105                                                  guint literal);
106 gint            camel_imapx_stream_gets         (CamelIMAPXStream *is,
107                                                  guchar **start,
108                                                  guint *len,
109                                                  GCancellable *cancellable,
110                                                  GError **error);
111 gint             camel_imapx_stream_getl        (CamelIMAPXStream *is,
112                                                  guchar **start,
113                                                  guint *len,
114                                                  GCancellable *cancellable,
115                                                  GError **error);
116
117 /* all throw IO,PARSE exceptions */
118
119 /* gets an atom, upper-cases */
120 gint            camel_imapx_stream_atom         (CamelIMAPXStream *is,
121                                                  guchar **start,
122                                                  guint *len,
123                                                  GCancellable *cancellable,
124                                                  GError **error);
125 /* gets an atom or string */
126 gint            camel_imapx_stream_astring      (CamelIMAPXStream *is,
127                                                  guchar **start,
128                                                  GCancellable *cancellable,
129                                                  GError **error);
130 /* gets a NIL or a string, start==NULL if NIL */
131 gint            camel_imapx_stream_nstring      (CamelIMAPXStream *is,
132                                                  guchar **start,
133                                                  GCancellable *cancellable,
134                                                  GError **error);
135 /* gets a NIL or string into a stream, stream==NULL if NIL */
136 gint            camel_imapx_stream_nstring_stream
137                                                 (CamelIMAPXStream *is,
138                                                  CamelStream **stream,
139                                                  GCancellable *cancellable,
140                                                  GError **error);
141 /* gets 'text' */
142 gint            camel_imapx_stream_text         (CamelIMAPXStream *is,
143                                                  guchar **text,
144                                                  GCancellable *cancellable,
145                                                  GError **error);
146
147 /* gets a 'number' */
148 guint64          camel_imapx_stream_number      (CamelIMAPXStream *is,
149                                                  GCancellable *cancellable,
150                                                  GError **error);
151
152 /* skips the rest of a line, including literals, etc */
153 gint            camel_imapx_stream_skip         (CamelIMAPXStream *is,
154                                                  GCancellable *cancellable,
155                                                  GError **error);
156
157 G_END_DECLS
158
159 #endif /* CAMEL_IMAPX_STREAM_H */