imapext-2007

view src/c-client/mail.h @ 1:28a55bc1110c

[mq]: imapext
author yuuji@gentei.org
date Mon, 14 Sep 2009 19:23:11 +0900
parents ada5e610ab86
children 2366b362676d 20c025a380ab
line source
1 /* ========================================================================
2 * Copyright 1988-2008 University of Washington
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 *
11 * ========================================================================
12 */
14 /*
15 * Program: Mailbox Access routines
16 *
17 * Author: Mark Crispin
18 * UW Technology
19 * University of Washington
20 * Seattle, WA 98195
21 * Internet: MRC@Washington.EDU
22 *
23 * Date: 22 November 1989
24 * Last Edited: 16 December 2008
25 */
27 /* The Version */
29 #define CCLIENTVERSION "2007e"
31 /* Build parameters */
33 #define CACHEINCREMENT 250 /* cache growth increments */
34 #define MAILTMPLEN 1024 /* size of a temporary buffer */
35 #define SENDBUFLEN 16385 /* size of temporary sending buffer, also
36 * used for SMTP commands and NETMBX generation
37 * buffer so shouldn't be made smaller than
38 * MAILTMPLEN. Note that there's a guard byte,
39 * so this is actually len+1. */
40 #define MAXAUTHENTICATORS 8 /* maximum number of SASL authenticators */
41 /* maximum number of messages */
42 #define MAXMESSAGES (unsigned long) 1000000
43 #define MAXLOGINTRIALS 3 /* maximum number of client login attempts */
44 #define MAXWILDCARDS 10 /* maximum wildcards allowed in LIST/LSUB */
47 /* These can't be changed without changing code */
49 #define NUSERFLAGS 30 /* maximum number of user flags */
50 #define MAXUSERFLAG 50 /* maximum length of a user flag */
51 #define BASEYEAR 1970 /* the year time began on Unix DON'T CHANGE */
52 /* default for unqualified addresses */
53 #define BADHOST ".MISSING-HOST-NAME."
54 /* default for syntax errors in addresses */
55 #define ERRHOST ".SYNTAX-ERROR."
58 /* Coddle certain compilers' 6-character symbol limitation */
60 #ifdef __COMPILER_KCC__
61 #include "shortsym.h"
62 #endif
65 /* Function status code */
67 #define NIL 0 /* convenient name */
68 #define T 1 /* opposite of NIL */
69 #define LONGT (long) 1 /* long T to pacify some compilers */
70 #define VOIDT (void *) "" /* void T ditto */
72 /* Global and Driver Parameters */
74 /* 0xx: driver and authenticator flags */
75 #define ENABLE_DRIVER (long) 1
76 #define DISABLE_DRIVER (long) 2
77 #define ENABLE_AUTHENTICATOR (long) 3
78 #define DISABLE_AUTHENTICATOR (long) 4
79 #define ENABLE_DEBUG (long) 5
80 #define DISABLE_DEBUG (long) 6
81 #define HIDE_AUTHENTICATOR (long) 7
82 #define UNHIDE_AUTHENTICATOR (long) 8
83 /* 1xx: c-client globals */
84 #define GET_DRIVERS (long) 101
85 #define SET_DRIVERS (long) 102
86 #define GET_GETS (long) 103
87 #define SET_GETS (long) 104
88 #define GET_CACHE (long) 105
89 #define SET_CACHE (long) 106
90 #define GET_SMTPVERBOSE (long) 107
91 #define SET_SMTPVERBOSE (long) 108
92 #define GET_RFC822OUTPUT (long) 109
93 #define SET_RFC822OUTPUT (long) 110
94 #define GET_READPROGRESS (long) 111
95 #define SET_READPROGRESS (long) 112
96 #define GET_THREADERS (long) 113
97 #define SET_THREADERS (long) 114
98 #define GET_NAMESPACE (long) 115
99 #define SET_NAMESPACE (long) 116
100 #define GET_MAILPROXYCOPY (long) 117
101 #define SET_MAILPROXYCOPY (long) 118
102 #define GET_SERVICENAME (long) 119
103 #define SET_SERVICENAME (long) 120
104 #define GET_DRIVER (long) 121
105 #define SET_DRIVER (long) 122
106 #define GET_EXPUNGEATPING (long) 123
107 #define SET_EXPUNGEATPING (long) 124
108 #define GET_PARSEPHRASE (long) 125
109 #define SET_PARSEPHRASE (long) 126
110 #define GET_SSLDRIVER (long) 127
111 #define SET_SSLDRIVER (long) 128
112 #define GET_TRYSSLFIRST (long) 129
113 #define SET_TRYSSLFIRST (long) 130
114 #define GET_BLOCKNOTIFY (long) 131
115 #define SET_BLOCKNOTIFY (long) 132
116 #define GET_SORTRESULTS (long) 133
117 #define SET_SORTRESULTS (long) 134
118 #define GET_THREADRESULTS (long) 135
119 #define SET_THREADRESULTS (long) 136
120 #define GET_PARSELINE (long) 137
121 #define SET_PARSELINE (long) 138
122 #define GET_NEWSRCQUERY (long) 139
123 #define SET_NEWSRCQUERY (long) 140
124 #define GET_FREEENVELOPESPAREP (long) 141
125 #define SET_FREEENVELOPESPAREP (long) 142
126 #define GET_FREEELTSPAREP (long) 143
127 #define SET_FREEELTSPAREP (long) 144
128 #define GET_SSLSTART (long) 145
129 #define SET_SSLSTART (long) 146
130 #define GET_DEBUGSENSITIVE (long) 147
131 #define SET_DEBUGSENSITIVE (long) 148
132 #define GET_TCPDEBUG (long) 149
133 #define SET_TCPDEBUG (long) 150
134 #define GET_FREESTREAMSPAREP (long) 151
135 #define SET_FREESTREAMSPAREP (long) 152
136 #define GET_FREEBODYSPAREP (long) 153
137 #define SET_FREEBODYSPAREP (long) 154
138 #define GET_COPYUID (long) 155
139 #define SET_COPYUID (long) 156
140 #define GET_APPENDUID (long) 157
141 #define SET_APPENDUID (long) 158
142 #define GET_RFC822OUTPUTFULL (long) 159
143 #define SET_RFC822OUTPUTFULL (long) 160
144 #define GET_BLOCKENVINIT (long) 161
145 #define SET_BLOCKENVINIT (long) 162
147 /* 2xx: environment */
148 #define GET_USERNAME (long) 201
149 #define SET_USERNAME (long) 202
150 #define GET_HOMEDIR (long) 203
151 #define SET_HOMEDIR (long) 204
152 #define GET_LOCALHOST (long) 205
153 #define SET_LOCALHOST (long) 206
154 #define GET_SYSINBOX (long) 207
155 #define SET_SYSINBOX (long) 208
156 #define GET_USERPROMPT (long) 209
157 #define SET_USERPROMPT (long) 210
158 #define GET_DISABLEPLAINTEXT (long) 211
159 #define SET_DISABLEPLAINTEXT (long) 212
160 #define GET_CHROOTSERVER (long) 213
161 #define SET_CHROOTSERVER (long) 214
162 #define GET_ADVERTISETHEWORLD (long) 215
163 #define SET_ADVERTISETHEWORLD (long) 216
164 #define GET_DISABLEAUTOSHAREDNS (long) 217
165 #define SET_DISABLEAUTOSHAREDNS (long) 218
166 #define GET_MAILSUBDIR 219
167 #define SET_MAILSUBDIR 220
168 #define GET_DISABLE822TZTEXT 221
169 #define SET_DISABLE822TZTEXT 222
170 #define GET_LIMITEDADVERTISE (long) 223
171 #define SET_LIMITEDADVERTISE (long) 224
172 #define GET_LOGOUTHOOK (long) 225
173 #define SET_LOGOUTHOOK (long) 226
174 #define GET_LOGOUTDATA (long) 227
175 #define SET_LOGOUTDATA (long) 228
176 #define GET_EXTERNALAUTHID (long) 229
177 #define SET_EXTERNALAUTHID (long) 230
178 #define GET_SSLCAPATH (long) 231
179 #define SET_SSLCAPATH (long) 232
181 /* 3xx: TCP/IP */
182 #define GET_OPENTIMEOUT (long) 300
183 #define SET_OPENTIMEOUT (long) 301
184 #define GET_READTIMEOUT (long) 302
185 #define SET_READTIMEOUT (long) 303
186 #define GET_WRITETIMEOUT (long) 304
187 #define SET_WRITETIMEOUT (long) 305
188 #define GET_CLOSETIMEOUT (long) 306
189 #define SET_CLOSETIMEOUT (long) 307
190 #define GET_TIMEOUT (long) 308
191 #define SET_TIMEOUT (long) 309
192 #define GET_RSHTIMEOUT (long) 310
193 #define SET_RSHTIMEOUT (long) 311
194 #define GET_ALLOWREVERSEDNS (long) 312
195 #define SET_ALLOWREVERSEDNS (long) 313
196 #define GET_RSHCOMMAND (long) 314
197 #define SET_RSHCOMMAND (long) 315
198 #define GET_RSHPATH (long) 316
199 #define SET_RSHPATH (long) 317
200 #define GET_SSHTIMEOUT (long) 318
201 #define SET_SSHTIMEOUT (long) 319
202 #define GET_SSHCOMMAND (long) 320
203 #define SET_SSHCOMMAND (long) 321
204 #define GET_SSHPATH (long) 322
205 #define SET_SSHPATH (long) 323
206 #define GET_SSLCERTIFICATEQUERY (long) 324
207 #define SET_SSLCERTIFICATEQUERY (long) 325
208 #define GET_SSLFAILURE (long) 326
209 #define SET_SSLFAILURE (long) 327
210 #define GET_NEWSRCCANONHOST (long) 328
211 #define SET_NEWSRCCANONHOST (long) 329
212 #define GET_KINIT (long) 330
213 #define SET_KINIT (long) 331
214 #define GET_SSLCLIENTCERT (long) 332
215 #define SET_SSLCLIENTCERT (long) 333
216 #define GET_SSLCLIENTKEY (long) 334
217 #define SET_SSLCLIENTKEY (long) 335
218 #define GET_KERBEROS_CP_SVR_NAME (long) 336
219 #define SET_KERBEROS_CP_SVR_NAME (long) 337
221 /* 4xx: network drivers */
222 #define GET_MAXLOGINTRIALS (long) 400
223 #define SET_MAXLOGINTRIALS (long) 401
224 #define GET_LOOKAHEAD (long) 402
225 #define SET_LOOKAHEAD (long) 403
226 #define GET_IMAPPORT (long) 404
227 #define SET_IMAPPORT (long) 405
228 #define GET_PREFETCH (long) 406
229 #define SET_PREFETCH (long) 407
230 #define GET_CLOSEONERROR (long) 408
231 #define SET_CLOSEONERROR (long) 409
232 #define GET_POP3PORT (long) 410
233 #define SET_POP3PORT (long) 411
234 #define GET_UIDLOOKAHEAD (long) 412
235 #define SET_UIDLOOKAHEAD (long) 413
236 #define GET_NNTPPORT (long) 414
237 #define SET_NNTPPORT (long) 415
238 #define GET_IMAPENVELOPE (long) 416
239 #define SET_IMAPENVELOPE (long) 417
240 #define GET_IMAPREFERRAL (long) 418
241 #define SET_IMAPREFERRAL (long) 419
242 #define GET_SSLIMAPPORT (long) 420
243 #define SET_SSLIMAPPORT (long) 421
244 #define GET_SSLPOPPORT (long) 422
245 #define SET_SSLPOPPORT (long) 423
246 #define GET_SSLNNTPPORT (long) 424
247 #define SET_SSLNNTPPORT (long) 425
248 #define GET_SSLSMTPPORT (long) 426
249 #define SET_SSLSMTPPORT (long) 427
250 #define GET_SMTPPORT (long) 428
251 #define SET_SMTPPORT (long) 429
252 #define GET_IMAPEXTRAHEADERS (long) 430
253 #define SET_IMAPEXTRAHEADERS (long) 431
254 #define GET_ACL (long) 432
255 #define SET_ACL (long) 433
256 #define GET_LISTRIGHTS (long) 434
257 #define SET_LISTRIGHTS (long) 435
258 #define GET_MYRIGHTS (long) 436
259 #define SET_MYRIGHTS (long) 437
260 #define GET_QUOTA (long) 438
261 #define SET_QUOTA (long) 439
262 #define GET_QUOTAROOT (long) 440
263 #define SET_QUOTAROOT (long) 441
264 #define GET_IMAPTRYSSL (long) 442
265 #define SET_IMAPTRYSSL (long) 443
266 #define GET_FETCHLOOKAHEAD (long) 444
267 #define SET_FETCHLOOKAHEAD (long) 445
268 #define GET_NNTPRANGE (long) 446
269 #define SET_NNTPRANGE (long) 447
270 #define GET_NNTPHIDEPATH (long) 448
271 #define SET_NNTPHIDEPATH (long) 449
272 #define GET_SENDCOMMAND (long) 450
273 #define SET_SENDCOMMAND (long) 451
274 #define GET_IDLETIMEOUT (long) 452
275 #define SET_IDLETIMEOUT (long) 453
276 #define GET_FETCHLOOKAHEADLIMIT (long) 454
277 #define SET_FETCHLOOKAHEADLIMIT (long) 455
279 /* 5xx: local file drivers */
280 #define GET_MBXPROTECTION (long) 500
281 #define SET_MBXPROTECTION (long) 501
282 #define GET_DIRPROTECTION (long) 502
283 #define SET_DIRPROTECTION (long) 503
284 #define GET_LOCKPROTECTION (long) 504
285 #define SET_LOCKPROTECTION (long) 505
286 #define GET_FROMWIDGET (long) 506
287 #define SET_FROMWIDGET (long) 507
288 #define GET_NEWSACTIVE (long) 508
289 #define SET_NEWSACTIVE (long) 509
290 #define GET_NEWSSPOOL (long) 510
291 #define SET_NEWSSPOOL (long) 511
292 #define GET_NEWSRC (long) 512
293 #define SET_NEWSRC (long) 513
294 #define GET_EXTENSION (long) 514
295 #define SET_EXTENSION (long) 515
296 #define GET_DISABLEFCNTLLOCK (long) 516
297 #define SET_DISABLEFCNTLLOCK (long) 517
298 #define GET_LOCKEACCESERROR (long) 518
299 #define SET_LOCKEACCESERROR (long) 519
300 #define GET_LISTMAXLEVEL (long) 520
301 #define SET_LISTMAXLEVEL (long) 521
302 #define GET_ANONYMOUSHOME (long) 522
303 #define SET_ANONYMOUSHOME (long) 523
304 #define GET_FTPHOME (long) 524
305 #define SET_FTPHOME (long) 525
306 #define GET_PUBLICHOME (long) 526
307 #define SET_PUBLICHOME (long) 527
308 #define GET_SHAREDHOME (long) 528
309 #define SET_SHAREDHOME (long) 529
310 #define GET_MHPROFILE (long) 530
311 #define SET_MHPROFILE (long) 531
312 #define GET_MHPATH (long) 532
313 #define SET_MHPATH (long) 533
314 #define GET_ONETIMEEXPUNGEATPING (long) 534
315 #define SET_ONETIMEEXPUNGEATPING (long) 535
316 #define GET_USERHASNOLIFE (long) 536
317 #define SET_USERHASNOLIFE (long) 537
318 #define GET_FTPPROTECTION (long) 538
319 #define SET_FTPPROTECTION (long) 539
320 #define GET_PUBLICPROTECTION (long) 540
321 #define SET_PUBLICPROTECTION (long) 541
322 #define GET_SHAREDPROTECTION (long) 542
323 #define SET_SHAREDPROTECTION (long) 543
324 #define GET_LOCKTIMEOUT (long) 544
325 #define SET_LOCKTIMEOUT (long) 545
326 #define GET_NOTIMEZONES (long) 546
327 #define SET_NOTIMEZONES (long) 547
328 #define GET_HIDEDOTFILES (long) 548
329 #define SET_HIDEDOTFILES (long) 549
330 #define GET_FTPDIRPROTECTION (long) 550
331 #define SET_FTPDIRPROTECTION (long) 551
332 #define GET_PUBLICDIRPROTECTION (long) 552
333 #define SET_PUBLICDIRPROTECTION (long) 553
334 #define GET_SHAREDDIRPROTECTION (long) 554
335 #define SET_SHAREDDIRPROTECTION (long) 555
336 #define GET_TRUSTDNS (long) 556
337 #define SET_TRUSTDNS (long) 557
338 #define GET_SASLUSESPTRNAME (long) 558
339 #define SET_SASLUSESPTRNAME (long) 559
340 #define GET_NETFSSTATBUG (long) 560
341 #define SET_NETFSSTATBUG (long) 561
342 #define GET_SNARFMAILBOXNAME (long) 562
343 #define SET_SNARFMAILBOXNAME (long) 563
344 #define GET_SNARFINTERVAL (long) 564
345 #define SET_SNARFINTERVAL (long) 565
346 #define GET_SNARFPRESERVE (long) 566
347 #define SET_SNARFPRESERVE (long) 567
348 #define GET_INBOXPATH (long) 568
349 #define SET_INBOXPATH (long) 569
350 #define GET_DIRFMTTEST (long) 570
351 #define SET_DIRFMTTEST (long) 571
352 #define GET_SCANCONTENTS (long) 572
353 #define SET_SCANCONTENTS (long) 573
354 #define GET_MHALLOWINBOX (long) 574
355 #define SET_MHALLOWINBOX (long) 575
357 /* Driver flags */
359 #define DR_DISABLE (long) 0x1 /* driver is disabled */
360 #define DR_LOCAL (long) 0x2 /* local file driver */
361 #define DR_MAIL (long) 0x4 /* supports mail */
362 #define DR_NEWS (long) 0x8 /* supports news */
363 #define DR_READONLY (long) 0x10 /* driver only allows readonly access */
364 #define DR_NOFAST (long) 0x20 /* "fast" data is slow (whole msg fetch) */
365 #define DR_NAMESPACE (long) 0x40/* driver has a special namespace */
366 #define DR_LOWMEM (long) 0x80 /* low amounts of memory available */
367 #define DR_LOCKING (long) 0x100 /* driver does locking */
368 #define DR_CRLF (long) 0x200 /* driver internal form uses CRLF newlines */
369 #define DR_NOSTICKY (long) 0x400/* driver does not support sticky UIDs */
370 #define DR_RECYCLE (long) 0x800 /* driver does stream recycling */
371 #define DR_XPOINT (long) 0x1000 /* needs to be checkpointed */
372 /* driver has no real internal date */
373 #define DR_NOINTDATE (long) 0x2000
374 /* driver does not announce new mail */
375 #define DR_NONEWMAIL (long) 0x4000
376 /* driver does not announce new mail when RO */
377 #define DR_NONEWMAILRONLY (long) 0x8000
378 /* driver can be halfopen */
379 #define DR_HALFOPEN (long) 0x10000
380 #define DR_DIRFMT (long) 0x20000/* driver is a directory-format */
381 #define DR_MODSEQ (long) 0x40000/* driver supports modseqs */
384 /* Cache management function codes */
386 #define CH_INIT (long) 10 /* initialize cache */
387 #define CH_SIZE (long) 11 /* (re-)size the cache */
388 #define CH_MAKEELT (long) 30 /* return elt, make if needed */
389 #define CH_ELT (long) 31 /* return elt if exists */
390 #define CH_SORTCACHE (long) 35 /* return sortcache entry, make if needed */
391 #define CH_FREE (long) 40 /* free space used by elt */
392 /* free space used by sortcache */
393 #define CH_FREESORTCACHE (long) 43
394 #define CH_EXPUNGE (long) 45 /* delete elt pointer from list */
397 /* Mailbox open options
398 * For compatibility with the past, OP_DEBUG must always be 1.
399 */
401 #define OP_DEBUG (long) 0x1 /* debug protocol negotiations */
402 #define OP_READONLY (long) 0x2 /* read-only open */
403 #define OP_ANONYMOUS (long) 0x4 /* anonymous open of newsgroup */
404 #define OP_SHORTCACHE (long) 0x8/* short (elt-only) caching */
405 #define OP_SILENT (long) 0x10 /* don't pass up events (internal use) */
406 #define OP_PROTOTYPE (long) 0x20/* return driver prototype */
407 #define OP_HALFOPEN (long) 0x40 /* half-open (IMAP connect but no select) */
408 #define OP_EXPUNGE (long) 0x80 /* silently expunge recycle stream */
409 #define OP_SECURE (long) 0x100 /* don't do non-secure authentication */
410 #define OP_TRYSSL (long) 0x200 /* try SSL first */
411 /* use multiple newsrc files */
412 #define OP_MULNEWSRC (long) 0x400
413 #define OP_NOKOD (long) 0x800 /* suppress kiss-of-death */
414 #define OP_SNIFF (long) 0x1000 /* metadata only open */
415 /* reserved for application use */
416 #define OP_RESERVED (unsigned long) 0xff000000
419 /* Net open options */
421 /* no error messages */
422 #define NET_SILENT ((unsigned long) 0x80000000)
423 /* no validation of SSL certificates */
424 #define NET_NOVALIDATECERT ((unsigned long) 0x40000000)
425 /* no open timeout */
426 #define NET_NOOPENTIMEOUT ((unsigned long) 0x20000000)
427 /* TLS not SSL */
428 #define NET_TLSCLIENT ((unsigned long) 0x10000000)
429 /* try SSL mode */
430 #define NET_TRYSSL ((unsigned long) 0x8000000)
432 /* Close options */
434 #define CL_EXPUNGE (long) 1 /* expunge silently */
437 /* Fetch options */
439 #define FT_UID (long) 0x1 /* argument is a UID */
440 #define FT_PEEK (long) 0x2 /* peek at data */
441 #define FT_NOT (long) 0x4 /* NOT flag for header lines fetch */
442 #define FT_INTERNAL (long) 0x8 /* text can be internal strings */
443 /* IMAP prefetch text when fetching header */
444 #define FT_PREFETCHTEXT (long) 0x20
445 #define FT_NOHDRS (long) 0x40 /* suppress fetching extra headers (note that
446 this breaks news handling) */
447 #define FT_NEEDENV (long) 0x80 /* (internal use) include envelope */
448 #define FT_NEEDBODY (long) 0x100/* (internal use) include body structure */
449 /* no fetch lookahead */
450 #define FT_NOLOOKAHEAD (long) 0x200
451 /* (internal use) lookahead in hdr searching */
452 #define FT_SEARCHLOOKAHEAD (long) 0x400
453 /* stringstruct return hack */
454 #define FT_RETURNSTRINGSTRUCT (long) 0x800
457 /* Flagging options */
459 #define ST_UID (long) 0x1 /* argument is a UID sequence */
460 #define ST_SILENT (long) 0x2 /* don't return results */
461 #define ST_SET (long) 0x4 /* set vs. clear */
464 /* Expunge options */
466 #define EX_UID (long) 0x1 /* argument is a UID sequence */
469 /* Copy options */
471 #define CP_UID (long) 0x1 /* argument is a UID sequence */
472 #define CP_MOVE (long) 0x2 /* delete from source after copying */
473 /* set debug in any created stream */
474 #define CP_DEBUG (long) 0x20000000
476 /* Search/sort/thread options */
478 #define SE_UID (long) 0x1 /* return UID */
479 #define SE_FREE (long) 0x2 /* free search program after finished */
480 #define SE_NOPREFETCH (long) 0x4/* no search prefetching */
481 #define SO_FREE (long) 0x8 /* free sort program after finished */
482 #define SE_NOSERVER (long) 0x10 /* don't do server-based search/sort/thread */
483 #define SE_RETAIN (long) 0x20 /* retain previous search results */
484 #define SO_OVERVIEW (long) 0x40 /* use overviews in searching (NNTP only) */
485 #define SE_NEEDBODY (long) 0x80 /* include body structure in prefetch */
486 #define SE_NOHDRS (long) 0x100 /* suppress prefetching extra headers (note
487 that this breaks news handling) */
488 #define SE_NOLOCAL (long) 0x200 /* no local retry (IMAP only) */
490 #define SO_NOSERVER SE_NOSERVER /* compatibility name */
491 #define SE_SILLYOK (long) 0x400 /* allow silly searches */
494 /* Status options */
496 #define SA_MESSAGES (long) 0x1 /* number of messages */
497 #define SA_RECENT (long) 0x2 /* number of recent messages */
498 #define SA_UNSEEN (long) 0x4 /* number of unseen messages */
499 #define SA_UIDNEXT (long) 0x8 /* next UID to be assigned */
500 /* UID validity value */
501 #define SA_UIDVALIDITY (long) 0x10
502 /* set OP_DEBUG on any created stream */
503 #define SA_DEBUG (long) 0x10000000
504 /* use multiple newsrcs */
505 #define SA_MULNEWSRC (long) 0x20000000
507 /* Mailgets flags */
509 #define MG_UID (long) 0x1 /* message number is a UID */
510 #define MG_COPY (long) 0x2 /* must return copy of argument */
512 /* SASL authenticator categories */
514 #define AU_SECURE (long) 0x1 /* /secure allowed */
515 #define AU_AUTHUSER (long) 0x2 /* /authuser=xxx allowed */
516 /* authenticator hidden */
517 #define AU_HIDE (long) 0x10000000
518 /* authenticator disabled */
519 #define AU_DISABLE (long) 0x20000000
522 /* Garbage collection flags */
524 #define GC_ELT (long) 0x1 /* message cache elements */
525 #define GC_ENV (long) 0x2 /* envelopes and bodies */
526 #define GC_TEXTS (long) 0x4 /* cached texts */
529 /* mm_log()/mm_notify() condition codes */
531 #define WARN (long) 1 /* mm_log warning type */
532 #define ERROR (long) 2 /* mm_log error type */
533 #define PARSE (long) 3 /* mm_log parse error type */
534 #define BYE (long) 4 /* mm_notify stream dying */
535 #define TCPDEBUG (long) 5 /* mm_log TCP debug babble */
538 /* Bits from mail_parse_flags(). Don't change these, since the header format
539 * used by tenex, mtx, and mbx corresponds to these bits.
540 */
542 #define fSEEN 0x1
543 #define fDELETED 0x2
544 #define fFLAGGED 0x4
545 #define fANSWERED 0x8
546 #define fOLD 0x10
547 #define fDRAFT 0x20
549 #define fEXPUNGED 0x8000 /* internal flag */
551 /* Bits for mm_list() and mm_lsub() */
553 /* Note that (LATT_NOINFERIORS LATT_HASCHILDREN LATT_HASNOCHILDREN) and
554 * (LATT_NOSELECT LATT_MARKED LATT_UNMARKED) each have eight possible states,
555 * but only four of these are valid. The other four are silly states which
556 * while invalid can unfortunately be expressed in the IMAP protocol.
557 */
559 /* terminal node in hierarchy */
560 #define LATT_NOINFERIORS (long) 0x1
561 /* name can not be selected */
562 #define LATT_NOSELECT (long) 0x2
563 /* changed since last accessed */
564 #define LATT_MARKED (long) 0x4
565 /* accessed since last changed */
566 #define LATT_UNMARKED (long) 0x8
567 /* name has referral to remote mailbox */
568 #define LATT_REFERRAL (long) 0x10
569 /* has selectable inferiors */
570 #define LATT_HASCHILDREN (long) 0x20
571 /* has no selectable inferiors */
572 #define LATT_HASNOCHILDREN (long) 0x40
575 /* Sort functions */
577 #define SORTDATE 0 /* date */
578 #define SORTARRIVAL 1 /* arrival date */
579 #define SORTFROM 2 /* from */
580 #define SORTSUBJECT 3 /* subject */
581 #define SORTTO 4 /* to */
582 #define SORTCC 5 /* cc */
583 #define SORTSIZE 6 /* size */
586 /* imapreferral_t codes */
588 #define REFAUTHFAILED (long) 0 /* authentication referral -- not logged in */
589 #define REFAUTH (long) 1 /* authentication referral -- logged in */
590 #define REFSELECT (long) 2 /* select referral */
591 #define REFCREATE (long) 3
592 #define REFDELETE (long) 4
593 #define REFRENAME (long) 5
594 #define REFSUBSCRIBE (long) 6
595 #define REFUNSUBSCRIBE (long) 7
596 #define REFSTATUS (long) 8
597 #define REFCOPY (long) 9
598 #define REFAPPEND (long) 10
601 /* sendcommand_t codes */
603 /* expunge response deferred */
604 #define SC_EXPUNGEDEFERRED (long) 1
606 /* Block notification codes */
608 #define BLOCK_NONE 0 /* not blocked */
609 #define BLOCK_SENSITIVE 1 /* sensitive code, disallow alarms */
610 #define BLOCK_NONSENSITIVE 2 /* non-sensitive code, allow alarms */
611 #define BLOCK_DNSLOOKUP 10 /* blocked on DNS lookup */
612 #define BLOCK_TCPOPEN 11 /* blocked on TCP open */
613 #define BLOCK_TCPREAD 12 /* blocked on TCP read */
614 #define BLOCK_TCPWRITE 13 /* blocked on TCP write */
615 #define BLOCK_TCPCLOSE 14 /* blocked on TCP close */
616 #define BLOCK_FILELOCK 20 /* blocked on file locking */
619 /* In-memory sized-text */
621 #define SIZEDTEXT struct mail_sizedtext
623 SIZEDTEXT {
624 unsigned char *data; /* text */
625 unsigned long size; /* size of text in octets */
626 };
629 /* String list */
631 #define STRINGLIST struct string_list
633 STRINGLIST {
634 SIZEDTEXT text; /* string text */
635 STRINGLIST *next;
636 };
639 /* Parse results from mail_valid_net_parse */
641 #define NETMAXHOST 256
642 #define NETMAXUSER 65
643 #define NETMAXMBX (MAILTMPLEN/4)
644 #define NETMAXSRV 21
645 typedef struct net_mailbox {
646 char host[NETMAXHOST]; /* host name (may be canonicalized) */
647 char orighost[NETMAXHOST]; /* host name before canonicalization */
648 char user[NETMAXUSER]; /* user name */
649 char authuser[NETMAXUSER]; /* authentication user name */
650 char mailbox[NETMAXMBX]; /* mailbox name */
651 char service[NETMAXSRV]; /* service name */
652 unsigned long port; /* TCP port number */
653 unsigned int anoflag : 1; /* anonymous */
654 unsigned int dbgflag : 1; /* debug flag */
655 unsigned int secflag : 1; /* secure flag */
656 unsigned int sslflag : 1; /* SSL driver flag */
657 unsigned int trysslflag : 1; /* try SSL driver first flag */
658 unsigned int novalidate : 1; /* don't validate certificates */
659 unsigned int tlsflag : 1; /* TLS flag */
660 unsigned int notlsflag : 1; /* do not do TLS flag */
661 unsigned int readonlyflag : 1;/* want readonly */
662 unsigned int norsh : 1; /* don't use rsh/ssh */
663 unsigned int loser : 1; /* server is a loser */
664 unsigned int tlssslv23 : 1; /* force SSLv23 client method over TLS */
665 } NETMBX;
667 /* Item in an address list */
669 #define ADDRESS struct mail_address
671 ADDRESS {
672 char *personal; /* personal name phrase */
673 char *adl; /* at-domain-list source route */
674 char *mailbox; /* mailbox name */
675 char *host; /* domain name of mailbox's host */
676 char *error; /* error in address from SMTP module */
677 struct {
678 char *type; /* address type (default "rfc822") */
679 char *addr; /* address as xtext */
680 } orcpt;
681 ADDRESS *next; /* pointer to next address in list */
682 };
685 /* Message envelope */
687 typedef struct mail_envelope {
688 unsigned int incomplete : 1; /* envelope may be incomplete */
689 unsigned int imapenvonly : 1; /* envelope only has IMAP envelope */
690 char *remail; /* remail header if any */
691 ADDRESS *return_path; /* error return address */
692 unsigned char *date; /* message composition date string */
693 ADDRESS *from; /* originator address list */
694 ADDRESS *sender; /* sender address list */
695 ADDRESS *reply_to; /* reply address list */
696 char *subject; /* message subject string */
697 ADDRESS *to; /* primary recipient list */
698 ADDRESS *cc; /* secondary recipient list */
699 ADDRESS *bcc; /* blind secondary recipient list */
700 char *in_reply_to; /* replied message ID */
701 char *message_id; /* message ID */
702 char *newsgroups; /* USENET newsgroups */
703 char *followup_to; /* USENET reply newsgroups */
704 char *references; /* USENET references */
705 void *sparep; /* spare pointer reserved for main program */
706 } ENVELOPE;
708 /* Primary body types */
709 /* If you change any of these you must also change body_types in rfc822.c */
711 #define TYPETEXT 0 /* unformatted text */
712 #define TYPEMULTIPART 1 /* multiple part */
713 #define TYPEMESSAGE 2 /* encapsulated message */
714 #define TYPEAPPLICATION 3 /* application data */
715 #define TYPEAUDIO 4 /* audio */
716 #define TYPEIMAGE 5 /* static image */
717 #define TYPEVIDEO 6 /* video */
718 #define TYPEMODEL 7 /* model */
719 #define TYPEOTHER 8 /* unknown */
720 #define TYPEMAX 15 /* maximum type code */
723 /* Body encodings */
724 /* If you change any of these you must also change body_encodings in rfc822.c
725 */
727 #define ENC7BIT 0 /* 7 bit SMTP semantic data */
728 #define ENC8BIT 1 /* 8 bit SMTP semantic data */
729 #define ENCBINARY 2 /* 8 bit binary data */
730 #define ENCBASE64 3 /* base-64 encoded data */
731 #define ENCQUOTEDPRINTABLE 4 /* human-readable 8-as-7 bit data */
732 #define ENCOTHER 5 /* unknown */
733 #define ENCMAX 10 /* maximum encoding code */
736 /* Body contents */
738 #define BODY struct mail_bodystruct
739 #define MESSAGE struct mail_body_message
740 #define PARAMETER struct mail_body_parameter
741 #define PART struct mail_body_part
742 #define PARTTEXT struct mail_body_text
744 /* Message body text */
746 PARTTEXT {
747 unsigned long offset; /* offset from body origin */
748 SIZEDTEXT text; /* text */
749 };
752 /* Message body structure */
754 BODY {
755 unsigned short type; /* body primary type */
756 unsigned short encoding; /* body transfer encoding */
757 char *subtype; /* subtype string */
758 PARAMETER *parameter; /* parameter list */
759 char *id; /* body identifier */
760 char *description; /* body description */
761 struct { /* body disposition */
762 char *type; /* disposition type */
763 PARAMETER *parameter; /* disposition parameters */
764 } disposition;
765 STRINGLIST *language; /* body language */
766 char *location; /* body content URI */
767 PARTTEXT mime; /* MIME header */
768 PARTTEXT contents; /* body part contents */
769 union { /* different ways of accessing contents */
770 PART *part; /* body part list */
771 MESSAGE *msg; /* body encapsulated message */
772 } nested;
773 struct {
774 unsigned long lines; /* size of text in lines */
775 unsigned long bytes; /* size of text in octets */
776 } size;
777 char *md5; /* MD5 checksum */
778 void *sparep; /* spare pointer reserved for main program */
779 };
782 /* Parameter list */
784 PARAMETER {
785 char *attribute; /* parameter attribute name */
786 char *value; /* parameter value */
787 PARAMETER *next; /* next parameter in list */
788 };
791 /* Multipart content list */
793 PART {
794 BODY body; /* body information for this part */
795 PART *next; /* next body part */
796 };
799 /* RFC-822 Message */
801 MESSAGE {
802 ENVELOPE *env; /* message envelope */
803 BODY *body; /* message body */
804 PARTTEXT full; /* full message */
805 STRINGLIST *lines; /* lines used to filter header */
806 PARTTEXT header; /* header text */
807 PARTTEXT text; /* body text */
808 };
810 /* Entry in the message cache array */
812 typedef struct message_cache {
813 unsigned long msgno; /* message number */
814 unsigned int lockcount : 8; /* non-zero if multiple references */
815 unsigned long rfc822_size; /* # of bytes of message as raw RFC822 */
816 struct { /* c-client internal use only */
817 unsigned long uid; /* message unique ID */
818 unsigned long mod; /* modseq */
819 PARTTEXT special; /* special text pointers */
820 MESSAGE msg; /* internal message pointers */
821 union { /* driver internal use */
822 unsigned long data;
823 void *ptr;
824 } spare;
825 unsigned int sequence : 1; /* saved sequence bit */
826 unsigned int dirty : 1; /* driver internal use */
827 unsigned int filter : 1; /* driver internal use */
828 unsigned int ghost : 1; /* driver internal use */
829 } private;
830 /* internal date */
831 unsigned int day : 5; /* day of month (1-31) */
832 unsigned int month : 4; /* month of year (1-12) */
833 unsigned int year : 7; /* year since BASEYEAR (expires in 127 yrs) */
834 unsigned int hours: 5; /* hours (0-23) */
835 unsigned int minutes: 6; /* minutes (0-59) */
836 unsigned int seconds: 6; /* seconds (0-59) */
837 unsigned int zoccident : 1; /* non-zero if west of UTC */
838 unsigned int zhours : 4; /* hours from UTC (0-12) */
839 unsigned int zminutes: 6; /* minutes (0-59) */
840 /* system flags */
841 unsigned int seen : 1; /* system Seen flag */
842 unsigned int deleted : 1; /* system Deleted flag */
843 unsigned int flagged : 1; /* system Flagged flag */
844 unsigned int answered : 1; /* system Answered flag */
845 unsigned int draft : 1; /* system Draft flag */
846 unsigned int recent : 1; /* system Recent flag */
847 /* message status */
848 unsigned int valid : 1; /* elt has valid flags */
849 unsigned int searched : 1; /* message was searched */
850 unsigned int sequence : 1; /* message is in sequence */
851 /* reserved for use by main program */
852 unsigned int spare : 1; /* first spare bit */
853 unsigned int spare2 : 1; /* second spare bit */
854 unsigned int spare3 : 1; /* third spare bit */
855 unsigned int spare4 : 1; /* fourth spare bit */
856 unsigned int spare5 : 1; /* fifth spare bit */
857 unsigned int spare6 : 1; /* sixth spare bit */
858 unsigned int spare7 : 1; /* seventh spare bit */
859 unsigned int spare8 : 1; /* eighth spare bit */
860 void *sparep; /* spare pointer */
861 void *maildirp; /* for the Maildir driver */
862 unsigned long user_flags; /* user-assignable flags */
863 } MESSAGECACHE;
865 /* String structure */
867 #define STRINGDRIVER struct string_driver
869 typedef struct mailstring {
870 void *data; /* driver-dependent data */
871 unsigned long data1; /* driver-dependent data */
872 unsigned long size; /* total length of string */
873 char *chunk; /* base address of chunk */
874 unsigned long chunksize; /* size of chunk */
875 unsigned long offset; /* offset of this chunk in base */
876 char *curpos; /* current position in chunk */
877 unsigned long cursize; /* number of bytes remaining in chunk */
878 STRINGDRIVER *dtb; /* driver that handles this type of string */
879 } STRING;
882 /* Dispatch table for string driver */
884 STRINGDRIVER {
885 /* initialize string driver */
886 void (*init) (STRING *s,void *data,unsigned long size);
887 /* get next character in string */
888 char (*next) (STRING *s);
889 /* set position in string */
890 void (*setpos) (STRING *s,unsigned long i);
891 };
894 /* Stringstruct access routines */
896 #define INIT(s,d,data,size) ((*((s)->dtb = &d)->init) (s,data,size))
897 #define SIZE(s) ((s)->size - GETPOS (s))
898 #define CHR(s) (*(s)->curpos)
899 #define SNX(s) (--(s)->cursize ? *(s)->curpos++ : (*(s)->dtb->next) (s))
900 #define GETPOS(s) ((s)->offset + ((s)->curpos - (s)->chunk))
901 #define SETPOS(s,i) (*(s)->dtb->setpos) (s,i)
903 /* Search program */
905 #define SEARCHPGM struct search_program
906 #define SEARCHHEADER struct search_header
907 #define SEARCHSET struct search_set
908 #define SEARCHOR struct search_or
909 #define SEARCHPGMLIST struct search_pgm_list
912 SEARCHHEADER { /* header search */
913 SIZEDTEXT line; /* header line */
914 SIZEDTEXT text; /* text in header */
915 SEARCHHEADER *next; /* next in list */
916 };
919 SEARCHSET { /* message set */
920 unsigned long first; /* sequence number */
921 unsigned long last; /* last value, if a range */
922 SEARCHSET *next; /* next in list */
923 };
926 SEARCHOR {
927 SEARCHPGM *first; /* first program */
928 SEARCHPGM *second; /* second program */
929 SEARCHOR *next; /* next in list */
930 };
933 SEARCHPGMLIST {
934 SEARCHPGM *pgm; /* search program */
935 SEARCHPGMLIST *next; /* next in list */
936 };
938 SEARCHPGM { /* search program */
939 SEARCHSET *msgno; /* message numbers */
940 SEARCHSET *uid; /* unique identifiers */
941 SEARCHOR *or; /* or'ed in programs */
942 SEARCHPGMLIST *not; /* and'ed not program */
943 SEARCHHEADER *header; /* list of headers */
944 STRINGLIST *bcc; /* bcc recipients */
945 STRINGLIST *body; /* text in message body */
946 STRINGLIST *cc; /* cc recipients */
947 STRINGLIST *from; /* originator */
948 STRINGLIST *keyword; /* keywords */
949 STRINGLIST *unkeyword; /* unkeywords */
950 STRINGLIST *subject; /* text in subject */
951 STRINGLIST *text; /* text in headers and body */
952 STRINGLIST *to; /* to recipients */
953 unsigned long larger; /* larger than this size */
954 unsigned long smaller; /* smaller than this size */
955 unsigned long older; /* older than this interval */
956 unsigned long younger; /* younger than this interval */
957 unsigned short sentbefore; /* sent before this date */
958 unsigned short senton; /* sent on this date */
959 unsigned short sentsince; /* sent since this date */
960 unsigned short before; /* before this date */
961 unsigned short on; /* on this date */
962 unsigned short since; /* since this date */
963 unsigned int answered : 1; /* answered messages */
964 unsigned int unanswered : 1; /* unanswered messages */
965 unsigned int deleted : 1; /* deleted messages */
966 unsigned int undeleted : 1; /* undeleted messages */
967 unsigned int draft : 1; /* message draft */
968 unsigned int undraft : 1; /* message undraft */
969 unsigned int flagged : 1; /* flagged messages */
970 unsigned int unflagged : 1; /* unflagged messages */
971 unsigned int recent : 1; /* recent messages */
972 unsigned int old : 1; /* old messages */
973 unsigned int seen : 1; /* seen messages */
974 unsigned int unseen : 1; /* unseen messages */
975 /* These must be simulated in IMAP */
976 STRINGLIST *return_path; /* error return address */
977 STRINGLIST *sender; /* sender address list */
978 STRINGLIST *reply_to; /* reply address list */
979 STRINGLIST *in_reply_to; /* replied message ID */
980 STRINGLIST *message_id; /* message ID */
981 STRINGLIST *newsgroups; /* USENET newsgroups */
982 STRINGLIST *followup_to; /* USENET reply newsgroups */
983 STRINGLIST *references; /* USENET references */
984 };
987 /* Mailbox status */
989 typedef struct mbx_status {
990 long flags; /* validity flags */
991 unsigned long messages; /* number of messages */
992 unsigned long recent; /* number of recent messages */
993 unsigned long unseen; /* number of unseen messages */
994 unsigned long uidnext; /* next UID to be assigned */
995 unsigned long uidvalidity; /* UID validity value */
996 } MAILSTATUS;
998 /* Sort program */
1000 typedef void (*postsort_t) (void *sc);
1002 #define SORTPGM struct sort_program
1004 SORTPGM {
1005 unsigned int reverse : 1; /* sort function is to be reversed */
1006 unsigned int abort : 1; /* abort sorting */
1007 short function; /* sort function */
1008 unsigned long nmsgs; /* number of messages being sorted */
1009 struct {
1010 unsigned long cached; /* number of messages cached so far */
1011 unsigned long sorted; /* number of messages sorted so far */
1012 unsigned long postsorted; /* number of postsorted messages so far */
1013 } progress;
1014 postsort_t postsort; /* post sorter */
1015 SORTPGM *next; /* next function */
1016 };
1019 /* Sort cache */
1021 #define SORTCACHE struct sort_cache
1023 SORTCACHE {
1024 unsigned int sorted : 1; /* message has been sorted */
1025 unsigned int postsorted : 1; /* message has been postsorted */
1026 unsigned int refwd : 1; /* subject is a re or fwd */
1027 unsigned int dirty : 1; /* has data not written to backup */
1028 SORTPGM *pgm; /* sort program */
1029 unsigned long num; /* message number (sequence or UID) */
1030 unsigned long date; /* sent date */
1031 unsigned long arrival; /* arrival date */
1032 unsigned long size; /* message size */
1033 char *from; /* from string */
1034 char *to; /* to string */
1035 char *cc; /* cc string */
1036 char *subject; /* extracted subject string */
1037 char *message_id; /* message-id string */
1038 char *unique; /* unique string, normally message-id */
1039 STRINGLIST *references; /* references string */
1040 };
1042 /* ACL list */
1044 #define ACLLIST struct acl_list
1046 ACLLIST {
1047 char *identifier; /* authentication identifier */
1048 char *rights; /* access rights */
1049 ACLLIST *next;
1050 };
1052 /* Quota resource list */
1054 #define QUOTALIST struct quota_list
1056 QUOTALIST {
1057 char *name; /* resource name */
1058 unsigned long usage; /* resource usage */
1059 unsigned long limit; /* resource limit */
1060 QUOTALIST *next; /* next resource */
1061 };
1063 /* Mail Access I/O stream */
1066 /* Structure for mail driver dispatch */
1068 #define DRIVER struct driver
1071 /* Mail I/O stream */
1073 typedef struct mail_stream {
1074 DRIVER *dtb; /* dispatch table for this driver */
1075 void *local; /* pointer to driver local data */
1076 char *mailbox; /* mailbox name (canonicalized) */
1077 char *original_mailbox; /* mailbox name (non-canonicalized) */
1078 unsigned short use; /* stream use count */
1079 unsigned short sequence; /* stream sequence */
1080 unsigned int inbox : 1; /* stream open on an INBOX */
1081 unsigned int lock : 1; /* stream lock flag */
1082 unsigned int debug : 1; /* stream debug flag */
1083 unsigned int silent : 1; /* don't pass events to main program */
1084 unsigned int rdonly : 1; /* stream read-only flag */
1085 unsigned int anonymous : 1; /* stream anonymous access flag */
1086 unsigned int scache : 1; /* stream short cache flag */
1087 unsigned int halfopen : 1; /* stream half-open flag */
1088 unsigned int secure : 1; /* stream secure flag */
1089 unsigned int tryssl : 1; /* stream tryssl flag */
1090 unsigned int mulnewsrc : 1; /* stream use multiple newsrc files */
1091 unsigned int perm_seen : 1; /* permanent Seen flag */
1092 unsigned int perm_deleted : 1;/* permanent Deleted flag */
1093 unsigned int perm_flagged : 1;/* permanent Flagged flag */
1094 unsigned int perm_answered :1;/* permanent Answered flag */
1095 unsigned int perm_draft : 1; /* permanent Draft flag */
1096 unsigned int kwd_create : 1; /* can create new keywords */
1097 unsigned int uid_nosticky : 1;/* UIDs are not preserved */
1098 unsigned int unhealthy : 1; /* unhealthy protocol negotiations */
1099 unsigned int nokod : 1; /* suppress kiss-of-death */
1100 unsigned int sniff : 1; /* metadata only */
1101 unsigned long perm_user_flags;/* mask of permanent user flags */
1102 unsigned long gensym; /* generated tag */
1103 unsigned long nmsgs; /* # of associated msgs */
1104 unsigned long recent; /* # of recent msgs */
1105 unsigned long uid_validity; /* UID validity sequence */
1106 unsigned long uid_last; /* last assigned UID */
1107 char *user_flags[NUSERFLAGS]; /* pointers to user flags in bit order */
1108 unsigned long cachesize; /* size of message cache */
1109 MESSAGECACHE **cache; /* message cache array */
1110 SORTCACHE **sc; /* sort cache array */
1111 unsigned long msgno; /* message number of `current' message */
1112 ENVELOPE *env; /* scratch buffer for envelope */
1113 BODY *body; /* scratch buffer for body */
1114 SIZEDTEXT text; /* scratch buffer for text */
1115 struct {
1116 char *name; /* mailbox name to snarf from */
1117 unsigned long time; /* last snarf time */
1118 long options; /* snarf open options */
1119 } snarf;
1120 struct { /* internal use only */
1121 struct { /* search temporaries */
1122 STRINGLIST *string; /* string(s) to search */
1123 long result; /* search result */
1124 char *text; /* cache of fetched text */
1125 } search;
1126 STRING string; /* stringstruct return hack */
1127 } private;
1128 /* reserved for use by main program */
1129 void *sparep; /* spare pointer */
1130 unsigned int spare : 1; /* first spare bit */
1131 unsigned int spare2 : 1; /* second spare bit */
1132 unsigned int spare3 : 1; /* third spare bit */
1133 unsigned int spare4 : 1; /* fourth spare bit */
1134 unsigned int spare5 : 1; /* fifth spare bit */
1135 unsigned int spare6 : 1; /* sixth spare bit */
1136 unsigned int spare7 : 1; /* seventh spare bit */
1137 unsigned int spare8 : 1; /* eighth spare bit */
1138 } MAILSTREAM;
1140 /* Mail I/O stream handle */
1142 typedef struct mail_stream_handle {
1143 MAILSTREAM *stream; /* pointer to mail stream */
1144 unsigned short sequence; /* sequence of what we expect stream to be */
1145 } MAILHANDLE;
1148 /* Message overview */
1150 typedef struct mail_overview {
1151 char *subject; /* message subject string */
1152 ADDRESS *from; /* originator address list */
1153 char *date; /* message composition date string */
1154 char *message_id; /* message ID */
1155 char *references; /* USENET references */
1156 struct { /* may be 0 or NUL if unknown/undefined */
1157 unsigned long octets; /* message octets (probably LF-newline form) */
1158 unsigned long lines; /* message lines */
1159 char *xref; /* cross references */
1160 } optional;
1161 } OVERVIEW;
1163 /* Network access I/O stream */
1166 /* Structure for network driver dispatch */
1168 #define NETDRIVER struct net_driver
1171 /* Network transport I/O stream */
1173 typedef struct net_stream {
1174 void *stream; /* driver's I/O stream */
1175 NETDRIVER *dtb; /* network driver */
1176 } NETSTREAM;
1179 /* Network transport driver dispatch */
1181 NETDRIVER {
1182 void *(*open) (char *host,char *service,unsigned long port);
1183 void *(*aopen) (NETMBX *mb,char *service,char *usrbuf);
1184 char *(*getline) (void *stream);
1185 long (*getbuffer) (void *stream,unsigned long size,char *buffer);
1186 long (*soutr) (void *stream,char *string);
1187 long (*sout) (void *stream,char *string,unsigned long size);
1188 void (*close) (void *stream);
1189 char *(*host) (void *stream);
1190 char *(*remotehost) (void *stream);
1191 unsigned long (*port) (void *stream);
1192 char *(*localhost) (void *stream);
1193 };
1196 /* Mailgets data identifier */
1198 typedef struct getsdata {
1199 MAILSTREAM *stream;
1200 unsigned long msgno;
1201 char *what;
1202 STRINGLIST *stl;
1203 unsigned long first;
1204 unsigned long last;
1205 long flags;
1206 } GETS_DATA;
1209 #define INIT_GETS(md,s,m,w,f,l) \
1210 md.stream = s, md.msgno = m, md.what = w, md.first = f, md.last = l, \
1211 md.stl = NIL, md.flags = NIL;
1213 /* Mail delivery I/O stream */
1215 typedef struct send_stream {
1216 NETSTREAM *netstream; /* network I/O stream */
1217 char *host; /* SMTP service host */
1218 char *reply; /* last reply string */
1219 long replycode; /* last reply code */
1220 unsigned int debug : 1; /* stream debug flag */
1221 unsigned int sensitive : 1; /* sensitive data in progress */
1222 unsigned int loser : 1; /* server is a loser */
1223 unsigned int saslcancel : 1; /* SASL cancelled by protocol */
1224 union { /* protocol specific */
1225 struct { /* SMTP specific */
1226 unsigned int ok : 1; /* supports ESMTP */
1227 struct { /* service extensions */
1228 unsigned int send : 1; /* supports SEND */
1229 unsigned int soml : 1; /* supports SOML */
1230 unsigned int saml : 1; /* supports SAML */
1231 unsigned int expn : 1; /* supports EXPN */
1232 unsigned int help : 1; /* supports HELP */
1233 unsigned int turn : 1; /* supports TURN */
1234 unsigned int etrn : 1; /* supports ETRN */
1235 unsigned int starttls:1;/* supports STARTTLS */
1236 unsigned int relay : 1; /* supports relaying */
1237 unsigned int pipe : 1; /* supports pipelining */
1238 unsigned int ensc : 1; /* supports enhanced status codes */
1239 unsigned int bmime : 1; /* supports BINARYMIME */
1240 unsigned int chunk : 1; /* supports CHUNKING */
1241 } service;
1242 struct { /* 8-bit MIME transport */
1243 unsigned int ok : 1; /* supports 8-bit MIME */
1244 unsigned int want : 1; /* want 8-bit MIME */
1245 } eightbit;
1246 struct { /* delivery status notification */
1247 unsigned int ok : 1; /* supports DSN */
1248 unsigned int want : 1; /* want DSN */
1249 struct { /* notification options */
1250 /* notify on failure */
1251 unsigned int failure : 1;
1252 /* notify on delay */
1253 unsigned int delay : 1;
1254 /* notify on success */
1255 unsigned int success : 1;
1256 } notify;
1257 unsigned int full : 1; /* return full headers */
1258 char *envid; /* envelope identifier as xtext */
1259 } dsn;
1260 struct { /* size declaration */
1261 unsigned int ok : 1; /* supports SIZE */
1262 unsigned long limit; /* maximum size supported */
1263 } size;
1264 struct { /* deliverby declaration */
1265 unsigned int ok : 1; /* supports DELIVERBY */
1266 unsigned long minby; /* minimum by-time */
1267 } deliverby;
1268 struct { /* authenticated turn */
1269 unsigned int ok : 1; /* supports ATRN */
1270 char *domains; /* domains */
1271 } atrn;
1272 /* supported SASL authenticators */
1273 unsigned int auth : MAXAUTHENTICATORS;
1274 } esmtp;
1275 struct { /* NNTP specific */
1276 unsigned int post : 1; /* supports POST */
1277 struct { /* NNTP extensions */
1278 unsigned int ok : 1; /* supports extensions */
1279 /* supports LISTGROUP */
1280 unsigned int listgroup : 1;
1281 unsigned int over : 1; /* supports OVER */
1282 unsigned int hdr : 1; /* supports HDR */
1283 unsigned int pat : 1; /* supports PAT */
1284 /* supports STARTTLS */
1285 unsigned int starttls : 1;
1286 /* server has MULTIDOMAIN */
1287 unsigned int multidomain : 1;
1288 /* supports AUTHINFO USER */
1289 unsigned int authuser : 1;
1290 /* supported authenticators */
1291 unsigned int sasl : MAXAUTHENTICATORS;
1292 } ext;
1293 } nntp;
1294 } protocol;
1295 } SENDSTREAM;
1297 /* Jacket into external interfaces */
1299 typedef long (*readfn_t) (void *stream,unsigned long size,char *buffer);
1300 typedef char *(*mailgets_t) (readfn_t f,void *stream,unsigned long size,
1301 GETS_DATA *md);
1302 typedef char *(*readprogress_t) (GETS_DATA *md,unsigned long octets);
1303 typedef void *(*mailcache_t) (MAILSTREAM *stream,unsigned long msgno,long op);
1304 typedef long (*mailproxycopy_t) (MAILSTREAM *stream,char *sequence,
1305 char *mailbox,long options);
1306 typedef long (*tcptimeout_t) (long overall,long last);
1307 typedef void *(*authchallenge_t) (void *stream,unsigned long *len);
1308 typedef long (*authrespond_t) (void *stream,char *s,unsigned long size);
1309 typedef long (*authcheck_t) (void);
1310 typedef long (*authclient_t) (authchallenge_t challenger,
1311 authrespond_t responder,char *service,NETMBX *mb,
1312 void *s,unsigned long *trial,char *user);
1313 typedef char *(*authresponse_t) (void *challenge,unsigned long clen,
1314 unsigned long *rlen);
1315 typedef char *(*authserver_t) (authresponse_t responder,int argc,char *argv[]);
1316 typedef void (*smtpverbose_t) (char *buffer);
1317 typedef void (*imapenvelope_t) (MAILSTREAM *stream,unsigned long msgno,
1318 ENVELOPE *env);
1319 typedef char *(*imapreferral_t) (MAILSTREAM *stream,char *url,long code);
1320 typedef void (*overview_t) (MAILSTREAM *stream,unsigned long uid,OVERVIEW *ov,
1321 unsigned long msgno);
1322 typedef unsigned long *(*sorter_t) (MAILSTREAM *stream,char *charset,
1323 SEARCHPGM *spg,SORTPGM *pgm,long flags);
1324 typedef void (*parseline_t) (ENVELOPE *env,char *hdr,char *data,char *host);
1325 typedef ADDRESS *(*parsephrase_t) (char *phrase,char *end,char *host);
1326 typedef void *(*blocknotify_t) (int reason,void *data);
1327 typedef long (*kinit_t) (char *host,char *reason);
1328 typedef void (*sendcommand_t) (MAILSTREAM *stream,char *cmd,long flags);
1329 typedef char *(*newsrcquery_t) (MAILSTREAM *stream,char *mulname,char *name);
1330 typedef void (*getacl_t) (MAILSTREAM *stream,char *mailbox,ACLLIST *acl);
1331 typedef void (*listrights_t) (MAILSTREAM *stream,char *mailbox,char *id,
1332 char *alwaysrights,STRINGLIST *possiblerights);
1333 typedef void (*myrights_t) (MAILSTREAM *stream,char *mailbox,char *rights);
1334 typedef void (*quota_t) (MAILSTREAM *stream,char *qroot,QUOTALIST *qlist);
1335 typedef void (*quotaroot_t) (MAILSTREAM *stream,char *mbx,STRINGLIST *qroot);
1336 typedef void (*sortresults_t) (MAILSTREAM *stream,unsigned long *list,
1337 unsigned long size);
1338 typedef char *(*userprompt_t) (void);
1339 typedef long (*append_t) (MAILSTREAM *stream,void *data,char **flags,
1340 char **date,STRING **message);
1341 typedef void (*copyuid_t) (MAILSTREAM *stream,char *mailbox,
1342 unsigned long uidvalidity,SEARCHSET *sourceset,
1343 SEARCHSET *destset);
1344 typedef void (*appenduid_t) (char *mailbox,unsigned long uidvalidity,
1345 SEARCHSET *set);
1346 typedef long (*dirfmttest_t) (char *name);
1347 typedef long (*scancontents_t) (char *name,char *contents,unsigned long csiz,
1348 unsigned long fsiz);
1350 typedef void (*freeeltsparep_t) (void **sparep);
1351 typedef void (*freeenvelopesparep_t) (void **sparep);
1352 typedef void (*freebodysparep_t) (void **sparep);
1353 typedef void (*freestreamsparep_t) (void **sparep);
1354 typedef void *(*sslstart_t) (void *stream,char *host,unsigned long flags);
1355 typedef long (*sslcertificatequery_t) (char *reason,char *host,char *cert);
1356 typedef void (*sslfailure_t) (char *host,char *reason,unsigned long flags);
1357 typedef void (*logouthook_t) (void *data);
1358 typedef char *(*sslclientcert_t) (void);
1359 typedef char *(*sslclientkey_t) (void);
1361 /* Globals */
1363 extern char *body_types[]; /* defined body type strings */
1364 extern char *body_encodings[]; /* defined body encoding strings */
1365 extern const char *days[]; /* day name strings */
1366 extern const char *months[]; /* month name strings */
1368 /* Threading */
1370 /* Thread node */
1372 #define THREADNODE struct thread_node
1374 THREADNODE {
1375 unsigned long num; /* message number */
1376 SORTCACHE *sc; /* (internal use) sortcache entry */
1377 THREADNODE *branch; /* branch at this point in tree */
1378 THREADNODE *next; /* next node */
1379 };
1381 typedef void (*threadresults_t) (MAILSTREAM *stream,THREADNODE *tree);
1384 /* Thread dispatch */
1386 #define THREADER struct threader_list
1388 THREADER {
1389 char *name; /* name of threader */
1390 THREADNODE *(*dispatch) (MAILSTREAM *stream,char *charset,SEARCHPGM *spg,
1391 long flags,sorter_t sorter);
1392 THREADER *next;
1393 };
1396 /* Container for references threading */
1398 typedef void ** container_t;
1400 /* Namespaces */
1402 #define NAMESPACE struct mail_namespace
1404 NAMESPACE {
1405 char *name; /* name of this namespace */
1406 int delimiter; /* hierarchy delimiter */
1407 PARAMETER *param; /* namespace parameters */
1408 NAMESPACE *next; /* next namespace */
1409 };
1412 /* Authentication */
1414 #define AUTHENTICATOR struct mail_authenticator
1416 AUTHENTICATOR {
1417 long flags; /* authenticator flags */
1418 char *name; /* name of this authenticator */
1419 authcheck_t valid; /* authenticator valid on this system */
1420 authclient_t client; /* client function that supports it */
1421 authserver_t server; /* server function that supports it */
1422 AUTHENTICATOR *next; /* next authenticator */
1423 };
1425 /* Mail driver dispatch */
1427 DRIVER {
1428 char *name; /* driver name */
1429 unsigned long flags; /* driver flags */
1430 DRIVER *next; /* next driver */
1431 /* mailbox is valid for us */
1432 DRIVER *(*valid) (char *mailbox);
1433 /* manipulate driver parameters */
1434 void *(*parameters) (long function,void *value);
1435 /* scan mailboxes */
1436 void (*scan) (MAILSTREAM *stream,char *ref,char *pat,char *contents);
1437 /* list mailboxes */
1438 void (*list) (MAILSTREAM *stream,char *ref,char *pat);
1439 /* list subscribed mailboxes */
1440 void (*lsub) (MAILSTREAM *stream,char *ref,char *pat);
1441 /* subscribe to mailbox */
1442 long (*subscribe) (MAILSTREAM *stream,char *mailbox);
1443 /* unsubscribe from mailbox */
1444 long (*unsubscribe) (MAILSTREAM *stream,char *mailbox);
1445 /* create mailbox */
1446 long (*create) (MAILSTREAM *stream,char *mailbox);
1447 /* delete mailbox */
1448 long (*mbxdel) (MAILSTREAM *stream,char *mailbox);
1449 /* rename mailbox */
1450 long (*mbxren) (MAILSTREAM *stream,char *old,char *newname);
1451 /* status of mailbox */
1452 long (*status) (MAILSTREAM *stream,char *mbx,long flags);
1454 /* open mailbox */
1455 MAILSTREAM *(*open) (MAILSTREAM *stream);
1456 /* close mailbox */
1457 void (*close) (MAILSTREAM *stream,long options);
1458 /* fetch message "fast" attributes */
1459 void (*fast) (MAILSTREAM *stream,char *sequence,long flags);
1460 /* fetch message flags */
1461 void (*msgflags) (MAILSTREAM *stream,char *sequence,long flags);
1462 /* fetch message overview */
1463 long (*overview) (MAILSTREAM *stream,overview_t ofn);
1464 /* fetch message envelopes */
1465 ENVELOPE *(*structure) (MAILSTREAM *stream,unsigned long msgno,BODY **body,
1466 long flags);
1467 /* return RFC-822 header */
1468 char *(*header) (MAILSTREAM *stream,unsigned long msgno,
1469 unsigned long *length,long flags);
1470 /* return RFC-822 text */
1471 long (*text) (MAILSTREAM *stream,unsigned long msgno,STRING *bs,long flags);
1472 /* load cache */
1473 long (*msgdata) (MAILSTREAM *stream,unsigned long msgno,char *section,
1474 unsigned long first,unsigned long last,STRINGLIST *lines,
1475 long flags);
1476 /* return UID for message */
1477 unsigned long (*uid) (MAILSTREAM *stream,unsigned long msgno);
1478 /* return message number from UID */
1479 unsigned long (*msgno) (MAILSTREAM *stream,unsigned long uid);
1480 /* modify flags */
1481 void (*flag) (MAILSTREAM *stream,char *sequence,char *flag,long flags);
1482 /* per-message modify flags */
1483 void (*flagmsg) (MAILSTREAM *stream,MESSAGECACHE *elt);
1484 /* search for message based on criteria */
1485 long (*search) (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,long flags);
1486 /* sort messages */
1487 unsigned long *(*sort) (MAILSTREAM *stream,char *charset,SEARCHPGM *spg,
1488 SORTPGM *pgm,long flags);
1489 /* thread messages */
1490 THREADNODE *(*thread) (MAILSTREAM *stream,char *type,char *charset,
1491 SEARCHPGM *spg,long flag);
1492 /* ping mailbox to see if still alive */
1493 long (*ping) (MAILSTREAM *stream);
1494 /* check for new messages */
1495 void (*check) (MAILSTREAM *stream);
1496 /* expunge deleted messages */
1497 long (*expunge) (MAILSTREAM *stream,char *sequence,long options);
1498 /* copy messages to another mailbox */
1499 long (*copy) (MAILSTREAM *stream,char *sequence,char *mailbox,long options);
1500 /* append string message to mailbox */
1501 long (*append) (MAILSTREAM *stream,char *mailbox,append_t af,void *data);
1502 /* garbage collect stream */
1503 void (*gc) (MAILSTREAM *stream,long gcflags);
1504 };
1507 #include "linkage.h"
1509 /* Compatibility support names for old interfaces */
1511 #define GET_TRYALTFIRST GET_TRYSSLFIRST
1512 #define SET_TRYALTFIRST SET_TRYSSLFIRST
1513 #define GET_IMAPTRYALT GET_IMAPTRYSSL
1514 #define SET_IMAPTRYALT SET_IMAPTRYSSL
1515 #define OP_TRYALT OP_TRYSSL
1516 #define altflag sslflag
1518 #define mail_close(stream) \
1519 mail_close_full (stream,NIL)
1520 #define mail_fetchfast(stream,sequence) \
1521 mail_fetch_fast (stream,sequence,NIL)
1522 #define mail_fetchfast_full mail_fetch_fast
1523 #define mail_fetchflags(stream,sequence) \
1524 mail_fetch_flags (stream,sequence,NIL)
1525 #define mail_fetchflags_full mail_fetch_flags
1526 #define mail_fetchenvelope(stream,msgno) \
1527 mail_fetch_structure (stream,msgno,NIL,NIL)
1528 #define mail_fetchstructure(stream,msgno,body) \
1529 mail_fetch_structure (stream,msgno,body,NIL)
1530 #define mail_fetchstructure_full mail_fetch_structure
1531 #define mail_fetchheader(stream,msgno) \
1532 mail_fetch_header (stream,msgno,NIL,NIL,NIL,FT_PEEK)
1533 #define mail_fetchheader_full(stream,msgno,lines,len,flags) \
1534 mail_fetch_header (stream,msgno,NIL,lines,len,FT_PEEK | (flags))
1535 #define mail_fetchtext(stream,msgno) \
1536 mail_fetch_text (stream,msgno,NIL,NIL,NIL)
1537 #define mail_fetchtext_full(stream,msgno,length,flags) \
1538 mail_fetch_text (stream,msgno,NIL,length,flags)
1539 #define mail_fetchbody(stream,msgno,section,length) \
1540 mail_fetch_body (stream,msgno,section,length,NIL)
1541 #define mail_fetchbody_full mail_fetch_body
1542 #define mail_setflag(stream,sequence,flag) \
1543 mail_flag (stream,sequence,flag,ST_SET)
1544 #define mail_setflag_full(stream,sequence,flag,flags) \
1545 mail_flag (stream,sequence,flag,ST_SET | (flags))
1546 #define mail_clearflag(stream,sequence,flag) \
1547 mail_flag (stream,sequence,flag,NIL)
1548 #define mail_clearflag_full mail_flag
1549 #define mail_search(stream,criteria) \
1550 mail_search_full (stream,NIL,mail_criteria (criteria),SE_FREE);
1551 #define mail_expunge(stream) \
1552 mail_expunge_full (stream,NIL,NIL)
1553 #define mail_copy(stream,sequence,mailbox) \
1554 mail_copy_full (stream,sequence,mailbox,NIL)
1555 #define mail_move(stream,sequence,mailbox) \
1556 mail_copy_full (stream,sequence,mailbox,CP_MOVE)
1557 #define mail_append(stream,mailbox,message) \
1558 mail_append_full (stream,mailbox,NIL,NIL,message)
1560 /* Interfaces for SVR4 locking brain-damage workaround */
1562 /* Driver dispatching */
1564 #define SAFE_DELETE(dtb,stream,mailbox) (*dtb->mbxdel) (stream,mailbox)
1565 #define SAFE_RENAME(dtb,stream,old,newname) (*dtb->mbxren) (stream,old,newname)
1566 #define SAFE_STATUS(dtb,stream,mbx,flags) (*dtb->status) (stream,mbx,flags)
1567 #define SAFE_COPY(dtb,stream,sequence,mailbox,options) \
1568 (*dtb->copy) (stream,sequence,mailbox,options)
1569 #define SAFE_APPEND(dtb,stream,mailbox,af,data) \
1570 (*dtb->append) (stream,mailbox,af,data)
1571 #define SAFE_SCAN_CONTENTS(dtb,name,contents,csiz,fsiz) \
1572 scan_contents (dtb,name,contents,csiz,fsiz)
1575 /* Driver callbacks */
1577 #define MM_EXISTS mm_exists
1578 #define MM_EXPUNGED mm_expunged
1579 #define MM_FLAGS mm_flags
1580 #define MM_NOTIFY mm_notify
1581 #define MM_STATUS mm_status
1582 #define MM_LOG mm_log
1583 #define MM_CRITICAL mm_critical
1584 #define MM_NOCRITICAL mm_nocritical
1585 #define MM_DISKERROR mm_diskerror
1586 #define MM_FATAL mm_fatal
1587 #define MM_APPEND(af) (*af)
1589 /* Function prototypes */
1591 void mm_searched (MAILSTREAM *stream,unsigned long number);
1592 void mm_exists (MAILSTREAM *stream,unsigned long number);
1593 void mm_expunged (MAILSTREAM *stream,unsigned long number);
1594 void mm_flags (MAILSTREAM *stream,unsigned long number);
1595 void mm_notify (MAILSTREAM *stream,char *string,long errflg);
1596 void mm_list (MAILSTREAM *stream,int delimiter,char *name,long attributes);
1597 void mm_lsub (MAILSTREAM *stream,int delimiter,char *name,long attributes);
1598 void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status);
1599 void mm_log (char *string,long errflg);
1600 void mm_dlog (char *string);
1601 void mm_login (NETMBX *mb,char *user,char *pwd,long trial);
1602 void mm_critical (MAILSTREAM *stream);
1603 void mm_nocritical (MAILSTREAM *stream);
1604 long mm_diskerror (MAILSTREAM *stream,long errcode,long serious);
1605 void mm_fatal (char *string);
1606 void *mm_cache (MAILSTREAM *stream,unsigned long msgno,long op);
1608 extern STRINGDRIVER mail_string;
1609 void mail_versioncheck (char *version);
1610 void mail_link (DRIVER *driver);
1611 void *mail_parameters (MAILSTREAM *stream,long function,void *value);
1612 DRIVER *mail_valid (MAILSTREAM *stream,char *mailbox,char *purpose);
1613 DRIVER *mail_valid_net (char *name,DRIVER *drv,char *host,char *mailbox);
1614 long mail_valid_net_parse (char *name,NETMBX *mb);
1615 long mail_valid_net_parse_work (char *name,NETMBX *mb,char *service);
1616 void mail_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents);
1617 void mail_list (MAILSTREAM *stream,char *ref,char *pat);
1618 void mail_lsub (MAILSTREAM *stream,char *ref,char *pat);
1619 long mail_subscribe (MAILSTREAM *stream,char *mailbox);
1620 long mail_unsubscribe (MAILSTREAM *stream,char *mailbox);
1621 long mail_create (MAILSTREAM *stream,char *mailbox);
1622 long mail_delete (MAILSTREAM *stream,char *mailbox);
1623 long mail_rename (MAILSTREAM *stream,char *old,char *newname);
1624 char *mail_utf7_valid (char *mailbox);
1625 long mail_status (MAILSTREAM *stream,char *mbx,long flags);
1626 long mail_status_default (MAILSTREAM *stream,char *mbx,long flags);
1627 MAILSTREAM *mail_open (MAILSTREAM *stream,char *name,long options);
1628 MAILSTREAM *mail_open_work (DRIVER *d,MAILSTREAM *stream,char *name,
1629 long options);
1630 MAILSTREAM *mail_close_full (MAILSTREAM *stream,long options);
1631 MAILHANDLE *mail_makehandle (MAILSTREAM *stream);
1632 void mail_free_handle (MAILHANDLE **handle);
1633 MAILSTREAM *mail_stream (MAILHANDLE *handle);
1635 void mail_fetch_fast (MAILSTREAM *stream,char *sequence,long flags);
1636 void mail_fetch_flags (MAILSTREAM *stream,char *sequence,long flags);
1637 void mail_fetch_overview (MAILSTREAM *stream,char *sequence,overview_t ofn);
1638 void mail_fetch_overview_sequence (MAILSTREAM *stream,char *sequence,
1639 overview_t ofn);
1640 void mail_fetch_overview_default (MAILSTREAM *stream,overview_t ofn);
1641 ENVELOPE *mail_fetch_structure (MAILSTREAM *stream,unsigned long msgno,
1642 BODY **body,long flags);
1643 char *mail_fetch_message (MAILSTREAM *stream,unsigned long msgno,
1644 unsigned long *len,long flags);
1645 char *mail_fetch_header (MAILSTREAM *stream,unsigned long msgno,char *section,
1646 STRINGLIST *lines,unsigned long *len,long flags);
1647 char *mail_fetch_text (MAILSTREAM *stream,unsigned long msgno,char *section,
1648 unsigned long *len,long flags);
1649 char *mail_fetch_mime (MAILSTREAM *stream,unsigned long msgno,char *section,
1650 unsigned long *len,long flags);
1651 char *mail_fetch_body (MAILSTREAM *stream,unsigned long msgno,char *section,
1652 unsigned long *len,long flags);
1653 long mail_partial_text (MAILSTREAM *stream,unsigned long msgno,char *section,
1654 unsigned long first,unsigned long last,long flags);
1655 long mail_partial_body (MAILSTREAM *stream,unsigned long msgno,char *section,
1656 unsigned long first,unsigned long last,long flags);
1657 char *mail_fetch_text_return (GETS_DATA *md,SIZEDTEXT *t,unsigned long *len);
1658 char *mail_fetch_string_return (GETS_DATA *md,STRING *bs,unsigned long i,
1659 unsigned long *len,long flags);
1660 long mail_read (void *stream,unsigned long size,char *buffer);
1661 unsigned long mail_uid (MAILSTREAM *stream,unsigned long msgno);
1662 unsigned long mail_msgno (MAILSTREAM *stream,unsigned long uid);
1663 void mail_fetchfrom (char *s,MAILSTREAM *stream,unsigned long msgno,
1664 long length);
1665 void mail_fetchsubject (char *s,MAILSTREAM *stream,unsigned long msgno,
1666 long length);
1667 MESSAGECACHE *mail_elt (MAILSTREAM *stream,unsigned long msgno);
1668 void mail_flag (MAILSTREAM *stream,char *sequence,char *flag,long flags);
1669 long mail_search_full (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,
1670 long flags);
1671 long mail_search_default (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,
1672 long flags);
1673 long mail_ping (MAILSTREAM *stream);
1674 void mail_check (MAILSTREAM *stream);
1675 long mail_expunge_full (MAILSTREAM *stream,char *sequence,long options);
1676 long mail_copy_full (MAILSTREAM *stream,char *sequence,char *mailbox,
1677 long options);
1678 long mail_append_full (MAILSTREAM *stream,char *mailbox,char *flags,char *date,
1679 STRING *message);
1680 long mail_append_multiple (MAILSTREAM *stream,char *mailbox,append_t af,
1681 void *data);
1682 void mail_gc (MAILSTREAM *stream,long gcflags);
1683 void mail_gc_msg (MESSAGE *msg,long gcflags);
1684 void mail_gc_body (BODY *body);
1686 BODY *mail_body (MAILSTREAM *stream,unsigned long msgno,
1687 unsigned char *section);
1688 char *mail_date (char *string,MESSAGECACHE *elt);
1689 char *mail_cdate (char *string,MESSAGECACHE *elt);
1690 long mail_parse_date (MESSAGECACHE *elt,unsigned char *string);
1691 void mail_exists (MAILSTREAM *stream,unsigned long nmsgs);
1692 void mail_recent (MAILSTREAM *stream,unsigned long recent);
1693 void mail_expunged (MAILSTREAM *stream,unsigned long msgno);
1694 void mail_lock (MAILSTREAM *stream);
1695 void mail_unlock (MAILSTREAM *stream);
1696 void mail_debug (MAILSTREAM *stream);
1697 void mail_nodebug (MAILSTREAM *stream);
1698 void mail_dlog (char *string,long flag);
1699 long mail_match_lines (STRINGLIST *lines,STRINGLIST *msglines,long flags);
1700 unsigned long mail_filter (char *text,unsigned long len,STRINGLIST *lines,
1701 long flags);
1702 long mail_search_msg (MAILSTREAM *stream,unsigned long msgno,char *section,
1703 SEARCHPGM *pgm);
1704 long mail_search_header_text (char *s,STRINGLIST *st);
1705 long mail_search_header (SIZEDTEXT *hdr,STRINGLIST *st);
1706 long mail_search_text (MAILSTREAM *stream,unsigned long msgno,char *section,
1707 STRINGLIST *st,long flags);
1708 long mail_search_body (MAILSTREAM *stream,unsigned long msgno,BODY *body,
1709 char *prefix,unsigned long section,long flags);
1710 long mail_search_string (SIZEDTEXT *s,char *charset,STRINGLIST **st);
1711 long mail_search_string_work (SIZEDTEXT *s,STRINGLIST **st);
1712 long mail_search_keyword (MAILSTREAM *stream,MESSAGECACHE *elt,STRINGLIST *st,
1713 long flag);
1714 long mail_search_addr (ADDRESS *adr,STRINGLIST *st);
1715 char *mail_search_gets (readfn_t f,void *stream,unsigned long size,
1716 GETS_DATA *md);
1717 SEARCHPGM *mail_criteria (char *criteria);
1718 int mail_criteria_date (unsigned short *date,char **r);
1719 int mail_criteria_string (STRINGLIST **s,char **r);
1720 unsigned short mail_shortdate (unsigned int year,unsigned int month,
1721 unsigned int day);
1722 SEARCHSET *mail_parse_set (char *s,char **ret);
1723 SEARCHSET *mail_append_set (SEARCHSET *set,unsigned long msgno);
1724 unsigned long *mail_sort (MAILSTREAM *stream,char *charset,SEARCHPGM *spg,
1725 SORTPGM *pgm,long flags);
1726 unsigned long *mail_sort_cache (MAILSTREAM *stream,SORTPGM *pgm,SORTCACHE **sc,
1727 long flags);
1728 unsigned long *mail_sort_msgs (MAILSTREAM *stream,char *charset,SEARCHPGM *spg,
1729 SORTPGM *pgm,long flags);
1730 SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm);
1731 unsigned int mail_strip_subject (char *t,char **ret);
1732 char *mail_strip_subject_wsp (char *s);
1733 char *mail_strip_subject_blob (char *s);
1734 int mail_sort_compare (const void *a1,const void *a2);
1735 unsigned long mail_longdate (MESSAGECACHE *elt);
1736 THREADNODE *mail_thread (MAILSTREAM *stream,char *type,char *charset,
1737 SEARCHPGM *spg,long flags);
1738 THREADNODE *mail_thread_msgs (MAILSTREAM *stream,char *type,char *charset,
1739 SEARCHPGM *spg,long flags,sorter_t sorter);
1740 THREADNODE *mail_thread_orderedsubject (MAILSTREAM *stream,char *charset,
1741 SEARCHPGM *spg,long flags,
1742 sorter_t sorter);
1743 THREADNODE *mail_thread_references (MAILSTREAM *stream,char *charset,
1744 SEARCHPGM *spg,long flags,
1745 sorter_t sorter);
1746 void mail_thread_loadcache (MAILSTREAM *stream,unsigned long uid,OVERVIEW *ov,
1747 unsigned long msgno);
1748 char *mail_thread_parse_msgid (char *s,char **ss);
1749 STRINGLIST *mail_thread_parse_references (char *s,long flag);
1750 long mail_thread_check_child (container_t mother,container_t daughter);
1751 container_t mail_thread_prune_dummy (container_t msg,container_t ane);
1752 container_t mail_thread_prune_dummy_work (container_t msg,container_t ane);
1753 THREADNODE *mail_thread_c2node (MAILSTREAM *stream,container_t con,long flags);
1754 THREADNODE *mail_thread_sort (THREADNODE *thr,THREADNODE **tc);
1755 int mail_thread_compare_date (const void *a1,const void *a2);
1756 long mail_sequence (MAILSTREAM *stream,unsigned char *sequence);
1757 long mail_uid_sequence (MAILSTREAM *stream,unsigned char *sequence);
1758 long mail_parse_flags (MAILSTREAM *stream,char *flag,unsigned long *uf);
1759 long mail_usable_network_stream (MAILSTREAM *stream,char *name);
1761 MESSAGECACHE *mail_new_cache_elt (unsigned long msgno);
1762 ENVELOPE *mail_newenvelope (void);
1763 ADDRESS *mail_newaddr (void);
1764 BODY *mail_newbody (void);
1765 BODY *mail_initbody (BODY *body);
1766 PARAMETER *mail_newbody_parameter (void);
1767 PART *mail_newbody_part (void);
1768 MESSAGE *mail_newmsg (void);
1769 STRINGLIST *mail_newstringlist (void);
1770 SEARCHPGM *mail_newsearchpgm (void);
1771 SEARCHHEADER *mail_newsearchheader (char *line,char *text);
1772 SEARCHSET *mail_newsearchset (void);
1773 SEARCHOR *mail_newsearchor (void);
1774 SEARCHPGMLIST *mail_newsearchpgmlist (void);
1775 SORTPGM *mail_newsortpgm (void);
1776 THREADNODE *mail_newthreadnode (SORTCACHE *sc);
1777 ACLLIST *mail_newacllist (void);
1778 QUOTALIST *mail_newquotalist (void);
1779 void mail_free_body (BODY **body);
1780 void mail_free_body_data (BODY *body);
1781 void mail_free_body_parameter (PARAMETER **parameter);
1782 void mail_free_body_part (PART **part);
1783 void mail_free_cache (MAILSTREAM *stream);
1784 void mail_free_elt (MESSAGECACHE **elt);
1785 void mail_free_envelope (ENVELOPE **env);
1786 void mail_free_address (ADDRESS **address);
1787 void mail_free_stringlist (STRINGLIST **string);
1788 void mail_free_searchpgm (SEARCHPGM **pgm);
1789 void mail_free_searchheader (SEARCHHEADER **hdr);
1790 void mail_free_searchset (SEARCHSET **set);
1791 void mail_free_searchor (SEARCHOR **orl);
1792 void mail_free_searchpgmlist (SEARCHPGMLIST **pgl);
1793 void mail_free_namespace (NAMESPACE **n);
1794 void mail_free_sortpgm (SORTPGM **pgm);
1795 void mail_free_threadnode (THREADNODE **thr);
1796 void mail_free_acllist (ACLLIST **al);
1797 void mail_free_quotalist (QUOTALIST **ql);
1798 void auth_link (AUTHENTICATOR *auth);
1799 char *mail_auth (char *mechanism,authresponse_t resp,int argc,char *argv[]);
1800 AUTHENTICATOR *mail_lookup_auth (unsigned long i);
1801 unsigned int mail_lookup_auth_name (char *mechanism,long flags);
1803 NETSTREAM *net_open (NETMBX *mb,NETDRIVER *dv,unsigned long port,
1804 NETDRIVER *ssld,char *ssls,unsigned long sslp);
1805 NETSTREAM *net_open_work (NETDRIVER *dv,char *host,char *service,
1806 unsigned long port,unsigned long portoverride,
1807 unsigned long flags);
1808 NETSTREAM *net_aopen (NETDRIVER *dv,NETMBX *mb,char *service,char *usrbuf);
1809 char *net_getline (NETSTREAM *stream);
1810 /* stream must be void* for use as readfn_t */
1811 long net_getbuffer (void *stream,unsigned long size,char *buffer);
1812 long net_soutr (NETSTREAM *stream,char *string);
1813 long net_sout (NETSTREAM *stream,char *string,unsigned long size);
1814 void net_close (NETSTREAM *stream);
1815 char *net_host (NETSTREAM *stream);
1816 char *net_remotehost (NETSTREAM *stream);
1817 unsigned long net_port (NETSTREAM *stream);
1818 char *net_localhost (NETSTREAM *stream);
1820 long sm_subscribe (char *mailbox);
1821 long sm_unsubscribe (char *mailbox);
1822 char *sm_read (void **sdb);
1824 void ssl_onceonlyinit (void);
1825 char *ssl_start_tls (char *s);
1826 void ssl_server_init (char *server);
1829 /* Server I/O functions */
1831 int PBIN (void);
1832 char *PSIN (char *s,int n);
1833 long PSINR (char *s,unsigned long n);
1834 int PBOUT (int c);
1835 long INWAIT (long seconds);
1836 int PSOUT (char *s);
1837 int PSOUTR (SIZEDTEXT *s);
1838 int PFLUSH (void);

UW-IMAP'd extensions by yuuji