1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
/* ========================================================================
* Copyright 1988-2007 University of Washington
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* ========================================================================
*/
/*
* Program: Interactive Mail Access Protocol 4rev1 (IMAP4R1) routines
*
* Author: Mark Crispin
* Networks and Distributed Computing
* Computing & Communications
* University of Washington
* Administration Building, AG-44
* Seattle, WA 98195
* Internet: MRC@CAC.Washington.EDU
*
* Date: 14 October 1988
* Last Edited: 5 September 2007
*/
/* This include file is provided for applications which need to look under
* the covers at the IMAP driver and in particular want to do different
* operations depending upon the IMAP server's protocol level and
* capabilities. It is NOT included in the normal c-client.h application
* export, and most applications do NOT need the definitions in this file.
*
* As of October 15, 2003, it is believed that:
*
* Version RFC Status Known Implementations
* ------- --- ------ ---------------------
* IMAP1 none extinct experimental TOPS-20 server
* IMAP2 1064 extinct old TOPS-20, SUMEX servers
* IMAP2 1176 rare TOPS-20, old UW servers
* IMAP2bis expired I-D uncommon old UW, Cyrus servers
* IMAP3 1203 extinct none (never implemented)
* IMAP4 1730 rare old UW, Cyrus, Netscape servers
* IMAP4rev1 2060, 3501 ubiquitous UW, Cyrus, and many others
*
* Most client implementations will only interoperate with an IMAP4rev1
* server. c-client based client implementations can interoperate with IMAP2,
* IMAP2bis, IMAP4, and IMAP4rev1 servers, but only if they are very careful.
*
* The LEVELxxx() macros in this file enable the client to determine the
* server protocol level and capabilities. This file also contains a few
* backdoor calls into the IMAP driver.
*/
/* Server protocol level and capabilities */
typedef struct imap_cap {
unsigned int rfc1176 : 1; /* server is RFC-1176 IMAP2 */
unsigned int imap2bis : 1; /* server is IMAP2bis */
unsigned int imap4 : 1; /* server is IMAP4 (RFC 1730) */
unsigned int imap4rev1 : 1; /* server is IMAP4rev1 */
unsigned int acl : 1; /* server has ACL (RFC 2086) */
unsigned int quota : 1; /* server has QUOTA (RFC 2087) */
unsigned int litplus : 1; /* server has LITERAL+ (RFC 2088) */
unsigned int idle : 1; /* server has IDLE (RFC 2177) */
unsigned int mbx_ref : 1; /* server has mailbox referrals (RFC 2193) */
unsigned int log_ref : 1; /* server has login referrals (RFC 2221) */
unsigned int authanon : 1; /* server has anonymous SASL (RFC 2245) */
unsigned int namespace :1; /* server has NAMESPACE (RFC 2342) */
unsigned int uidplus : 1; /* server has UIDPLUS (RFC 2359) */
unsigned int starttls : 1; /* server has STARTTLS (RFC 2595) */
/* server disallows LOGIN command (RFC 2595) */
unsigned int logindisabled : 1;
unsigned int id : 1; /* server has ID (RFC 2971) */
unsigned int children : 1; /* server has CHILDREN (RFC 3348) */
unsigned int multiappend : 1; /* server has multi-APPEND (RFC 3502) ;*/
unsigned int binary : 1; /* server has BINARY (RFC 3516) */
unsigned int unselect : 1; /* server has UNSELECT */
unsigned int sasl_ir : 1; /* server has SASL-IR initial response */
unsigned int sort : 1; /* server has SORT */
unsigned int scan : 1; /* server has SCAN */
unsigned int urlauth : 1; /* server has URLAUTH (RFC 4467) */
unsigned int catenate : 1; /* server has CATENATE (RFC 4469) */
unsigned int condstore : 1; /* server has CONDSTORE (RFC 4551) */
unsigned int esearch : 1; /* server has ESEARCH (RFC 4731) */
unsigned int within : 1; /* server has WITHIN (RFC 5032) */
unsigned int extlevel; /* extension data level supported by server */
unsigned int x_gm_ext1:1; /* special extension for gmail server */
/* supported authenticators */
unsigned int auth : MAXAUTHENTICATORS;
THREADER *threader; /* list of threaders */
} IMAPCAP;
/* IMAP4rev1 level or better */
#define LEVELIMAP4rev1(stream) imap_cap (stream)->imap4rev1
#define LEVELSTATUS LEVELIMAP4rev1
/* IMAP4 level or better (not including RFC 1730 design mistakes) */
#define LEVELIMAP4(stream) (imap_cap (stream)->imap4rev1 || \
imap_cap (stream)->imap4)
/* IMAP4 RFC-1730 level */
#define LEVEL1730(stream) imap_cap (stream)->imap4
/* IMAP2bis level or better */
#define LEVELIMAP2bis(stream) imap_cap (stream)->imap2bis
/* IMAP2 RFC-1176 level or better */
#define LEVEL1176(stream) imap_cap (stream)->rfc1176
/* IMAP2 RFC-1064 or better */
#define LEVEL1064(stream) 1
/* Has ACL extension */
#define LEVELACL(stream) imap_cap (stream)->acl
/* Has X-GM-EXT-1 extension */
#define XGMEXT1(stream) imap_cap(stream)->x_gm_ext1
/* Has QUOTA extension */
#define LEVELQUOTA(stream) imap_cap (stream)->quota
/* Has LITERALPLUS extension */
#define LEVELLITERALPLUS(stream) imap_cap (stream)->litplus
/* Has IDLE extension */
#define LEVELIDLE(stream) imap_cap (stream)->idle
/* Has mailbox referrals */
#define LEVELMBX_REF(stream) imap_cap (stream)->mbx_ref
/* Has login referrals */
#define LEVELLOG_REF(stream) imap_cap (stream)->log_ref
/* Has AUTH=ANONYMOUS extension */
#define LEVELANONYMOUS(stream) imap_cap (stream)->authanon
/* Has NAMESPACE extension */
#define LEVELNAMESPACE(stream) imap_cap (stream)->namespace
/* Has UIDPLUS extension */
#define LEVELUIDPLUS(stream) imap_cap (stream)->uidplus
/* Has STARTTLS extension */
#define LEVELSTARTTLS(stream) imap_cap (stream)->starttls
/* Has LOGINDISABLED extension */
#define LEVELLOGINDISABLED(stream) imap_cap (stream)->logindisabled
/* Has ID extension */
#define LEVELID(stream) imap_cap (stream)->id
/* Has CHILDREN extension */
#define LEVELCHILDREN(stream) imap_cap (stream)->children
/* Has MULTIAPPEND extension */
#define LEVELMULTIAPPEND(stream) imap_cap (stream)->multiappend
/* Has BINARY extension */
#define LEVELBINARY(stream) imap_cap (stream)->binary
/* Has UNSELECT extension */
#define LEVELUNSELECT(stream) imap_cap (stream)->unselect
/* Has SASL initial response extension */
#define LEVELSASLIR(stream) imap_cap (stream)->sasl_ir
/* Has SORT extension */
#define LEVELSORT(stream) imap_cap (stream)->sort
/* Has at least one THREAD extension */
#define LEVELTHREAD(stream) ((imap_cap (stream)->threader) ? T : NIL)
/* Has SCAN extension */
#define LEVELSCAN(stream) imap_cap (stream)->scan
/* Has URLAUTH extension */
#define LEVELURLAUTH(stream) imap_cap (stream)->urlauth
/* Has CATENATE extension */
#define LEVELCATENATE(stream) imap_cap (stream)->catenate
/* Has CONDSTORE extension */
#define LEVELCONDSTORE(stream) imap_cap (stream)->condstore
/* Has ESEARCH extension */
#define LEVELESEARCH(stream) imap_cap (stream)->esearch
/* Has WITHIN extension */
#define LEVELWITHIN(stream) imap_cap (stream)->within
/* Body structure extension levels */
/* These are in BODYSTRUCTURE order. Note that multipart bodies do not have
* body-fld-md5. This is alright, since all subsequent body structure
* extensions are in both singlepart and multipart bodies. If that ever
* changes, this will have to be split.
*/
#define BODYEXTMD5 1 /* body-fld-md5 */
#define BODYEXTDSP 2 /* body-fld-dsp */
#define BODYEXTLANG 3 /* body-fld-lang */
#define BODYEXTLOC 4 /* body-fld-loc */
/* Function prototypes */
IMAPCAP *imap_cap (MAILSTREAM *stream);
char *imap_host (MAILSTREAM *stream);
long imap_cache (MAILSTREAM *stream,unsigned long msgno,char *seg,
STRINGLIST *stl,SIZEDTEXT *text);
/* Temporary */
long imap_setacl (MAILSTREAM *stream,char *mailbox,char *id,char *rights);
long imap_deleteacl (MAILSTREAM *stream,char *mailbox,char *id);
long imap_getacl (MAILSTREAM *stream,char *mailbox);
long imap_listrights (MAILSTREAM *stream,char *mailbox,char *id);
long imap_myrights (MAILSTREAM *stream,char *mailbox);
long imap_setquota (MAILSTREAM *stream,char *qroot,STRINGLIST *limits);
long imap_getquota (MAILSTREAM *stream,char *qroot);
long imap_getquotaroot (MAILSTREAM *stream,char *mailbox);
|