imapext-2007

view src/c-client/mail.h @ 0:ada5e610ab86

imap-2007e
author yuuji@gentei.org
date Mon, 14 Sep 2009 15:17:45 +0900
parents
children 28a55bc1110c 5cecc027b845
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 unsigned long user_flags; /* user-assignable flags */
862 } MESSAGECACHE;
864 /* String structure */
866 #define STRINGDRIVER struct string_driver
868 typedef struct mailstring {
869 void *data; /* driver-dependent data */
870 unsigned long data1; /* driver-dependent data */
871 unsigned long size; /* total length of string */
872 char *chunk; /* base address of chunk */
873 unsigned long chunksize; /* size of chunk */
874 unsigned long offset; /* offset of this chunk in base */
875 char *curpos; /* current position in chunk */
876 unsigned long cursize; /* number of bytes remaining in chunk */
877 STRINGDRIVER *dtb; /* driver that handles this type of string */
878 } STRING;
881 /* Dispatch table for string driver */
883 STRINGDRIVER {
884 /* initialize string driver */
885 void (*init) (STRING *s,void *data,unsigned long size);
886 /* get next character in string */
887 char (*next) (STRING *s);
888 /* set position in string */
889 void (*setpos) (STRING *s,unsigned long i);
890 };
893 /* Stringstruct access routines */
895 #define INIT(s,d,data,size) ((*((s)->dtb = &d)->init) (s,data,size))
896 #define SIZE(s) ((s)->size - GETPOS (s))
897 #define CHR(s) (*(s)->curpos)
898 #define SNX(s) (--(s)->cursize ? *(s)->curpos++ : (*(s)->dtb->next) (s))
899 #define GETPOS(s) ((s)->offset + ((s)->curpos - (s)->chunk))
900 #define SETPOS(s,i) (*(s)->dtb->setpos) (s,i)
902 /* Search program */
904 #define SEARCHPGM struct search_program
905 #define SEARCHHEADER struct search_header
906 #define SEARCHSET struct search_set
907 #define SEARCHOR struct search_or
908 #define SEARCHPGMLIST struct search_pgm_list
911 SEARCHHEADER { /* header search */
912 SIZEDTEXT line; /* header line */
913 SIZEDTEXT text; /* text in header */
914 SEARCHHEADER *next; /* next in list */
915 };
918 SEARCHSET { /* message set */
919 unsigned long first; /* sequence number */
920 unsigned long last; /* last value, if a range */
921 SEARCHSET *next; /* next in list */
922 };
925 SEARCHOR {
926 SEARCHPGM *first; /* first program */
927 SEARCHPGM *second; /* second program */
928 SEARCHOR *next; /* next in list */
929 };
932 SEARCHPGMLIST {
933 SEARCHPGM *pgm; /* search program */
934 SEARCHPGMLIST *next; /* next in list */
935 };
937 SEARCHPGM { /* search program */
938 SEARCHSET *msgno; /* message numbers */
939 SEARCHSET *uid; /* unique identifiers */
940 SEARCHOR *or; /* or'ed in programs */
941 SEARCHPGMLIST *not; /* and'ed not program */
942 SEARCHHEADER *header; /* list of headers */
943 STRINGLIST *bcc; /* bcc recipients */
944 STRINGLIST *body; /* text in message body */
945 STRINGLIST *cc; /* cc recipients */
946 STRINGLIST *from; /* originator */
947 STRINGLIST *keyword; /* keywords */
948 STRINGLIST *unkeyword; /* unkeywords */
949 STRINGLIST *subject; /* text in subject */
950 STRINGLIST *text; /* text in headers and body */
951 STRINGLIST *to; /* to recipients */
952 unsigned long larger; /* larger than this size */
953 unsigned long smaller; /* smaller than this size */
954 unsigned long older; /* older than this interval */
955 unsigned long younger; /* younger than this interval */
956 unsigned short sentbefore; /* sent before this date */
957 unsigned short senton; /* sent on this date */
958 unsigned short sentsince; /* sent since this date */
959 unsigned short before; /* before this date */
960 unsigned short on; /* on this date */
961 unsigned short since; /* since this date */
962 unsigned int answered : 1; /* answered messages */
963 unsigned int unanswered : 1; /* unanswered messages */
964 unsigned int deleted : 1; /* deleted messages */
965 unsigned int undeleted : 1; /* undeleted messages */
966 unsigned int draft : 1; /* message draft */
967 unsigned int undraft : 1; /* message undraft */
968 unsigned int flagged : 1; /* flagged messages */
969 unsigned int unflagged : 1; /* unflagged messages */
970 unsigned int recent : 1; /* recent messages */
971 unsigned int old : 1; /* old messages */
972 unsigned int seen : 1; /* seen messages */
973 unsigned int unseen : 1; /* unseen messages */
974 /* These must be simulated in IMAP */
975 STRINGLIST *return_path; /* error return address */
976 STRINGLIST *sender; /* sender address list */
977 STRINGLIST *reply_to; /* reply address list */
978 STRINGLIST *in_reply_to; /* replied message ID */
979 STRINGLIST *message_id; /* message ID */
980 STRINGLIST *newsgroups; /* USENET newsgroups */
981 STRINGLIST *followup_to; /* USENET reply newsgroups */
982 STRINGLIST *references; /* USENET references */
983 };
986 /* Mailbox status */
988 typedef struct mbx_status {
989 long flags; /* validity flags */
990 unsigned long messages; /* number of messages */
991 unsigned long recent; /* number of recent messages */
992 unsigned long unseen; /* number of unseen messages */
993 unsigned long uidnext; /* next UID to be assigned */
994 unsigned long uidvalidity; /* UID validity value */
995 } MAILSTATUS;
997 /* Sort program */
999 typedef void (*postsort_t) (void *sc);
1001 #define SORTPGM struct sort_program
1003 SORTPGM {
1004 unsigned int reverse : 1; /* sort function is to be reversed */
1005 unsigned int abort : 1; /* abort sorting */
1006 short function; /* sort function */
1007 unsigned long nmsgs; /* number of messages being sorted */
1008 struct {
1009 unsigned long cached; /* number of messages cached so far */
1010 unsigned long sorted; /* number of messages sorted so far */
1011 unsigned long postsorted; /* number of postsorted messages so far */
1012 } progress;
1013 postsort_t postsort; /* post sorter */
1014 SORTPGM *next; /* next function */
1015 };
1018 /* Sort cache */
1020 #define SORTCACHE struct sort_cache
1022 SORTCACHE {
1023 unsigned int sorted : 1; /* message has been sorted */
1024 unsigned int postsorted : 1; /* message has been postsorted */
1025 unsigned int refwd : 1; /* subject is a re or fwd */
1026 unsigned int dirty : 1; /* has data not written to backup */
1027 SORTPGM *pgm; /* sort program */
1028 unsigned long num; /* message number (sequence or UID) */
1029 unsigned long date; /* sent date */
1030 unsigned long arrival; /* arrival date */
1031 unsigned long size; /* message size */
1032 char *from; /* from string */
1033 char *to; /* to string */
1034 char *cc; /* cc string */
1035 char *subject; /* extracted subject string */
1036 char *message_id; /* message-id string */
1037 char *unique; /* unique string, normally message-id */
1038 STRINGLIST *references; /* references string */
1039 };
1041 /* ACL list */
1043 #define ACLLIST struct acl_list
1045 ACLLIST {
1046 char *identifier; /* authentication identifier */
1047 char *rights; /* access rights */
1048 ACLLIST *next;
1049 };
1051 /* Quota resource list */
1053 #define QUOTALIST struct quota_list
1055 QUOTALIST {
1056 char *name; /* resource name */
1057 unsigned long usage; /* resource usage */
1058 unsigned long limit; /* resource limit */
1059 QUOTALIST *next; /* next resource */
1060 };
1062 /* Mail Access I/O stream */
1065 /* Structure for mail driver dispatch */
1067 #define DRIVER struct driver
1070 /* Mail I/O stream */
1072 typedef struct mail_stream {
1073 DRIVER *dtb; /* dispatch table for this driver */
1074 void *local; /* pointer to driver local data */
1075 char *mailbox; /* mailbox name (canonicalized) */
1076 char *original_mailbox; /* mailbox name (non-canonicalized) */
1077 unsigned short use; /* stream use count */
1078 unsigned short sequence; /* stream sequence */
1079 unsigned int inbox : 1; /* stream open on an INBOX */
1080 unsigned int lock : 1; /* stream lock flag */
1081 unsigned int debug : 1; /* stream debug flag */
1082 unsigned int silent : 1; /* don't pass events to main program */
1083 unsigned int rdonly : 1; /* stream read-only flag */
1084 unsigned int anonymous : 1; /* stream anonymous access flag */
1085 unsigned int scache : 1; /* stream short cache flag */
1086 unsigned int halfopen : 1; /* stream half-open flag */
1087 unsigned int secure : 1; /* stream secure flag */
1088 unsigned int tryssl : 1; /* stream tryssl flag */
1089 unsigned int mulnewsrc : 1; /* stream use multiple newsrc files */
1090 unsigned int perm_seen : 1; /* permanent Seen flag */
1091 unsigned int perm_deleted : 1;/* permanent Deleted flag */
1092 unsigned int perm_flagged : 1;/* permanent Flagged flag */
1093 unsigned int perm_answered :1;/* permanent Answered flag */
1094 unsigned int perm_draft : 1; /* permanent Draft flag */
1095 unsigned int kwd_create : 1; /* can create new keywords */
1096 unsigned int uid_nosticky : 1;/* UIDs are not preserved */
1097 unsigned int unhealthy : 1; /* unhealthy protocol negotiations */
1098 unsigned int nokod : 1; /* suppress kiss-of-death */
1099 unsigned int sniff : 1; /* metadata only */
1100 unsigned long perm_user_flags;/* mask of permanent user flags */
1101 unsigned long gensym; /* generated tag */
1102 unsigned long nmsgs; /* # of associated msgs */
1103 unsigned long recent; /* # of recent msgs */
1104 unsigned long uid_validity; /* UID validity sequence */
1105 unsigned long uid_last; /* last assigned UID */
1106 char *user_flags[NUSERFLAGS]; /* pointers to user flags in bit order */
1107 unsigned long cachesize; /* size of message cache */
1108 MESSAGECACHE **cache; /* message cache array */
1109 SORTCACHE **sc; /* sort cache array */
1110 unsigned long msgno; /* message number of `current' message */
1111 ENVELOPE *env; /* scratch buffer for envelope */
1112 BODY *body; /* scratch buffer for body */
1113 SIZEDTEXT text; /* scratch buffer for text */
1114 struct {
1115 char *name; /* mailbox name to snarf from */
1116 unsigned long time; /* last snarf time */
1117 long options; /* snarf open options */
1118 } snarf;
1119 struct { /* internal use only */
1120 struct { /* search temporaries */
1121 STRINGLIST *string; /* string(s) to search */
1122 long result; /* search result */
1123 char *text; /* cache of fetched text */
1124 } search;
1125 STRING string; /* stringstruct return hack */
1126 } private;
1127 /* reserved for use by main program */
1128 void *sparep; /* spare pointer */
1129 unsigned int spare : 1; /* first spare bit */
1130 unsigned int spare2 : 1; /* second spare bit */
1131 unsigned int spare3 : 1; /* third spare bit */
1132 unsigned int spare4 : 1; /* fourth spare bit */
1133 unsigned int spare5 : 1; /* fifth spare bit */
1134 unsigned int spare6 : 1; /* sixth spare bit */
1135 unsigned int spare7 : 1; /* seventh spare bit */
1136 unsigned int spare8 : 1; /* eighth spare bit */
1137 } MAILSTREAM;
1139 /* Mail I/O stream handle */
1141 typedef struct mail_stream_handle {
1142 MAILSTREAM *stream; /* pointer to mail stream */
1143 unsigned short sequence; /* sequence of what we expect stream to be */
1144 } MAILHANDLE;
1147 /* Message overview */
1149 typedef struct mail_overview {
1150 char *subject; /* message subject string */
1151 ADDRESS *from; /* originator address list */
1152 char *date; /* message composition date string */
1153 char *message_id; /* message ID */
1154 char *references; /* USENET references */
1155 struct { /* may be 0 or NUL if unknown/undefined */
1156 unsigned long octets; /* message octets (probably LF-newline form) */
1157 unsigned long lines; /* message lines */
1158 char *xref; /* cross references */
1159 } optional;
1160 } OVERVIEW;
1162 /* Network access I/O stream */
1165 /* Structure for network driver dispatch */
1167 #define NETDRIVER struct net_driver
1170 /* Network transport I/O stream */
1172 typedef struct net_stream {
1173 void *stream; /* driver's I/O stream */
1174 NETDRIVER *dtb; /* network driver */
1175 } NETSTREAM;
1178 /* Network transport driver dispatch */
1180 NETDRIVER {
1181 void *(*open) (char *host,char *service,unsigned long port);
1182 void *(*aopen) (NETMBX *mb,char *service,char *usrbuf);
1183 char *(*getline) (void *stream);
1184 long (*getbuffer) (void *stream,unsigned long size,char *buffer);
1185 long (*soutr) (void *stream,char *string);
1186 long (*sout) (void *stream,char *string,unsigned long size);
1187 void (*close) (void *stream);
1188 char *(*host) (void *stream);
1189 char *(*remotehost) (void *stream);
1190 unsigned long (*port) (void *stream);
1191 char *(*localhost) (void *stream);
1192 };
1195 /* Mailgets data identifier */
1197 typedef struct getsdata {
1198 MAILSTREAM *stream;
1199 unsigned long msgno;
1200 char *what;
1201 STRINGLIST *stl;
1202 unsigned long first;
1203 unsigned long last;
1204 long flags;
1205 } GETS_DATA;
1208 #define INIT_GETS(md,s,m,w,f,l) \
1209 md.stream = s, md.msgno = m, md.what = w, md.first = f, md.last = l, \
1210 md.stl = NIL, md.flags = NIL;
1212 /* Mail delivery I/O stream */
1214 typedef struct send_stream {
1215 NETSTREAM *netstream; /* network I/O stream */
1216 char *host; /* SMTP service host */
1217 char *reply; /* last reply string */
1218 long replycode; /* last reply code */
1219 unsigned int debug : 1; /* stream debug flag */
1220 unsigned int sensitive : 1; /* sensitive data in progress */
1221 unsigned int loser : 1; /* server is a loser */
1222 unsigned int saslcancel : 1; /* SASL cancelled by protocol */
1223 union { /* protocol specific */
1224 struct { /* SMTP specific */
1225 unsigned int ok : 1; /* supports ESMTP */
1226 struct { /* service extensions */
1227 unsigned int send : 1; /* supports SEND */
1228 unsigned int soml : 1; /* supports SOML */
1229 unsigned int saml : 1; /* supports SAML */
1230 unsigned int expn : 1; /* supports EXPN */
1231 unsigned int help : 1; /* supports HELP */
1232 unsigned int turn : 1; /* supports TURN */
1233 unsigned int etrn : 1; /* supports ETRN */
1234 unsigned int starttls:1;/* supports STARTTLS */
1235 unsigned int relay : 1; /* supports relaying */
1236 unsigned int pipe : 1; /* supports pipelining */
1237 unsigned int ensc : 1; /* supports enhanced status codes */
1238 unsigned int bmime : 1; /* supports BINARYMIME */
1239 unsigned int chunk : 1; /* supports CHUNKING */
1240 } service;
1241 struct { /* 8-bit MIME transport */
1242 unsigned int ok : 1; /* supports 8-bit MIME */
1243 unsigned int want : 1; /* want 8-bit MIME */
1244 } eightbit;
1245 struct { /* delivery status notification */
1246 unsigned int ok : 1; /* supports DSN */
1247 unsigned int want : 1; /* want DSN */
1248 struct { /* notification options */
1249 /* notify on failure */
1250 unsigned int failure : 1;
1251 /* notify on delay */
1252 unsigned int delay : 1;
1253 /* notify on success */
1254 unsigned int success : 1;
1255 } notify;
1256 unsigned int full : 1; /* return full headers */
1257 char *envid; /* envelope identifier as xtext */
1258 } dsn;
1259 struct { /* size declaration */
1260 unsigned int ok : 1; /* supports SIZE */
1261 unsigned long limit; /* maximum size supported */
1262 } size;
1263 struct { /* deliverby declaration */
1264 unsigned int ok : 1; /* supports DELIVERBY */
1265 unsigned long minby; /* minimum by-time */
1266 } deliverby;
1267 struct { /* authenticated turn */
1268 unsigned int ok : 1; /* supports ATRN */
1269 char *domains; /* domains */
1270 } atrn;
1271 /* supported SASL authenticators */
1272 unsigned int auth : MAXAUTHENTICATORS;
1273 } esmtp;
1274 struct { /* NNTP specific */
1275 unsigned int post : 1; /* supports POST */
1276 struct { /* NNTP extensions */
1277 unsigned int ok : 1; /* supports extensions */
1278 /* supports LISTGROUP */
1279 unsigned int listgroup : 1;
1280 unsigned int over : 1; /* supports OVER */
1281 unsigned int hdr : 1; /* supports HDR */
1282 unsigned int pat : 1; /* supports PAT */
1283 /* supports STARTTLS */
1284 unsigned int starttls : 1;
1285 /* server has MULTIDOMAIN */
1286 unsigned int multidomain : 1;
1287 /* supports AUTHINFO USER */
1288 unsigned int authuser : 1;
1289 /* supported authenticators */
1290 unsigned int sasl : MAXAUTHENTICATORS;
1291 } ext;
1292 } nntp;
1293 } protocol;
1294 } SENDSTREAM;
1296 /* Jacket into external interfaces */
1298 typedef long (*readfn_t) (void *stream,unsigned long size,char *buffer);
1299 typedef char *(*mailgets_t) (readfn_t f,void *stream,unsigned long size,
1300 GETS_DATA *md);
1301 typedef char *(*readprogress_t) (GETS_DATA *md,unsigned long octets);
1302 typedef void *(*mailcache_t) (MAILSTREAM *stream,unsigned long msgno,long op);
1303 typedef long (*mailproxycopy_t) (MAILSTREAM *stream,char *sequence,
1304 char *mailbox,long options);
1305 typedef long (*tcptimeout_t) (long overall,long last);
1306 typedef void *(*authchallenge_t) (void *stream,unsigned long *len);
1307 typedef long (*authrespond_t) (void *stream,char *s,unsigned long size);
1308 typedef long (*authcheck_t) (void);
1309 typedef long (*authclient_t) (authchallenge_t challenger,
1310 authrespond_t responder,char *service,NETMBX *mb,
1311 void *s,unsigned long *trial,char *user);
1312 typedef char *(*authresponse_t) (void *challenge,unsigned long clen,
1313 unsigned long *rlen);
1314 typedef char *(*authserver_t) (authresponse_t responder,int argc,char *argv[]);
1315 typedef void (*smtpverbose_t) (char *buffer);
1316 typedef void (*imapenvelope_t) (MAILSTREAM *stream,unsigned long msgno,
1317 ENVELOPE *env);
1318 typedef char *(*imapreferral_t) (MAILSTREAM *stream,char *url,long code);
1319 typedef void (*overview_t) (MAILSTREAM *stream,unsigned long uid,OVERVIEW *ov,
1320 unsigned long msgno);
1321 typedef unsigned long *(*sorter_t) (MAILSTREAM *stream,char *charset,
1322 SEARCHPGM *spg,SORTPGM *pgm,long flags);
1323 typedef void (*parseline_t) (ENVELOPE *env,char *hdr,char *data,char *host);
1324 typedef ADDRESS *(*parsephrase_t) (char *phrase,char *end,char *host);
1325 typedef void *(*blocknotify_t) (int reason,void *data);
1326 typedef long (*kinit_t) (char *host,char *reason);
1327 typedef void (*sendcommand_t) (MAILSTREAM *stream,char *cmd,long flags);
1328 typedef char *(*newsrcquery_t) (MAILSTREAM *stream,char *mulname,char *name);
1329 typedef void (*getacl_t) (MAILSTREAM *stream,char *mailbox,ACLLIST *acl);
1330 typedef void (*listrights_t) (MAILSTREAM *stream,char *mailbox,char *id,
1331 char *alwaysrights,STRINGLIST *possiblerights);
1332 typedef void (*myrights_t) (MAILSTREAM *stream,char *mailbox,char *rights);
1333 typedef void (*quota_t) (MAILSTREAM *stream,char *qroot,QUOTALIST *qlist);
1334 typedef void (*quotaroot_t) (MAILSTREAM *stream,char *mbx,STRINGLIST *qroot);
1335 typedef void (*sortresults_t) (MAILSTREAM *stream,unsigned long *list,
1336 unsigned long size);
1337 typedef char *(*userprompt_t) (void);
1338 typedef long (*append_t) (MAILSTREAM *stream,void *data,char **flags,
1339 char **date,STRING **message);
1340 typedef void (*copyuid_t) (MAILSTREAM *stream,char *mailbox,
1341 unsigned long uidvalidity,SEARCHSET *sourceset,
1342 SEARCHSET *destset);
1343 typedef void (*appenduid_t) (char *mailbox,unsigned long uidvalidity,
1344 SEARCHSET *set);
1345 typedef long (*dirfmttest_t) (char *name);
1346 typedef long (*scancontents_t) (char *name,char *contents,unsigned long csiz,
1347 unsigned long fsiz);
1349 typedef void (*freeeltsparep_t) (void **sparep);
1350 typedef void (*freeenvelopesparep_t) (void **sparep);
1351 typedef void (*freebodysparep_t) (void **sparep);
1352 typedef void (*freestreamsparep_t) (void **sparep);
1353 typedef void *(*sslstart_t) (void *stream,char *host,unsigned long flags);
1354 typedef long (*sslcertificatequery_t) (char *reason,char *host,char *cert);
1355 typedef void (*sslfailure_t) (char *host,char *reason,unsigned long flags);
1356 typedef void (*logouthook_t) (void *data);
1357 typedef char *(*sslclientcert_t) (void);
1358 typedef char *(*sslclientkey_t) (void);
1360 /* Globals */
1362 extern char *body_types[]; /* defined body type strings */
1363 extern char *body_encodings[]; /* defined body encoding strings */
1364 extern const char *days[]; /* day name strings */
1365 extern const char *months[]; /* month name strings */
1367 /* Threading */
1369 /* Thread node */
1371 #define THREADNODE struct thread_node
1373 THREADNODE {
1374 unsigned long num; /* message number */
1375 SORTCACHE *sc; /* (internal use) sortcache entry */
1376 THREADNODE *branch; /* branch at this point in tree */
1377 THREADNODE *next; /* next node */
1378 };
1380 typedef void (*threadresults_t) (MAILSTREAM *stream,THREADNODE *tree);
1383 /* Thread dispatch */
1385 #define THREADER struct threader_list
1387 THREADER {
1388 char *name; /* name of threader */
1389 THREADNODE *(*dispatch) (MAILSTREAM *stream,char *charset,SEARCHPGM *spg,
1390 long flags,sorter_t sorter);
1391 THREADER *next;
1392 };
1395 /* Container for references threading */
1397 typedef void ** container_t;
1399 /* Namespaces */
1401 #define NAMESPACE struct mail_namespace
1403 NAMESPACE {
1404 char *name; /* name of this namespace */
1405 int delimiter; /* hierarchy delimiter */
1406 PARAMETER *param; /* namespace parameters */
1407 NAMESPACE *next; /* next namespace */
1408 };
1411 /* Authentication */
1413 #define AUTHENTICATOR struct mail_authenticator
1415 AUTHENTICATOR {
1416 long flags; /* authenticator flags */
1417 char *name; /* name of this authenticator */
1418 authcheck_t valid; /* authenticator valid on this system */
1419 authclient_t client; /* client function that supports it */
1420 authserver_t server; /* server function that supports it */
1421 AUTHENTICATOR *next; /* next authenticator */
1422 };
1424 /* Mail driver dispatch */
1426 DRIVER {
1427 char *name; /* driver name */
1428 unsigned long flags; /* driver flags */
1429 DRIVER *next; /* next driver */
1430 /* mailbox is valid for us */
1431 DRIVER *(*valid) (char *mailbox);
1432 /* manipulate driver parameters */
1433 void *(*parameters) (long function,void *value);
1434 /* scan mailboxes */
1435 void (*scan) (MAILSTREAM *stream,char *ref,char *pat,char *contents);
1436 /* list mailboxes */
1437 void (*list) (MAILSTREAM *stream,char *ref,char *pat);
1438 /* list subscribed mailboxes */
1439 void (*lsub) (MAILSTREAM *stream,char *ref,char *pat);
1440 /* subscribe to mailbox */
1441 long (*subscribe) (MAILSTREAM *stream,char *mailbox);
1442 /* unsubscribe from mailbox */
1443 long (*unsubscribe) (MAILSTREAM *stream,char *mailbox);
1444 /* create mailbox */
1445 long (*create) (MAILSTREAM *stream,char *mailbox);
1446 /* delete mailbox */
1447 long (*mbxdel) (MAILSTREAM *stream,char *mailbox);
1448 /* rename mailbox */
1449 long (*mbxren) (MAILSTREAM *stream,char *old,char *newname);
1450 /* status of mailbox */
1451 long (*status) (MAILSTREAM *stream,char *mbx,long flags);
1453 /* open mailbox */
1454 MAILSTREAM *(*open) (MAILSTREAM *stream);
1455 /* close mailbox */
1456 void (*close) (MAILSTREAM *stream,long options);
1457 /* fetch message "fast" attributes */
1458 void (*fast) (MAILSTREAM *stream,char *sequence,long flags);
1459 /* fetch message flags */
1460 void (*msgflags) (MAILSTREAM *stream,char *sequence,long flags);
1461 /* fetch message overview */
1462 long (*overview) (MAILSTREAM *stream,overview_t ofn);
1463 /* fetch message envelopes */
1464 ENVELOPE *(*structure) (MAILSTREAM *stream,unsigned long msgno,BODY **body,
1465 long flags);
1466 /* return RFC-822 header */
1467 char *(*header) (MAILSTREAM *stream,unsigned long msgno,
1468 unsigned long *length,long flags);
1469 /* return RFC-822 text */
1470 long (*text) (MAILSTREAM *stream,unsigned long msgno,STRING *bs,long flags);
1471 /* load cache */
1472 long (*msgdata) (MAILSTREAM *stream,unsigned long msgno,char *section,
1473 unsigned long first,unsigned long last,STRINGLIST *lines,
1474 long flags);
1475 /* return UID for message */
1476 unsigned long (*uid) (MAILSTREAM *stream,unsigned long msgno);
1477 /* return message number from UID */
1478 unsigned long (*msgno) (MAILSTREAM *stream,unsigned long uid);
1479 /* modify flags */
1480 void (*flag) (MAILSTREAM *stream,char *sequence,char *flag,long flags);
1481 /* per-message modify flags */
1482 void (*flagmsg) (MAILSTREAM *stream,MESSAGECACHE *elt);
1483 /* search for message based on criteria */
1484 long (*search) (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,long flags);
1485 /* sort messages */
1486 unsigned long *(*sort) (MAILSTREAM *stream,char *charset,SEARCHPGM *spg,
1487 SORTPGM *pgm,long flags);
1488 /* thread messages */
1489 THREADNODE *(*thread) (MAILSTREAM *stream,char *type,char *charset,
1490 SEARCHPGM *spg,long flag);
1491 /* ping mailbox to see if still alive */
1492 long (*ping) (MAILSTREAM *stream);
1493 /* check for new messages */
1494 void (*check) (MAILSTREAM *stream);
1495 /* expunge deleted messages */
1496 long (*expunge) (MAILSTREAM *stream,char *sequence,long options);
1497 /* copy messages to another mailbox */
1498 long (*copy) (MAILSTREAM *stream,char *sequence,char *mailbox,long options);
1499 /* append string message to mailbox */
1500 long (*append) (MAILSTREAM *stream,char *mailbox,append_t af,void *data);
1501 /* garbage collect stream */
1502 void (*gc) (MAILSTREAM *stream,long gcflags);
1503 };
1506 #include "linkage.h"
1508 /* Compatibility support names for old interfaces */
1510 #define GET_TRYALTFIRST GET_TRYSSLFIRST
1511 #define SET_TRYALTFIRST SET_TRYSSLFIRST
1512 #define GET_IMAPTRYALT GET_IMAPTRYSSL
1513 #define SET_IMAPTRYALT SET_IMAPTRYSSL
1514 #define OP_TRYALT OP_TRYSSL
1515 #define altflag sslflag
1517 #define mail_close(stream) \
1518 mail_close_full (stream,NIL)
1519 #define mail_fetchfast(stream,sequence) \
1520 mail_fetch_fast (stream,sequence,NIL)
1521 #define mail_fetchfast_full mail_fetch_fast
1522 #define mail_fetchflags(stream,sequence) \
1523 mail_fetch_flags (stream,sequence,NIL)
1524 #define mail_fetchflags_full mail_fetch_flags
1525 #define mail_fetchenvelope(stream,msgno) \
1526 mail_fetch_structure (stream,msgno,NIL,NIL)
1527 #define mail_fetchstructure(stream,msgno,body) \
1528 mail_fetch_structure (stream,msgno,body,NIL)
1529 #define mail_fetchstructure_full mail_fetch_structure
1530 #define mail_fetchheader(stream,msgno) \
1531 mail_fetch_header (stream,msgno,NIL,NIL,NIL,FT_PEEK)
1532 #define mail_fetchheader_full(stream,msgno,lines,len,flags) \
1533 mail_fetch_header (stream,msgno,NIL,lines,len,FT_PEEK | (flags))
1534 #define mail_fetchtext(stream,msgno) \
1535 mail_fetch_text (stream,msgno,NIL,NIL,NIL)
1536 #define mail_fetchtext_full(stream,msgno,length,flags) \
1537 mail_fetch_text (stream,msgno,NIL,length,flags)
1538 #define mail_fetchbody(stream,msgno,section,length) \
1539 mail_fetch_body (stream,msgno,section,length,NIL)
1540 #define mail_fetchbody_full mail_fetch_body
1541 #define mail_setflag(stream,sequence,flag) \
1542 mail_flag (stream,sequence,flag,ST_SET)
1543 #define mail_setflag_full(stream,sequence,flag,flags) \
1544 mail_flag (stream,sequence,flag,ST_SET | (flags))
1545 #define mail_clearflag(stream,sequence,flag) \
1546 mail_flag (stream,sequence,flag,NIL)
1547 #define mail_clearflag_full mail_flag
1548 #define mail_search(stream,criteria) \
1549 mail_search_full (stream,NIL,mail_criteria (criteria),SE_FREE);
1550 #define mail_expunge(stream) \
1551 mail_expunge_full (stream,NIL,NIL)
1552 #define mail_copy(stream,sequence,mailbox) \
1553 mail_copy_full (stream,sequence,mailbox,NIL)
1554 #define mail_move(stream,sequence,mailbox) \
1555 mail_copy_full (stream,sequence,mailbox,CP_MOVE)
1556 #define mail_append(stream,mailbox,message) \
1557 mail_append_full (stream,mailbox,NIL,NIL,message)
1559 /* Interfaces for SVR4 locking brain-damage workaround */
1561 /* Driver dispatching */
1563 #define SAFE_DELETE(dtb,stream,mailbox) (*dtb->mbxdel) (stream,mailbox)
1564 #define SAFE_RENAME(dtb,stream,old,newname) (*dtb->mbxren) (stream,old,newname)
1565 #define SAFE_STATUS(dtb,stream,mbx,flags) (*dtb->status) (stream,mbx,flags)
1566 #define SAFE_COPY(dtb,stream,sequence,mailbox,options) \
1567 (*dtb->copy) (stream,sequence,mailbox,options)
1568 #define SAFE_APPEND(dtb,stream,mailbox,af,data) \
1569 (*dtb->append) (stream,mailbox,af,data)
1570 #define SAFE_SCAN_CONTENTS(dtb,name,contents,csiz,fsiz) \
1571 scan_contents (dtb,name,contents,csiz,fsiz)
1574 /* Driver callbacks */
1576 #define MM_EXISTS mm_exists
1577 #define MM_EXPUNGED mm_expunged
1578 #define MM_FLAGS mm_flags
1579 #define MM_NOTIFY mm_notify
1580 #define MM_STATUS mm_status
1581 #define MM_LOG mm_log
1582 #define MM_CRITICAL mm_critical
1583 #define MM_NOCRITICAL mm_nocritical
1584 #define MM_DISKERROR mm_diskerror
1585 #define MM_FATAL mm_fatal
1586 #define MM_APPEND(af) (*af)
1588 /* Function prototypes */
1590 void mm_searched (MAILSTREAM *stream,unsigned long number);
1591 void mm_exists (MAILSTREAM *stream,unsigned long number);
1592 void mm_expunged (MAILSTREAM *stream,unsigned long number);
1593 void mm_flags (MAILSTREAM *stream,unsigned long number);
1594 void mm_notify (MAILSTREAM *stream,char *string,long errflg);
1595 void mm_list (MAILSTREAM *stream,int delimiter,char *name,long attributes);
1596 void mm_lsub (MAILSTREAM *stream,int delimiter,char *name,long attributes);
1597 void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status);
1598 void mm_log (char *string,long errflg);
1599 void mm_dlog (char *string);
1600 void mm_login (NETMBX *mb,char *user,char *pwd,long trial);
1601 void mm_critical (MAILSTREAM *stream);
1602 void mm_nocritical (MAILSTREAM *stream);
1603 long mm_diskerror (MAILSTREAM *stream,long errcode,long serious);
1604 void mm_fatal (char *string);
1605 void *mm_cache (MAILSTREAM *stream,unsigned long msgno,long op);
1607 extern STRINGDRIVER mail_string;
1608 void mail_versioncheck (char *version);
1609 void mail_link (DRIVER *driver);
1610 void *mail_parameters (MAILSTREAM *stream,long function,void *value);
1611 DRIVER *mail_valid (MAILSTREAM *stream,char *mailbox,char *purpose);
1612 DRIVER *mail_valid_net (char *name,DRIVER *drv,char *host,char *mailbox);
1613 long mail_valid_net_parse (char *name,NETMBX *mb);
1614 long mail_valid_net_parse_work (char *name,NETMBX *mb,char *service);
1615 void mail_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents);
1616 void mail_list (MAILSTREAM *stream,char *ref,char *pat);
1617 void mail_lsub (MAILSTREAM *stream,char *ref,char *pat);
1618 long mail_subscribe (MAILSTREAM *stream,char *mailbox);
1619 long mail_unsubscribe (MAILSTREAM *stream,char *mailbox);
1620 long mail_create (MAILSTREAM *stream,char *mailbox);
1621 long mail_delete (MAILSTREAM *stream,char *mailbox);
1622 long mail_rename (MAILSTREAM *stream,char *old,char *newname);
1623 char *mail_utf7_valid (char *mailbox);
1624 long mail_status (MAILSTREAM *stream,char *mbx,long flags);
1625 long mail_status_default (MAILSTREAM *stream,char *mbx,long flags);
1626 MAILSTREAM *mail_open (MAILSTREAM *stream,char *name,long options);
1627 MAILSTREAM *mail_open_work (DRIVER *d,MAILSTREAM *stream,char *name,
1628 long options);
1629 MAILSTREAM *mail_close_full (MAILSTREAM *stream,long options);
1630 MAILHANDLE *mail_makehandle (MAILSTREAM *stream);
1631 void mail_free_handle (MAILHANDLE **handle);
1632 MAILSTREAM *mail_stream (MAILHANDLE *handle);
1634 void mail_fetch_fast (MAILSTREAM *stream,char *sequence,long flags);
1635 void mail_fetch_flags (MAILSTREAM *stream,char *sequence,long flags);
1636 void mail_fetch_overview (MAILSTREAM *stream,char *sequence,overview_t ofn);
1637 void mail_fetch_overview_sequence (MAILSTREAM *stream,char *sequence,
1638 overview_t ofn);
1639 void mail_fetch_overview_default (MAILSTREAM *stream,overview_t ofn);
1640 ENVELOPE *mail_fetch_structure (MAILSTREAM *stream,unsigned long msgno,
1641 BODY **body,long flags);
1642 char *mail_fetch_message (MAILSTREAM *stream,unsigned long msgno,
1643 unsigned long *len,long flags);
1644 char *mail_fetch_header (MAILSTREAM *stream,unsigned long msgno,char *section,
1645 STRINGLIST *lines,unsigned long *len,long flags);
1646 char *mail_fetch_text (MAILSTREAM *stream,unsigned long msgno,char *section,
1647 unsigned long *len,long flags);
1648 char *mail_fetch_mime (MAILSTREAM *stream,unsigned long msgno,char *section,
1649 unsigned long *len,long flags);
1650 char *mail_fetch_body (MAILSTREAM *stream,unsigned long msgno,char *section,
1651 unsigned long *len,long flags);
1652 long mail_partial_text (MAILSTREAM *stream,unsigned long msgno,char *section,
1653 unsigned long first,unsigned long last,long flags);
1654 long mail_partial_body (MAILSTREAM *stream,unsigned long msgno,char *section,
1655 unsigned long first,unsigned long last,long flags);
1656 char *mail_fetch_text_return (GETS_DATA *md,SIZEDTEXT *t,unsigned long *len);
1657 char *mail_fetch_string_return (GETS_DATA *md,STRING *bs,unsigned long i,
1658 unsigned long *len,long flags);
1659 long mail_read (void *stream,unsigned long size,char *buffer);
1660 unsigned long mail_uid (MAILSTREAM *stream,unsigned long msgno);
1661 unsigned long mail_msgno (MAILSTREAM *stream,unsigned long uid);
1662 void mail_fetchfrom (char *s,MAILSTREAM *stream,unsigned long msgno,
1663 long length);
1664 void mail_fetchsubject (char *s,MAILSTREAM *stream,unsigned long msgno,
1665 long length);
1666 MESSAGECACHE *mail_elt (MAILSTREAM *stream,unsigned long msgno);
1667 void mail_flag (MAILSTREAM *stream,char *sequence,char *flag,long flags);
1668 long mail_search_full (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,
1669 long flags);
1670 long mail_search_default (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,
1671 long flags);
1672 long mail_ping (MAILSTREAM *stream);
1673 void mail_check (MAILSTREAM *stream);
1674 long mail_expunge_full (MAILSTREAM *stream,char *sequence,long options);
1675 long mail_copy_full (MAILSTREAM *stream,char *sequence,char *mailbox,
1676 long options);
1677 long mail_append_full (MAILSTREAM *stream,char *mailbox,char *flags,char *date,
1678 STRING *message);
1679 long mail_append_multiple (MAILSTREAM *stream,char *mailbox,append_t af,
1680 void *data);
1681 void mail_gc (MAILSTREAM *stream,long gcflags);
1682 void mail_gc_msg (MESSAGE *msg,long gcflags);
1683 void mail_gc_body (BODY *body);
1685 BODY *mail_body (MAILSTREAM *stream,unsigned long msgno,
1686 unsigned char *section);
1687 char *mail_date (char *string,MESSAGECACHE *elt);
1688 char *mail_cdate (char *string,MESSAGECACHE *elt);
1689 long mail_parse_date (MESSAGECACHE *elt,unsigned char *string);
1690 void mail_exists (MAILSTREAM *stream,unsigned long nmsgs);
1691 void mail_recent (MAILSTREAM *stream,unsigned long recent);
1692 void mail_expunged (MAILSTREAM *stream,unsigned long msgno);
1693 void mail_lock (MAILSTREAM *stream);
1694 void mail_unlock (MAILSTREAM *stream);
1695 void mail_debug (MAILSTREAM *stream);
1696 void mail_nodebug (MAILSTREAM *stream);
1697 void mail_dlog (char *string,long flag);
1698 long mail_match_lines (STRINGLIST *lines,STRINGLIST *msglines,long flags);
1699 unsigned long mail_filter (char *text,unsigned long len,STRINGLIST *lines,
1700 long flags);
1701 long mail_search_msg (MAILSTREAM *stream,unsigned long msgno,char *section,
1702 SEARCHPGM *pgm);
1703 long mail_search_header_text (char *s,STRINGLIST *st);
1704 long mail_search_header (SIZEDTEXT *hdr,STRINGLIST *st);
1705 long mail_search_text (MAILSTREAM *stream,unsigned long msgno,char *section,
1706 STRINGLIST *st,long flags);
1707 long mail_search_body (MAILSTREAM *stream,unsigned long msgno,BODY *body,
1708 char *prefix,unsigned long section,long flags);
1709 long mail_search_string (SIZEDTEXT *s,char *charset,STRINGLIST **st);
1710 long mail_search_string_work (SIZEDTEXT *s,STRINGLIST **st);
1711 long mail_search_keyword (MAILSTREAM *stream,MESSAGECACHE *elt,STRINGLIST *st,
1712 long flag);
1713 long mail_search_addr (ADDRESS *adr,STRINGLIST *st);
1714 char *mail_search_gets (readfn_t f,void *stream,unsigned long size,
1715 GETS_DATA *md);
1716 SEARCHPGM *mail_criteria (char *criteria);
1717 int mail_criteria_date (unsigned short *date,char **r);
1718 int mail_criteria_string (STRINGLIST **s,char **r);
1719 unsigned short mail_shortdate (unsigned int year,unsigned int month,
1720 unsigned int day);
1721 SEARCHSET *mail_parse_set (char *s,char **ret);
1722 SEARCHSET *mail_append_set (SEARCHSET *set,unsigned long msgno);
1723 unsigned long *mail_sort (MAILSTREAM *stream,char *charset,SEARCHPGM *spg,
1724 SORTPGM *pgm,long flags);
1725 unsigned long *mail_sort_cache (MAILSTREAM *stream,SORTPGM *pgm,SORTCACHE **sc,
1726 long flags);
1727 unsigned long *mail_sort_msgs (MAILSTREAM *stream,char *charset,SEARCHPGM *spg,
1728 SORTPGM *pgm,long flags);
1729 SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm);
1730 unsigned int mail_strip_subject (char *t,char **ret);
1731 char *mail_strip_subject_wsp (char *s);
1732 char *mail_strip_subject_blob (char *s);
1733 int mail_sort_compare (const void *a1,const void *a2);
1734 unsigned long mail_longdate (MESSAGECACHE *elt);
1735 THREADNODE *mail_thread (MAILSTREAM *stream,char *type,char *charset,
1736 SEARCHPGM *spg,long flags);
1737 THREADNODE *mail_thread_msgs (MAILSTREAM *stream,char *type,char *charset,
1738 SEARCHPGM *spg,long flags,sorter_t sorter);
1739 THREADNODE *mail_thread_orderedsubject (MAILSTREAM *stream,char *charset,
1740 SEARCHPGM *spg,long flags,
1741 sorter_t sorter);
1742 THREADNODE *mail_thread_references (MAILSTREAM *stream,char *charset,
1743 SEARCHPGM *spg,long flags,
1744 sorter_t sorter);
1745 void mail_thread_loadcache (MAILSTREAM *stream,unsigned long uid,OVERVIEW *ov,
1746 unsigned long msgno);
1747 char *mail_thread_parse_msgid (char *s,char **ss);
1748 STRINGLIST *mail_thread_parse_references (char *s,long flag);
1749 long mail_thread_check_child (container_t mother,container_t daughter);
1750 container_t mail_thread_prune_dummy (container_t msg,container_t ane);
1751 container_t mail_thread_prune_dummy_work (container_t msg,container_t ane);
1752 THREADNODE *mail_thread_c2node (MAILSTREAM *stream,container_t con,long flags);
1753 THREADNODE *mail_thread_sort (THREADNODE *thr,THREADNODE **tc);
1754 int mail_thread_compare_date (const void *a1,const void *a2);
1755 long mail_sequence (MAILSTREAM *stream,unsigned char *sequence);
1756 long mail_uid_sequence (MAILSTREAM *stream,unsigned char *sequence);
1757 long mail_parse_flags (MAILSTREAM *stream,char *flag,unsigned long *uf);
1758 long mail_usable_network_stream (MAILSTREAM *stream,char *name);
1760 MESSAGECACHE *mail_new_cache_elt (unsigned long msgno);
1761 ENVELOPE *mail_newenvelope (void);
1762 ADDRESS *mail_newaddr (void);
1763 BODY *mail_newbody (void);
1764 BODY *mail_initbody (BODY *body);
1765 PARAMETER *mail_newbody_parameter (void);
1766 PART *mail_newbody_part (void);
1767 MESSAGE *mail_newmsg (void);
1768 STRINGLIST *mail_newstringlist (void);
1769 SEARCHPGM *mail_newsearchpgm (void);
1770 SEARCHHEADER *mail_newsearchheader (char *line,char *text);
1771 SEARCHSET *mail_newsearchset (void);
1772 SEARCHOR *mail_newsearchor (void);
1773 SEARCHPGMLIST *mail_newsearchpgmlist (void);
1774 SORTPGM *mail_newsortpgm (void);
1775 THREADNODE *mail_newthreadnode (SORTCACHE *sc);
1776 ACLLIST *mail_newacllist (void);
1777 QUOTALIST *mail_newquotalist (void);
1778 void mail_free_body (BODY **body);
1779 void mail_free_body_data (BODY *body);
1780 void mail_free_body_parameter (PARAMETER **parameter);
1781 void mail_free_body_part (PART **part);
1782 void mail_free_cache (MAILSTREAM *stream);
1783 void mail_free_elt (MESSAGECACHE **elt);
1784 void mail_free_envelope (ENVELOPE **env);
1785 void mail_free_address (ADDRESS **address);
1786 void mail_free_stringlist (STRINGLIST **string);
1787 void mail_free_searchpgm (SEARCHPGM **pgm);
1788 void mail_free_searchheader (SEARCHHEADER **hdr);
1789 void mail_free_searchset (SEARCHSET **set);
1790 void mail_free_searchor (SEARCHOR **orl);
1791 void mail_free_searchpgmlist (SEARCHPGMLIST **pgl);
1792 void mail_free_namespace (NAMESPACE **n);
1793 void mail_free_sortpgm (SORTPGM **pgm);
1794 void mail_free_threadnode (THREADNODE **thr);
1795 void mail_free_acllist (ACLLIST **al);
1796 void mail_free_quotalist (QUOTALIST **ql);
1797 void auth_link (AUTHENTICATOR *auth);
1798 char *mail_auth (char *mechanism,authresponse_t resp,int argc,char *argv[]);
1799 AUTHENTICATOR *mail_lookup_auth (unsigned long i);
1800 unsigned int mail_lookup_auth_name (char *mechanism,long flags);
1802 NETSTREAM *net_open (NETMBX *mb,NETDRIVER *dv,unsigned long port,
1803 NETDRIVER *ssld,char *ssls,unsigned long sslp);
1804 NETSTREAM *net_open_work (NETDRIVER *dv,char *host,char *service,
1805 unsigned long port,unsigned long portoverride,
1806 unsigned long flags);
1807 NETSTREAM *net_aopen (NETDRIVER *dv,NETMBX *mb,char *service,char *usrbuf);
1808 char *net_getline (NETSTREAM *stream);
1809 /* stream must be void* for use as readfn_t */
1810 long net_getbuffer (void *stream,unsigned long size,char *buffer);
1811 long net_soutr (NETSTREAM *stream,char *string);
1812 long net_sout (NETSTREAM *stream,char *string,unsigned long size);
1813 void net_close (NETSTREAM *stream);
1814 char *net_host (NETSTREAM *stream);
1815 char *net_remotehost (NETSTREAM *stream);
1816 unsigned long net_port (NETSTREAM *stream);
1817 char *net_localhost (NETSTREAM *stream);
1819 long sm_subscribe (char *mailbox);
1820 long sm_unsubscribe (char *mailbox);
1821 char *sm_read (void **sdb);
1823 void ssl_onceonlyinit (void);
1824 char *ssl_start_tls (char *s);
1825 void ssl_server_init (char *server);
1828 /* Server I/O functions */
1830 int PBIN (void);
1831 char *PSIN (char *s,int n);
1832 long PSINR (char *s,unsigned long n);
1833 int PBOUT (int c);
1834 long INWAIT (long seconds);
1835 int PSOUT (char *s);
1836 int PSOUTR (SIZEDTEXT *s);
1837 int PFLUSH (void);

UW-IMAP'd extensions by yuuji