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