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