2 * Copyright 2016 Eduardo Chappa
4 * Last Edited: February 6, 2015 Eduardo Chappa <chappa@gmx.com>
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
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__
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
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
233 #define GET_ENCRYPTION_RANGE_MIN (long) 338
234 #define SET_ENCRYPTION_RANGE_MIN (long) 339
235 #define GET_ENCRYPTION_RANGE_MAX (long) 340
236 #define SET_ENCRYPTION_RANGE_MAX (long) 341
238 /* 4xx: network drivers */
239 #define GET_MAXLOGINTRIALS (long) 400
240 #define SET_MAXLOGINTRIALS (long) 401
241 #define GET_LOOKAHEAD (long) 402
242 #define SET_LOOKAHEAD (long) 403
243 #define GET_IMAPPORT (long) 404
244 #define SET_IMAPPORT (long) 405
245 #define GET_PREFETCH (long) 406
246 #define SET_PREFETCH (long) 407
247 #define GET_CLOSEONERROR (long) 408
248 #define SET_CLOSEONERROR (long) 409
249 #define GET_POP3PORT (long) 410
250 #define SET_POP3PORT (long) 411
251 #define GET_UIDLOOKAHEAD (long) 412
252 #define SET_UIDLOOKAHEAD (long) 413
253 #define GET_NNTPPORT (long) 414
254 #define SET_NNTPPORT (long) 415
255 #define GET_IMAPENVELOPE (long) 416
256 #define SET_IMAPENVELOPE (long) 417
257 #define GET_IMAPREFERRAL (long) 418
258 #define SET_IMAPREFERRAL (long) 419
259 #define GET_SSLIMAPPORT (long) 420
260 #define SET_SSLIMAPPORT (long) 421
261 #define GET_SSLPOPPORT (long) 422
262 #define SET_SSLPOPPORT (long) 423
263 #define GET_SSLNNTPPORT (long) 424
264 #define SET_SSLNNTPPORT (long) 425
265 #define GET_SSLSMTPPORT (long) 426
266 #define SET_SSLSMTPPORT (long) 427
267 #define GET_SMTPPORT (long) 428
268 #define SET_SMTPPORT (long) 429
269 #define GET_IMAPEXTRAHEADERS (long) 430
270 #define SET_IMAPEXTRAHEADERS (long) 431
271 #define GET_ACL (long) 432
272 #define SET_ACL (long) 433
273 #define GET_LISTRIGHTS (long) 434
274 #define SET_LISTRIGHTS (long) 435
275 #define GET_MYRIGHTS (long) 436
276 #define SET_MYRIGHTS (long) 437
277 #define GET_QUOTA (long) 438
278 #define SET_QUOTA (long) 439
279 #define GET_QUOTAROOT (long) 440
280 #define SET_QUOTAROOT (long) 441
281 #define GET_IMAPTRYSSL (long) 442
282 #define SET_IMAPTRYSSL (long) 443
283 #define GET_FETCHLOOKAHEAD (long) 444
284 #define SET_FETCHLOOKAHEAD (long) 445
285 #define GET_NNTPRANGE (long) 446
286 #define SET_NNTPRANGE (long) 447
287 #define GET_NNTPHIDEPATH (long) 448
288 #define SET_NNTPHIDEPATH (long) 449
289 #define GET_SENDCOMMAND (long) 450
290 #define SET_SENDCOMMAND (long) 451
291 #define GET_IDLETIMEOUT (long) 452
292 #define SET_IDLETIMEOUT (long) 453
293 #define GET_FETCHLOOKAHEADLIMIT (long) 454
294 #define SET_FETCHLOOKAHEADLIMIT (long) 455
296 /* 5xx: local file drivers */
297 #define GET_MBXPROTECTION (long) 500
298 #define SET_MBXPROTECTION (long) 501
299 #define GET_DIRPROTECTION (long) 502
300 #define SET_DIRPROTECTION (long) 503
301 #define GET_LOCKPROTECTION (long) 504
302 #define SET_LOCKPROTECTION (long) 505
303 #define GET_FROMWIDGET (long) 506
304 #define SET_FROMWIDGET (long) 507
305 #define GET_NEWSACTIVE (long) 508
306 #define SET_NEWSACTIVE (long) 509
307 #define GET_NEWSSPOOL (long) 510
308 #define SET_NEWSSPOOL (long) 511
309 #define GET_NEWSRC (long) 512
310 #define SET_NEWSRC (long) 513
311 #define GET_EXTENSION (long) 514
312 #define SET_EXTENSION (long) 515
313 #define GET_DISABLEFCNTLLOCK (long) 516
314 #define SET_DISABLEFCNTLLOCK (long) 517
315 #define GET_LOCKEACCESERROR (long) 518
316 #define SET_LOCKEACCESERROR (long) 519
317 #define GET_LISTMAXLEVEL (long) 520
318 #define SET_LISTMAXLEVEL (long) 521
319 #define GET_ANONYMOUSHOME (long) 522
320 #define SET_ANONYMOUSHOME (long) 523
321 #define GET_FTPHOME (long) 524
322 #define SET_FTPHOME (long) 525
323 #define GET_PUBLICHOME (long) 526
324 #define SET_PUBLICHOME (long) 527
325 #define GET_SHAREDHOME (long) 528
326 #define SET_SHAREDHOME (long) 529
327 #define GET_MHPROFILE (long) 530
328 #define SET_MHPROFILE (long) 531
329 #define GET_MHPATH (long) 532
330 #define SET_MHPATH (long) 533
331 #define GET_ONETIMEEXPUNGEATPING (long) 534
332 #define SET_ONETIMEEXPUNGEATPING (long) 535
333 #define GET_USERHASNOLIFE (long) 536
334 #define SET_USERHASNOLIFE (long) 537
335 #define GET_FTPPROTECTION (long) 538
336 #define SET_FTPPROTECTION (long) 539
337 #define GET_PUBLICPROTECTION (long) 540
338 #define SET_PUBLICPROTECTION (long) 541
339 #define GET_SHAREDPROTECTION (long) 542
340 #define SET_SHAREDPROTECTION (long) 543
341 #define GET_LOCKTIMEOUT (long) 544
342 #define SET_LOCKTIMEOUT (long) 545
343 #define GET_NOTIMEZONES (long) 546
344 #define SET_NOTIMEZONES (long) 547
345 #define GET_HIDEDOTFILES (long) 548
346 #define SET_HIDEDOTFILES (long) 549
347 #define GET_FTPDIRPROTECTION (long) 550
348 #define SET_FTPDIRPROTECTION (long) 551
349 #define GET_PUBLICDIRPROTECTION (long) 552
350 #define SET_PUBLICDIRPROTECTION (long) 553
351 #define GET_SHAREDDIRPROTECTION (long) 554
352 #define SET_SHAREDDIRPROTECTION (long) 555
353 #define GET_TRUSTDNS (long) 556
354 #define SET_TRUSTDNS (long) 557
355 #define GET_SASLUSESPTRNAME (long) 558
356 #define SET_SASLUSESPTRNAME (long) 559
357 #define GET_NETFSSTATBUG (long) 560
358 #define SET_NETFSSTATBUG (long) 561
359 #define GET_SNARFMAILBOXNAME (long) 562
360 #define SET_SNARFMAILBOXNAME (long) 563
361 #define GET_SNARFINTERVAL (long) 564
362 #define SET_SNARFINTERVAL (long) 565
363 #define GET_SNARFPRESERVE (long) 566
364 #define SET_SNARFPRESERVE (long) 567
365 #define GET_INBOXPATH (long) 568
366 #define SET_INBOXPATH (long) 569
367 #define GET_DIRFMTTEST (long) 570
368 #define SET_DIRFMTTEST (long) 571
369 #define GET_SCANCONTENTS (long) 572
370 #define SET_SCANCONTENTS (long) 573
371 #define GET_MHALLOWINBOX (long) 574
372 #define SET_MHALLOWINBOX (long) 575
376 #define DR_DISABLE (long) 0x1 /* driver is disabled */
377 #define DR_LOCAL (long) 0x2 /* local file driver */
378 #define DR_MAIL (long) 0x4 /* supports mail */
379 #define DR_NEWS (long) 0x8 /* supports news */
380 #define DR_READONLY (long) 0x10 /* driver only allows readonly access */
381 #define DR_NOFAST (long) 0x20 /* "fast" data is slow (whole msg fetch) */
382 #define DR_NAMESPACE (long) 0x40/* driver has a special namespace */
383 #define DR_LOWMEM (long) 0x80 /* low amounts of memory available */
384 #define DR_LOCKING (long) 0x100 /* driver does locking */
385 #define DR_CRLF (long) 0x200 /* driver internal form uses CRLF newlines */
386 #define DR_NOSTICKY (long) 0x400/* driver does not support sticky UIDs */
387 #define DR_RECYCLE (long) 0x800 /* driver does stream recycling */
388 #define DR_XPOINT (long) 0x1000 /* needs to be checkpointed */
389 /* driver has no real internal date */
390 #define DR_NOINTDATE (long) 0x2000
391 /* driver does not announce new mail */
392 #define DR_NONEWMAIL (long) 0x4000
393 /* driver does not announce new mail when RO */
394 #define DR_NONEWMAILRONLY (long) 0x8000
395 /* driver can be halfopen */
396 #define DR_HALFOPEN (long) 0x10000
397 #define DR_DIRFMT (long) 0x20000/* driver is a directory-format */
398 #define DR_MODSEQ (long) 0x40000/* driver supports modseqs */
401 /* Cache management function codes */
403 #define CH_INIT (long) 10 /* initialize cache */
404 #define CH_SIZE (long) 11 /* (re-)size the cache */
405 #define CH_MAKEELT (long) 30 /* return elt, make if needed */
406 #define CH_ELT (long) 31 /* return elt if exists */
407 #define CH_SORTCACHE (long) 35 /* return sortcache entry, make if needed */
408 #define CH_FREE (long) 40 /* free space used by elt */
409 /* free space used by sortcache */
410 #define CH_FREESORTCACHE (long) 43
411 #define CH_EXPUNGE (long) 45 /* delete elt pointer from list */
414 /* Mailbox open options
415 * For compatibility with the past, OP_DEBUG must always be 1.
418 #define OP_DEBUG (long) 0x1 /* debug protocol negotiations */
419 #define OP_READONLY (long) 0x2 /* read-only open */
420 #define OP_ANONYMOUS (long) 0x4 /* anonymous open of newsgroup */
421 #define OP_SHORTCACHE (long) 0x8/* short (elt-only) caching */
422 #define OP_SILENT (long) 0x10 /* don't pass up events (internal use) */
423 #define OP_PROTOTYPE (long) 0x20/* return driver prototype */
424 #define OP_HALFOPEN (long) 0x40 /* half-open (IMAP connect but no select) */
425 #define OP_EXPUNGE (long) 0x80 /* silently expunge recycle stream */
426 #define OP_SECURE (long) 0x100 /* don't do non-secure authentication */
427 #define OP_TRYSSL (long) 0x200 /* try SSL first */
428 /* use multiple newsrc files */
429 #define OP_MULNEWSRC (long) 0x400
430 #define OP_NOKOD (long) 0x800 /* suppress kiss-of-death */
431 #define OP_SNIFF (long) 0x1000 /* metadata only open */
432 /* reserved for application use */
433 #define OP_RESERVED (unsigned long) 0xff000000
436 /* Net open options */
438 /* no error messages */
439 #define NET_SILENT ((unsigned long) 0x80000000)
440 /* no validation of SSL certificates */
441 #define NET_NOVALIDATECERT ((unsigned long) 0x40000000)
442 /* no open timeout */
443 #define NET_NOOPENTIMEOUT ((unsigned long) 0x20000000)
445 #define NET_TLSCLIENT ((unsigned long) 0x10000000)
447 #define NET_TRYSSL ((unsigned long) 0x8000000)
449 #define NET_TRYTLS1 ((unsigned long) 0x4000000)
450 /* try TLS1_1 mode */
451 #define NET_TRYTLS1_1 ((unsigned long) 0x2000000)
452 /* try TLS1_2 mode */
453 #define NET_TRYTLS1_2 ((unsigned long) 0x1000000)
454 /* try TLS1_3 mode */
455 #define NET_TRYTLS1_3 ((unsigned long) 0x800000)
459 #define CL_EXPUNGE (long) 1 /* expunge silently */
464 #define FT_UID (long) 0x1 /* argument is a UID */
465 #define FT_PEEK (long) 0x2 /* peek at data */
466 #define FT_NOT (long) 0x4 /* NOT flag for header lines fetch */
467 #define FT_INTERNAL (long) 0x8 /* text can be internal strings */
468 /* IMAP prefetch text when fetching header */
469 #define FT_PREFETCHTEXT (long) 0x20
470 #define FT_NOHDRS (long) 0x40 /* suppress fetching extra headers (note that
471 this breaks news handling) */
472 #define FT_NEEDENV (long) 0x80 /* (internal use) include envelope */
473 #define FT_NEEDBODY (long) 0x100/* (internal use) include body structure */
474 /* no fetch lookahead */
475 #define FT_NOLOOKAHEAD (long) 0x200
476 /* (internal use) lookahead in hdr searching */
477 #define FT_SEARCHLOOKAHEAD (long) 0x400
478 /* stringstruct return hack */
479 #define FT_RETURNSTRINGSTRUCT (long) 0x800
482 /* Flagging options */
484 #define ST_UID (long) 0x1 /* argument is a UID sequence */
485 #define ST_SILENT (long) 0x2 /* don't return results */
486 #define ST_SET (long) 0x4 /* set vs. clear */
489 /* Expunge options */
491 #define EX_UID (long) 0x1 /* argument is a UID sequence */
496 #define CP_UID (long) 0x1 /* argument is a UID sequence */
497 #define CP_MOVE (long) 0x2 /* delete from source after copying */
498 /* set debug in any created stream */
499 #define CP_DEBUG (long) 0x20000000
501 /* Search/sort/thread options */
503 #define SE_UID (long) 0x1 /* return UID */
504 #define SE_FREE (long) 0x2 /* free search program after finished */
505 #define SE_NOPREFETCH (long) 0x4/* no search prefetching */
506 #define SO_FREE (long) 0x8 /* free sort program after finished */
507 #define SE_NOSERVER (long) 0x10 /* don't do server-based search/sort/thread */
508 #define SE_RETAIN (long) 0x20 /* retain previous search results */
509 #define SO_OVERVIEW (long) 0x40 /* use overviews in searching (NNTP only) */
510 #define SE_NEEDBODY (long) 0x80 /* include body structure in prefetch */
511 #define SE_NOHDRS (long) 0x100 /* suppress prefetching extra headers (note
512 that this breaks news handling) */
513 #define SE_NOLOCAL (long) 0x200 /* no local retry (IMAP only) */
515 #define SO_NOSERVER SE_NOSERVER /* compatibility name */
516 #define SE_SILLYOK (long) 0x400 /* allow silly searches */
521 #define SA_MESSAGES (long) 0x1 /* number of messages */
522 #define SA_RECENT (long) 0x2 /* number of recent messages */
523 #define SA_UNSEEN (long) 0x4 /* number of unseen messages */
524 #define SA_UIDNEXT (long) 0x8 /* next UID to be assigned */
525 /* UID validity value */
526 #define SA_UIDVALIDITY (long) 0x10
527 /* set OP_DEBUG on any created stream */
528 #define SA_DEBUG (long) 0x10000000
529 /* use multiple newsrcs */
530 #define SA_MULNEWSRC (long) 0x20000000
534 #define MG_UID (long) 0x1 /* message number is a UID */
535 #define MG_COPY (long) 0x2 /* must return copy of argument */
537 /* SASL authenticator categories */
539 #define AU_SECURE (long) 0x1 /* /secure allowed */
540 #define AU_AUTHUSER (long) 0x2 /* /authuser=xxx allowed */
541 /* authenticator hidden */
542 #define AU_HIDE (long) 0x10000000
543 /* authenticator disabled */
544 #define AU_DISABLE (long) 0x20000000
547 /* Garbage collection flags */
549 #define GC_ELT (long) 0x1 /* message cache elements */
550 #define GC_ENV (long) 0x2 /* envelopes and bodies */
551 #define GC_TEXTS (long) 0x4 /* cached texts */
554 /* mm_log()/mm_notify() condition codes */
556 #define WARN (long) 1 /* mm_log warning type */
557 #define ERROR (long) 2 /* mm_log error type */
558 #define PARSE (long) 3 /* mm_log parse error type */
559 #define BYE (long) 4 /* mm_notify stream dying */
560 #define TCPDEBUG (long) 5 /* mm_log TCP debug babble */
563 /* Bits from mail_parse_flags(). Don't change these, since the header format
564 * used by tenex, mtx, and mbx corresponds to these bits.
570 #define fANSWERED 0x8
574 #define fEXPUNGED 0x8000 /* internal flag */
576 /* Bits for mm_list() and mm_lsub() */
578 /* Note that (LATT_NOINFERIORS LATT_HASCHILDREN LATT_HASNOCHILDREN) and
579 * (LATT_NOSELECT LATT_MARKED LATT_UNMARKED) each have eight possible states,
580 * but only four of these are valid. The other four are silly states which
581 * while invalid can unfortunately be expressed in the IMAP protocol.
584 /* terminal node in hierarchy */
585 #define LATT_NOINFERIORS (long) 0x1
586 /* name can not be selected */
587 #define LATT_NOSELECT (long) 0x2
588 /* changed since last accessed */
589 #define LATT_MARKED (long) 0x4
590 /* accessed since last changed */
591 #define LATT_UNMARKED (long) 0x8
592 /* name has referral to remote mailbox */
593 #define LATT_REFERRAL (long) 0x10
594 /* has selectable inferiors */
595 #define LATT_HASCHILDREN (long) 0x20
596 /* has no selectable inferiors */
597 #define LATT_HASNOCHILDREN (long) 0x40
598 /* folder contains all messages */
599 #define LATT_ALL (long) 0x80
600 /* folder contains archived messages */
601 #define LATT_ARCHIVE (long) 0x100
602 /* folder contains drafts */
603 #define LATT_DRAFTS (long) 0x200
604 /* folder contains Flagged messages */
605 #define LATT_FLAGGED (long) 0x400
606 /* folder contains junk messages */
607 #define LATT_JUNK (long) 0x800
608 /* folder contains Sent mail */
609 #define LATT_SENT (long) 0x1000
610 /* folder contains deleted messages */
611 #define LATT_TRASH (long) 0x2000
615 #define SORTDATE 0 /* date */
616 #define SORTARRIVAL 1 /* arrival date */
617 #define SORTFROM 2 /* from */
618 #define SORTSUBJECT 3 /* subject */
619 #define SORTTO 4 /* to */
620 #define SORTCC 5 /* cc */
621 #define SORTSIZE 6 /* size */
624 /* imapreferral_t codes */
626 #define REFAUTHFAILED (long) 0 /* authentication referral -- not logged in */
627 #define REFAUTH (long) 1 /* authentication referral -- logged in */
628 #define REFSELECT (long) 2 /* select referral */
629 #define REFCREATE (long) 3
630 #define REFDELETE (long) 4
631 #define REFRENAME (long) 5
632 #define REFSUBSCRIBE (long) 6
633 #define REFUNSUBSCRIBE (long) 7
634 #define REFSTATUS (long) 8
635 #define REFCOPY (long) 9
636 #define REFAPPEND (long) 10
639 /* sendcommand_t codes */
641 /* expunge response deferred */
642 #define SC_EXPUNGEDEFERRED (long) 1
644 /* Block notification codes */
646 #define BLOCK_NONE 0 /* not blocked */
647 #define BLOCK_SENSITIVE 1 /* sensitive code, disallow alarms */
648 #define BLOCK_NONSENSITIVE 2 /* non-sensitive code, allow alarms */
649 #define BLOCK_DNSLOOKUP 10 /* blocked on DNS lookup */
650 #define BLOCK_TCPOPEN 11 /* blocked on TCP open */
651 #define BLOCK_TCPREAD 12 /* blocked on TCP read */
652 #define BLOCK_TCPWRITE 13 /* blocked on TCP write */
653 #define BLOCK_TCPCLOSE 14 /* blocked on TCP close */
654 #define BLOCK_FILELOCK 20 /* blocked on file locking */
657 /* In-memory sized-text */
659 #define SIZEDTEXT struct mail_sizedtext
662 unsigned char *data
; /* text */
663 unsigned long size
; /* size of text in octets */
669 #define STRINGLIST struct string_list
672 SIZEDTEXT text
; /* string text */
677 /* Parse results from mail_valid_net_parse */
679 #define NETMAXHOST 256
680 #define NETMAXUSER 65
681 #define NETMAXMBX (MAILTMPLEN/4)
683 #define NETMAXAUTH 16
684 typedef struct net_mailbox
{
685 char host
[NETMAXHOST
]; /* host name (may be canonicalized) */
686 char orighost
[NETMAXHOST
]; /* host name before canonicalization */
687 char user
[NETMAXUSER
]; /* user name */
688 char auth
[NETMAXAUTH
]; /* authenticator name (PLAIN, etc.) */
689 char authuser
[NETMAXUSER
]; /* authentication user name */
690 char mailbox
[NETMAXMBX
]; /* mailbox name */
691 char service
[NETMAXSRV
]; /* service name */
692 unsigned long port
; /* TCP port number */
693 unsigned int anoflag
: 1; /* anonymous */
694 unsigned int dbgflag
: 1; /* debug flag */
695 unsigned int secflag
: 1; /* secure flag */
696 unsigned int sslflag
: 1; /* SSL driver flag */
697 unsigned int tls1
: 1; /* Use TLSv1 */
698 unsigned int tls1_1
: 1; /* Use TLSv1.1 */
699 unsigned int tls1_2
: 1; /* Use TLSV1.2 */
700 unsigned int tls1_3
: 1; /* Use TLSV1.3 */
701 unsigned int trysslflag
: 1; /* try SSL driver first flag */
702 unsigned int novalidate
: 1; /* don't validate certificates */
703 unsigned int tlsflag
: 1; /* TLS flag */
704 unsigned int notlsflag
: 1; /* do not do TLS flag */
705 unsigned int readonlyflag
: 1;/* want readonly */
706 unsigned int norsh
: 1; /* don't use rsh/ssh */
707 unsigned int loser
: 1; /* server is a loser */
708 unsigned int tlssslv23
: 1; /* force SSLv23 client method over TLS */
711 #define SSL_MTHD(M) ((M).tlssslv23 ? NIL \
712 : (M).tls1 ? NET_TRYTLS1 \
713 : (M).tls1_1 ? NET_TRYTLS1_1 \
714 : (M).tls1_2 ? NET_TRYTLS1_2 \
715 : (M).tls1_3 ? NET_TRYTLS1_3 \
719 /* Item in an address list */
721 #define ADDRESS struct mail_address
724 char *personal
; /* personal name phrase */
725 char *adl
; /* at-domain-list source route */
726 char *mailbox
; /* mailbox name */
727 char *host
; /* domain name of mailbox's host */
728 char *error
; /* error in address from SMTP module */
730 char *type
; /* address type (default "rfc822") */
731 char *addr
; /* address as xtext */
733 ADDRESS
*next
; /* pointer to next address in list */
737 /* Message envelope */
739 typedef struct mail_envelope
{
740 unsigned int ngpathexists
: 1; /* newsgroups may be bogus */
741 unsigned int incomplete
: 1; /* envelope may be incomplete */
742 unsigned int imapenvonly
: 1; /* envelope only has IMAP envelope */
743 char *remail
; /* remail header if any */
744 ADDRESS
*return_path
; /* error return address */
745 unsigned char *date
; /* message composition date string */
746 ADDRESS
*from
; /* originator address list */
747 ADDRESS
*sender
; /* sender address list */
748 ADDRESS
*reply_to
; /* reply address list */
749 char *subject
; /* message subject string */
750 ADDRESS
*to
; /* primary recipient list */
751 ADDRESS
*cc
; /* secondary recipient list */
752 ADDRESS
*bcc
; /* blind secondary recipient list */
753 char *in_reply_to
; /* replied message ID */
754 char *message_id
; /* message ID */
755 char *newsgroups
; /* USENET newsgroups */
756 char *followup_to
; /* USENET reply newsgroups */
757 char *references
; /* USENET references */
758 void *sparep
; /* spare pointer reserved for main program */
761 /* Primary body types */
762 /* If you change any of these you must also change body_types in rfc822.c */
764 #define TYPETEXT 0 /* unformatted text */
765 #define TYPEMULTIPART 1 /* multiple part */
766 #define TYPEMESSAGE 2 /* encapsulated message */
767 #define TYPEAPPLICATION 3 /* application data */
768 #define TYPEAUDIO 4 /* audio */
769 #define TYPEIMAGE 5 /* static image */
770 #define TYPEVIDEO 6 /* video */
771 #define TYPEMODEL 7 /* model */
772 #define TYPEOTHER 8 /* unknown */
773 #define TYPEMAX 15 /* maximum type code */
777 /* If you change any of these you must also change body_encodings in rfc822.c
780 #define ENC7BIT 0 /* 7 bit SMTP semantic data */
781 #define ENC8BIT 1 /* 8 bit SMTP semantic data */
782 #define ENCBINARY 2 /* 8 bit binary data */
783 #define ENCBASE64 3 /* base-64 encoded data */
784 #define ENCQUOTEDPRINTABLE 4 /* human-readable 8-as-7 bit data */
785 #define ENCOTHER 5 /* unknown */
786 #define ENCMAX 10 /* maximum encoding code */
791 #define BODY struct mail_bodystruct
792 #define MESSAGE struct mail_body_message
793 #define PARAMETER struct mail_body_parameter
794 #define PART struct mail_body_part
795 #define PARTTEXT struct mail_body_text
797 /* Message body text */
800 unsigned long offset
; /* offset from body origin */
801 SIZEDTEXT text
; /* text */
805 /* Message body structure */
808 unsigned short type
; /* body primary type */
809 unsigned short encoding
; /* body transfer encoding */
810 char *subtype
; /* subtype string */
811 PARAMETER
*parameter
; /* parameter list */
812 char *id
; /* body identifier */
813 char *description
; /* body description */
814 struct { /* body disposition */
815 char *type
; /* disposition type */
816 PARAMETER
*parameter
; /* disposition parameters */
818 STRINGLIST
*language
; /* body language */
819 char *location
; /* body content URI */
820 PARTTEXT mime
; /* MIME header */
821 PARTTEXT contents
; /* body part contents */
822 union { /* different ways of accessing contents */
823 PART
*part
; /* body part list */
824 MESSAGE
*msg
; /* body encapsulated message */
827 unsigned long lines
; /* size of text in lines */
828 unsigned long bytes
; /* size of text in octets */
830 char *md5
; /* MD5 checksum */
831 void *sparep
; /* spare pointer reserved for main program */
838 char *attribute
; /* parameter attribute name */
839 char *value
; /* parameter value */
840 PARAMETER
*next
; /* next parameter in list */
844 /* Multipart content list */
847 BODY body
; /* body information for this part */
848 PART
*next
; /* next body part */
852 /* RFC-822 Message */
855 ENVELOPE
*env
; /* message envelope */
856 BODY
*body
; /* message body */
857 PARTTEXT full
; /* full message */
858 STRINGLIST
*lines
; /* lines used to filter header */
859 PARTTEXT header
; /* header text */
860 PARTTEXT text
; /* body text */
863 /* Entry in the message cache array */
865 typedef struct message_cache
{
866 unsigned long msgno
; /* message number */
867 unsigned int lockcount
: 8; /* non-zero if multiple references */
868 unsigned long rfc822_size
; /* # of bytes of message as raw RFC822 */
869 struct { /* c-client internal use only */
870 unsigned long uid
; /* message unique ID */
871 unsigned long mod
; /* modseq */
872 PARTTEXT special
; /* special text pointers */
873 MESSAGE msg
; /* internal message pointers */
874 union { /* driver internal use */
878 unsigned int sequence
: 1; /* saved sequence bit */
879 unsigned int dirty
: 1; /* driver internal use */
880 unsigned int filter
: 1; /* driver internal use */
881 unsigned int ghost
: 1; /* driver internal use */
884 unsigned int day
: 5; /* day of month (1-31) */
885 unsigned int month
: 4; /* month of year (1-12) */
886 unsigned int year
: 7; /* year since BASEYEAR (expires in 127 yrs) */
887 unsigned int hours
: 5; /* hours (0-23) */
888 unsigned int minutes
: 6; /* minutes (0-59) */
889 unsigned int seconds
: 6; /* seconds (0-59) */
890 unsigned int zoccident
: 1; /* non-zero if west of UTC */
891 unsigned int zhours
: 4; /* hours from UTC (0-12) */
892 unsigned int zminutes
: 6; /* minutes (0-59) */
894 unsigned int seen
: 1; /* system Seen flag */
895 unsigned int deleted
: 1; /* system Deleted flag */
896 unsigned int flagged
: 1; /* system Flagged flag */
897 unsigned int answered
: 1; /* system Answered flag */
898 unsigned int draft
: 1; /* system Draft flag */
899 unsigned int recent
: 1; /* system Recent flag */
901 unsigned int valid
: 1; /* elt has valid flags */
902 unsigned int searched
: 1; /* message was searched */
903 unsigned int sequence
: 1; /* message is in sequence */
904 /* reserved for use by main program */
905 unsigned int spare
: 1; /* first spare bit */
906 unsigned int spare2
: 1; /* second spare bit */
907 unsigned int spare3
: 1; /* third spare bit */
908 unsigned int spare4
: 1; /* fourth spare bit */
909 unsigned int spare5
: 1; /* fifth spare bit */
910 unsigned int spare6
: 1; /* sixth spare bit */
911 unsigned int spare7
: 1; /* seventh spare bit */
912 unsigned int spare8
: 1; /* eighth spare bit */
913 void *sparep
; /* spare pointer */
914 unsigned long user_flags
; /* user-assignable flags */
917 /* String structure */
919 #define STRINGDRIVER struct string_driver
921 typedef struct mailstring
{
922 void *data
; /* driver-dependent data */
923 unsigned long data1
; /* driver-dependent data */
924 unsigned long size
; /* total length of string */
925 char *chunk
; /* base address of chunk */
926 unsigned long chunksize
; /* size of chunk */
927 unsigned long offset
; /* offset of this chunk in base */
928 char *curpos
; /* current position in chunk */
929 unsigned long cursize
; /* number of bytes remaining in chunk */
930 STRINGDRIVER
*dtb
; /* driver that handles this type of string */
934 /* Dispatch table for string driver */
937 /* initialize string driver */
938 void (*init
) (STRING
*s
,void *data
,unsigned long size
);
939 /* get next character in string */
940 char (*next
) (STRING
*s
);
941 /* set position in string */
942 void (*setpos
) (STRING
*s
,unsigned long i
);
946 /* Stringstruct access routines */
948 #define INIT(s,d,data,size) ((*((s)->dtb = &d)->init) (s,data,size))
949 #define SIZE(s) ((s)->size - GETPOS (s))
950 #define CHR(s) (*(s)->curpos)
951 #define SNX(s) (--(s)->cursize ? *(s)->curpos++ : (*(s)->dtb->next) (s))
952 #define GETPOS(s) ((s)->offset + ((s)->curpos - (s)->chunk))
953 #define SETPOS(s,i) (*(s)->dtb->setpos) (s,i)
957 #define SEARCHPGM struct search_program
958 #define SEARCHHEADER struct search_header
959 #define SEARCHSET struct search_set
960 #define SEARCHOR struct search_or
961 #define SEARCHPGMLIST struct search_pgm_list
964 SEARCHHEADER
{ /* header search */
965 SIZEDTEXT line
; /* header line */
966 SIZEDTEXT text
; /* text in header */
967 SEARCHHEADER
*next
; /* next in list */
971 SEARCHSET
{ /* message set */
972 unsigned long first
; /* sequence number */
973 unsigned long last
; /* last value, if a range */
974 SEARCHSET
*next
; /* next in list */
979 SEARCHPGM
*first
; /* first program */
980 SEARCHPGM
*second
; /* second program */
981 SEARCHOR
*next
; /* next in list */
986 SEARCHPGM
*pgm
; /* search program */
987 SEARCHPGMLIST
*next
; /* next in list */
990 SEARCHPGM
{ /* search program */
991 SEARCHSET
*msgno
; /* message numbers */
992 SEARCHSET
*uid
; /* unique identifiers */
993 SEARCHOR
*or; /* or'ed in programs */
994 SEARCHPGMLIST
*not; /* and'ed not program */
995 SEARCHHEADER
*header
; /* list of headers */
996 STRINGLIST
*bcc
; /* bcc recipients */
997 STRINGLIST
*body
; /* text in message body */
998 STRINGLIST
*cc
; /* cc recipients */
999 STRINGLIST
*from
; /* originator */
1000 STRINGLIST
*keyword
; /* keywords */
1001 STRINGLIST
*unkeyword
; /* unkeywords */
1002 STRINGLIST
*subject
; /* text in subject */
1003 STRINGLIST
*text
; /* text in headers and body */
1004 STRINGLIST
*to
; /* to recipients */
1005 STRINGLIST
*x_gm_ext1
; /* use X-GM-EXT-1 extension */
1006 unsigned long larger
; /* larger than this size */
1007 unsigned long smaller
; /* smaller than this size */
1008 unsigned long older
; /* older than this interval */
1009 unsigned long younger
; /* younger than this interval */
1010 unsigned short sentbefore
; /* sent before this date */
1011 unsigned short senton
; /* sent on this date */
1012 unsigned short sentsince
; /* sent since this date */
1013 unsigned short before
; /* before this date */
1014 unsigned short on
; /* on this date */
1015 unsigned short since
; /* since this date */
1016 unsigned int answered
: 1; /* answered messages */
1017 unsigned int unanswered
: 1; /* unanswered messages */
1018 unsigned int deleted
: 1; /* deleted messages */
1019 unsigned int undeleted
: 1; /* undeleted messages */
1020 unsigned int draft
: 1; /* message draft */
1021 unsigned int undraft
: 1; /* message undraft */
1022 unsigned int flagged
: 1; /* flagged messages */
1023 unsigned int unflagged
: 1; /* unflagged messages */
1024 unsigned int recent
: 1; /* recent messages */
1025 unsigned int old
: 1; /* old messages */
1026 unsigned int seen
: 1; /* seen messages */
1027 unsigned int unseen
: 1; /* unseen messages */
1028 /* These must be simulated in IMAP */
1029 STRINGLIST
*return_path
; /* error return address */
1030 STRINGLIST
*sender
; /* sender address list */
1031 STRINGLIST
*reply_to
; /* reply address list */
1032 STRINGLIST
*in_reply_to
; /* replied message ID */
1033 STRINGLIST
*message_id
; /* message ID */
1034 STRINGLIST
*newsgroups
; /* USENET newsgroups */
1035 STRINGLIST
*followup_to
; /* USENET reply newsgroups */
1036 STRINGLIST
*references
; /* USENET references */
1040 /* Mailbox status */
1042 typedef struct mbx_status
{
1043 long flags
; /* validity flags */
1044 unsigned long messages
; /* number of messages */
1045 unsigned long recent
; /* number of recent messages */
1046 unsigned long unseen
; /* number of unseen messages */
1047 unsigned long uidnext
; /* next UID to be assigned */
1048 unsigned long uidvalidity
; /* UID validity value */
1053 typedef void (*postsort_t
) (void *sc
);
1055 #define SORTPGM struct sort_program
1058 unsigned int reverse
: 1; /* sort function is to be reversed */
1059 unsigned int abort
: 1; /* abort sorting */
1060 short function
; /* sort function */
1061 unsigned long nmsgs
; /* number of messages being sorted */
1063 unsigned long cached
; /* number of messages cached so far */
1064 unsigned long sorted
; /* number of messages sorted so far */
1065 unsigned long postsorted
; /* number of postsorted messages so far */
1067 postsort_t postsort
; /* post sorter */
1068 SORTPGM
*next
; /* next function */
1074 #define SORTCACHE struct sort_cache
1077 unsigned int sorted
: 1; /* message has been sorted */
1078 unsigned int postsorted
: 1; /* message has been postsorted */
1079 unsigned int refwd
: 1; /* subject is a re or fwd */
1080 unsigned int dirty
: 1; /* has data not written to backup */
1081 SORTPGM
*pgm
; /* sort program */
1082 unsigned long num
; /* message number (sequence or UID) */
1083 unsigned long date
; /* sent date */
1084 unsigned long arrival
; /* arrival date */
1085 unsigned long size
; /* message size */
1086 char *from
; /* from string */
1087 char *to
; /* to string */
1088 char *cc
; /* cc string */
1089 char *subject
; /* extracted subject string */
1090 char *message_id
; /* message-id string */
1091 char *unique
; /* unique string, normally message-id */
1092 STRINGLIST
*references
; /* references string */
1097 #define ACLLIST struct acl_list
1100 char *identifier
; /* authentication identifier */
1101 char *rights
; /* access rights */
1105 /* Quota resource list */
1107 #define QUOTALIST struct quota_list
1110 char *name
; /* resource name */
1111 unsigned long usage
; /* resource usage */
1112 unsigned long limit
; /* resource limit */
1113 QUOTALIST
*next
; /* next resource */
1118 #define IDLIST struct id_list
1121 char *name
; /* name of field */
1122 char *value
; /* value of the field */
1123 IDLIST
*next
; /* next value in the list */
1126 /* Mail Access I/O stream */
1129 /* Structure for mail driver dispatch */
1131 #define DRIVER struct driver
1134 /* Mail I/O stream */
1136 typedef struct mail_stream
{
1137 DRIVER
*dtb
; /* dispatch table for this driver */
1138 void *local
; /* pointer to driver local data */
1139 char *mailbox
; /* mailbox name (canonicalized) */
1140 char *original_mailbox
; /* mailbox name (non-canonicalized) */
1141 unsigned short use
; /* stream use count */
1142 unsigned short sequence
; /* stream sequence */
1143 unsigned int inbox
: 1; /* stream open on an INBOX */
1144 unsigned int lock
: 1; /* stream lock flag */
1145 unsigned int debug
: 1; /* stream debug flag */
1146 unsigned int silent
: 1; /* don't pass events to main program */
1147 unsigned int rdonly
: 1; /* stream read-only flag */
1148 unsigned int anonymous
: 1; /* stream anonymous access flag */
1149 unsigned int scache
: 1; /* stream short cache flag */
1150 unsigned int halfopen
: 1; /* stream half-open flag */
1151 unsigned int secure
: 1; /* stream secure flag */
1152 unsigned int tryssl
: 1; /* stream tryssl flag */
1153 unsigned int mulnewsrc
: 1; /* stream use multiple newsrc files */
1154 unsigned int perm_seen
: 1; /* permanent Seen flag */
1155 unsigned int perm_deleted
: 1;/* permanent Deleted flag */
1156 unsigned int perm_flagged
: 1;/* permanent Flagged flag */
1157 unsigned int perm_answered
:1;/* permanent Answered flag */
1158 unsigned int perm_draft
: 1; /* permanent Draft flag */
1159 unsigned int kwd_create
: 1; /* can create new keywords */
1160 unsigned int uid_nosticky
: 1;/* UIDs are not preserved */
1161 unsigned int unhealthy
: 1; /* unhealthy protocol negotiations */
1162 unsigned int nokod
: 1; /* suppress kiss-of-death */
1163 unsigned int sniff
: 1; /* metadata only */
1164 unsigned long perm_user_flags
;/* mask of permanent user flags */
1165 unsigned long gensym
; /* generated tag */
1166 unsigned long nmsgs
; /* # of associated msgs */
1167 unsigned long recent
; /* # of recent msgs */
1168 unsigned long uid_validity
; /* UID validity sequence */
1169 unsigned long uid_last
; /* last assigned UID */
1170 char *user_flags
[NUSERFLAGS
]; /* pointers to user flags in bit order */
1171 unsigned long cachesize
; /* size of message cache */
1172 MESSAGECACHE
**cache
; /* message cache array */
1173 SORTCACHE
**sc
; /* sort cache array */
1174 unsigned long msgno
; /* message number of `current' message */
1175 ENVELOPE
*env
; /* scratch buffer for envelope */
1176 BODY
*body
; /* scratch buffer for body */
1177 SIZEDTEXT text
; /* scratch buffer for text */
1179 char *name
; /* mailbox name to snarf from */
1180 unsigned long time
; /* last snarf time */
1181 long options
; /* snarf open options */
1183 struct { /* internal use only */
1184 struct { /* search temporaries */
1185 STRINGLIST
*string
; /* string(s) to search */
1186 long result
; /* search result */
1187 char *text
; /* cache of fetched text */
1189 STRING string
; /* stringstruct return hack */
1191 /* reserved for use by main program */
1192 void *sparep
; /* spare pointer */
1193 unsigned int spare
: 1; /* first spare bit */
1194 unsigned int spare2
: 1; /* second spare bit */
1195 unsigned int spare3
: 1; /* third spare bit */
1196 unsigned int spare4
: 1; /* fourth spare bit */
1197 unsigned int spare5
: 1; /* fifth spare bit */
1198 unsigned int spare6
: 1; /* sixth spare bit */
1199 unsigned int spare7
: 1; /* seventh spare bit */
1200 unsigned int spare8
: 1; /* eighth spare bit */
1203 /* Mail I/O stream handle */
1205 typedef struct mail_stream_handle
{
1206 MAILSTREAM
*stream
; /* pointer to mail stream */
1207 unsigned short sequence
; /* sequence of what we expect stream to be */
1211 /* Message overview */
1213 typedef struct mail_overview
{
1214 char *subject
; /* message subject string */
1215 ADDRESS
*from
; /* originator address list */
1216 char *date
; /* message composition date string */
1217 char *message_id
; /* message ID */
1218 char *references
; /* USENET references */
1219 struct { /* may be 0 or NUL if unknown/undefined */
1220 unsigned long octets
; /* message octets (probably LF-newline form) */
1221 unsigned long lines
; /* message lines */
1222 char *xref
; /* cross references */
1226 /* Network access I/O stream */
1229 /* Structure for network driver dispatch */
1231 #define NETDRIVER struct net_driver
1234 /* Network transport I/O stream */
1236 typedef struct net_stream
{
1237 void *stream
; /* driver's I/O stream */
1238 NETDRIVER
*dtb
; /* network driver */
1242 /* Network transport driver dispatch */
1245 void *(*open
) (char *host
,char *service
,unsigned long port
);
1246 void *(*aopen
) (NETMBX
*mb
,char *service
,char *usrbuf
);
1247 char *(*getline
) (void *stream
);
1248 long (*getbuffer
) (void *stream
,unsigned long size
,char *buffer
);
1249 long (*soutr
) (void *stream
,char *string
);
1250 long (*sout
) (void *stream
,char *string
,unsigned long size
);
1251 void (*close
) (void *stream
);
1252 char *(*host
) (void *stream
);
1253 char *(*remotehost
) (void *stream
);
1254 unsigned long (*port
) (void *stream
);
1255 char *(*localhost
) (void *stream
);
1259 /* Mailgets data identifier */
1261 typedef struct getsdata
{
1263 unsigned long msgno
;
1266 unsigned long first
;
1272 #define INIT_GETS(md,s,m,w,f,l) \
1273 md.stream = s, md.msgno = m, md.what = w, md.first = f, md.last = l, \
1274 md.stl = NIL, md.flags = NIL;
1276 /* Mail delivery I/O stream */
1278 typedef struct send_stream
{
1279 NETSTREAM
*netstream
; /* network I/O stream */
1280 char *host
; /* SMTP service host */
1281 char *reply
; /* last reply string */
1282 long replycode
; /* last reply code */
1283 unsigned int debug
: 1; /* stream debug flag */
1284 unsigned int sensitive
: 1; /* sensitive data in progress */
1285 unsigned int loser
: 1; /* server is a loser */
1286 unsigned int saslcancel
: 1; /* SASL cancelled by protocol */
1287 union { /* protocol specific */
1288 struct { /* SMTP specific */
1289 unsigned int ok
: 1; /* supports ESMTP */
1290 struct { /* service extensions */
1291 unsigned int send
: 1; /* supports SEND */
1292 unsigned int soml
: 1; /* supports SOML */
1293 unsigned int saml
: 1; /* supports SAML */
1294 unsigned int expn
: 1; /* supports EXPN */
1295 unsigned int help
: 1; /* supports HELP */
1296 unsigned int turn
: 1; /* supports TURN */
1297 unsigned int etrn
: 1; /* supports ETRN */
1298 unsigned int starttls
:1;/* supports STARTTLS */
1299 unsigned int relay
: 1; /* supports relaying */
1300 unsigned int pipe
: 1; /* supports pipelining */
1301 unsigned int ensc
: 1; /* supports enhanced status codes */
1302 unsigned int bmime
: 1; /* supports BINARYMIME */
1303 unsigned int chunk
: 1; /* supports CHUNKING */
1305 struct { /* 8-bit MIME transport */
1306 unsigned int ok
: 1; /* supports 8-bit MIME */
1307 unsigned int want
: 1; /* want 8-bit MIME */
1309 struct { /* delivery status notification */
1310 unsigned int ok
: 1; /* supports DSN */
1311 unsigned int want
: 1; /* want DSN */
1312 struct { /* notification options */
1313 /* notify on failure */
1314 unsigned int failure
: 1;
1315 /* notify on delay */
1316 unsigned int delay
: 1;
1317 /* notify on success */
1318 unsigned int success
: 1;
1320 unsigned int full
: 1; /* return full headers */
1321 char *envid
; /* envelope identifier as xtext */
1323 struct { /* size declaration */
1324 unsigned int ok
: 1; /* supports SIZE */
1325 unsigned long limit
; /* maximum size supported */
1327 struct { /* deliverby declaration */
1328 unsigned int ok
: 1; /* supports DELIVERBY */
1329 unsigned long minby
; /* minimum by-time */
1331 struct { /* authenticated turn */
1332 unsigned int ok
: 1; /* supports ATRN */
1333 char *domains
; /* domains */
1335 /* supported SASL authenticators */
1336 unsigned int auth
: MAXAUTHENTICATORS
;
1338 struct { /* NNTP specific */
1339 unsigned int post
: 1; /* supports POST */
1340 struct { /* NNTP extensions */
1341 unsigned int ok
: 1; /* supports extensions */
1342 /* supports LISTGROUP */
1343 unsigned int listgroup
: 1;
1344 unsigned int over
: 1; /* supports OVER */
1345 unsigned int hdr
: 1; /* supports HDR */
1346 unsigned int pat
: 1; /* supports PAT */
1347 /* supports STARTTLS */
1348 unsigned int starttls
: 1;
1349 /* server has MULTIDOMAIN */
1350 unsigned int multidomain
: 1;
1351 /* supports AUTHINFO USER */
1352 unsigned int authuser
: 1;
1353 /* supported authenticators */
1354 unsigned int sasl
: MAXAUTHENTICATORS
;
1360 /* Jacket into external interfaces */
1362 typedef long (*readfn_t
) (void *stream
,unsigned long size
,char *buffer
);
1363 typedef char *(*mailgets_t
) (readfn_t f
,void *stream
,unsigned long size
,
1365 typedef char *(*readprogress_t
) (GETS_DATA
*md
,unsigned long octets
);
1366 typedef void *(*mailcache_t
) (MAILSTREAM
*stream
,unsigned long msgno
,long op
);
1367 typedef long (*mailproxycopy_t
) (MAILSTREAM
*stream
,char *sequence
,
1368 char *mailbox
,long options
);
1369 typedef long (*tcptimeout_t
) (long overall
,long last
, char *host
);
1370 typedef long (*ucs4width_t
) (unsigned long c
);
1371 typedef void *(*authchallenge_t
) (void *stream
,unsigned long *len
);
1372 typedef long (*authrespond_t
) (void *stream
,char *s
,unsigned long size
);
1373 typedef long (*authcheck_t
) (void);
1374 typedef long (*authclient_t
) (authchallenge_t challenger
,
1375 authrespond_t responder
,char *service
,NETMBX
*mb
,
1376 void *s
,unsigned long *trial
,char *user
);
1377 typedef char *(*authresponse_t
) (void *challenge
,unsigned long clen
,
1378 unsigned long *rlen
);
1379 typedef char *(*authserver_t
) (authresponse_t responder
,int argc
,char *argv
[]);
1380 typedef void (*smtpverbose_t
) (char *buffer
);
1381 typedef void (*imapenvelope_t
) (MAILSTREAM
*stream
,unsigned long msgno
,
1383 typedef char *(*imapreferral_t
) (MAILSTREAM
*stream
,char *url
,long code
);
1384 typedef void (*overview_t
) (MAILSTREAM
*stream
,unsigned long uid
,OVERVIEW
*ov
,
1385 unsigned long msgno
);
1386 typedef unsigned long *(*sorter_t
) (MAILSTREAM
*stream
,char *charset
,
1387 SEARCHPGM
*spg
,SORTPGM
*pgm
,long flags
);
1388 typedef void (*parseline_t
) (ENVELOPE
*env
,char *hdr
,char *data
,char *host
);
1389 typedef ADDRESS
*(*parsephrase_t
) (char *phrase
,char *end
,char *host
);
1390 typedef void *(*blocknotify_t
) (int reason
,void *data
);
1391 typedef long (*kinit_t
) (char *host
,char *reason
);
1392 typedef void (*sendcommand_t
) (MAILSTREAM
*stream
,char *cmd
,long flags
);
1393 typedef char *(*newsrcquery_t
) (MAILSTREAM
*stream
,char *mulname
,char *name
);
1394 typedef void (*getacl_t
) (MAILSTREAM
*stream
,char *mailbox
,ACLLIST
*acl
);
1395 typedef void (*listrights_t
) (MAILSTREAM
*stream
,char *mailbox
,char *id
,
1396 char *alwaysrights
,STRINGLIST
*possiblerights
);
1397 typedef void (*myrights_t
) (MAILSTREAM
*stream
,char *mailbox
,char *rights
);
1398 typedef void (*quota_t
) (MAILSTREAM
*stream
,char *qroot
,QUOTALIST
*qlist
);
1399 typedef void (*quotaroot_t
) (MAILSTREAM
*stream
,char *mbx
,STRINGLIST
*qroot
);
1400 typedef void (*sortresults_t
) (MAILSTREAM
*stream
,unsigned long *list
,
1401 unsigned long size
);
1402 typedef char *(*userprompt_t
) (void);
1403 typedef long (*append_t
) (MAILSTREAM
*stream
,void *data
,char **flags
,
1404 char **date
,STRING
**message
);
1405 typedef void (*copyuid_t
) (MAILSTREAM
*stream
,char *mailbox
,
1406 unsigned long uidvalidity
,SEARCHSET
*sourceset
,
1407 SEARCHSET
*destset
);
1408 typedef void (*appenduid_t
) (char *mailbox
,unsigned long uidvalidity
,
1410 typedef long (*dirfmttest_t
) (char *name
);
1411 typedef long (*scancontents_t
) (char *name
,char *contents
,unsigned long csiz
,
1412 unsigned long fsiz
);
1414 typedef void (*freeeltsparep_t
) (void **sparep
);
1415 typedef void (*freeenvelopesparep_t
) (void **sparep
);
1416 typedef void (*freebodysparep_t
) (void **sparep
);
1417 typedef void (*freestreamsparep_t
) (void **sparep
);
1418 typedef void *(*sslstart_t
) (void *stream
,char *host
,unsigned long flags
);
1419 typedef long (*sslcertificatequery_t
) (char *reason
,char *host
,char *cert
);
1420 typedef void (*sslfailure_t
) (char *host
,char *reason
,unsigned long flags
);
1421 typedef void (*logouthook_t
) (void *data
);
1422 typedef char *(*sslclientcert_t
) (void);
1423 typedef char *(*sslclientkey_t
) (void);
1427 extern char *body_types
[]; /* defined body type strings */
1428 extern char *body_encodings
[]; /* defined body encoding strings */
1429 extern const char *days
[]; /* day name strings */
1430 extern const char *months
[]; /* month name strings */
1436 #define THREADNODE struct thread_node
1439 unsigned long num
; /* message number */
1440 SORTCACHE
*sc
; /* (internal use) sortcache entry */
1441 THREADNODE
*branch
; /* branch at this point in tree */
1442 THREADNODE
*next
; /* next node */
1445 typedef void (*threadresults_t
) (MAILSTREAM
*stream
,THREADNODE
*tree
);
1448 /* Thread dispatch */
1450 #define THREADER struct threader_list
1453 char *name
; /* name of threader */
1454 THREADNODE
*(*dispatch
) (MAILSTREAM
*stream
,char *charset
,SEARCHPGM
*spg
,
1455 long flags
,sorter_t sorter
);
1460 /* Container for references threading */
1462 typedef void ** container_t
;
1466 #define NAMESPACE struct mail_namespace
1469 char *name
; /* name of this namespace */
1470 int delimiter
; /* hierarchy delimiter */
1471 PARAMETER
*param
; /* namespace parameters */
1472 NAMESPACE
*next
; /* next namespace */
1476 /* Authentication */
1478 #define AUTHENTICATOR struct mail_authenticator
1481 long flags
; /* authenticator flags */
1482 char *name
; /* name of this authenticator */
1483 authcheck_t valid
; /* authenticator valid on this system */
1484 authclient_t client
; /* client function that supports it */
1485 authserver_t server
; /* server function that supports it */
1486 AUTHENTICATOR
*next
; /* next authenticator */
1489 /* Mail driver dispatch */
1492 char *name
; /* driver name */
1493 unsigned long flags
; /* driver flags */
1494 DRIVER
*next
; /* next driver */
1495 /* mailbox is valid for us */
1496 DRIVER
*(*valid
) (char *mailbox
);
1497 /* manipulate driver parameters */
1498 void *(*parameters
) (long function
,void *value
);
1499 /* scan mailboxes */
1500 void (*scan
) (MAILSTREAM
*stream
,char *ref
,char *pat
,char *contents
);
1501 /* list mailboxes */
1502 void (*list
) (MAILSTREAM
*stream
,char *ref
,char *pat
);
1503 /* list subscribed mailboxes */
1504 void (*lsub
) (MAILSTREAM
*stream
,char *ref
,char *pat
);
1505 /* subscribe to mailbox */
1506 long (*subscribe
) (MAILSTREAM
*stream
,char *mailbox
);
1507 /* unsubscribe from mailbox */
1508 long (*unsubscribe
) (MAILSTREAM
*stream
,char *mailbox
);
1509 /* create mailbox */
1510 long (*create
) (MAILSTREAM
*stream
,char *mailbox
);
1511 /* delete mailbox */
1512 long (*mbxdel
) (MAILSTREAM
*stream
,char *mailbox
);
1513 /* rename mailbox */
1514 long (*mbxren
) (MAILSTREAM
*stream
,char *old
,char *newname
);
1515 /* status of mailbox */
1516 long (*status
) (MAILSTREAM
*stream
,char *mbx
,long flags
);
1519 MAILSTREAM
*(*open
) (MAILSTREAM
*stream
);
1521 void (*close
) (MAILSTREAM
*stream
,long options
);
1522 /* fetch message "fast" attributes */
1523 void (*fast
) (MAILSTREAM
*stream
,char *sequence
,long flags
);
1524 /* fetch message flags */
1525 void (*msgflags
) (MAILSTREAM
*stream
,char *sequence
,long flags
);
1526 /* fetch message overview */
1527 long (*overview
) (MAILSTREAM
*stream
,overview_t ofn
);
1528 /* fetch message envelopes */
1529 ENVELOPE
*(*structure
) (MAILSTREAM
*stream
,unsigned long msgno
,BODY
**body
,
1531 /* return RFC-822 header */
1532 char *(*header
) (MAILSTREAM
*stream
,unsigned long msgno
,
1533 unsigned long *length
,long flags
);
1534 /* return RFC-822 text */
1535 long (*text
) (MAILSTREAM
*stream
,unsigned long msgno
,STRING
*bs
,long flags
);
1537 long (*msgdata
) (MAILSTREAM
*stream
,unsigned long msgno
,char *section
,
1538 unsigned long first
,unsigned long last
,STRINGLIST
*lines
,
1540 /* return UID for message */
1541 unsigned long (*uid
) (MAILSTREAM
*stream
,unsigned long msgno
);
1542 /* return message number from UID */
1543 unsigned long (*msgno
) (MAILSTREAM
*stream
,unsigned long uid
);
1545 void (*flag
) (MAILSTREAM
*stream
,char *sequence
,char *flag
,long flags
);
1546 /* per-message modify flags */
1547 void (*flagmsg
) (MAILSTREAM
*stream
,MESSAGECACHE
*elt
);
1548 /* search for message based on criteria */
1549 long (*search
) (MAILSTREAM
*stream
,char *charset
,SEARCHPGM
*pgm
,long flags
);
1551 unsigned long *(*sort
) (MAILSTREAM
*stream
,char *charset
,SEARCHPGM
*spg
,
1552 SORTPGM
*pgm
,long flags
);
1553 /* thread messages */
1554 THREADNODE
*(*thread
) (MAILSTREAM
*stream
,char *type
,char *charset
,
1555 SEARCHPGM
*spg
,long flag
);
1556 /* ping mailbox to see if still alive */
1557 long (*ping
) (MAILSTREAM
*stream
);
1558 /* check for new messages */
1559 void (*check
) (MAILSTREAM
*stream
);
1560 /* expunge deleted messages */
1561 long (*expunge
) (MAILSTREAM
*stream
,char *sequence
,long options
);
1562 /* copy messages to another mailbox */
1563 long (*copy
) (MAILSTREAM
*stream
,char *sequence
,char *mailbox
,long options
);
1564 /* append string message to mailbox */
1565 long (*append
) (MAILSTREAM
*stream
,char *mailbox
,append_t af
,void *data
);
1566 /* garbage collect stream */
1567 void (*gc
) (MAILSTREAM
*stream
,long gcflags
);
1571 #include "linkage.h"
1573 /* Compatibility support names for old interfaces */
1575 #define GET_TRYALTFIRST GET_TRYSSLFIRST
1576 #define SET_TRYALTFIRST SET_TRYSSLFIRST
1577 #define GET_IMAPTRYALT GET_IMAPTRYSSL
1578 #define SET_IMAPTRYALT SET_IMAPTRYSSL
1579 #define OP_TRYALT OP_TRYSSL
1580 #define altflag sslflag
1582 #define mail_close(stream) \
1583 mail_close_full (stream,NIL)
1584 #define mail_fetchfast(stream,sequence) \
1585 mail_fetch_fast (stream,sequence,NIL)
1586 #define mail_fetchfast_full mail_fetch_fast
1587 #define mail_fetchflags(stream,sequence) \
1588 mail_fetch_flags (stream,sequence,NIL)
1589 #define mail_fetchflags_full mail_fetch_flags
1590 #define mail_fetchenvelope(stream,msgno) \
1591 mail_fetch_structure (stream,msgno,NIL,NIL)
1592 #define mail_fetchstructure(stream,msgno,body) \
1593 mail_fetch_structure (stream,msgno,body,NIL)
1594 #define mail_fetchstructure_full mail_fetch_structure
1595 #define mail_fetchheader(stream,msgno) \
1596 mail_fetch_header (stream,msgno,NIL,NIL,NIL,FT_PEEK)
1597 #define mail_fetchheader_full(stream,msgno,lines,len,flags) \
1598 mail_fetch_header (stream,msgno,NIL,lines,len,FT_PEEK | (flags))
1599 #define mail_fetchtext(stream,msgno) \
1600 mail_fetch_text (stream,msgno,NIL,NIL,NIL)
1601 #define mail_fetchtext_full(stream,msgno,length,flags) \
1602 mail_fetch_text (stream,msgno,NIL,length,flags)
1603 #define mail_fetchbody(stream,msgno,section,length) \
1604 mail_fetch_body (stream,msgno,section,length,NIL)
1605 #define mail_fetchbody_full mail_fetch_body
1606 #define mail_setflag(stream,sequence,flag) \
1607 mail_flag (stream,sequence,flag,ST_SET)
1608 #define mail_setflag_full(stream,sequence,flag,flags) \
1609 mail_flag (stream,sequence,flag,ST_SET | (flags))
1610 #define mail_clearflag(stream,sequence,flag) \
1611 mail_flag (stream,sequence,flag,NIL)
1612 #define mail_clearflag_full mail_flag
1613 #define mail_search(stream,criteria) \
1614 mail_search_full (stream,NIL,mail_criteria (criteria),SE_FREE);
1615 #define mail_expunge(stream) \
1616 mail_expunge_full (stream,NIL,NIL)
1617 #define mail_copy(stream,sequence,mailbox) \
1618 mail_copy_full (stream,sequence,mailbox,NIL)
1619 #define mail_move(stream,sequence,mailbox) \
1620 mail_copy_full (stream,sequence,mailbox,CP_MOVE)
1621 #define mail_append(stream,mailbox,message) \
1622 mail_append_full (stream,mailbox,NIL,NIL,message)
1624 /* Interfaces for SVR4 locking brain-damage workaround */
1626 /* Driver dispatching */
1628 #define SAFE_DELETE(dtb,stream,mailbox) (*dtb->mbxdel) (stream,mailbox)
1629 #define SAFE_RENAME(dtb,stream,old,newname) (*dtb->mbxren) (stream,old,newname)
1630 #define SAFE_STATUS(dtb,stream,mbx,flags) (*dtb->status) (stream,mbx,flags)
1631 #define SAFE_COPY(dtb,stream,sequence,mailbox,options) \
1632 (*dtb->copy) (stream,sequence,mailbox,options)
1633 #define SAFE_APPEND(dtb,stream,mailbox,af,data) \
1634 (*dtb->append) (stream,mailbox,af,data)
1635 #define SAFE_SCAN_CONTENTS(dtb,name,contents,csiz,fsiz) \
1636 scan_contents (dtb,name,contents,csiz,fsiz)
1639 /* Driver callbacks */
1641 #define MM_EXISTS mm_exists
1642 #define MM_EXPUNGED mm_expunged
1643 #define MM_FLAGS mm_flags
1644 #define MM_NOTIFY mm_notify
1645 #define MM_STATUS mm_status
1646 #define MM_LOG mm_log
1647 #define MM_CRITICAL mm_critical
1648 #define MM_NOCRITICAL mm_nocritical
1649 #define MM_DISKERROR mm_diskerror
1650 #define MM_FATAL mm_fatal
1651 #define MM_APPEND(af) (*af)
1653 /* Function prototypes */
1655 void mm_searched (MAILSTREAM
*stream
,unsigned long number
);
1656 void mm_exists (MAILSTREAM
*stream
,unsigned long number
);
1657 void mm_expunged (MAILSTREAM
*stream
,unsigned long number
);
1658 void mm_flags (MAILSTREAM
*stream
,unsigned long number
);
1659 void mm_notify (MAILSTREAM
*stream
,char *string
,long errflg
);
1660 void mm_list (MAILSTREAM
*stream
,int delimiter
,char *name
,long attributes
);
1661 void mm_lsub (MAILSTREAM
*stream
,int delimiter
,char *name
,long attributes
);
1662 void mm_status (MAILSTREAM
*stream
,char *mailbox
,MAILSTATUS
*status
);
1663 void mm_log (char *string
,long errflg
);
1664 void mm_dlog (char *string
);
1665 void mm_login (NETMBX
*mb
,char *user
,char *pwd
,long trial
);
1666 void mm_critical (MAILSTREAM
*stream
);
1667 void mm_nocritical (MAILSTREAM
*stream
);
1668 long mm_diskerror (MAILSTREAM
*stream
,long errcode
,long serious
);
1669 void mm_fatal (char *string
);
1670 void *mm_cache (MAILSTREAM
*stream
,unsigned long msgno
,long op
);
1672 extern STRINGDRIVER mail_string
;
1673 void mail_versioncheck (char *version
);
1674 void mail_link (DRIVER
*driver
);
1675 void *mail_parameters (MAILSTREAM
*stream
,long function
,void *value
);
1676 DRIVER
*mail_valid (MAILSTREAM
*stream
,char *mailbox
,char *purpose
);
1677 DRIVER
*mail_valid_net (char *name
,DRIVER
*drv
,char *host
,char *mailbox
);
1678 long mail_valid_net_parse (char *name
,NETMBX
*mb
);
1679 long mail_valid_net_parse_work (char *name
,NETMBX
*mb
,char *service
);
1680 void mail_scan (MAILSTREAM
*stream
,char *ref
,char *pat
,char *contents
);
1681 void mail_list (MAILSTREAM
*stream
,char *ref
,char *pat
);
1682 void mail_lsub (MAILSTREAM
*stream
,char *ref
,char *pat
);
1683 long mail_subscribe (MAILSTREAM
*stream
,char *mailbox
);
1684 long mail_unsubscribe (MAILSTREAM
*stream
,char *mailbox
);
1685 long mail_create (MAILSTREAM
*stream
,char *mailbox
);
1686 long mail_delete (MAILSTREAM
*stream
,char *mailbox
);
1687 long mail_rename (MAILSTREAM
*stream
,char *old
,char *newname
);
1688 char *mail_utf7_valid (char *mailbox
);
1689 long mail_status (MAILSTREAM
*stream
,char *mbx
,long flags
);
1690 long mail_status_default (MAILSTREAM
*stream
,char *mbx
,long flags
);
1691 MAILSTREAM
*mail_open (MAILSTREAM
*stream
,char *name
,long options
);
1692 MAILSTREAM
*mail_open_work (DRIVER
*d
,MAILSTREAM
*stream
,char *name
,
1694 MAILSTREAM
*mail_close_full (MAILSTREAM
*stream
,long options
);
1695 MAILHANDLE
*mail_makehandle (MAILSTREAM
*stream
);
1696 void mail_free_handle (MAILHANDLE
**handle
);
1697 MAILSTREAM
*mail_stream (MAILHANDLE
*handle
);
1699 void mail_fetch_fast (MAILSTREAM
*stream
,char *sequence
,long flags
);
1700 void mail_fetch_flags (MAILSTREAM
*stream
,char *sequence
,long flags
);
1701 void mail_fetch_overview (MAILSTREAM
*stream
,char *sequence
,overview_t ofn
);
1702 void mail_fetch_overview_sequence (MAILSTREAM
*stream
,char *sequence
,
1704 void mail_fetch_overview_default (MAILSTREAM
*stream
,overview_t ofn
);
1705 ENVELOPE
*mail_fetch_structure (MAILSTREAM
*stream
,unsigned long msgno
,
1706 BODY
**body
,long flags
);
1707 char *mail_fetch_message (MAILSTREAM
*stream
,unsigned long msgno
,
1708 unsigned long *len
,long flags
);
1709 char *mail_fetch_header (MAILSTREAM
*stream
,unsigned long msgno
,char *section
,
1710 STRINGLIST
*lines
,unsigned long *len
,long flags
);
1711 char *mail_fetch_text (MAILSTREAM
*stream
,unsigned long msgno
,char *section
,
1712 unsigned long *len
,long flags
);
1713 char *mail_fetch_mime (MAILSTREAM
*stream
,unsigned long msgno
,char *section
,
1714 unsigned long *len
,long flags
);
1715 char *mail_fetch_body (MAILSTREAM
*stream
,unsigned long msgno
,char *section
,
1716 unsigned long *len
,long flags
);
1717 long mail_partial_text (MAILSTREAM
*stream
,unsigned long msgno
,char *section
,
1718 unsigned long first
,unsigned long last
,long flags
);
1719 long mail_partial_body (MAILSTREAM
*stream
,unsigned long msgno
,char *section
,
1720 unsigned long first
,unsigned long last
,long flags
);
1721 char *mail_fetch_text_return (GETS_DATA
*md
,SIZEDTEXT
*t
,unsigned long *len
);
1722 char *mail_fetch_string_return (GETS_DATA
*md
,STRING
*bs
,unsigned long i
,
1723 unsigned long *len
,long flags
);
1724 long mail_read (void *stream
,unsigned long size
,char *buffer
);
1725 unsigned long mail_uid (MAILSTREAM
*stream
,unsigned long msgno
);
1726 unsigned long mail_msgno (MAILSTREAM
*stream
,unsigned long uid
);
1727 void mail_fetchfrom (char *s
,MAILSTREAM
*stream
,unsigned long msgno
,
1729 void mail_fetchsubject (char *s
,MAILSTREAM
*stream
,unsigned long msgno
,
1731 MESSAGECACHE
*mail_elt (MAILSTREAM
*stream
,unsigned long msgno
);
1732 void mail_flag (MAILSTREAM
*stream
,char *sequence
,char *flag
,long flags
);
1733 long mail_search_full (MAILSTREAM
*stream
,char *charset
,SEARCHPGM
*pgm
,
1735 long mail_search_default (MAILSTREAM
*stream
,char *charset
,SEARCHPGM
*pgm
,
1737 long mail_ping (MAILSTREAM
*stream
);
1738 void mail_check (MAILSTREAM
*stream
);
1739 long mail_expunge_full (MAILSTREAM
*stream
,char *sequence
,long options
);
1740 long mail_copy_full (MAILSTREAM
*stream
,char *sequence
,char *mailbox
,
1742 long mail_append_full (MAILSTREAM
*stream
,char *mailbox
,char *flags
,char *date
,
1744 long mail_append_multiple (MAILSTREAM
*stream
,char *mailbox
,append_t af
,
1746 void mail_gc (MAILSTREAM
*stream
,long gcflags
);
1747 void mail_gc_msg (MESSAGE
*msg
,long gcflags
);
1748 void mail_gc_body (BODY
*body
);
1750 BODY
*mail_body_section (BODY
*b
, unsigned char *section
);
1751 BODY
*mail_body (MAILSTREAM
*stream
,unsigned long msgno
,
1752 unsigned char *section
);
1753 char *mail_date (char *string
,MESSAGECACHE
*elt
);
1754 char *mail_cdate (char *string
,MESSAGECACHE
*elt
);
1755 long mail_parse_date (MESSAGECACHE
*elt
,unsigned char *string
);
1756 void mail_exists (MAILSTREAM
*stream
,unsigned long nmsgs
);
1757 void mail_recent (MAILSTREAM
*stream
,unsigned long recent
);
1758 void mail_expunged (MAILSTREAM
*stream
,unsigned long msgno
);
1759 void mail_lock (MAILSTREAM
*stream
);
1760 void mail_unlock (MAILSTREAM
*stream
);
1761 void mail_debug (MAILSTREAM
*stream
);
1762 void mail_nodebug (MAILSTREAM
*stream
);
1763 void mail_dlog (char *string
,long flag
);
1764 long mail_match_lines (STRINGLIST
*lines
,STRINGLIST
*msglines
,long flags
);
1765 unsigned long mail_filter (char *text
,unsigned long len
,STRINGLIST
*lines
,
1767 long mail_search_msg (MAILSTREAM
*stream
,unsigned long msgno
,char *section
,
1769 long mail_search_header_text (char *s
,STRINGLIST
*st
);
1770 long mail_search_header (SIZEDTEXT
*hdr
,STRINGLIST
*st
);
1771 long mail_search_text (MAILSTREAM
*stream
,unsigned long msgno
,char *section
,
1772 STRINGLIST
*st
,long flags
);
1773 long mail_search_body (MAILSTREAM
*stream
,unsigned long msgno
,BODY
*body
,
1774 char *prefix
,unsigned long section
,long flags
);
1775 long mail_search_string (SIZEDTEXT
*s
,char *charset
,STRINGLIST
**st
);
1776 long mail_search_string_work (SIZEDTEXT
*s
,STRINGLIST
**st
);
1777 long mail_search_keyword (MAILSTREAM
*stream
,MESSAGECACHE
*elt
,STRINGLIST
*st
,
1779 long mail_search_addr (ADDRESS
*adr
,STRINGLIST
*st
);
1780 char *mail_search_gets (readfn_t f
,void *stream
,unsigned long size
,
1782 SEARCHPGM
*mail_criteria (char *criteria
);
1783 int mail_criteria_date (unsigned short *date
,char **r
);
1784 int mail_criteria_string (STRINGLIST
**s
,char **r
);
1785 unsigned short mail_shortdate (unsigned int year
,unsigned int month
,
1787 SEARCHSET
*mail_parse_set (char *s
,char **ret
);
1788 SEARCHSET
*mail_append_set (SEARCHSET
*set
,unsigned long msgno
);
1789 unsigned long *mail_sort (MAILSTREAM
*stream
,char *charset
,SEARCHPGM
*spg
,
1790 SORTPGM
*pgm
,long flags
);
1791 unsigned long *mail_sort_cache (MAILSTREAM
*stream
,SORTPGM
*pgm
,SORTCACHE
**sc
,
1793 unsigned long *mail_sort_msgs (MAILSTREAM
*stream
,char *charset
,SEARCHPGM
*spg
,
1794 SORTPGM
*pgm
,long flags
);
1795 SORTCACHE
**mail_sort_loadcache (MAILSTREAM
*stream
,SORTPGM
*pgm
);
1796 unsigned int mail_strip_subject (char *t
,char **ret
);
1797 char *mail_strip_subject_wsp (char *s
);
1798 char *mail_strip_subject_blob (char *s
);
1799 int mail_sort_compare (const void *a1
,const void *a2
);
1800 unsigned long mail_longdate (MESSAGECACHE
*elt
);
1801 THREADNODE
*mail_thread (MAILSTREAM
*stream
,char *type
,char *charset
,
1802 SEARCHPGM
*spg
,long flags
);
1803 THREADNODE
*mail_thread_msgs (MAILSTREAM
*stream
,char *type
,char *charset
,
1804 SEARCHPGM
*spg
,long flags
,sorter_t sorter
);
1805 THREADNODE
*mail_thread_orderedsubject (MAILSTREAM
*stream
,char *charset
,
1806 SEARCHPGM
*spg
,long flags
,
1808 THREADNODE
*mail_thread_references (MAILSTREAM
*stream
,char *charset
,
1809 SEARCHPGM
*spg
,long flags
,
1811 void mail_thread_loadcache (MAILSTREAM
*stream
,unsigned long uid
,OVERVIEW
*ov
,
1812 unsigned long msgno
);
1813 char *mail_thread_parse_msgid (char *s
,char **ss
);
1814 STRINGLIST
*mail_thread_parse_references (char *s
,long flag
);
1815 long mail_thread_check_child (container_t mother
,container_t daughter
);
1816 container_t
mail_thread_prune_dummy (container_t msg
,container_t ane
);
1817 container_t
mail_thread_prune_dummy_work (container_t msg
,container_t ane
);
1818 THREADNODE
*mail_thread_c2node (MAILSTREAM
*stream
,container_t con
,long flags
);
1819 THREADNODE
*mail_thread_sort (THREADNODE
*thr
,THREADNODE
**tc
);
1820 int mail_thread_compare_date (const void *a1
,const void *a2
);
1821 long mail_sequence (MAILSTREAM
*stream
,unsigned char *sequence
);
1822 long mail_uid_sequence (MAILSTREAM
*stream
,unsigned char *sequence
);
1823 long mail_parse_flags (MAILSTREAM
*stream
,char *flag
,unsigned long *uf
);
1824 long mail_usable_network_stream (MAILSTREAM
*stream
,char *name
);
1826 MESSAGECACHE
*mail_new_cache_elt (unsigned long msgno
);
1827 ENVELOPE
*mail_newenvelope (void);
1828 ADDRESS
*mail_newaddr (void);
1829 BODY
*mail_newbody (void);
1830 BODY
*mail_initbody (BODY
*body
);
1831 PARAMETER
*mail_newbody_parameter (void);
1832 PART
*mail_newbody_part (void);
1833 MESSAGE
*mail_newmsg (void);
1834 STRINGLIST
*mail_newstringlist (void);
1835 SEARCHPGM
*mail_newsearchpgm (void);
1836 SEARCHHEADER
*mail_newsearchheader (char *line
,char *text
);
1837 SEARCHSET
*mail_newsearchset (void);
1838 SEARCHOR
*mail_newsearchor (void);
1839 SEARCHPGMLIST
*mail_newsearchpgmlist (void);
1840 SORTPGM
*mail_newsortpgm (void);
1841 THREADNODE
*mail_newthreadnode (SORTCACHE
*sc
);
1842 ACLLIST
*mail_newacllist (void);
1843 QUOTALIST
*mail_newquotalist (void);
1844 void mail_free_idlist (IDLIST
**idlist
);
1845 void mail_free_body (BODY
**body
);
1846 void mail_free_body_data (BODY
*body
);
1847 void mail_free_body_parameter (PARAMETER
**parameter
);
1848 void mail_free_body_part (PART
**part
);
1849 void mail_free_cache (MAILSTREAM
*stream
);
1850 void mail_free_elt (MESSAGECACHE
**elt
);
1851 void mail_free_envelope (ENVELOPE
**env
);
1852 void mail_free_address (ADDRESS
**address
);
1853 void mail_free_stringlist (STRINGLIST
**string
);
1854 void mail_free_searchpgm (SEARCHPGM
**pgm
);
1855 void mail_free_searchheader (SEARCHHEADER
**hdr
);
1856 void mail_free_searchset (SEARCHSET
**set
);
1857 void mail_free_searchor (SEARCHOR
**orl
);
1858 void mail_free_searchpgmlist (SEARCHPGMLIST
**pgl
);
1859 void mail_free_namespace (NAMESPACE
**n
);
1860 void mail_free_sortpgm (SORTPGM
**pgm
);
1861 void mail_free_threadnode (THREADNODE
**thr
);
1862 void mail_free_acllist (ACLLIST
**al
);
1863 void mail_free_quotalist (QUOTALIST
**ql
);
1864 void auth_link (AUTHENTICATOR
*auth
);
1865 char *mail_auth (char *mechanism
,authresponse_t resp
,int argc
,char *argv
[]);
1866 AUTHENTICATOR
*mail_lookup_auth (unsigned long i
);
1867 unsigned int mail_lookup_auth_name (char *mechanism
,long flags
);
1869 NETSTREAM
*net_open (NETMBX
*mb
,NETDRIVER
*dv
,unsigned long port
,
1870 NETDRIVER
*ssld
,char *ssls
,unsigned long sslp
);
1871 NETSTREAM
*net_open_work (NETDRIVER
*dv
,char *host
,char *service
,
1872 unsigned long port
,unsigned long portoverride
,
1873 unsigned long flags
);
1874 NETSTREAM
*net_aopen (NETDRIVER
*dv
,NETMBX
*mb
,char *service
,char *usrbuf
);
1875 char *net_getline (NETSTREAM
*stream
);
1876 /* stream must be void* for use as readfn_t */
1877 long net_getbuffer (void *stream
,unsigned long size
,char *buffer
);
1878 long net_soutr (NETSTREAM
*stream
,char *string
);
1879 long net_sout (NETSTREAM
*stream
,char *string
,unsigned long size
);
1880 void net_close (NETSTREAM
*stream
);
1881 char *net_host (NETSTREAM
*stream
);
1882 char *net_remotehost (NETSTREAM
*stream
);
1883 unsigned long net_port (NETSTREAM
*stream
);
1884 char *net_localhost (NETSTREAM
*stream
);
1886 long sm_subscribe (char *mailbox
);
1887 long sm_unsubscribe (char *mailbox
);
1888 char *sm_read (char *sbname
,void **sdb
);
1890 void ssl_onceonlyinit (void);
1891 char *ssl_start_tls (char *s
);
1892 void ssl_server_init (char *server
);
1893 void free_c_client_module_globals(void);
1895 /* Server I/O functions */
1898 char *PSIN (char *s
,int n
);
1899 long PSINR (char *s
,unsigned long n
);
1901 long INWAIT (long seconds
);
1902 int PSOUT (char *s
);
1903 int PSOUTR (SIZEDTEXT
*s
);