imapext-2007

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

imap-2007e
author yuuji@gentei.org
date Mon, 14 Sep 2009 15:17:45 +0900
parents
children 28a55bc1110c 5cecc027b845
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/c-client/mail.h	Mon Sep 14 15:17:45 2009 +0900
     1.3 @@ -0,0 +1,1837 @@
     1.4 +/* ========================================================================
     1.5 + * Copyright 1988-2008 University of Washington
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *     http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * 
    1.14 + * ========================================================================
    1.15 + */
    1.16 +
    1.17 +/*
    1.18 + * Program:	Mailbox Access routines
    1.19 + *
    1.20 + * Author:	Mark Crispin
    1.21 + *		UW Technology
    1.22 + *		University of Washington
    1.23 + *		Seattle, WA  98195
    1.24 + *		Internet: MRC@Washington.EDU
    1.25 + *
    1.26 + * Date:	22 November 1989
    1.27 + * Last Edited:	16 December 2008
    1.28 + */
    1.29 +
    1.30 +/* The Version */
    1.31 +
    1.32 +#define CCLIENTVERSION "2007e"
    1.33 +
    1.34 +/* Build parameters */
    1.35 +
    1.36 +#define CACHEINCREMENT 250	/* cache growth increments */
    1.37 +#define MAILTMPLEN 1024		/* size of a temporary buffer */
    1.38 +#define SENDBUFLEN 16385	/* size of temporary sending buffer, also
    1.39 +				 * used for SMTP commands and NETMBX generation
    1.40 +				 * buffer so shouldn't be made smaller than
    1.41 +				 * MAILTMPLEN.  Note that there's a guard byte,
    1.42 +				 * so this is actually len+1. */
    1.43 +#define MAXAUTHENTICATORS 8	/* maximum number of SASL authenticators */
    1.44 +				/* maximum number of messages */
    1.45 +#define MAXMESSAGES (unsigned long) 1000000
    1.46 +#define MAXLOGINTRIALS 3	/* maximum number of client login attempts */
    1.47 +#define MAXWILDCARDS 10		/* maximum wildcards allowed in LIST/LSUB */
    1.48 +
    1.49 +
    1.50 +/* These can't be changed without changing code */
    1.51 +
    1.52 +#define NUSERFLAGS 30		/* maximum number of user flags */
    1.53 +#define MAXUSERFLAG 50		/* maximum length of a user flag */
    1.54 +#define BASEYEAR 1970		/* the year time began on Unix DON'T CHANGE */
    1.55 +				/* default for unqualified addresses */
    1.56 +#define BADHOST ".MISSING-HOST-NAME."
    1.57 +				/* default for syntax errors in addresses */
    1.58 +#define ERRHOST ".SYNTAX-ERROR."
    1.59 +
    1.60 +
    1.61 +/* Coddle certain compilers' 6-character symbol limitation */
    1.62 +
    1.63 +#ifdef __COMPILER_KCC__
    1.64 +#include "shortsym.h"
    1.65 +#endif
    1.66 +
    1.67 +
    1.68 +/* Function status code */
    1.69 +
    1.70 +#define NIL 0			/* convenient name */
    1.71 +#define T 1			/* opposite of NIL */
    1.72 +#define LONGT (long) 1		/* long T to pacify some compilers */
    1.73 +#define VOIDT (void *) ""	/* void T ditto */
    1.74 +
    1.75 +/* Global and Driver Parameters */
    1.76 +
    1.77 +	/* 0xx: driver and authenticator flags */
    1.78 +#define ENABLE_DRIVER (long) 1
    1.79 +#define DISABLE_DRIVER (long) 2
    1.80 +#define ENABLE_AUTHENTICATOR (long) 3
    1.81 +#define DISABLE_AUTHENTICATOR (long) 4
    1.82 +#define ENABLE_DEBUG (long) 5
    1.83 +#define DISABLE_DEBUG (long) 6
    1.84 +#define HIDE_AUTHENTICATOR (long) 7
    1.85 +#define UNHIDE_AUTHENTICATOR (long) 8
    1.86 +	/* 1xx: c-client globals */
    1.87 +#define GET_DRIVERS (long) 101
    1.88 +#define SET_DRIVERS (long) 102
    1.89 +#define GET_GETS (long) 103
    1.90 +#define SET_GETS (long) 104
    1.91 +#define GET_CACHE (long) 105
    1.92 +#define SET_CACHE (long) 106
    1.93 +#define GET_SMTPVERBOSE (long) 107
    1.94 +#define SET_SMTPVERBOSE (long) 108
    1.95 +#define GET_RFC822OUTPUT (long) 109
    1.96 +#define SET_RFC822OUTPUT (long) 110
    1.97 +#define GET_READPROGRESS (long) 111
    1.98 +#define SET_READPROGRESS (long) 112
    1.99 +#define GET_THREADERS (long) 113
   1.100 +#define SET_THREADERS (long) 114
   1.101 +#define GET_NAMESPACE (long) 115
   1.102 +#define SET_NAMESPACE (long) 116
   1.103 +#define GET_MAILPROXYCOPY (long) 117
   1.104 +#define SET_MAILPROXYCOPY (long) 118
   1.105 +#define GET_SERVICENAME (long) 119
   1.106 +#define SET_SERVICENAME (long) 120
   1.107 +#define GET_DRIVER (long) 121
   1.108 +#define SET_DRIVER (long) 122
   1.109 +#define GET_EXPUNGEATPING (long) 123
   1.110 +#define SET_EXPUNGEATPING (long) 124
   1.111 +#define GET_PARSEPHRASE (long) 125
   1.112 +#define SET_PARSEPHRASE (long) 126
   1.113 +#define GET_SSLDRIVER (long) 127
   1.114 +#define SET_SSLDRIVER (long) 128
   1.115 +#define GET_TRYSSLFIRST (long) 129
   1.116 +#define SET_TRYSSLFIRST (long) 130
   1.117 +#define GET_BLOCKNOTIFY (long) 131
   1.118 +#define SET_BLOCKNOTIFY (long) 132
   1.119 +#define GET_SORTRESULTS (long) 133
   1.120 +#define SET_SORTRESULTS (long) 134
   1.121 +#define GET_THREADRESULTS (long) 135
   1.122 +#define SET_THREADRESULTS (long) 136
   1.123 +#define GET_PARSELINE (long) 137
   1.124 +#define SET_PARSELINE (long) 138
   1.125 +#define GET_NEWSRCQUERY (long) 139
   1.126 +#define SET_NEWSRCQUERY (long) 140
   1.127 +#define GET_FREEENVELOPESPAREP (long) 141
   1.128 +#define SET_FREEENVELOPESPAREP (long) 142
   1.129 +#define GET_FREEELTSPAREP (long) 143
   1.130 +#define SET_FREEELTSPAREP (long) 144
   1.131 +#define GET_SSLSTART (long) 145
   1.132 +#define SET_SSLSTART (long) 146
   1.133 +#define GET_DEBUGSENSITIVE (long) 147
   1.134 +#define SET_DEBUGSENSITIVE (long) 148
   1.135 +#define GET_TCPDEBUG (long) 149
   1.136 +#define SET_TCPDEBUG (long) 150
   1.137 +#define GET_FREESTREAMSPAREP (long) 151
   1.138 +#define SET_FREESTREAMSPAREP (long) 152
   1.139 +#define GET_FREEBODYSPAREP (long) 153
   1.140 +#define SET_FREEBODYSPAREP (long) 154
   1.141 +#define GET_COPYUID (long) 155
   1.142 +#define SET_COPYUID (long) 156
   1.143 +#define GET_APPENDUID (long) 157
   1.144 +#define SET_APPENDUID (long) 158
   1.145 +#define GET_RFC822OUTPUTFULL (long) 159
   1.146 +#define SET_RFC822OUTPUTFULL (long) 160
   1.147 +#define GET_BLOCKENVINIT (long) 161
   1.148 +#define SET_BLOCKENVINIT (long) 162
   1.149 +
   1.150 +	/* 2xx: environment */
   1.151 +#define GET_USERNAME (long) 201
   1.152 +#define SET_USERNAME (long) 202
   1.153 +#define GET_HOMEDIR (long) 203
   1.154 +#define SET_HOMEDIR (long) 204
   1.155 +#define GET_LOCALHOST (long) 205
   1.156 +#define SET_LOCALHOST (long) 206
   1.157 +#define GET_SYSINBOX (long) 207
   1.158 +#define SET_SYSINBOX (long) 208
   1.159 +#define GET_USERPROMPT (long) 209
   1.160 +#define SET_USERPROMPT (long) 210
   1.161 +#define GET_DISABLEPLAINTEXT (long) 211
   1.162 +#define SET_DISABLEPLAINTEXT (long) 212
   1.163 +#define GET_CHROOTSERVER (long) 213
   1.164 +#define SET_CHROOTSERVER (long) 214
   1.165 +#define GET_ADVERTISETHEWORLD (long) 215
   1.166 +#define SET_ADVERTISETHEWORLD (long) 216
   1.167 +#define GET_DISABLEAUTOSHAREDNS (long) 217
   1.168 +#define SET_DISABLEAUTOSHAREDNS (long) 218
   1.169 +#define GET_MAILSUBDIR 219
   1.170 +#define SET_MAILSUBDIR 220
   1.171 +#define GET_DISABLE822TZTEXT 221
   1.172 +#define SET_DISABLE822TZTEXT 222
   1.173 +#define GET_LIMITEDADVERTISE (long) 223
   1.174 +#define SET_LIMITEDADVERTISE (long) 224
   1.175 +#define GET_LOGOUTHOOK (long) 225
   1.176 +#define SET_LOGOUTHOOK (long) 226
   1.177 +#define GET_LOGOUTDATA (long) 227
   1.178 +#define SET_LOGOUTDATA (long) 228
   1.179 +#define GET_EXTERNALAUTHID (long) 229
   1.180 +#define SET_EXTERNALAUTHID (long) 230
   1.181 +#define GET_SSLCAPATH (long) 231
   1.182 +#define SET_SSLCAPATH (long) 232
   1.183 +
   1.184 +	/* 3xx: TCP/IP */
   1.185 +#define GET_OPENTIMEOUT (long) 300
   1.186 +#define SET_OPENTIMEOUT (long) 301
   1.187 +#define GET_READTIMEOUT (long) 302
   1.188 +#define SET_READTIMEOUT (long) 303
   1.189 +#define GET_WRITETIMEOUT (long) 304
   1.190 +#define SET_WRITETIMEOUT (long) 305
   1.191 +#define GET_CLOSETIMEOUT (long) 306
   1.192 +#define SET_CLOSETIMEOUT (long) 307
   1.193 +#define GET_TIMEOUT (long) 308
   1.194 +#define SET_TIMEOUT (long) 309
   1.195 +#define GET_RSHTIMEOUT (long) 310
   1.196 +#define SET_RSHTIMEOUT (long) 311
   1.197 +#define GET_ALLOWREVERSEDNS (long) 312
   1.198 +#define SET_ALLOWREVERSEDNS (long) 313
   1.199 +#define GET_RSHCOMMAND (long) 314
   1.200 +#define SET_RSHCOMMAND (long) 315
   1.201 +#define GET_RSHPATH (long) 316
   1.202 +#define SET_RSHPATH (long) 317
   1.203 +#define GET_SSHTIMEOUT (long) 318
   1.204 +#define SET_SSHTIMEOUT (long) 319
   1.205 +#define GET_SSHCOMMAND (long) 320
   1.206 +#define SET_SSHCOMMAND (long) 321
   1.207 +#define GET_SSHPATH (long) 322
   1.208 +#define SET_SSHPATH (long) 323
   1.209 +#define GET_SSLCERTIFICATEQUERY (long) 324
   1.210 +#define SET_SSLCERTIFICATEQUERY (long) 325
   1.211 +#define GET_SSLFAILURE (long) 326
   1.212 +#define SET_SSLFAILURE (long) 327
   1.213 +#define GET_NEWSRCCANONHOST (long) 328
   1.214 +#define SET_NEWSRCCANONHOST (long) 329
   1.215 +#define GET_KINIT (long) 330
   1.216 +#define SET_KINIT (long) 331
   1.217 +#define GET_SSLCLIENTCERT (long) 332
   1.218 +#define SET_SSLCLIENTCERT (long) 333
   1.219 +#define GET_SSLCLIENTKEY (long) 334
   1.220 +#define SET_SSLCLIENTKEY (long) 335
   1.221 +#define GET_KERBEROS_CP_SVR_NAME (long) 336
   1.222 +#define SET_KERBEROS_CP_SVR_NAME (long) 337
   1.223 +
   1.224 +	/* 4xx: network drivers */
   1.225 +#define GET_MAXLOGINTRIALS (long) 400
   1.226 +#define SET_MAXLOGINTRIALS (long) 401
   1.227 +#define GET_LOOKAHEAD (long) 402
   1.228 +#define SET_LOOKAHEAD (long) 403
   1.229 +#define GET_IMAPPORT (long) 404
   1.230 +#define SET_IMAPPORT (long) 405
   1.231 +#define GET_PREFETCH (long) 406
   1.232 +#define SET_PREFETCH (long) 407
   1.233 +#define GET_CLOSEONERROR (long) 408
   1.234 +#define SET_CLOSEONERROR (long) 409
   1.235 +#define GET_POP3PORT (long) 410
   1.236 +#define SET_POP3PORT (long) 411
   1.237 +#define GET_UIDLOOKAHEAD (long) 412
   1.238 +#define SET_UIDLOOKAHEAD (long) 413
   1.239 +#define GET_NNTPPORT (long) 414
   1.240 +#define SET_NNTPPORT (long) 415
   1.241 +#define GET_IMAPENVELOPE (long) 416
   1.242 +#define SET_IMAPENVELOPE (long) 417
   1.243 +#define GET_IMAPREFERRAL (long) 418
   1.244 +#define SET_IMAPREFERRAL (long) 419
   1.245 +#define GET_SSLIMAPPORT (long) 420
   1.246 +#define SET_SSLIMAPPORT (long) 421
   1.247 +#define GET_SSLPOPPORT (long) 422
   1.248 +#define SET_SSLPOPPORT (long) 423
   1.249 +#define GET_SSLNNTPPORT (long) 424
   1.250 +#define SET_SSLNNTPPORT (long) 425
   1.251 +#define GET_SSLSMTPPORT (long) 426
   1.252 +#define SET_SSLSMTPPORT (long) 427
   1.253 +#define GET_SMTPPORT (long) 428
   1.254 +#define SET_SMTPPORT (long) 429
   1.255 +#define GET_IMAPEXTRAHEADERS (long) 430
   1.256 +#define SET_IMAPEXTRAHEADERS (long) 431
   1.257 +#define GET_ACL (long) 432
   1.258 +#define SET_ACL (long) 433
   1.259 +#define GET_LISTRIGHTS (long) 434
   1.260 +#define SET_LISTRIGHTS (long) 435
   1.261 +#define GET_MYRIGHTS (long) 436
   1.262 +#define SET_MYRIGHTS (long) 437
   1.263 +#define GET_QUOTA (long) 438
   1.264 +#define SET_QUOTA (long) 439
   1.265 +#define GET_QUOTAROOT (long) 440
   1.266 +#define SET_QUOTAROOT (long) 441
   1.267 +#define GET_IMAPTRYSSL (long) 442
   1.268 +#define SET_IMAPTRYSSL (long) 443
   1.269 +#define GET_FETCHLOOKAHEAD (long) 444
   1.270 +#define SET_FETCHLOOKAHEAD (long) 445
   1.271 +#define GET_NNTPRANGE (long) 446
   1.272 +#define SET_NNTPRANGE (long) 447
   1.273 +#define GET_NNTPHIDEPATH (long) 448
   1.274 +#define SET_NNTPHIDEPATH (long) 449
   1.275 +#define GET_SENDCOMMAND (long) 450
   1.276 +#define SET_SENDCOMMAND (long) 451
   1.277 +#define GET_IDLETIMEOUT (long) 452
   1.278 +#define SET_IDLETIMEOUT (long) 453
   1.279 +#define GET_FETCHLOOKAHEADLIMIT (long) 454
   1.280 +#define SET_FETCHLOOKAHEADLIMIT (long) 455
   1.281 +
   1.282 +	/* 5xx: local file drivers */
   1.283 +#define GET_MBXPROTECTION (long) 500
   1.284 +#define SET_MBXPROTECTION (long) 501
   1.285 +#define GET_DIRPROTECTION (long) 502
   1.286 +#define SET_DIRPROTECTION (long) 503
   1.287 +#define GET_LOCKPROTECTION (long) 504
   1.288 +#define SET_LOCKPROTECTION (long) 505
   1.289 +#define GET_FROMWIDGET (long) 506
   1.290 +#define SET_FROMWIDGET (long) 507
   1.291 +#define GET_NEWSACTIVE (long) 508
   1.292 +#define SET_NEWSACTIVE (long) 509
   1.293 +#define GET_NEWSSPOOL (long) 510
   1.294 +#define SET_NEWSSPOOL (long) 511
   1.295 +#define GET_NEWSRC (long) 512
   1.296 +#define SET_NEWSRC (long) 513
   1.297 +#define GET_EXTENSION (long) 514
   1.298 +#define SET_EXTENSION (long) 515
   1.299 +#define GET_DISABLEFCNTLLOCK (long) 516
   1.300 +#define SET_DISABLEFCNTLLOCK (long) 517
   1.301 +#define GET_LOCKEACCESERROR (long) 518
   1.302 +#define SET_LOCKEACCESERROR (long) 519
   1.303 +#define GET_LISTMAXLEVEL (long) 520
   1.304 +#define SET_LISTMAXLEVEL (long) 521
   1.305 +#define GET_ANONYMOUSHOME (long) 522
   1.306 +#define SET_ANONYMOUSHOME (long) 523
   1.307 +#define GET_FTPHOME (long) 524
   1.308 +#define SET_FTPHOME (long) 525
   1.309 +#define GET_PUBLICHOME (long) 526
   1.310 +#define SET_PUBLICHOME (long) 527
   1.311 +#define GET_SHAREDHOME (long) 528
   1.312 +#define SET_SHAREDHOME (long) 529
   1.313 +#define GET_MHPROFILE (long) 530
   1.314 +#define SET_MHPROFILE (long) 531
   1.315 +#define GET_MHPATH (long) 532
   1.316 +#define SET_MHPATH (long) 533
   1.317 +#define GET_ONETIMEEXPUNGEATPING (long) 534
   1.318 +#define SET_ONETIMEEXPUNGEATPING (long) 535
   1.319 +#define GET_USERHASNOLIFE (long) 536
   1.320 +#define SET_USERHASNOLIFE (long) 537
   1.321 +#define GET_FTPPROTECTION (long) 538
   1.322 +#define SET_FTPPROTECTION (long) 539
   1.323 +#define GET_PUBLICPROTECTION (long) 540
   1.324 +#define SET_PUBLICPROTECTION (long) 541
   1.325 +#define GET_SHAREDPROTECTION (long) 542
   1.326 +#define SET_SHAREDPROTECTION (long) 543
   1.327 +#define GET_LOCKTIMEOUT (long) 544
   1.328 +#define SET_LOCKTIMEOUT (long) 545
   1.329 +#define GET_NOTIMEZONES (long) 546
   1.330 +#define SET_NOTIMEZONES (long) 547
   1.331 +#define GET_HIDEDOTFILES (long) 548
   1.332 +#define SET_HIDEDOTFILES (long) 549
   1.333 +#define GET_FTPDIRPROTECTION (long) 550
   1.334 +#define SET_FTPDIRPROTECTION (long) 551
   1.335 +#define GET_PUBLICDIRPROTECTION (long) 552
   1.336 +#define SET_PUBLICDIRPROTECTION (long) 553
   1.337 +#define GET_SHAREDDIRPROTECTION (long) 554
   1.338 +#define SET_SHAREDDIRPROTECTION (long) 555
   1.339 +#define GET_TRUSTDNS (long) 556
   1.340 +#define SET_TRUSTDNS (long) 557
   1.341 +#define GET_SASLUSESPTRNAME (long) 558
   1.342 +#define SET_SASLUSESPTRNAME (long) 559
   1.343 +#define GET_NETFSSTATBUG (long) 560
   1.344 +#define SET_NETFSSTATBUG (long) 561
   1.345 +#define GET_SNARFMAILBOXNAME (long) 562
   1.346 +#define SET_SNARFMAILBOXNAME (long) 563
   1.347 +#define GET_SNARFINTERVAL (long) 564
   1.348 +#define SET_SNARFINTERVAL (long) 565
   1.349 +#define GET_SNARFPRESERVE (long) 566
   1.350 +#define SET_SNARFPRESERVE (long) 567
   1.351 +#define GET_INBOXPATH (long) 568
   1.352 +#define SET_INBOXPATH (long) 569
   1.353 +#define GET_DIRFMTTEST (long) 570
   1.354 +#define SET_DIRFMTTEST (long) 571
   1.355 +#define GET_SCANCONTENTS (long) 572
   1.356 +#define SET_SCANCONTENTS (long) 573
   1.357 +#define GET_MHALLOWINBOX (long) 574
   1.358 +#define SET_MHALLOWINBOX (long) 575
   1.359 +
   1.360 +/* Driver flags */
   1.361 +
   1.362 +#define DR_DISABLE (long) 0x1	/* driver is disabled */
   1.363 +#define DR_LOCAL (long) 0x2	/* local file driver */
   1.364 +#define DR_MAIL (long) 0x4	/* supports mail */
   1.365 +#define DR_NEWS (long) 0x8	/* supports news */
   1.366 +#define DR_READONLY (long) 0x10	/* driver only allows readonly access */
   1.367 +#define DR_NOFAST (long) 0x20	/* "fast" data is slow (whole msg fetch) */
   1.368 +#define DR_NAMESPACE (long) 0x40/* driver has a special namespace */
   1.369 +#define DR_LOWMEM (long) 0x80	/* low amounts of memory available */
   1.370 +#define DR_LOCKING (long) 0x100	/* driver does locking */
   1.371 +#define DR_CRLF (long) 0x200	/* driver internal form uses CRLF newlines */
   1.372 +#define DR_NOSTICKY (long) 0x400/* driver does not support sticky UIDs */
   1.373 +#define DR_RECYCLE (long) 0x800	/* driver does stream recycling */
   1.374 +#define DR_XPOINT (long) 0x1000	/* needs to be checkpointed */
   1.375 +				/* driver has no real internal date */
   1.376 +#define DR_NOINTDATE (long) 0x2000
   1.377 +				/* driver does not announce new mail */
   1.378 +#define DR_NONEWMAIL (long) 0x4000
   1.379 +				/* driver does not announce new mail when RO */
   1.380 +#define DR_NONEWMAILRONLY (long) 0x8000
   1.381 +				/* driver can be halfopen */
   1.382 +#define DR_HALFOPEN (long) 0x10000
   1.383 +#define DR_DIRFMT (long) 0x20000/* driver is a directory-format */
   1.384 +#define DR_MODSEQ (long) 0x40000/* driver supports modseqs */
   1.385 +
   1.386 +
   1.387 +/* Cache management function codes */
   1.388 +
   1.389 +#define CH_INIT (long) 10	/* initialize cache */
   1.390 +#define CH_SIZE (long) 11	/* (re-)size the cache */
   1.391 +#define CH_MAKEELT (long) 30	/* return elt, make if needed */
   1.392 +#define CH_ELT (long) 31	/* return elt if exists */
   1.393 +#define CH_SORTCACHE (long) 35	/* return sortcache entry, make if needed */
   1.394 +#define CH_FREE (long) 40	/* free space used by elt */
   1.395 +				/* free space used by sortcache */
   1.396 +#define CH_FREESORTCACHE (long) 43
   1.397 +#define CH_EXPUNGE (long) 45	/* delete elt pointer from list */
   1.398 +
   1.399 +
   1.400 +/* Mailbox open options
   1.401 + * For compatibility with the past, OP_DEBUG must always be 1.
   1.402 + */
   1.403 +
   1.404 +#define OP_DEBUG (long) 0x1	/* debug protocol negotiations */
   1.405 +#define OP_READONLY (long) 0x2	/* read-only open */
   1.406 +#define OP_ANONYMOUS (long) 0x4	/* anonymous open of newsgroup */
   1.407 +#define OP_SHORTCACHE (long) 0x8/* short (elt-only) caching */
   1.408 +#define OP_SILENT (long) 0x10	/* don't pass up events (internal use) */
   1.409 +#define OP_PROTOTYPE (long) 0x20/* return driver prototype */
   1.410 +#define OP_HALFOPEN (long) 0x40	/* half-open (IMAP connect but no select) */
   1.411 +#define OP_EXPUNGE (long) 0x80	/* silently expunge recycle stream */
   1.412 +#define OP_SECURE (long) 0x100	/* don't do non-secure authentication */
   1.413 +#define OP_TRYSSL (long) 0x200	/* try SSL first */
   1.414 +				/* use multiple newsrc files */
   1.415 +#define OP_MULNEWSRC (long) 0x400
   1.416 +#define OP_NOKOD (long) 0x800	/* suppress kiss-of-death */
   1.417 +#define OP_SNIFF (long) 0x1000	/* metadata only open */
   1.418 +				/* reserved for application use */
   1.419 +#define OP_RESERVED (unsigned long) 0xff000000
   1.420 +
   1.421 +
   1.422 +/* Net open options */
   1.423 +
   1.424 +				/* no error messages */
   1.425 +#define NET_SILENT ((unsigned long) 0x80000000)
   1.426 +				/* no validation of SSL certificates */
   1.427 +#define NET_NOVALIDATECERT ((unsigned long) 0x40000000)
   1.428 +				/* no open timeout */
   1.429 +#define NET_NOOPENTIMEOUT ((unsigned long) 0x20000000)
   1.430 +				/* TLS not SSL */
   1.431 +#define NET_TLSCLIENT ((unsigned long) 0x10000000)
   1.432 +				/* try SSL mode */
   1.433 +#define NET_TRYSSL ((unsigned long) 0x8000000)
   1.434 +
   1.435 +/* Close options */
   1.436 +
   1.437 +#define CL_EXPUNGE (long) 1	/* expunge silently */
   1.438 +
   1.439 +
   1.440 +/* Fetch options */
   1.441 +
   1.442 +#define FT_UID (long) 0x1	/* argument is a UID */
   1.443 +#define FT_PEEK (long) 0x2	/* peek at data */
   1.444 +#define FT_NOT (long) 0x4	/* NOT flag for header lines fetch */
   1.445 +#define FT_INTERNAL (long) 0x8	/* text can be internal strings */
   1.446 +				/* IMAP prefetch text when fetching header */
   1.447 +#define FT_PREFETCHTEXT (long) 0x20
   1.448 +#define FT_NOHDRS (long) 0x40	/* suppress fetching extra headers (note that
   1.449 +				   this breaks news handling) */
   1.450 +#define FT_NEEDENV (long) 0x80	/* (internal use) include envelope */
   1.451 +#define FT_NEEDBODY (long) 0x100/* (internal use) include body structure */
   1.452 +				/* no fetch lookahead */
   1.453 +#define FT_NOLOOKAHEAD (long) 0x200
   1.454 +				/* (internal use) lookahead in hdr searching */
   1.455 +#define FT_SEARCHLOOKAHEAD (long) 0x400
   1.456 +				/* stringstruct return hack */
   1.457 +#define FT_RETURNSTRINGSTRUCT (long) 0x800
   1.458 +
   1.459 +
   1.460 +/* Flagging options */
   1.461 +
   1.462 +#define ST_UID (long) 0x1	/* argument is a UID sequence */
   1.463 +#define ST_SILENT (long) 0x2	/* don't return results */
   1.464 +#define ST_SET (long) 0x4	/* set vs. clear */
   1.465 +
   1.466 +
   1.467 +/* Expunge options */
   1.468 +
   1.469 +#define EX_UID (long) 0x1	/* argument is a UID sequence */
   1.470 +
   1.471 +
   1.472 +/* Copy options */
   1.473 +
   1.474 +#define CP_UID (long) 0x1	/* argument is a UID sequence */
   1.475 +#define CP_MOVE (long) 0x2	/* delete from source after copying */
   1.476 +				/* set debug in any created stream */
   1.477 +#define CP_DEBUG (long) 0x20000000
   1.478 +
   1.479 +/* Search/sort/thread options */
   1.480 +
   1.481 +#define SE_UID (long) 0x1	/* return UID */
   1.482 +#define SE_FREE (long) 0x2	/* free search program after finished */
   1.483 +#define SE_NOPREFETCH (long) 0x4/* no search prefetching */
   1.484 +#define SO_FREE (long) 0x8	/* free sort program after finished */
   1.485 +#define SE_NOSERVER (long) 0x10	/* don't do server-based search/sort/thread */
   1.486 +#define SE_RETAIN (long) 0x20	/* retain previous search results */
   1.487 +#define SO_OVERVIEW (long) 0x40	/* use overviews in searching (NNTP only) */
   1.488 +#define SE_NEEDBODY (long) 0x80	/* include body structure in prefetch */
   1.489 +#define SE_NOHDRS (long) 0x100	/* suppress prefetching extra headers (note
   1.490 +				   that this breaks news handling) */
   1.491 +#define SE_NOLOCAL (long) 0x200	/* no local retry (IMAP only) */
   1.492 +
   1.493 +#define SO_NOSERVER SE_NOSERVER	/* compatibility name */
   1.494 +#define SE_SILLYOK (long) 0x400	/* allow silly searches */
   1.495 +
   1.496 +
   1.497 +/* Status options */
   1.498 +
   1.499 +#define SA_MESSAGES (long) 0x1	/* number of messages */
   1.500 +#define SA_RECENT (long) 0x2	/* number of recent messages */
   1.501 +#define SA_UNSEEN (long) 0x4	/* number of unseen messages */
   1.502 +#define SA_UIDNEXT (long) 0x8	/* next UID to be assigned */
   1.503 +				/* UID validity value */
   1.504 +#define SA_UIDVALIDITY (long) 0x10
   1.505 +				/* set OP_DEBUG on any created stream */
   1.506 +#define SA_DEBUG (long) 0x10000000
   1.507 +				/* use multiple newsrcs */
   1.508 +#define SA_MULNEWSRC (long) 0x20000000
   1.509 +
   1.510 +/* Mailgets flags */
   1.511 +
   1.512 +#define MG_UID (long) 0x1	/* message number is a UID */
   1.513 +#define MG_COPY (long) 0x2	/* must return copy of argument */
   1.514 +
   1.515 +/* SASL authenticator categories */
   1.516 +
   1.517 +#define AU_SECURE (long) 0x1	/* /secure allowed */
   1.518 +#define AU_AUTHUSER (long) 0x2	/* /authuser=xxx allowed */
   1.519 +				/* authenticator hidden */
   1.520 +#define AU_HIDE (long) 0x10000000
   1.521 +				/* authenticator disabled */
   1.522 +#define AU_DISABLE (long) 0x20000000
   1.523 +
   1.524 +
   1.525 +/* Garbage collection flags */
   1.526 +
   1.527 +#define GC_ELT (long) 0x1	/* message cache elements */
   1.528 +#define GC_ENV (long) 0x2	/* envelopes and bodies */
   1.529 +#define GC_TEXTS (long) 0x4	/* cached texts */
   1.530 +
   1.531 +
   1.532 +/* mm_log()/mm_notify() condition codes */
   1.533 +
   1.534 +#define WARN (long) 1		/* mm_log warning type */
   1.535 +#define ERROR (long) 2		/* mm_log error type */
   1.536 +#define PARSE (long) 3		/* mm_log parse error type */
   1.537 +#define BYE (long) 4		/* mm_notify stream dying */
   1.538 +#define TCPDEBUG (long) 5	/* mm_log TCP debug babble */
   1.539 +
   1.540 +
   1.541 +/* Bits from mail_parse_flags().  Don't change these, since the header format
   1.542 + * used by tenex, mtx, and mbx corresponds to these bits.
   1.543 + */
   1.544 +
   1.545 +#define fSEEN 0x1
   1.546 +#define fDELETED 0x2
   1.547 +#define fFLAGGED 0x4
   1.548 +#define fANSWERED 0x8
   1.549 +#define fOLD 0x10
   1.550 +#define fDRAFT 0x20
   1.551 +
   1.552 +#define fEXPUNGED 0x8000	/* internal flag */
   1.553 +
   1.554 +/* Bits for mm_list() and mm_lsub() */
   1.555 +
   1.556 +/* Note that (LATT_NOINFERIORS LATT_HASCHILDREN LATT_HASNOCHILDREN) and
   1.557 + * (LATT_NOSELECT LATT_MARKED LATT_UNMARKED) each have eight possible states,
   1.558 + * but only four of these are valid.  The other four are silly states which
   1.559 + * while invalid can unfortunately be expressed in the IMAP protocol.
   1.560 + */
   1.561 +
   1.562 +				/* terminal node in hierarchy */
   1.563 +#define LATT_NOINFERIORS (long) 0x1
   1.564 +				/* name can not be selected */
   1.565 +#define LATT_NOSELECT (long) 0x2
   1.566 +				/* changed since last accessed */
   1.567 +#define LATT_MARKED (long) 0x4
   1.568 +				/* accessed since last changed */
   1.569 +#define LATT_UNMARKED (long) 0x8
   1.570 +				/* name has referral to remote mailbox */
   1.571 +#define LATT_REFERRAL (long) 0x10
   1.572 +				/* has selectable inferiors */
   1.573 +#define LATT_HASCHILDREN (long) 0x20
   1.574 +				/* has no selectable inferiors */
   1.575 +#define LATT_HASNOCHILDREN (long) 0x40
   1.576 +
   1.577 +
   1.578 +/* Sort functions */
   1.579 +
   1.580 +#define SORTDATE 0		/* date */
   1.581 +#define SORTARRIVAL 1		/* arrival date */
   1.582 +#define SORTFROM 2		/* from */
   1.583 +#define SORTSUBJECT 3		/* subject */
   1.584 +#define SORTTO 4		/* to */
   1.585 +#define SORTCC 5		/* cc */
   1.586 +#define SORTSIZE 6		/* size */
   1.587 +
   1.588 +
   1.589 +/* imapreferral_t codes */
   1.590 +
   1.591 +#define REFAUTHFAILED (long) 0	/* authentication referral -- not logged in */
   1.592 +#define REFAUTH (long) 1	/* authentication referral -- logged in */
   1.593 +#define REFSELECT (long) 2	/* select referral */
   1.594 +#define REFCREATE (long) 3
   1.595 +#define REFDELETE (long) 4
   1.596 +#define REFRENAME (long) 5
   1.597 +#define REFSUBSCRIBE (long) 6
   1.598 +#define REFUNSUBSCRIBE (long) 7
   1.599 +#define REFSTATUS (long) 8
   1.600 +#define REFCOPY (long) 9
   1.601 +#define REFAPPEND (long) 10
   1.602 +
   1.603 +
   1.604 +/* sendcommand_t codes */
   1.605 +
   1.606 +				/* expunge response deferred */
   1.607 +#define SC_EXPUNGEDEFERRED (long) 1
   1.608 +
   1.609 +/* Block notification codes */
   1.610 +
   1.611 +#define BLOCK_NONE 0		/* not blocked */
   1.612 +#define BLOCK_SENSITIVE 1	/* sensitive code, disallow alarms */
   1.613 +#define BLOCK_NONSENSITIVE 2	/* non-sensitive code, allow alarms */
   1.614 +#define BLOCK_DNSLOOKUP 10	/* blocked on DNS lookup */
   1.615 +#define BLOCK_TCPOPEN 11	/* blocked on TCP open */
   1.616 +#define BLOCK_TCPREAD 12	/* blocked on TCP read */
   1.617 +#define BLOCK_TCPWRITE 13	/* blocked on TCP write */
   1.618 +#define BLOCK_TCPCLOSE 14	/* blocked on TCP close */
   1.619 +#define BLOCK_FILELOCK 20	/* blocked on file locking */
   1.620 +
   1.621 +
   1.622 +/* In-memory sized-text */
   1.623 +
   1.624 +#define SIZEDTEXT struct mail_sizedtext
   1.625 +
   1.626 +SIZEDTEXT {
   1.627 +  unsigned char *data;		/* text */
   1.628 +  unsigned long size;		/* size of text in octets */
   1.629 +};
   1.630 +
   1.631 +
   1.632 +/* String list */
   1.633 +
   1.634 +#define STRINGLIST struct string_list
   1.635 +
   1.636 +STRINGLIST {
   1.637 +  SIZEDTEXT text;		/* string text */
   1.638 +  STRINGLIST *next;
   1.639 +};
   1.640 +
   1.641 +
   1.642 +/* Parse results from mail_valid_net_parse */
   1.643 +
   1.644 +#define NETMAXHOST 256
   1.645 +#define NETMAXUSER 65
   1.646 +#define NETMAXMBX (MAILTMPLEN/4)
   1.647 +#define NETMAXSRV 21
   1.648 +typedef struct net_mailbox {
   1.649 +  char host[NETMAXHOST];	/* host name (may be canonicalized) */
   1.650 +  char orighost[NETMAXHOST];	/* host name before canonicalization */
   1.651 +  char user[NETMAXUSER];	/* user name */
   1.652 +  char authuser[NETMAXUSER];	/* authentication user name */
   1.653 +  char mailbox[NETMAXMBX];	/* mailbox name */
   1.654 +  char service[NETMAXSRV];	/* service name */
   1.655 +  unsigned long port;		/* TCP port number */
   1.656 +  unsigned int anoflag : 1;	/* anonymous */
   1.657 +  unsigned int dbgflag : 1;	/* debug flag */
   1.658 +  unsigned int secflag : 1;	/* secure flag */
   1.659 +  unsigned int sslflag : 1;	/* SSL driver flag */
   1.660 +  unsigned int trysslflag : 1;	/* try SSL driver first flag */
   1.661 +  unsigned int novalidate : 1;	/* don't validate certificates */
   1.662 +  unsigned int tlsflag : 1;	/* TLS flag */
   1.663 +  unsigned int notlsflag : 1;	/* do not do TLS flag */
   1.664 +  unsigned int readonlyflag : 1;/* want readonly */
   1.665 +  unsigned int norsh : 1;	/* don't use rsh/ssh */
   1.666 +  unsigned int loser : 1;	/* server is a loser */
   1.667 +  unsigned int tlssslv23 : 1;	/* force SSLv23 client method over TLS */
   1.668 +} NETMBX;
   1.669 +
   1.670 +/* Item in an address list */
   1.671 +
   1.672 +#define ADDRESS struct mail_address
   1.673 +
   1.674 +ADDRESS {
   1.675 +  char *personal;		/* personal name phrase */
   1.676 +  char *adl;			/* at-domain-list source route */
   1.677 +  char *mailbox;		/* mailbox name */
   1.678 +  char *host;			/* domain name of mailbox's host */
   1.679 +  char *error;			/* error in address from SMTP module */
   1.680 +  struct {
   1.681 +    char *type;			/* address type (default "rfc822") */
   1.682 +    char *addr;			/* address as xtext */
   1.683 +  } orcpt;
   1.684 +  ADDRESS *next;		/* pointer to next address in list */
   1.685 +};
   1.686 +
   1.687 +
   1.688 +/* Message envelope */
   1.689 +
   1.690 +typedef struct mail_envelope {
   1.691 +  unsigned int incomplete : 1;	/* envelope may be incomplete */
   1.692 +  unsigned int imapenvonly : 1;	/* envelope only has IMAP envelope */
   1.693 +  char *remail;			/* remail header if any */
   1.694 +  ADDRESS *return_path;		/* error return address */
   1.695 +  unsigned char *date;		/* message composition date string */
   1.696 +  ADDRESS *from;		/* originator address list */
   1.697 +  ADDRESS *sender;		/* sender address list */
   1.698 +  ADDRESS *reply_to;		/* reply address list */
   1.699 +  char *subject;		/* message subject string */
   1.700 +  ADDRESS *to;			/* primary recipient list */
   1.701 +  ADDRESS *cc;			/* secondary recipient list */
   1.702 +  ADDRESS *bcc;			/* blind secondary recipient list */
   1.703 +  char *in_reply_to;		/* replied message ID */
   1.704 +  char *message_id;		/* message ID */
   1.705 +  char *newsgroups;		/* USENET newsgroups */
   1.706 +  char *followup_to;		/* USENET reply newsgroups */
   1.707 +  char *references;		/* USENET references */
   1.708 +  void *sparep;			/* spare pointer reserved for main program */
   1.709 +} ENVELOPE;
   1.710 +
   1.711 +/* Primary body types */
   1.712 +/* If you change any of these you must also change body_types in rfc822.c */
   1.713 +
   1.714 +#define TYPETEXT 0		/* unformatted text */
   1.715 +#define TYPEMULTIPART 1		/* multiple part */
   1.716 +#define TYPEMESSAGE 2		/* encapsulated message */
   1.717 +#define TYPEAPPLICATION 3	/* application data */
   1.718 +#define TYPEAUDIO 4		/* audio */
   1.719 +#define TYPEIMAGE 5		/* static image */
   1.720 +#define TYPEVIDEO 6		/* video */
   1.721 +#define TYPEMODEL 7		/* model */
   1.722 +#define TYPEOTHER 8		/* unknown */
   1.723 +#define TYPEMAX 15		/* maximum type code */
   1.724 +
   1.725 +
   1.726 +/* Body encodings */
   1.727 +/* If you change any of these you must also change body_encodings in rfc822.c
   1.728 + */
   1.729 +
   1.730 +#define ENC7BIT 0		/* 7 bit SMTP semantic data */
   1.731 +#define ENC8BIT 1		/* 8 bit SMTP semantic data */
   1.732 +#define ENCBINARY 2		/* 8 bit binary data */
   1.733 +#define ENCBASE64 3		/* base-64 encoded data */
   1.734 +#define ENCQUOTEDPRINTABLE 4	/* human-readable 8-as-7 bit data */
   1.735 +#define ENCOTHER 5		/* unknown */
   1.736 +#define ENCMAX 10		/* maximum encoding code */
   1.737 +
   1.738 +
   1.739 +/* Body contents */
   1.740 +
   1.741 +#define BODY struct mail_bodystruct
   1.742 +#define MESSAGE struct mail_body_message
   1.743 +#define PARAMETER struct mail_body_parameter
   1.744 +#define PART struct mail_body_part
   1.745 +#define PARTTEXT struct mail_body_text
   1.746 +
   1.747 +/* Message body text */
   1.748 +
   1.749 +PARTTEXT {
   1.750 +  unsigned long offset;		/* offset from body origin */
   1.751 +  SIZEDTEXT text;		/* text */
   1.752 +};
   1.753 +
   1.754 +
   1.755 +/* Message body structure */
   1.756 +
   1.757 +BODY {
   1.758 +  unsigned short type;		/* body primary type */
   1.759 +  unsigned short encoding;	/* body transfer encoding */
   1.760 +  char *subtype;		/* subtype string */
   1.761 +  PARAMETER *parameter;		/* parameter list */
   1.762 +  char *id;			/* body identifier */
   1.763 +  char *description;		/* body description */
   1.764 +  struct {			/* body disposition */
   1.765 +    char *type;			/* disposition type */
   1.766 +    PARAMETER *parameter;	/* disposition parameters */
   1.767 +  } disposition;
   1.768 +  STRINGLIST *language;		/* body language */
   1.769 +  char *location;		/* body content URI */
   1.770 +  PARTTEXT mime;		/* MIME header */
   1.771 +  PARTTEXT contents;		/* body part contents */
   1.772 +  union {			/* different ways of accessing contents */
   1.773 +    PART *part;			/* body part list */
   1.774 +    MESSAGE *msg;		/* body encapsulated message */
   1.775 +  } nested;
   1.776 +  struct {
   1.777 +    unsigned long lines;	/* size of text in lines */
   1.778 +    unsigned long bytes;	/* size of text in octets */
   1.779 +  } size;
   1.780 +  char *md5;			/* MD5 checksum */
   1.781 +  void *sparep;			/* spare pointer reserved for main program */
   1.782 +};
   1.783 +
   1.784 +
   1.785 +/* Parameter list */
   1.786 +
   1.787 +PARAMETER {
   1.788 +  char *attribute;		/* parameter attribute name */
   1.789 +  char *value;			/* parameter value */
   1.790 +  PARAMETER *next;		/* next parameter in list */
   1.791 +};
   1.792 +
   1.793 +
   1.794 +/* Multipart content list */
   1.795 +
   1.796 +PART {
   1.797 +  BODY body;			/* body information for this part */
   1.798 +  PART *next;			/* next body part */
   1.799 +};
   1.800 +
   1.801 +
   1.802 +/* RFC-822 Message */
   1.803 +
   1.804 +MESSAGE {
   1.805 +  ENVELOPE *env;		/* message envelope */
   1.806 +  BODY *body;			/* message body */
   1.807 +  PARTTEXT full;		/* full message */
   1.808 +  STRINGLIST *lines;		/* lines used to filter header */
   1.809 +  PARTTEXT header;		/* header text */
   1.810 +  PARTTEXT text;		/* body text */
   1.811 +};
   1.812 +
   1.813 +/* Entry in the message cache array */
   1.814 +
   1.815 +typedef struct message_cache {
   1.816 +  unsigned long msgno;		/* message number */
   1.817 +  unsigned int lockcount : 8;	/* non-zero if multiple references */
   1.818 +  unsigned long rfc822_size;	/* # of bytes of message as raw RFC822 */
   1.819 +  struct {			/* c-client internal use only */
   1.820 +    unsigned long uid;		/* message unique ID */
   1.821 +    unsigned long mod;		/* modseq */
   1.822 +    PARTTEXT special;		/* special text pointers */
   1.823 +    MESSAGE msg;		/* internal message pointers */
   1.824 +    union {			/* driver internal use */
   1.825 +      unsigned long data;
   1.826 +      void *ptr;
   1.827 +    } spare;
   1.828 +    unsigned int sequence : 1;	/* saved sequence bit */
   1.829 +    unsigned int dirty : 1;	/* driver internal use */
   1.830 +    unsigned int filter : 1;	/* driver internal use */
   1.831 +    unsigned int ghost : 1;	/* driver internal use */
   1.832 +  } private;
   1.833 +			/* internal date */
   1.834 +  unsigned int day : 5;		/* day of month (1-31) */
   1.835 +  unsigned int month : 4;	/* month of year (1-12) */
   1.836 +  unsigned int year : 7;	/* year since BASEYEAR (expires in 127 yrs) */
   1.837 +  unsigned int hours: 5;	/* hours (0-23) */
   1.838 +  unsigned int minutes: 6;	/* minutes (0-59) */
   1.839 +  unsigned int seconds: 6;	/* seconds (0-59) */
   1.840 +  unsigned int zoccident : 1;	/* non-zero if west of UTC */
   1.841 +  unsigned int zhours : 4;	/* hours from UTC (0-12) */
   1.842 +  unsigned int zminutes: 6;	/* minutes (0-59) */
   1.843 +			/* system flags */
   1.844 +  unsigned int seen : 1;	/* system Seen flag */
   1.845 +  unsigned int deleted : 1;	/* system Deleted flag */
   1.846 +  unsigned int flagged : 1; 	/* system Flagged flag */
   1.847 +  unsigned int answered : 1;	/* system Answered flag */
   1.848 +  unsigned int draft : 1;	/* system Draft flag */
   1.849 +  unsigned int recent : 1;	/* system Recent flag */
   1.850 +			/* message status */
   1.851 +  unsigned int valid : 1;	/* elt has valid flags */
   1.852 +  unsigned int searched : 1;	/* message was searched */
   1.853 +  unsigned int sequence : 1;	/* message is in sequence */
   1.854 +			/* reserved for use by main program */
   1.855 +  unsigned int spare : 1;	/* first spare bit */
   1.856 +  unsigned int spare2 : 1;	/* second spare bit */
   1.857 +  unsigned int spare3 : 1;	/* third spare bit */
   1.858 +  unsigned int spare4 : 1;	/* fourth spare bit */
   1.859 +  unsigned int spare5 : 1;	/* fifth spare bit */
   1.860 +  unsigned int spare6 : 1;	/* sixth spare bit */
   1.861 +  unsigned int spare7 : 1;	/* seventh spare bit */
   1.862 +  unsigned int spare8 : 1;	/* eighth spare bit */
   1.863 +  void *sparep;			/* spare pointer */
   1.864 +  unsigned long user_flags;	/* user-assignable flags */
   1.865 +} MESSAGECACHE;
   1.866 +
   1.867 +/* String structure */
   1.868 +
   1.869 +#define STRINGDRIVER struct string_driver
   1.870 +
   1.871 +typedef struct mailstring {
   1.872 +  void *data;			/* driver-dependent data */
   1.873 +  unsigned long data1;		/* driver-dependent data */
   1.874 +  unsigned long size;		/* total length of string */
   1.875 +  char *chunk;			/* base address of chunk */
   1.876 +  unsigned long chunksize;	/* size of chunk */
   1.877 +  unsigned long offset;		/* offset of this chunk in base */
   1.878 +  char *curpos;			/* current position in chunk */
   1.879 +  unsigned long cursize;	/* number of bytes remaining in chunk */
   1.880 +  STRINGDRIVER *dtb;		/* driver that handles this type of string */
   1.881 +} STRING;
   1.882 +
   1.883 +
   1.884 +/* Dispatch table for string driver */
   1.885 +
   1.886 +STRINGDRIVER {
   1.887 +				/* initialize string driver */
   1.888 +  void (*init) (STRING *s,void *data,unsigned long size);
   1.889 +				/* get next character in string */
   1.890 +  char (*next) (STRING *s);
   1.891 +				/* set position in string */
   1.892 +  void (*setpos) (STRING *s,unsigned long i);
   1.893 +};
   1.894 +
   1.895 +
   1.896 +/* Stringstruct access routines */
   1.897 +
   1.898 +#define INIT(s,d,data,size) ((*((s)->dtb = &d)->init) (s,data,size))
   1.899 +#define SIZE(s) ((s)->size - GETPOS (s))
   1.900 +#define CHR(s) (*(s)->curpos)
   1.901 +#define SNX(s) (--(s)->cursize ? *(s)->curpos++ : (*(s)->dtb->next) (s))
   1.902 +#define GETPOS(s) ((s)->offset + ((s)->curpos - (s)->chunk))
   1.903 +#define SETPOS(s,i) (*(s)->dtb->setpos) (s,i)
   1.904 +
   1.905 +/* Search program */
   1.906 +
   1.907 +#define SEARCHPGM struct search_program
   1.908 +#define SEARCHHEADER struct search_header
   1.909 +#define SEARCHSET struct search_set
   1.910 +#define SEARCHOR struct search_or
   1.911 +#define SEARCHPGMLIST struct search_pgm_list
   1.912 +
   1.913 +
   1.914 +SEARCHHEADER {			/* header search */
   1.915 +  SIZEDTEXT line;		/* header line */
   1.916 +  SIZEDTEXT text;		/* text in header */
   1.917 +  SEARCHHEADER *next;		/* next in list */
   1.918 +};
   1.919 +
   1.920 +
   1.921 +SEARCHSET {			/* message set */
   1.922 +  unsigned long first;		/* sequence number */
   1.923 +  unsigned long last;		/* last value, if a range */
   1.924 +  SEARCHSET *next;		/* next in list */
   1.925 +};
   1.926 +
   1.927 +
   1.928 +SEARCHOR {
   1.929 +  SEARCHPGM *first;		/* first program */
   1.930 +  SEARCHPGM *second;		/* second program */
   1.931 +  SEARCHOR *next;		/* next in list */
   1.932 +};
   1.933 +
   1.934 +
   1.935 +SEARCHPGMLIST {
   1.936 +  SEARCHPGM *pgm;		/* search program */
   1.937 +  SEARCHPGMLIST *next;		/* next in list */
   1.938 +};
   1.939 +
   1.940 +SEARCHPGM {			/* search program */
   1.941 +  SEARCHSET *msgno;		/* message numbers */
   1.942 +  SEARCHSET *uid;		/* unique identifiers */
   1.943 +  SEARCHOR *or;			/* or'ed in programs */
   1.944 +  SEARCHPGMLIST *not;		/* and'ed not program */
   1.945 +  SEARCHHEADER *header;		/* list of headers */
   1.946 +  STRINGLIST *bcc;		/* bcc recipients */
   1.947 +  STRINGLIST *body;		/* text in message body */
   1.948 +  STRINGLIST *cc;		/* cc recipients */
   1.949 +  STRINGLIST *from;		/* originator */
   1.950 +  STRINGLIST *keyword;		/* keywords */
   1.951 +  STRINGLIST *unkeyword;	/* unkeywords */
   1.952 +  STRINGLIST *subject;		/* text in subject */
   1.953 +  STRINGLIST *text;		/* text in headers and body */
   1.954 +  STRINGLIST *to;		/* to recipients */
   1.955 +  unsigned long larger;		/* larger than this size */
   1.956 +  unsigned long smaller;	/* smaller than this size */
   1.957 +  unsigned long older;		/* older than this interval */
   1.958 +  unsigned long younger;	/* younger than this interval */
   1.959 +  unsigned short sentbefore;	/* sent before this date */
   1.960 +  unsigned short senton;	/* sent on this date */
   1.961 +  unsigned short sentsince;	/* sent since this date */
   1.962 +  unsigned short before;	/* before this date */
   1.963 +  unsigned short on;		/* on this date */
   1.964 +  unsigned short since;		/* since this date */
   1.965 +  unsigned int answered : 1;	/* answered messages */
   1.966 +  unsigned int unanswered : 1;	/* unanswered messages */
   1.967 +  unsigned int deleted : 1;	/* deleted messages */
   1.968 +  unsigned int undeleted : 1;	/* undeleted messages */
   1.969 +  unsigned int draft : 1;	/* message draft */
   1.970 +  unsigned int undraft : 1;	/* message undraft */
   1.971 +  unsigned int flagged : 1;	/* flagged messages */
   1.972 +  unsigned int unflagged : 1;	/* unflagged messages */
   1.973 +  unsigned int recent : 1;	/* recent messages */
   1.974 +  unsigned int old : 1;		/* old messages */
   1.975 +  unsigned int seen : 1;	/* seen messages */
   1.976 +  unsigned int unseen : 1;	/* unseen messages */
   1.977 +  /* These must be simulated in IMAP */
   1.978 +  STRINGLIST *return_path;	/* error return address */
   1.979 +  STRINGLIST *sender;		/* sender address list */
   1.980 +  STRINGLIST *reply_to;		/* reply address list */
   1.981 +  STRINGLIST *in_reply_to;	/* replied message ID */
   1.982 +  STRINGLIST *message_id;	/* message ID */
   1.983 +  STRINGLIST *newsgroups;	/* USENET newsgroups */
   1.984 +  STRINGLIST *followup_to;	/* USENET reply newsgroups */
   1.985 +  STRINGLIST *references;	/* USENET references */
   1.986 +};
   1.987 +
   1.988 +
   1.989 +/* Mailbox status */
   1.990 +
   1.991 +typedef struct mbx_status {
   1.992 +  long flags;			/* validity flags */
   1.993 +  unsigned long messages;	/* number of messages */
   1.994 +  unsigned long recent;		/* number of recent messages */
   1.995 +  unsigned long unseen;		/* number of unseen messages */
   1.996 +  unsigned long uidnext;	/* next UID to be assigned */
   1.997 +  unsigned long uidvalidity;	/* UID validity value */
   1.998 +} MAILSTATUS;
   1.999 +
  1.1000 +/* Sort program */
  1.1001 +
  1.1002 +typedef void (*postsort_t) (void *sc);
  1.1003 +
  1.1004 +#define SORTPGM struct sort_program
  1.1005 +
  1.1006 +SORTPGM {
  1.1007 +  unsigned int reverse : 1;	/* sort function is to be reversed */
  1.1008 +  unsigned int abort : 1;	/* abort sorting */
  1.1009 +  short function;		/* sort function */
  1.1010 +  unsigned long nmsgs;		/* number of messages being sorted */
  1.1011 +  struct {
  1.1012 +    unsigned long cached;	/* number of messages cached so far */
  1.1013 +    unsigned long sorted;	/* number of messages sorted so far */
  1.1014 +    unsigned long postsorted;	/* number of postsorted messages so far */
  1.1015 +  } progress;
  1.1016 +  postsort_t postsort;		/* post sorter */
  1.1017 +  SORTPGM *next;		/* next function */
  1.1018 +};
  1.1019 +
  1.1020 +
  1.1021 +/* Sort cache */
  1.1022 +
  1.1023 +#define SORTCACHE struct sort_cache
  1.1024 +
  1.1025 +SORTCACHE {
  1.1026 +  unsigned int sorted : 1;	/* message has been sorted */
  1.1027 +  unsigned int postsorted : 1;	/* message has been postsorted */
  1.1028 +  unsigned int refwd : 1;	/* subject is a re or fwd */
  1.1029 +  unsigned int dirty : 1;	/* has data not written to backup */
  1.1030 +  SORTPGM *pgm;			/* sort program */
  1.1031 +  unsigned long num;		/* message number (sequence or UID) */
  1.1032 +  unsigned long date;		/* sent date */
  1.1033 +  unsigned long arrival;	/* arrival date */
  1.1034 +  unsigned long size;		/* message size */
  1.1035 +  char *from;			/* from string */
  1.1036 +  char *to;			/* to string */
  1.1037 +  char *cc;			/* cc string */
  1.1038 +  char *subject;		/* extracted subject string */
  1.1039 +  char *message_id;		/* message-id string */
  1.1040 +  char *unique;			/* unique string, normally message-id */
  1.1041 +  STRINGLIST *references;	/* references string */
  1.1042 +};
  1.1043 +
  1.1044 +/* ACL list */
  1.1045 +
  1.1046 +#define ACLLIST struct acl_list
  1.1047 +
  1.1048 +ACLLIST {
  1.1049 +  char *identifier;		/* authentication identifier */
  1.1050 +  char *rights;			/* access rights */
  1.1051 +  ACLLIST *next;
  1.1052 +};
  1.1053 +
  1.1054 +/* Quota resource list */
  1.1055 +
  1.1056 +#define QUOTALIST struct quota_list
  1.1057 +
  1.1058 +QUOTALIST {
  1.1059 +  char *name;			/* resource name */
  1.1060 +  unsigned long usage;		/* resource usage */
  1.1061 +  unsigned long limit;		/* resource limit */
  1.1062 +  QUOTALIST *next;		/* next resource */
  1.1063 +};
  1.1064 +
  1.1065 +/* Mail Access I/O stream */
  1.1066 +
  1.1067 +
  1.1068 +/* Structure for mail driver dispatch */
  1.1069 +
  1.1070 +#define DRIVER struct driver	
  1.1071 +
  1.1072 +
  1.1073 +/* Mail I/O stream */
  1.1074 +	
  1.1075 +typedef struct mail_stream {
  1.1076 +  DRIVER *dtb;			/* dispatch table for this driver */
  1.1077 +  void *local;			/* pointer to driver local data */
  1.1078 +  char *mailbox;		/* mailbox name (canonicalized) */
  1.1079 +  char *original_mailbox;	/* mailbox name (non-canonicalized) */
  1.1080 +  unsigned short use;		/* stream use count */
  1.1081 +  unsigned short sequence;	/* stream sequence */
  1.1082 +  unsigned int inbox : 1;	/* stream open on an INBOX */
  1.1083 +  unsigned int lock : 1;	/* stream lock flag */
  1.1084 +  unsigned int debug : 1;	/* stream debug flag */
  1.1085 +  unsigned int silent : 1;	/* don't pass events to main program */
  1.1086 +  unsigned int rdonly : 1;	/* stream read-only flag */
  1.1087 +  unsigned int anonymous : 1;	/* stream anonymous access flag */
  1.1088 +  unsigned int scache : 1;	/* stream short cache flag */
  1.1089 +  unsigned int halfopen : 1;	/* stream half-open flag */
  1.1090 +  unsigned int secure : 1;	/* stream secure flag */
  1.1091 +  unsigned int tryssl : 1;	/* stream tryssl flag */
  1.1092 +  unsigned int mulnewsrc : 1;	/* stream use multiple newsrc files */
  1.1093 +  unsigned int perm_seen : 1;	/* permanent Seen flag */
  1.1094 +  unsigned int perm_deleted : 1;/* permanent Deleted flag */
  1.1095 +  unsigned int perm_flagged : 1;/* permanent Flagged flag */
  1.1096 +  unsigned int perm_answered :1;/* permanent Answered flag */
  1.1097 +  unsigned int perm_draft : 1;	/* permanent Draft flag */
  1.1098 +  unsigned int kwd_create : 1;	/* can create new keywords */
  1.1099 +  unsigned int uid_nosticky : 1;/* UIDs are not preserved */
  1.1100 +  unsigned int unhealthy : 1;	/* unhealthy protocol negotiations */
  1.1101 +  unsigned int nokod : 1;	/* suppress kiss-of-death */
  1.1102 +  unsigned int sniff : 1;	/* metadata only */
  1.1103 +  unsigned long perm_user_flags;/* mask of permanent user flags */
  1.1104 +  unsigned long gensym;		/* generated tag */
  1.1105 +  unsigned long nmsgs;		/* # of associated msgs */
  1.1106 +  unsigned long recent;		/* # of recent msgs */
  1.1107 +  unsigned long uid_validity;	/* UID validity sequence */
  1.1108 +  unsigned long uid_last;	/* last assigned UID */
  1.1109 +  char *user_flags[NUSERFLAGS];	/* pointers to user flags in bit order */
  1.1110 +  unsigned long cachesize;	/* size of message cache */
  1.1111 +  MESSAGECACHE **cache;		/* message cache array */
  1.1112 +  SORTCACHE **sc;		/* sort cache array */
  1.1113 +  unsigned long msgno;		/* message number of `current' message */
  1.1114 +  ENVELOPE *env;		/* scratch buffer for envelope */
  1.1115 +  BODY *body;			/* scratch buffer for body */
  1.1116 +  SIZEDTEXT text;		/* scratch buffer for text */
  1.1117 +  struct {
  1.1118 +    char *name;			/* mailbox name to snarf from */
  1.1119 +    unsigned long time;		/* last snarf time */
  1.1120 +    long options;		/* snarf open options */
  1.1121 +  } snarf;
  1.1122 +  struct {			/* internal use only */
  1.1123 +    struct {			/* search temporaries */
  1.1124 +      STRINGLIST *string;	/* string(s) to search */
  1.1125 +      long result;		/* search result */
  1.1126 +      char *text;		/* cache of fetched text */
  1.1127 +    } search;
  1.1128 +    STRING string;		/* stringstruct return hack */
  1.1129 +  } private;
  1.1130 +			/* reserved for use by main program */
  1.1131 +  void *sparep;			/* spare pointer */
  1.1132 +  unsigned int spare : 1;	/* first spare bit */
  1.1133 +  unsigned int spare2 : 1;	/* second spare bit */
  1.1134 +  unsigned int spare3 : 1;	/* third spare bit */
  1.1135 +  unsigned int spare4 : 1;	/* fourth spare bit */
  1.1136 +  unsigned int spare5 : 1;	/* fifth spare bit */
  1.1137 +  unsigned int spare6 : 1;	/* sixth spare bit */
  1.1138 +  unsigned int spare7 : 1;	/* seventh spare bit */
  1.1139 +  unsigned int spare8 : 1;	/* eighth spare bit */
  1.1140 +} MAILSTREAM;
  1.1141 +
  1.1142 +/* Mail I/O stream handle */
  1.1143 +
  1.1144 +typedef struct mail_stream_handle {
  1.1145 +  MAILSTREAM *stream;		/* pointer to mail stream */
  1.1146 +  unsigned short sequence;	/* sequence of what we expect stream to be */
  1.1147 +} MAILHANDLE;
  1.1148 +
  1.1149 +
  1.1150 +/* Message overview */
  1.1151 +
  1.1152 +typedef struct mail_overview {
  1.1153 +  char *subject;		/* message subject string */
  1.1154 +  ADDRESS *from;		/* originator address list */
  1.1155 +  char *date;			/* message composition date string */
  1.1156 +  char *message_id;		/* message ID */
  1.1157 +  char *references;		/* USENET references */
  1.1158 +  struct {			/* may be 0 or NUL if unknown/undefined */
  1.1159 +    unsigned long octets;	/* message octets (probably LF-newline form) */
  1.1160 +    unsigned long lines;	/* message lines */
  1.1161 +    char *xref;			/* cross references */
  1.1162 +  } optional;
  1.1163 +} OVERVIEW;
  1.1164 +
  1.1165 +/* Network access I/O stream */
  1.1166 +
  1.1167 +
  1.1168 +/* Structure for network driver dispatch */
  1.1169 +
  1.1170 +#define NETDRIVER struct net_driver
  1.1171 +
  1.1172 +
  1.1173 +/* Network transport I/O stream */
  1.1174 +
  1.1175 +typedef struct net_stream {
  1.1176 +  void *stream;			/* driver's I/O stream */
  1.1177 +  NETDRIVER *dtb;		/* network driver */
  1.1178 +} NETSTREAM;
  1.1179 +
  1.1180 +
  1.1181 +/* Network transport driver dispatch */
  1.1182 +
  1.1183 +NETDRIVER {
  1.1184 +  void *(*open) (char *host,char *service,unsigned long port);
  1.1185 +  void *(*aopen) (NETMBX *mb,char *service,char *usrbuf);
  1.1186 +  char *(*getline) (void *stream);
  1.1187 +  long (*getbuffer) (void *stream,unsigned long size,char *buffer);
  1.1188 +  long (*soutr) (void *stream,char *string);
  1.1189 +  long (*sout) (void *stream,char *string,unsigned long size);
  1.1190 +  void (*close) (void *stream);
  1.1191 +  char *(*host) (void *stream);
  1.1192 +  char *(*remotehost) (void *stream);
  1.1193 +  unsigned long (*port) (void *stream);
  1.1194 +  char *(*localhost) (void *stream);
  1.1195 +};
  1.1196 +
  1.1197 +
  1.1198 +/* Mailgets data identifier */
  1.1199 +
  1.1200 +typedef struct getsdata {
  1.1201 +  MAILSTREAM *stream;
  1.1202 +  unsigned long msgno;
  1.1203 +  char *what;
  1.1204 +  STRINGLIST *stl;
  1.1205 +  unsigned long first;
  1.1206 +  unsigned long last;
  1.1207 +  long flags;
  1.1208 +} GETS_DATA;
  1.1209 +
  1.1210 +
  1.1211 +#define INIT_GETS(md,s,m,w,f,l) \
  1.1212 +  md.stream = s, md.msgno = m, md.what = w, md.first = f, md.last = l, \
  1.1213 +  md.stl = NIL, md.flags = NIL;
  1.1214 +
  1.1215 +/* Mail delivery I/O stream */
  1.1216 +
  1.1217 +typedef struct send_stream {
  1.1218 +  NETSTREAM *netstream;		/* network I/O stream */
  1.1219 +  char *host;			/* SMTP service host */
  1.1220 +  char *reply;			/* last reply string */
  1.1221 +  long replycode;		/* last reply code */
  1.1222 +  unsigned int debug : 1;	/* stream debug flag */
  1.1223 +  unsigned int sensitive : 1;	/* sensitive data in progress */
  1.1224 +  unsigned int loser : 1;	/* server is a loser */
  1.1225 +  unsigned int saslcancel : 1;	/* SASL cancelled by protocol */
  1.1226 +  union {			/* protocol specific */
  1.1227 +    struct {			/* SMTP specific */
  1.1228 +      unsigned int ok : 1;	/* supports ESMTP */
  1.1229 +      struct {			/* service extensions */
  1.1230 +	unsigned int send : 1;	/* supports SEND */
  1.1231 +	unsigned int soml : 1;	/* supports SOML */
  1.1232 +	unsigned int saml : 1;	/* supports SAML */
  1.1233 +	unsigned int expn : 1;	/* supports EXPN */
  1.1234 +	unsigned int help : 1;	/* supports HELP */
  1.1235 +	unsigned int turn : 1;	/* supports TURN */
  1.1236 +	unsigned int etrn : 1;	/* supports ETRN */
  1.1237 +	unsigned int starttls:1;/* supports STARTTLS */
  1.1238 +	unsigned int relay : 1;	/* supports relaying */
  1.1239 +	unsigned int pipe : 1;	/* supports pipelining */
  1.1240 +	unsigned int ensc : 1;	/* supports enhanced status codes */
  1.1241 +	unsigned int bmime : 1;	/* supports BINARYMIME */
  1.1242 +	unsigned int chunk : 1;	/* supports CHUNKING */
  1.1243 +      } service;
  1.1244 +      struct {			/* 8-bit MIME transport */
  1.1245 +	unsigned int ok : 1;	/* supports 8-bit MIME */
  1.1246 +	unsigned int want : 1;	/* want 8-bit MIME */
  1.1247 +      } eightbit;
  1.1248 +      struct {			/* delivery status notification */
  1.1249 +	unsigned int ok : 1;	/* supports DSN */
  1.1250 +	unsigned int want : 1;	/* want DSN */
  1.1251 +	struct {		/* notification options */
  1.1252 +				/* notify on failure */
  1.1253 +	  unsigned int failure : 1;
  1.1254 +				/* notify on delay */
  1.1255 +	  unsigned int delay : 1;
  1.1256 +				/* notify on success */
  1.1257 +	  unsigned int success : 1;
  1.1258 +	} notify;
  1.1259 +	unsigned int full : 1;	/* return full headers */
  1.1260 +	char *envid;		/* envelope identifier as xtext */
  1.1261 +      } dsn;
  1.1262 +      struct {			/* size declaration */
  1.1263 +	unsigned int ok : 1;	/* supports SIZE */
  1.1264 +	unsigned long limit;	/* maximum size supported */
  1.1265 +      } size;
  1.1266 +      struct {			/* deliverby declaration */
  1.1267 +	unsigned int ok : 1;	/* supports DELIVERBY */
  1.1268 +	unsigned long minby;	/* minimum by-time */
  1.1269 +      } deliverby;
  1.1270 +      struct {			/* authenticated turn */
  1.1271 +	unsigned int ok : 1;	/* supports ATRN */
  1.1272 +	char *domains;		/* domains */
  1.1273 +      } atrn;
  1.1274 +				/* supported SASL authenticators */
  1.1275 +      unsigned int auth : MAXAUTHENTICATORS;
  1.1276 +    } esmtp;
  1.1277 +    struct {			/* NNTP specific */
  1.1278 +      unsigned int post : 1;	/* supports POST */
  1.1279 +      struct {			/* NNTP extensions */
  1.1280 +	unsigned int ok : 1;	/* supports extensions */
  1.1281 +				/* supports LISTGROUP */
  1.1282 +	unsigned int listgroup : 1;
  1.1283 +	unsigned int over : 1;	/* supports OVER */
  1.1284 +	unsigned int hdr : 1;	/* supports HDR */
  1.1285 +	unsigned int pat : 1;	/* supports PAT */
  1.1286 +				/* supports STARTTLS */
  1.1287 +	unsigned int starttls : 1;
  1.1288 +				/* server has MULTIDOMAIN */
  1.1289 +	unsigned int multidomain : 1;
  1.1290 +				/* supports AUTHINFO USER */
  1.1291 +	unsigned int authuser : 1;
  1.1292 +				/* supported authenticators */
  1.1293 +	unsigned int sasl : MAXAUTHENTICATORS;
  1.1294 +      } ext;
  1.1295 +    } nntp;
  1.1296 +  } protocol;
  1.1297 +} SENDSTREAM;
  1.1298 +
  1.1299 +/* Jacket into external interfaces */
  1.1300 +
  1.1301 +typedef long (*readfn_t) (void *stream,unsigned long size,char *buffer);
  1.1302 +typedef char *(*mailgets_t) (readfn_t f,void *stream,unsigned long size,
  1.1303 +			     GETS_DATA *md);
  1.1304 +typedef char *(*readprogress_t) (GETS_DATA *md,unsigned long octets);
  1.1305 +typedef void *(*mailcache_t) (MAILSTREAM *stream,unsigned long msgno,long op);
  1.1306 +typedef long (*mailproxycopy_t) (MAILSTREAM *stream,char *sequence,
  1.1307 +				 char *mailbox,long options);
  1.1308 +typedef long (*tcptimeout_t) (long overall,long last);
  1.1309 +typedef void *(*authchallenge_t) (void *stream,unsigned long *len);
  1.1310 +typedef long (*authrespond_t) (void *stream,char *s,unsigned long size);
  1.1311 +typedef long (*authcheck_t) (void);
  1.1312 +typedef long (*authclient_t) (authchallenge_t challenger,
  1.1313 +			      authrespond_t responder,char *service,NETMBX *mb,
  1.1314 +			      void *s,unsigned long *trial,char *user);
  1.1315 +typedef char *(*authresponse_t) (void *challenge,unsigned long clen,
  1.1316 +				 unsigned long *rlen);
  1.1317 +typedef char *(*authserver_t) (authresponse_t responder,int argc,char *argv[]);
  1.1318 +typedef void (*smtpverbose_t) (char *buffer);
  1.1319 +typedef void (*imapenvelope_t) (MAILSTREAM *stream,unsigned long msgno,
  1.1320 +				ENVELOPE *env);
  1.1321 +typedef char *(*imapreferral_t) (MAILSTREAM *stream,char *url,long code);
  1.1322 +typedef void (*overview_t) (MAILSTREAM *stream,unsigned long uid,OVERVIEW *ov,
  1.1323 +			    unsigned long msgno);
  1.1324 +typedef unsigned long *(*sorter_t) (MAILSTREAM *stream,char *charset,
  1.1325 +				    SEARCHPGM *spg,SORTPGM *pgm,long flags);
  1.1326 +typedef void (*parseline_t) (ENVELOPE *env,char *hdr,char *data,char *host);
  1.1327 +typedef ADDRESS *(*parsephrase_t) (char *phrase,char *end,char *host);
  1.1328 +typedef void *(*blocknotify_t) (int reason,void *data);
  1.1329 +typedef long (*kinit_t) (char *host,char *reason);
  1.1330 +typedef void (*sendcommand_t) (MAILSTREAM *stream,char *cmd,long flags);
  1.1331 +typedef char *(*newsrcquery_t) (MAILSTREAM *stream,char *mulname,char *name);
  1.1332 +typedef void (*getacl_t) (MAILSTREAM *stream,char *mailbox,ACLLIST *acl);
  1.1333 +typedef void (*listrights_t) (MAILSTREAM *stream,char *mailbox,char *id,
  1.1334 +			      char *alwaysrights,STRINGLIST *possiblerights);
  1.1335 +typedef void (*myrights_t) (MAILSTREAM *stream,char *mailbox,char *rights);
  1.1336 +typedef void (*quota_t) (MAILSTREAM *stream,char *qroot,QUOTALIST *qlist);
  1.1337 +typedef void (*quotaroot_t) (MAILSTREAM *stream,char *mbx,STRINGLIST *qroot);
  1.1338 +typedef void (*sortresults_t) (MAILSTREAM *stream,unsigned long *list,
  1.1339 +			       unsigned long size);
  1.1340 +typedef char *(*userprompt_t) (void);
  1.1341 +typedef long (*append_t) (MAILSTREAM *stream,void *data,char **flags,
  1.1342 +			  char **date,STRING **message);
  1.1343 +typedef void (*copyuid_t) (MAILSTREAM *stream,char *mailbox,
  1.1344 +			   unsigned long uidvalidity,SEARCHSET *sourceset,
  1.1345 +			   SEARCHSET *destset);
  1.1346 +typedef void (*appenduid_t) (char *mailbox,unsigned long uidvalidity,
  1.1347 +			     SEARCHSET *set);
  1.1348 +typedef long (*dirfmttest_t) (char *name);
  1.1349 +typedef long (*scancontents_t) (char *name,char *contents,unsigned long csiz,
  1.1350 +				unsigned long fsiz);
  1.1351 +
  1.1352 +typedef void (*freeeltsparep_t) (void **sparep);
  1.1353 +typedef void (*freeenvelopesparep_t) (void **sparep);
  1.1354 +typedef void (*freebodysparep_t) (void **sparep);
  1.1355 +typedef void (*freestreamsparep_t) (void **sparep);
  1.1356 +typedef void *(*sslstart_t) (void *stream,char *host,unsigned long flags);
  1.1357 +typedef long (*sslcertificatequery_t) (char *reason,char *host,char *cert);
  1.1358 +typedef void (*sslfailure_t) (char *host,char *reason,unsigned long flags);
  1.1359 +typedef void (*logouthook_t) (void *data);
  1.1360 +typedef char *(*sslclientcert_t) (void);
  1.1361 +typedef char *(*sslclientkey_t) (void);
  1.1362 +
  1.1363 +/* Globals */
  1.1364 +
  1.1365 +extern char *body_types[];	/* defined body type strings */
  1.1366 +extern char *body_encodings[];	/* defined body encoding strings */
  1.1367 +extern const char *days[];	/* day name strings */
  1.1368 +extern const char *months[];	/* month name strings */
  1.1369 +
  1.1370 +/* Threading */
  1.1371 +
  1.1372 +/* Thread node */
  1.1373 +
  1.1374 +#define THREADNODE struct thread_node
  1.1375 +
  1.1376 +THREADNODE {
  1.1377 +  unsigned long num;		/* message number */
  1.1378 +  SORTCACHE *sc;		/* (internal use) sortcache entry */
  1.1379 +  THREADNODE *branch;		/* branch at this point in tree */
  1.1380 +  THREADNODE *next;		/* next node */
  1.1381 +};
  1.1382 +
  1.1383 +typedef void (*threadresults_t) (MAILSTREAM *stream,THREADNODE *tree);
  1.1384 +
  1.1385 +
  1.1386 +/* Thread dispatch */
  1.1387 +
  1.1388 +#define THREADER struct threader_list
  1.1389 +
  1.1390 +THREADER {
  1.1391 +  char *name;			/* name of threader */
  1.1392 +  THREADNODE *(*dispatch) (MAILSTREAM *stream,char *charset,SEARCHPGM *spg,
  1.1393 +			   long flags,sorter_t sorter);
  1.1394 +  THREADER *next;
  1.1395 +};
  1.1396 +
  1.1397 +
  1.1398 +/* Container for references threading */
  1.1399 +
  1.1400 +typedef void ** container_t;
  1.1401 +
  1.1402 +/* Namespaces */
  1.1403 +
  1.1404 +#define NAMESPACE struct mail_namespace
  1.1405 +
  1.1406 +NAMESPACE {
  1.1407 +  char *name;			/* name of this namespace */
  1.1408 +  int delimiter;		/* hierarchy delimiter */
  1.1409 +  PARAMETER *param;		/* namespace parameters */
  1.1410 +  NAMESPACE *next;		/* next namespace */
  1.1411 +};
  1.1412 +
  1.1413 +
  1.1414 +/* Authentication */
  1.1415 +
  1.1416 +#define AUTHENTICATOR struct mail_authenticator
  1.1417 +
  1.1418 +AUTHENTICATOR {
  1.1419 +  long flags;			/* authenticator flags */
  1.1420 +  char *name;			/* name of this authenticator */
  1.1421 +  authcheck_t valid;		/* authenticator valid on this system */
  1.1422 +  authclient_t client;		/* client function that supports it */
  1.1423 +  authserver_t server;		/* server function that supports it */
  1.1424 +  AUTHENTICATOR *next;		/* next authenticator */
  1.1425 +};
  1.1426 +
  1.1427 +/* Mail driver dispatch */
  1.1428 +
  1.1429 +DRIVER {
  1.1430 +  char *name;			/* driver name */
  1.1431 +  unsigned long flags;		/* driver flags */
  1.1432 +  DRIVER *next;			/* next driver */
  1.1433 +				/* mailbox is valid for us */
  1.1434 +  DRIVER *(*valid) (char *mailbox);
  1.1435 +				/* manipulate driver parameters */
  1.1436 +  void *(*parameters) (long function,void *value);
  1.1437 +				/* scan mailboxes */
  1.1438 +  void (*scan) (MAILSTREAM *stream,char *ref,char *pat,char *contents);
  1.1439 +				/* list mailboxes */
  1.1440 +  void (*list) (MAILSTREAM *stream,char *ref,char *pat);
  1.1441 +				/* list subscribed mailboxes */
  1.1442 +  void (*lsub) (MAILSTREAM *stream,char *ref,char *pat);
  1.1443 +				/* subscribe to mailbox */
  1.1444 +  long (*subscribe) (MAILSTREAM *stream,char *mailbox);
  1.1445 +				/* unsubscribe from mailbox */
  1.1446 +  long (*unsubscribe) (MAILSTREAM *stream,char *mailbox);
  1.1447 +				/* create mailbox */
  1.1448 +  long (*create) (MAILSTREAM *stream,char *mailbox);
  1.1449 +				/* delete mailbox */
  1.1450 +  long (*mbxdel) (MAILSTREAM *stream,char *mailbox);
  1.1451 +				/* rename mailbox */
  1.1452 +  long (*mbxren) (MAILSTREAM *stream,char *old,char *newname);
  1.1453 +				/* status of mailbox */
  1.1454 +  long (*status) (MAILSTREAM *stream,char *mbx,long flags);
  1.1455 +
  1.1456 +				/* open mailbox */
  1.1457 +  MAILSTREAM *(*open) (MAILSTREAM *stream);
  1.1458 +				/* close mailbox */
  1.1459 +  void (*close) (MAILSTREAM *stream,long options);
  1.1460 +				/* fetch message "fast" attributes */
  1.1461 +  void (*fast) (MAILSTREAM *stream,char *sequence,long flags);
  1.1462 +				/* fetch message flags */
  1.1463 +  void (*msgflags) (MAILSTREAM *stream,char *sequence,long flags);
  1.1464 +				/* fetch message overview */
  1.1465 +  long (*overview) (MAILSTREAM *stream,overview_t ofn);
  1.1466 +				/* fetch message envelopes */
  1.1467 +  ENVELOPE *(*structure) (MAILSTREAM *stream,unsigned long msgno,BODY **body,
  1.1468 +			  long flags);
  1.1469 +				/* return RFC-822 header */
  1.1470 +  char *(*header) (MAILSTREAM *stream,unsigned long msgno,
  1.1471 +		   unsigned long *length,long flags);
  1.1472 +				/* return RFC-822 text */
  1.1473 +  long (*text) (MAILSTREAM *stream,unsigned long msgno,STRING *bs,long flags);
  1.1474 +				/* load cache */
  1.1475 +  long (*msgdata) (MAILSTREAM *stream,unsigned long msgno,char *section,
  1.1476 +		   unsigned long first,unsigned long last,STRINGLIST *lines,
  1.1477 +		   long flags);
  1.1478 +				/* return UID for message */
  1.1479 +  unsigned long (*uid) (MAILSTREAM *stream,unsigned long msgno);
  1.1480 +				/* return message number from UID */
  1.1481 +  unsigned long (*msgno) (MAILSTREAM *stream,unsigned long uid);
  1.1482 +				/* modify flags */
  1.1483 +  void (*flag) (MAILSTREAM *stream,char *sequence,char *flag,long flags);
  1.1484 +				/* per-message modify flags */
  1.1485 +  void (*flagmsg) (MAILSTREAM *stream,MESSAGECACHE *elt);
  1.1486 +				/* search for message based on criteria */
  1.1487 +  long (*search) (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,long flags);
  1.1488 +				/* sort messages */
  1.1489 +  unsigned long *(*sort) (MAILSTREAM *stream,char *charset,SEARCHPGM *spg,
  1.1490 +			  SORTPGM *pgm,long flags);
  1.1491 +				/* thread messages */
  1.1492 +  THREADNODE *(*thread) (MAILSTREAM *stream,char *type,char *charset,
  1.1493 +			 SEARCHPGM *spg,long flag);
  1.1494 +				/* ping mailbox to see if still alive */
  1.1495 +  long (*ping) (MAILSTREAM *stream);
  1.1496 +				/* check for new messages */
  1.1497 +  void (*check) (MAILSTREAM *stream);
  1.1498 +				/* expunge deleted messages */
  1.1499 +  long (*expunge) (MAILSTREAM *stream,char *sequence,long options);
  1.1500 +				/* copy messages to another mailbox */
  1.1501 +  long (*copy) (MAILSTREAM *stream,char *sequence,char *mailbox,long options);
  1.1502 +				/* append string message to mailbox */
  1.1503 +  long (*append) (MAILSTREAM *stream,char *mailbox,append_t af,void *data);
  1.1504 +				/* garbage collect stream */
  1.1505 +  void (*gc) (MAILSTREAM *stream,long gcflags);
  1.1506 +};
  1.1507 +
  1.1508 +
  1.1509 +#include "linkage.h"
  1.1510 +
  1.1511 +/* Compatibility support names for old interfaces */
  1.1512 +
  1.1513 +#define GET_TRYALTFIRST GET_TRYSSLFIRST
  1.1514 +#define SET_TRYALTFIRST SET_TRYSSLFIRST
  1.1515 +#define GET_IMAPTRYALT GET_IMAPTRYSSL
  1.1516 +#define SET_IMAPTRYALT SET_IMAPTRYSSL
  1.1517 +#define OP_TRYALT OP_TRYSSL
  1.1518 +#define altflag sslflag
  1.1519 +
  1.1520 +#define mail_close(stream) \
  1.1521 +  mail_close_full (stream,NIL)
  1.1522 +#define mail_fetchfast(stream,sequence) \
  1.1523 +  mail_fetch_fast (stream,sequence,NIL)
  1.1524 +#define mail_fetchfast_full mail_fetch_fast
  1.1525 +#define mail_fetchflags(stream,sequence) \
  1.1526 +  mail_fetch_flags (stream,sequence,NIL)
  1.1527 +#define mail_fetchflags_full mail_fetch_flags
  1.1528 +#define mail_fetchenvelope(stream,msgno) \
  1.1529 +  mail_fetch_structure (stream,msgno,NIL,NIL)
  1.1530 +#define mail_fetchstructure(stream,msgno,body) \
  1.1531 +  mail_fetch_structure (stream,msgno,body,NIL)
  1.1532 +#define mail_fetchstructure_full mail_fetch_structure
  1.1533 +#define mail_fetchheader(stream,msgno) \
  1.1534 +  mail_fetch_header (stream,msgno,NIL,NIL,NIL,FT_PEEK)
  1.1535 +#define mail_fetchheader_full(stream,msgno,lines,len,flags) \
  1.1536 +  mail_fetch_header (stream,msgno,NIL,lines,len,FT_PEEK | (flags))
  1.1537 +#define mail_fetchtext(stream,msgno) \
  1.1538 +  mail_fetch_text (stream,msgno,NIL,NIL,NIL)
  1.1539 +#define mail_fetchtext_full(stream,msgno,length,flags) \
  1.1540 +  mail_fetch_text (stream,msgno,NIL,length,flags)
  1.1541 +#define mail_fetchbody(stream,msgno,section,length) \
  1.1542 +  mail_fetch_body (stream,msgno,section,length,NIL)
  1.1543 +#define mail_fetchbody_full mail_fetch_body
  1.1544 +#define mail_setflag(stream,sequence,flag) \
  1.1545 +  mail_flag (stream,sequence,flag,ST_SET)
  1.1546 +#define mail_setflag_full(stream,sequence,flag,flags) \
  1.1547 +  mail_flag (stream,sequence,flag,ST_SET | (flags))
  1.1548 +#define mail_clearflag(stream,sequence,flag) \
  1.1549 +  mail_flag (stream,sequence,flag,NIL)
  1.1550 +#define mail_clearflag_full mail_flag
  1.1551 +#define mail_search(stream,criteria) \
  1.1552 +  mail_search_full (stream,NIL,mail_criteria (criteria),SE_FREE);
  1.1553 +#define mail_expunge(stream) \
  1.1554 +  mail_expunge_full (stream,NIL,NIL)
  1.1555 +#define mail_copy(stream,sequence,mailbox) \
  1.1556 +  mail_copy_full (stream,sequence,mailbox,NIL)
  1.1557 +#define mail_move(stream,sequence,mailbox) \
  1.1558 +  mail_copy_full (stream,sequence,mailbox,CP_MOVE)
  1.1559 +#define mail_append(stream,mailbox,message) \
  1.1560 +  mail_append_full (stream,mailbox,NIL,NIL,message)
  1.1561 +
  1.1562 +/* Interfaces for SVR4 locking brain-damage workaround */
  1.1563 +
  1.1564 +/* Driver dispatching */
  1.1565 +
  1.1566 +#define SAFE_DELETE(dtb,stream,mailbox) (*dtb->mbxdel) (stream,mailbox)
  1.1567 +#define SAFE_RENAME(dtb,stream,old,newname) (*dtb->mbxren) (stream,old,newname)
  1.1568 +#define SAFE_STATUS(dtb,stream,mbx,flags) (*dtb->status) (stream,mbx,flags)
  1.1569 +#define SAFE_COPY(dtb,stream,sequence,mailbox,options) \
  1.1570 +  (*dtb->copy) (stream,sequence,mailbox,options)
  1.1571 +#define SAFE_APPEND(dtb,stream,mailbox,af,data) \
  1.1572 +  (*dtb->append) (stream,mailbox,af,data)
  1.1573 +#define SAFE_SCAN_CONTENTS(dtb,name,contents,csiz,fsiz) \
  1.1574 +  scan_contents (dtb,name,contents,csiz,fsiz)
  1.1575 +
  1.1576 +
  1.1577 +/* Driver callbacks */
  1.1578 +
  1.1579 +#define MM_EXISTS mm_exists
  1.1580 +#define MM_EXPUNGED mm_expunged
  1.1581 +#define MM_FLAGS mm_flags
  1.1582 +#define MM_NOTIFY mm_notify
  1.1583 +#define MM_STATUS mm_status
  1.1584 +#define MM_LOG mm_log
  1.1585 +#define MM_CRITICAL mm_critical
  1.1586 +#define MM_NOCRITICAL mm_nocritical
  1.1587 +#define MM_DISKERROR mm_diskerror
  1.1588 +#define MM_FATAL mm_fatal
  1.1589 +#define MM_APPEND(af) (*af)
  1.1590 +
  1.1591 +/* Function prototypes */
  1.1592 +
  1.1593 +void mm_searched (MAILSTREAM *stream,unsigned long number);
  1.1594 +void mm_exists (MAILSTREAM *stream,unsigned long number);
  1.1595 +void mm_expunged (MAILSTREAM *stream,unsigned long number);
  1.1596 +void mm_flags (MAILSTREAM *stream,unsigned long number);
  1.1597 +void mm_notify (MAILSTREAM *stream,char *string,long errflg);
  1.1598 +void mm_list (MAILSTREAM *stream,int delimiter,char *name,long attributes);
  1.1599 +void mm_lsub (MAILSTREAM *stream,int delimiter,char *name,long attributes);
  1.1600 +void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status);
  1.1601 +void mm_log (char *string,long errflg);
  1.1602 +void mm_dlog (char *string);
  1.1603 +void mm_login (NETMBX *mb,char *user,char *pwd,long trial);
  1.1604 +void mm_critical (MAILSTREAM *stream);
  1.1605 +void mm_nocritical (MAILSTREAM *stream);
  1.1606 +long mm_diskerror (MAILSTREAM *stream,long errcode,long serious);
  1.1607 +void mm_fatal (char *string);
  1.1608 +void *mm_cache (MAILSTREAM *stream,unsigned long msgno,long op);
  1.1609 +
  1.1610 +extern STRINGDRIVER mail_string;
  1.1611 +void mail_versioncheck (char *version);
  1.1612 +void mail_link (DRIVER *driver);
  1.1613 +void *mail_parameters (MAILSTREAM *stream,long function,void *value);
  1.1614 +DRIVER *mail_valid (MAILSTREAM *stream,char *mailbox,char *purpose);
  1.1615 +DRIVER *mail_valid_net (char *name,DRIVER *drv,char *host,char *mailbox);
  1.1616 +long mail_valid_net_parse (char *name,NETMBX *mb);
  1.1617 +long mail_valid_net_parse_work (char *name,NETMBX *mb,char *service);
  1.1618 +void mail_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents);
  1.1619 +void mail_list (MAILSTREAM *stream,char *ref,char *pat);
  1.1620 +void mail_lsub (MAILSTREAM *stream,char *ref,char *pat);
  1.1621 +long mail_subscribe (MAILSTREAM *stream,char *mailbox);
  1.1622 +long mail_unsubscribe (MAILSTREAM *stream,char *mailbox);
  1.1623 +long mail_create (MAILSTREAM *stream,char *mailbox);
  1.1624 +long mail_delete (MAILSTREAM *stream,char *mailbox);
  1.1625 +long mail_rename (MAILSTREAM *stream,char *old,char *newname);
  1.1626 +char *mail_utf7_valid (char *mailbox);
  1.1627 +long mail_status (MAILSTREAM *stream,char *mbx,long flags);
  1.1628 +long mail_status_default (MAILSTREAM *stream,char *mbx,long flags);
  1.1629 +MAILSTREAM *mail_open (MAILSTREAM *stream,char *name,long options);
  1.1630 +MAILSTREAM *mail_open_work (DRIVER *d,MAILSTREAM *stream,char *name,
  1.1631 +			    long options);
  1.1632 +MAILSTREAM *mail_close_full (MAILSTREAM *stream,long options);
  1.1633 +MAILHANDLE *mail_makehandle (MAILSTREAM *stream);
  1.1634 +void mail_free_handle (MAILHANDLE **handle);
  1.1635 +MAILSTREAM *mail_stream (MAILHANDLE *handle);
  1.1636 +
  1.1637 +void mail_fetch_fast (MAILSTREAM *stream,char *sequence,long flags);
  1.1638 +void mail_fetch_flags (MAILSTREAM *stream,char *sequence,long flags);
  1.1639 +void mail_fetch_overview (MAILSTREAM *stream,char *sequence,overview_t ofn);
  1.1640 +void mail_fetch_overview_sequence (MAILSTREAM *stream,char *sequence,
  1.1641 +				   overview_t ofn);
  1.1642 +void mail_fetch_overview_default (MAILSTREAM *stream,overview_t ofn);
  1.1643 +ENVELOPE *mail_fetch_structure (MAILSTREAM *stream,unsigned long msgno,
  1.1644 +				BODY **body,long flags);
  1.1645 +char *mail_fetch_message (MAILSTREAM *stream,unsigned long msgno,
  1.1646 +			  unsigned long *len,long flags);
  1.1647 +char *mail_fetch_header (MAILSTREAM *stream,unsigned long msgno,char *section,
  1.1648 +			 STRINGLIST *lines,unsigned long *len,long flags);
  1.1649 +char *mail_fetch_text (MAILSTREAM *stream,unsigned long msgno,char *section,
  1.1650 +		       unsigned long *len,long flags);
  1.1651 +char *mail_fetch_mime (MAILSTREAM *stream,unsigned long msgno,char *section,
  1.1652 +		       unsigned long *len,long flags);
  1.1653 +char *mail_fetch_body (MAILSTREAM *stream,unsigned long msgno,char *section,
  1.1654 +		       unsigned long *len,long flags);
  1.1655 +long mail_partial_text (MAILSTREAM *stream,unsigned long msgno,char *section,
  1.1656 +			unsigned long first,unsigned long last,long flags);
  1.1657 +long mail_partial_body (MAILSTREAM *stream,unsigned long msgno,char *section,
  1.1658 +			unsigned long first,unsigned long last,long flags);
  1.1659 +char *mail_fetch_text_return (GETS_DATA *md,SIZEDTEXT *t,unsigned long *len);
  1.1660 +char *mail_fetch_string_return (GETS_DATA *md,STRING *bs,unsigned long i,
  1.1661 +				unsigned long *len,long flags);
  1.1662 +long mail_read (void *stream,unsigned long size,char *buffer);
  1.1663 +unsigned long mail_uid (MAILSTREAM *stream,unsigned long msgno);
  1.1664 +unsigned long mail_msgno (MAILSTREAM *stream,unsigned long uid);
  1.1665 +void mail_fetchfrom (char *s,MAILSTREAM *stream,unsigned long msgno,
  1.1666 +		     long length);
  1.1667 +void mail_fetchsubject (char *s,MAILSTREAM *stream,unsigned long msgno,
  1.1668 +			long length);
  1.1669 +MESSAGECACHE *mail_elt (MAILSTREAM *stream,unsigned long msgno);
  1.1670 +void mail_flag (MAILSTREAM *stream,char *sequence,char *flag,long flags);
  1.1671 +long mail_search_full (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,
  1.1672 +		       long flags);
  1.1673 +long mail_search_default (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,
  1.1674 +			  long flags);
  1.1675 +long mail_ping (MAILSTREAM *stream);
  1.1676 +void mail_check (MAILSTREAM *stream);
  1.1677 +long mail_expunge_full (MAILSTREAM *stream,char *sequence,long options);
  1.1678 +long mail_copy_full (MAILSTREAM *stream,char *sequence,char *mailbox,
  1.1679 +		     long options);
  1.1680 +long mail_append_full (MAILSTREAM *stream,char *mailbox,char *flags,char *date,
  1.1681 +		       STRING *message);
  1.1682 +long mail_append_multiple (MAILSTREAM *stream,char *mailbox,append_t af,
  1.1683 +			   void *data);
  1.1684 +void mail_gc (MAILSTREAM *stream,long gcflags);
  1.1685 +void mail_gc_msg (MESSAGE *msg,long gcflags);
  1.1686 +void mail_gc_body (BODY *body);
  1.1687 +
  1.1688 +BODY *mail_body (MAILSTREAM *stream,unsigned long msgno,
  1.1689 +		 unsigned char *section);
  1.1690 +char *mail_date (char *string,MESSAGECACHE *elt);
  1.1691 +char *mail_cdate (char *string,MESSAGECACHE *elt);
  1.1692 +long mail_parse_date (MESSAGECACHE *elt,unsigned char *string);
  1.1693 +void mail_exists (MAILSTREAM *stream,unsigned long nmsgs);
  1.1694 +void mail_recent (MAILSTREAM *stream,unsigned long recent);
  1.1695 +void mail_expunged (MAILSTREAM *stream,unsigned long msgno);
  1.1696 +void mail_lock (MAILSTREAM *stream);
  1.1697 +void mail_unlock (MAILSTREAM *stream);
  1.1698 +void mail_debug (MAILSTREAM *stream);
  1.1699 +void mail_nodebug (MAILSTREAM *stream);
  1.1700 +void mail_dlog (char *string,long flag);
  1.1701 +long mail_match_lines (STRINGLIST *lines,STRINGLIST *msglines,long flags);
  1.1702 +unsigned long mail_filter (char *text,unsigned long len,STRINGLIST *lines,
  1.1703 +			   long flags);
  1.1704 +long mail_search_msg (MAILSTREAM *stream,unsigned long msgno,char *section,
  1.1705 +		      SEARCHPGM *pgm);
  1.1706 +long mail_search_header_text (char *s,STRINGLIST *st);
  1.1707 +long mail_search_header (SIZEDTEXT *hdr,STRINGLIST *st);
  1.1708 +long mail_search_text (MAILSTREAM *stream,unsigned long msgno,char *section,
  1.1709 +		       STRINGLIST *st,long flags);
  1.1710 +long mail_search_body (MAILSTREAM *stream,unsigned long msgno,BODY *body,
  1.1711 +		       char *prefix,unsigned long section,long flags);
  1.1712 +long mail_search_string (SIZEDTEXT *s,char *charset,STRINGLIST **st);
  1.1713 +long mail_search_string_work (SIZEDTEXT *s,STRINGLIST **st);
  1.1714 +long mail_search_keyword (MAILSTREAM *stream,MESSAGECACHE *elt,STRINGLIST *st,
  1.1715 +			  long flag);
  1.1716 +long mail_search_addr (ADDRESS *adr,STRINGLIST *st);
  1.1717 +char *mail_search_gets (readfn_t f,void *stream,unsigned long size,
  1.1718 +			GETS_DATA *md);
  1.1719 +SEARCHPGM *mail_criteria (char *criteria);
  1.1720 +int mail_criteria_date (unsigned short *date,char **r);
  1.1721 +int mail_criteria_string (STRINGLIST **s,char **r);
  1.1722 +unsigned short mail_shortdate (unsigned int year,unsigned int month,
  1.1723 +			       unsigned int day);
  1.1724 +SEARCHSET *mail_parse_set (char *s,char **ret);
  1.1725 +SEARCHSET *mail_append_set (SEARCHSET *set,unsigned long msgno);
  1.1726 +unsigned long *mail_sort (MAILSTREAM *stream,char *charset,SEARCHPGM *spg,
  1.1727 +			  SORTPGM *pgm,long flags);
  1.1728 +unsigned long *mail_sort_cache (MAILSTREAM *stream,SORTPGM *pgm,SORTCACHE **sc,
  1.1729 +				long flags);
  1.1730 +unsigned long *mail_sort_msgs (MAILSTREAM *stream,char *charset,SEARCHPGM *spg,
  1.1731 +			       SORTPGM *pgm,long flags);
  1.1732 +SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm);
  1.1733 +unsigned int mail_strip_subject (char *t,char **ret);
  1.1734 +char *mail_strip_subject_wsp (char *s);
  1.1735 +char *mail_strip_subject_blob (char *s);
  1.1736 +int mail_sort_compare (const void *a1,const void *a2);
  1.1737 +unsigned long mail_longdate (MESSAGECACHE *elt);
  1.1738 +THREADNODE *mail_thread (MAILSTREAM *stream,char *type,char *charset,
  1.1739 +			 SEARCHPGM *spg,long flags);
  1.1740 +THREADNODE *mail_thread_msgs (MAILSTREAM *stream,char *type,char *charset,
  1.1741 +			      SEARCHPGM *spg,long flags,sorter_t sorter);
  1.1742 +THREADNODE *mail_thread_orderedsubject (MAILSTREAM *stream,char *charset,
  1.1743 +					SEARCHPGM *spg,long flags,
  1.1744 +					sorter_t sorter);
  1.1745 +THREADNODE *mail_thread_references (MAILSTREAM *stream,char *charset,
  1.1746 +				    SEARCHPGM *spg,long flags,
  1.1747 +				    sorter_t sorter);
  1.1748 +void mail_thread_loadcache (MAILSTREAM *stream,unsigned long uid,OVERVIEW *ov,
  1.1749 +			    unsigned long msgno);
  1.1750 +char *mail_thread_parse_msgid (char *s,char **ss);
  1.1751 +STRINGLIST *mail_thread_parse_references (char *s,long flag);
  1.1752 +long mail_thread_check_child (container_t mother,container_t daughter);
  1.1753 +container_t mail_thread_prune_dummy (container_t msg,container_t ane);
  1.1754 +container_t mail_thread_prune_dummy_work (container_t msg,container_t ane);
  1.1755 +THREADNODE *mail_thread_c2node (MAILSTREAM *stream,container_t con,long flags);
  1.1756 +THREADNODE *mail_thread_sort (THREADNODE *thr,THREADNODE **tc);
  1.1757 +int mail_thread_compare_date (const void *a1,const void *a2);
  1.1758 +long mail_sequence (MAILSTREAM *stream,unsigned char *sequence);
  1.1759 +long mail_uid_sequence (MAILSTREAM *stream,unsigned char *sequence);
  1.1760 +long mail_parse_flags (MAILSTREAM *stream,char *flag,unsigned long *uf);
  1.1761 +long mail_usable_network_stream (MAILSTREAM *stream,char *name);
  1.1762 +
  1.1763 +MESSAGECACHE *mail_new_cache_elt (unsigned long msgno);
  1.1764 +ENVELOPE *mail_newenvelope (void);
  1.1765 +ADDRESS *mail_newaddr (void);
  1.1766 +BODY *mail_newbody (void);
  1.1767 +BODY *mail_initbody (BODY *body);
  1.1768 +PARAMETER *mail_newbody_parameter (void);
  1.1769 +PART *mail_newbody_part (void);
  1.1770 +MESSAGE *mail_newmsg (void);
  1.1771 +STRINGLIST *mail_newstringlist (void);
  1.1772 +SEARCHPGM *mail_newsearchpgm (void);
  1.1773 +SEARCHHEADER *mail_newsearchheader (char *line,char *text);
  1.1774 +SEARCHSET *mail_newsearchset (void);
  1.1775 +SEARCHOR *mail_newsearchor (void);
  1.1776 +SEARCHPGMLIST *mail_newsearchpgmlist (void);
  1.1777 +SORTPGM *mail_newsortpgm (void);
  1.1778 +THREADNODE *mail_newthreadnode (SORTCACHE *sc);
  1.1779 +ACLLIST *mail_newacllist (void);
  1.1780 +QUOTALIST *mail_newquotalist (void);
  1.1781 +void mail_free_body (BODY **body);
  1.1782 +void mail_free_body_data (BODY *body);
  1.1783 +void mail_free_body_parameter (PARAMETER **parameter);
  1.1784 +void mail_free_body_part (PART **part);
  1.1785 +void mail_free_cache (MAILSTREAM *stream);
  1.1786 +void mail_free_elt (MESSAGECACHE **elt);
  1.1787 +void mail_free_envelope (ENVELOPE **env);
  1.1788 +void mail_free_address (ADDRESS **address);
  1.1789 +void mail_free_stringlist (STRINGLIST **string);
  1.1790 +void mail_free_searchpgm (SEARCHPGM **pgm);
  1.1791 +void mail_free_searchheader (SEARCHHEADER **hdr);
  1.1792 +void mail_free_searchset (SEARCHSET **set);
  1.1793 +void mail_free_searchor (SEARCHOR **orl);
  1.1794 +void mail_free_searchpgmlist (SEARCHPGMLIST **pgl);
  1.1795 +void mail_free_namespace (NAMESPACE **n);
  1.1796 +void mail_free_sortpgm (SORTPGM **pgm);
  1.1797 +void mail_free_threadnode (THREADNODE **thr);
  1.1798 +void mail_free_acllist (ACLLIST **al);
  1.1799 +void mail_free_quotalist (QUOTALIST **ql);
  1.1800 +void auth_link (AUTHENTICATOR *auth);
  1.1801 +char *mail_auth (char *mechanism,authresponse_t resp,int argc,char *argv[]);
  1.1802 +AUTHENTICATOR *mail_lookup_auth (unsigned long i);
  1.1803 +unsigned int mail_lookup_auth_name (char *mechanism,long flags);
  1.1804 +
  1.1805 +NETSTREAM *net_open (NETMBX *mb,NETDRIVER *dv,unsigned long port,
  1.1806 +		     NETDRIVER *ssld,char *ssls,unsigned long sslp);
  1.1807 +NETSTREAM *net_open_work (NETDRIVER *dv,char *host,char *service,
  1.1808 +			  unsigned long port,unsigned long portoverride,
  1.1809 +			  unsigned long flags);
  1.1810 +NETSTREAM *net_aopen (NETDRIVER *dv,NETMBX *mb,char *service,char *usrbuf);
  1.1811 +char *net_getline (NETSTREAM *stream);
  1.1812 +				/* stream must be void* for use as readfn_t */
  1.1813 +long net_getbuffer (void *stream,unsigned long size,char *buffer);
  1.1814 +long net_soutr (NETSTREAM *stream,char *string);
  1.1815 +long net_sout (NETSTREAM *stream,char *string,unsigned long size);
  1.1816 +void net_close (NETSTREAM *stream);
  1.1817 +char *net_host (NETSTREAM *stream);
  1.1818 +char *net_remotehost (NETSTREAM *stream);
  1.1819 +unsigned long net_port (NETSTREAM *stream);
  1.1820 +char *net_localhost (NETSTREAM *stream);
  1.1821 +
  1.1822 +long sm_subscribe (char *mailbox);
  1.1823 +long sm_unsubscribe (char *mailbox);
  1.1824 +char *sm_read (void **sdb);
  1.1825 +
  1.1826 +void ssl_onceonlyinit (void);
  1.1827 +char *ssl_start_tls (char *s);
  1.1828 +void ssl_server_init (char *server);
  1.1829 +
  1.1830 +
  1.1831 +/* Server I/O functions */
  1.1832 +
  1.1833 +int PBIN (void);
  1.1834 +char *PSIN (char *s,int n);
  1.1835 +long PSINR (char *s,unsigned long n);
  1.1836 +int PBOUT (int c);
  1.1837 +long INWAIT (long seconds);
  1.1838 +int PSOUT (char *s);
  1.1839 +int PSOUTR (SIZEDTEXT *s);
  1.1840 +int PFLUSH (void);

UW-IMAP'd extensions by yuuji