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