mutt.h 29.4 KB
Newer Older
1

Thomas Roessler's avatar
Thomas Roessler committed
2
/*
3
 * Copyright (C) 1996-2002,2010,2013 Michael R. Elkins <me@mutt.org>
4
 * Copyright (C) 2004 g10 Code GmbH
Thomas Roessler's avatar
Thomas Roessler committed
5 6 7 8 9 10 11 12 13 14 15 16 17
 * 
 *     This program is free software; you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation; either version 2 of the License, or
 *     (at your option) any later version.
 * 
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 * 
 *     You should have received a copy of the GNU General Public License
 *     along with this program; if not, write to the Free Software
18
 *     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
Thomas Roessler's avatar
Thomas Roessler committed
19 20
 */ 

21 22 23
#ifndef MUTT_H
#define MUTT_H 

Thomas Roessler's avatar
Thomas Roessler committed
24
#include <stdio.h>
25
#include <stdlib.h>
26 27 28
#ifdef HAVE_UNISTD_H
# include <unistd.h> /* needed for SEEK_SET */
#endif
29 30 31
#ifdef HAVE_UNIX_H
# include <unix.h>   /* needed for snprintf on QNX. */
#endif
Thomas Roessler's avatar
Thomas Roessler committed
32
#include <sys/types.h>
Thomas Roessler's avatar
Thomas Roessler committed
33
#include <sys/stat.h>
Thomas Roessler's avatar
Thomas Roessler committed
34 35 36
#include <time.h>
#include <limits.h>
#include <stdarg.h>
37
#include <signal.h>
38 39 40 41 42 43
/* On OS X 10.5.x, wide char functions are inlined by default breaking
 * --without-wc-funcs compilation
 */
#ifdef __APPLE_CC__
#define _DONT_USE_CTYPE_INLINE_
#endif
44
#ifdef HAVE_WCHAR_H
45 46 47 48
# include <wchar.h>
#endif
#if defined(HAVE_WCTYPE_H) && defined(HAVE_WC_FUNCS)
# include <wctype.h>
49
#endif
Thomas Roessler's avatar
Thomas Roessler committed
50

Thomas Roessler's avatar
Thomas Roessler committed
51
#ifndef _POSIX_PATH_MAX
52
#include <limits.h>
Thomas Roessler's avatar
Thomas Roessler committed
53 54
#endif

55 56 57 58 59
/* PATH_MAX is undefined on the hurd */
#if !defined(PATH_MAX) && defined(_POSIX_PATH_MAX)
#define PATH_MAX _POSIX_PATH_MAX
#endif

60 61 62
#include <pwd.h>
#include <grp.h>

Thomas Roessler's avatar
Thomas Roessler committed
63 64
#include "rfc822.h"
#include "hash.h"
65
#include "charset.h"
Thomas Roessler's avatar
Thomas Roessler committed
66

67 68 69 70 71 72 73
#ifndef HAVE_WC_FUNCS
# ifdef MB_LEN_MAX
#  undef MB_LEN_MAX
# endif
# define MB_LEN_MAX 16
#endif

Thomas Roessler's avatar
Thomas Roessler committed
74 75 76 77 78 79 80 81 82
/* nifty trick I stole from ELM 2.5alpha. */
#ifdef MAIN_C
#define WHERE 
#define INITVAL(x) = x
#else
#define WHERE extern
#define INITVAL(x) 
#endif

83 84
#define WHERE_DEFINED 1

85 86
#include "mutt_regex.h"

Thomas Roessler's avatar
Thomas Roessler committed
87
/* flags for mutt_enter_string() */
88 89 90 91 92 93 94 95
#define  MUTT_ALIAS   1      /* do alias "completion" by calling up the alias-menu */
#define  MUTT_FILE    (1<<1) /* do file completion */
#define  MUTT_EFILE   (1<<2) /* do file completion, plus incoming folders */
#define  MUTT_CMD     (1<<3) /* do completion on previous word */
#define  MUTT_PASS    (1<<4) /* password mode (no echo) */
#define  MUTT_CLEAR   (1<<5) /* clear input if printable character is pressed */
#define  MUTT_COMMAND (1<<6) /* do command completion */
#define  MUTT_PATTERN (1<<7) /* pattern mode - only used for history classes */
David Champion's avatar
David Champion committed
96
#define  MUTT_LABEL   (1<<8) /* do label completion */
Thomas Roessler's avatar
Thomas Roessler committed
97 98

/* flags for mutt_get_token() */
99 100 101 102 103 104 105
#define MUTT_TOKEN_EQUAL      1       /* treat '=' as a special */
#define MUTT_TOKEN_CONDENSE   (1<<1)  /* ^(char) to control chars (macros) */
#define MUTT_TOKEN_SPACE      (1<<2)  /* don't treat whitespace as a term */
#define MUTT_TOKEN_QUOTE      (1<<3)  /* don't interpret quotes */
#define MUTT_TOKEN_PATTERN    (1<<4)  /* !)|~ are terms (for patterns) */
#define MUTT_TOKEN_COMMENT    (1<<5)  /* don't reap comments */
#define MUTT_TOKEN_SEMICOLON  (1<<6)  /* don't treat ; as special */
Thomas Roessler's avatar
Thomas Roessler committed
106 107 108 109 110 111 112 113 114

typedef struct
{
  char *data;	/* pointer to data */
  char *dptr;	/* current read/write position */
  size_t dsize;	/* length of data */
  int destroy;	/* destroy `data' when done? */
} BUFFER;

115 116 117 118 119 120
typedef struct
{
  int ch; /* raw key pressed */
  int op; /* function op */
} event_t;

Thomas Roessler's avatar
Thomas Roessler committed
121
/* flags for _mutt_system() */
122
#define MUTT_DETACH_PROCESS	1	/* detach subprocess from group */
Thomas Roessler's avatar
Thomas Roessler committed
123 124 125 126

/* flags for mutt_FormatString() */
typedef enum
{
127 128 129 130 131 132 133 134
  MUTT_FORMAT_FORCESUBJ   = (1<<0), /* print the subject even if unchanged */
  MUTT_FORMAT_TREE        = (1<<1), /* draw the thread tree */
  MUTT_FORMAT_MAKEPRINT   = (1<<2), /* make sure that all chars are printable */
  MUTT_FORMAT_OPTIONAL    = (1<<3),
  MUTT_FORMAT_STAT_FILE   = (1<<4), /* used by mutt_attach_fmt */
  MUTT_FORMAT_ARROWCURSOR = (1<<5), /* reserve space for arrow_cursor */
  MUTT_FORMAT_INDEX       = (1<<6), /* this is a main index entry */
  MUTT_FORMAT_NOFILTER    = (1<<7)  /* do not allow filtering on this pass */
Thomas Roessler's avatar
Thomas Roessler committed
135 136 137
} format_flag;

/* types for mutt_add_hook() */
138 139 140 141 142 143 144 145 146 147 148 149
#define MUTT_FOLDERHOOK  1
#define MUTT_MBOXHOOK    (1<<1)
#define MUTT_SENDHOOK    (1<<2)
#define MUTT_FCCHOOK     (1<<3)
#define MUTT_SAVEHOOK    (1<<4)
#define MUTT_CHARSETHOOK (1<<5)
#define MUTT_ICONVHOOK   (1<<6)
#define MUTT_MESSAGEHOOK (1<<7)
#define MUTT_CRYPTHOOK   (1<<8)
#define MUTT_ACCOUNTHOOK (1<<9)
#define MUTT_REPLYHOOK   (1<<10)
#define MUTT_SEND2HOOK   (1<<11)
150 151 152 153 154
#ifdef USE_COMPRESSED
#define MUTT_OPENHOOK    (1<<12)
#define MUTT_APPENDHOOK  (1<<13)
#define MUTT_CLOSEHOOK   (1<<14)
#endif
Thomas Roessler's avatar
Thomas Roessler committed
155 156

/* tree characters for linearize_tree and print_enriched_string */
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
#define MUTT_TREE_LLCORNER      1
#define MUTT_TREE_ULCORNER      2
#define MUTT_TREE_LTEE          3
#define MUTT_TREE_HLINE         4
#define MUTT_TREE_VLINE         5
#define MUTT_TREE_SPACE         6
#define MUTT_TREE_RARROW        7
#define MUTT_TREE_STAR          8
#define MUTT_TREE_HIDDEN        9
#define MUTT_TREE_EQUALS        10
#define MUTT_TREE_TTEE          11
#define MUTT_TREE_BTEE          12
#define MUTT_TREE_MISSING       13
#define MUTT_TREE_MAX           14

#define MUTT_THREAD_COLLAPSE    (1<<0)
#define MUTT_THREAD_UNCOLLAPSE  (1<<1)
#define MUTT_THREAD_GET_HIDDEN  (1<<2)
#define MUTT_THREAD_UNREAD      (1<<3)
#define MUTT_THREAD_NEXT_UNREAD (1<<4)
177

Thomas Roessler's avatar
Thomas Roessler committed
178 179 180
enum
{
  /* modes for mutt_view_attachment() */
181 182 183
  MUTT_REGULAR = 1,
  MUTT_MAILCAP,
  MUTT_AS_TEXT,
Thomas Roessler's avatar
Thomas Roessler committed
184 185

  /* action codes used by mutt_set_flag() and mutt_pattern_function() */
186 187 188 189 190 191 192 193 194
  MUTT_ALL,
  MUTT_NONE,
  MUTT_NEW,
  MUTT_OLD,
  MUTT_REPLIED,
  MUTT_READ,
  MUTT_UNREAD,
  MUTT_DELETE,
  MUTT_UNDELETE,
195
  MUTT_PURGE,
196 197 198 199 200 201 202
  MUTT_DELETED,
  MUTT_FLAG,
  MUTT_TAG,
  MUTT_UNTAG,
  MUTT_LIMIT,
  MUTT_EXPIRED,
  MUTT_SUPERSEDED,
203
  MUTT_TRASH,
Thomas Roessler's avatar
Thomas Roessler committed
204 205

  /* actions for mutt_pattern_comp/mutt_pattern_exec */
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
  MUTT_AND,
  MUTT_OR,
  MUTT_THREAD,
  MUTT_TO,
  MUTT_CC,
  MUTT_COLLAPSED,
  MUTT_SUBJECT,
  MUTT_FROM,
  MUTT_DATE,
  MUTT_DATE_RECEIVED,
  MUTT_DUPLICATED,
  MUTT_UNREFERENCED,
  MUTT_ID,
  MUTT_BODY,
  MUTT_HEADER,
  MUTT_HORMEL,
  MUTT_WHOLE_MSG,
  MUTT_SENDER,
  MUTT_MESSAGE,
  MUTT_SCORE,
  MUTT_SIZE,
  MUTT_REFERENCE,
  MUTT_RECIPIENT,
  MUTT_LIST,
  MUTT_SUBSCRIBED_LIST,
  MUTT_PERSONAL_RECIP,
  MUTT_PERSONAL_FROM,
  MUTT_ADDRESS,
  MUTT_CRYPT_SIGN,
  MUTT_CRYPT_VERIFIED,
  MUTT_CRYPT_ENCRYPT,
  MUTT_PGP_KEY,
  MUTT_XLABEL,
  MUTT_MIMEATTACH,
240
  
Thomas Roessler's avatar
Thomas Roessler committed
241
  /* Options for Mailcap lookup */
242 243 244 245
  MUTT_EDIT,
  MUTT_COMPOSE,
  MUTT_PRINT,
  MUTT_AUTOVIEW,
Thomas Roessler's avatar
Thomas Roessler committed
246

Thomas Roessler's avatar
Thomas Roessler committed
247
  /* options for socket code */
248
  MUTT_NEW_SOCKET,
249
#ifdef USE_SSL_OPENSSL
250
  MUTT_NEW_SSL_SOCKET,
251
#endif
Thomas Roessler's avatar
Thomas Roessler committed
252

Thomas Roessler's avatar
Thomas Roessler committed
253
  /* Options for mutt_save_attachment */
254 255
  MUTT_SAVE_APPEND,
  MUTT_SAVE_OVERWRITE
Thomas Roessler's avatar
Thomas Roessler committed
256 257 258 259 260
};

/* possible arguments to set_quadoption() */
enum
{
261 262 263 264
  MUTT_NO,
  MUTT_YES,
  MUTT_ASKNO,
  MUTT_ASKYES
Thomas Roessler's avatar
Thomas Roessler committed
265 266 267 268 269
};

/* quad-option vars */
enum
{
270 271 272
  OPT_ABORT,
  OPT_BOUNCE,
  OPT_COPY,
Thomas Roessler's avatar
Thomas Roessler committed
273
  OPT_DELETE,
274
  OPT_FORWEDIT,
275
  OPT_FCCATTACH,
276
  OPT_INCLUDE,
277
  OPT_MFUPTO,
Thomas Roessler's avatar
Thomas Roessler committed
278
  OPT_MIMEFWD,
279
  OPT_MIMEFWDREST,
Thomas Roessler's avatar
Thomas Roessler committed
280
  OPT_MOVE,
281
  OPT_PGPMIMEAUTO,     /* ask to revert to PGP/MIME when inline fails */
282
#ifdef USE_POP
283
  OPT_POPDELETE,
284
  OPT_POPRECONNECT,
285
#endif
Thomas Roessler's avatar
Thomas Roessler committed
286
  OPT_POSTPONE,
287
  OPT_PRINT,
Thomas Roessler's avatar
Thomas Roessler committed
288 289 290
  OPT_QUIT,
  OPT_REPLYTO,
  OPT_RECALL,
291
#if defined(USE_SSL)
292 293
  OPT_SSLSTARTTLS,
#endif
294
  OPT_SUBJECT,
295 296 297 298
  OPT_VERIFYSIG,      /* verify PGP signatures */
    
  /* THIS MUST BE THE LAST VALUE. */
  OPT_MAX
Thomas Roessler's avatar
Thomas Roessler committed
299 300 301 302 303 304 305 306 307 308 309
};

/* flags to ci_send_message() */
#define SENDREPLY	(1<<0)
#define SENDGROUPREPLY	(1<<1)
#define SENDLISTREPLY	(1<<2)
#define SENDFORWARD	(1<<3)
#define SENDPOSTPONED	(1<<4)
#define SENDBATCH	(1<<5)
#define SENDMAILX	(1<<6)
#define SENDKEY		(1<<7)
310
#define SENDRESEND	(1<<8)
311
#define SENDPOSTPONEDFCC	(1<<9) /* used by mutt_get_postponed() to signal that the x-mutt-fcc header field was present */
312
#define SENDNOFREEHEADER	(1<<10)   /* Used by the -E flag */
313
#define SENDDRAFTFILE		(1<<11)   /* Used by the -H flag */
314 315

/* flags for mutt_compose_menu() */
316
#define MUTT_COMPOSE_NOFREEHEADER (1<<0)
Thomas Roessler's avatar
Thomas Roessler committed
317

318
/* flags to _mutt_select_file() */
319 320 321
#define MUTT_SEL_BUFFY  (1<<0)
#define MUTT_SEL_MULTI  (1<<1)
#define MUTT_SEL_FOLDER (1<<2)
322

323
/* flags for parse_spam_list */
324 325
#define MUTT_SPAM          1
#define MUTT_NOSPAM        2
326

Thomas Roessler's avatar
Thomas Roessler committed
327 328 329 330
/* boolean vars */
enum
{
  OPTALLOW8BIT,
331
  OPTALLOWANSI,
Thomas Roessler's avatar
Thomas Roessler committed
332
  OPTARROWCURSOR,
Thomas Roessler's avatar
Thomas Roessler committed
333 334
  OPTASCIICHARS,
  OPTASKBCC,
Thomas Roessler's avatar
Thomas Roessler committed
335
  OPTASKCC,
Thomas Roessler's avatar
Thomas Roessler committed
336 337 338 339 340
  OPTATTACHSPLIT,
  OPTAUTOEDIT,
  OPTAUTOTAG,
  OPTBEEP,
  OPTBEEPNEW,
Thomas Roessler's avatar
Thomas Roessler committed
341
  OPTBOUNCEDELIVERED,
342
  OPTBRAILLEFRIENDLY,
343
  OPTCHECKMBOXSIZE,
Thomas Roessler's avatar
Thomas Roessler committed
344
  OPTCHECKNEW,
345
  OPTCOLLAPSEUNREAD,
Thomas Roessler's avatar
Thomas Roessler committed
346 347
  OPTCONFIRMAPPEND,
  OPTCONFIRMCREATE,
348
  OPTDELETEUNTAG,
349
  OPTDIGESTCOLLAPSE,
350
  OPTDUPTHREADS,
Thomas Roessler's avatar
Thomas Roessler committed
351
  OPTEDITHDRS,
352
  OPTENCODEFROM,
353
  OPTENVFROM,
Thomas Roessler's avatar
Thomas Roessler committed
354
  OPTFASTREPLY,
355
  OPTFCCCLEAR,
356
  OPTFLAGSAFE,
Thomas Roessler's avatar
Thomas Roessler committed
357 358 359 360
  OPTFOLLOWUPTO,
  OPTFORCENAME,
  OPTFORWDECODE,
  OPTFORWQUOTE,
361
#ifdef USE_HCACHE
Thomas Glanzmann's avatar
Thomas Glanzmann committed
362
  OPTHCACHEVERIFY,
363
#if defined(HAVE_QDBM) || defined(HAVE_TC)
364 365
  OPTHCACHECOMPRESS,
#endif /* HAVE_QDBM */
Thomas Glanzmann's avatar
Thomas Glanzmann committed
366
#endif
Thomas Roessler's avatar
Thomas Roessler committed
367
  OPTHDRS,
Thomas Roessler's avatar
Thomas Roessler committed
368
  OPTHEADER,
Thomas Roessler's avatar
Thomas Roessler committed
369 370
  OPTHELP,
  OPTHIDDENHOST,
371
  OPTHIDELIMITED,
372
  OPTHIDEMISSING,
373
  OPTHIDETHREADSUBJECT,
374 375
  OPTHIDETOPLIMITED,
  OPTHIDETOPMISSING,
376
  OPTHONORDISP,
377
  OPTIGNORELWS,
Thomas Roessler's avatar
Thomas Roessler committed
378
  OPTIGNORELISTREPLYTO,
379
#ifdef USE_IMAP
380
  OPTIMAPCHECKSUBSCRIBED,
381
  OPTIMAPIDLE,
382 383
  OPTIMAPLSUB,
  OPTIMAPPASSIVE,
384
  OPTIMAPPEEK,
385
  OPTIMAPSERVERNOISE,
386
#endif
387 388
#if defined(USE_SSL)
# ifndef USE_SSL_GNUTLS
389
  OPTSSLSYSTEMCERTS,
390
  OPTSSLV2,
391
# endif /* USE_SSL_GNUTLS */
392 393
  OPTSSLV3,
  OPTTLSV1,
394 395
  OPTTLSV1_1,
  OPTTLSV1_2,
396
  OPTSSLFORCETLS,
397
  OPTSSLVERIFYDATES,
398
  OPTSSLVERIFYHOST,
399
#endif /* defined(USE_SSL) */
400
  OPTIMPLICITAUTOVIEW,
401
  OPTINCLUDEONLYFIRST,
402
  OPTKEEPFLAGGED,
403
  OPTMAILCAPSANITIZE,
404
  OPTMAILCHECKRECENT,
405
  OPTMAILCHECKSTATS,
406
  OPTMAILDIRTRASH,
407
  OPTMAILDIRCHECKCUR,
Thomas Roessler's avatar
Thomas Roessler committed
408 409 410
  OPTMARKERS,
  OPTMARKOLD,
  OPTMENUSCROLL,	/* scroll menu instead of implicit next-page */
411
  OPTMENUMOVEOFF,	/* allow menu to scroll past last entry */
412 413 414
#if defined(USE_IMAP) || defined(USE_POP)
  OPTMESSAGECACHECLEAN,
#endif
Thomas Roessler's avatar
Thomas Roessler committed
415 416
  OPTMETAKEY,		/* interpret ALT-x as ESC-x */
  OPTMETOO,
417
  OPTMHPURGE,
Thomas Roessler's avatar
Thomas Roessler committed
418
  OPTMIMEFORWDECODE,
419
  OPTNARROWTREE,
Thomas Roessler's avatar
Thomas Roessler committed
420 421 422
  OPTPAGERSTOP,
  OPTPIPEDECODE,
  OPTPIPESPLIT,
423 424
#ifdef USE_POP
  OPTPOPAUTHTRYALL,
425
  OPTPOPLAST,
426
#endif
427
  OPTPOSTPONEENCRYPT,
428
  OPTPRINTDECODE,
429
  OPTPRINTSPLIT,
Thomas Roessler's avatar
Thomas Roessler committed
430 431
  OPTPROMPTAFTER,
  OPTREADONLY,
432
  OPTREFLOWSPACEQUOTES,
433
  OPTREFLOWTEXT,
434
  OPTREPLYSELF,
Thomas Roessler's avatar
Thomas Roessler committed
435
  OPTRESOLVE,
436
  OPTRESUMEDRAFTFILES,
437
  OPTRESUMEEDITEDDRAFTFILES,
Thomas Roessler's avatar
Thomas Roessler committed
438 439
  OPTREVALIAS,
  OPTREVNAME,
440
  OPTREVREAL,
Thomas Roessler's avatar
Thomas Roessler committed
441
  OPTRFC2047PARAMS,
Thomas Roessler's avatar
Thomas Roessler committed
442
  OPTSAVEADDRESS,
Thomas Roessler's avatar
Thomas Roessler committed
443
  OPTSAVEEMPTY,
Thomas Roessler's avatar
Thomas Roessler committed
444
  OPTSAVENAME,
Thomas Roessler's avatar
Thomas Roessler committed
445
  OPTSCORE,
446 447 448 449 450 451 452
#ifdef USE_SIDEBAR
  OPTSIDEBAR,
  OPTSIDEBARFOLDERINDENT,
  OPTSIDEBARNEWMAILONLY,
  OPTSIDEBARNEXTNEWWRAP,
  OPTSIDEBARSHORTPATH,
#endif
Thomas Roessler's avatar
Thomas Roessler committed
453
  OPTSIGDASHES,
454
  OPTSIGONTOP,
Thomas Roessler's avatar
Thomas Roessler committed
455
  OPTSORTRE,
456
  OPTSPAMSEP,
Thomas Roessler's avatar
Thomas Roessler committed
457 458 459
  OPTSTATUSONTOP,
  OPTSTRICTTHREADS,
  OPTSUSPEND,
460
  OPTTEXTFLOWED,
Thomas Roessler's avatar
Thomas Roessler committed
461
  OPTTHOROUGHSRC,
462
  OPTTHREADRECEIVED,
Thomas Roessler's avatar
Thomas Roessler committed
463
  OPTTILDE,
464
  OPTTSENABLED,
465
  OPTUNCOLLAPSEJUMP,
466
  OPTUNCOLLAPSENEW,
Thomas Roessler's avatar
Thomas Roessler committed
467 468 469
  OPTUSE8BITMIME,
  OPTUSEDOMAIN,
  OPTUSEFROM,
470
  OPTUSEGPGAGENT,
471
#ifdef HAVE_LIBIDN
472 473
  OPTIDNDECODE,
  OPTIDNENCODE,
474
#endif
475 476 477
#ifdef HAVE_GETADDRINFO
  OPTUSEIPV6,
#endif
Thomas Roessler's avatar
Thomas Roessler committed
478 479 480 481 482
  OPTWAITKEY,
  OPTWEED,
  OPTWRAP,
  OPTWRAPSEARCH,
  OPTWRITEBCC,		/* write out a bcc header? */
483
  OPTXMAILER,
484

485
  OPTCRYPTUSEGPGME,
486
  OPTCRYPTUSEPKA,
487

Thomas Roessler's avatar
Thomas Roessler committed
488 489
  /* PGP options */
  
490 491
  OPTCRYPTAUTOSIGN,
  OPTCRYPTAUTOENCRYPT,
492 493
  OPTCRYPTAUTOPGP,
  OPTCRYPTAUTOSMIME,
494
  OPTCRYPTCONFIRMHOOK,
495
  OPTCRYPTOPPORTUNISTICENCRYPT,
496 497 498
  OPTCRYPTREPLYENCRYPT,
  OPTCRYPTREPLYSIGN,
  OPTCRYPTREPLYSIGNENCRYPTED,
499
  OPTCRYPTTIMESTAMP,
500
  OPTSMIMEISDEFAULT,
Thomas Roessler's avatar
Thomas Roessler committed
501
  OPTASKCERTLABEL,
502
  OPTSDEFAULTDECRYPTKEY,
503
  OPTPGPIGNORESUB,
504
  OPTPGPCHECKEXIT,
Thomas Roessler's avatar
Thomas Roessler committed
505
  OPTPGPLONGIDS,
506
  OPTPGPAUTODEC,
507
#if 0
Thomas Roessler's avatar
Thomas Roessler committed
508
  OPTPGPENCRYPTSELF,
509
#endif
510
  OPTPGPRETAINABLESIG,
Thomas Roessler's avatar
Thomas Roessler committed
511
  OPTPGPSTRICTENC,
512
  OPTFORWDECRYPT,
513
  OPTPGPSHOWUNUSABLE,
514 515
  OPTPGPAUTOINLINE,
  OPTPGPREPLYINLINE,
Thomas Roessler's avatar
Thomas Roessler committed
516 517 518

  /* pseudo options */

Ondřej Bílka's avatar
Ondřej Bílka committed
519
  OPTAUXSORT,		/* (pseudo) using auxiliary sort function */
Thomas Roessler's avatar
Thomas Roessler committed
520 521 522 523 524 525 526 527
  OPTFORCEREFRESH,	/* (pseudo) refresh even during macros */
  OPTLOCALES,		/* (pseudo) set if user has valid locale definition */
  OPTNOCURSES,		/* (pseudo) when sending in batch mode */
  OPTNEEDREDRAW,	/* (pseudo) to notify caller of a submenu */
  OPTSEARCHREVERSE,	/* (pseudo) used by ci_search_command */
  OPTMSGERR,		/* (pseudo) used by mutt_error/mutt_message */
  OPTSEARCHINVALID,	/* (pseudo) used to invalidate the search pat */
  OPTSIGNALSBLOCKED,	/* (pseudo) using by mutt_block_signals () */
528
  OPTSYSSIGNALSBLOCKED,	/* (pseudo) using by mutt_block_signals_system () */
Thomas Roessler's avatar
Thomas Roessler committed
529
  OPTNEEDRESORT,	/* (pseudo) used to force a re-sort */
530
  OPTRESORTINIT,	/* (pseudo) used to force the next resort to be from scratch */
Thomas Roessler's avatar
Thomas Roessler committed
531 532 533 534 535
  OPTVIEWATTACH,	/* (pseudo) signals that we are viewing attachments */
  OPTFORCEREDRAWINDEX,	/* (pseudo) used to force a redraw in the main index */
  OPTFORCEREDRAWPAGER,	/* (pseudo) used to force a redraw in the pager */
  OPTSORTSUBTHREADS,	/* (pseudo) used when $sort_aux changes */
  OPTNEEDRESCORE,	/* (pseudo) set when the `score' command is used */
536
  OPTATTACHMSG,		/* (pseudo) used by attach-message */
537 538 539 540
  OPTKEEPQUIET,		/* (pseudo) shut up the message and refresh
			 * 	    functions while we are executing an
			 * 	    external program.
			 */
541
  OPTMENUCALLER,	/* (pseudo) tell menu to give caller a take */
542
  OPTREDRAWTREE,	/* (pseudo) redraw the thread tree */
Thomas Roessler's avatar
Thomas Roessler committed
543 544
  OPTPGPCHECKTRUST,	/* (pseudo) used by pgp_select_key () */
  OPTDONTHANDLEPGPKEYS,	/* (pseudo) used to extract PGP keys */
545
  OPTIGNOREMACROEVENTS, /* (pseudo) don't process macro/push/exec events while set */
Thomas Roessler's avatar
Thomas Roessler committed
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566

  OPTMAX
};

#define mutt_bit_alloc(n) calloc ((n + 7) / 8, sizeof (char))
#define mutt_bit_set(v,n) v[n/8] |= (1 << (n % 8))
#define mutt_bit_unset(v,n) v[n/8] &= ~(1 << (n % 8))
#define mutt_bit_toggle(v,n) v[n/8] ^= (1 << (n % 8))
#define mutt_bit_isset(v,n) (v[n/8] & (1 << (n % 8)))

#define set_option(x) mutt_bit_set(Options,x)
#define unset_option(x) mutt_bit_unset(Options,x)
#define toggle_option(x) mutt_bit_toggle(Options,x)
#define option(x) mutt_bit_isset(Options,x)

typedef struct list_t
{
  char *data;
  struct list_t *next;
} LIST;

567 568 569 570 571 572
typedef struct rx_list_t
{
  REGEXP *rx;
  struct rx_list_t *next;
} RX_LIST;

573
typedef struct replace_list_t
574 575 576 577
{
  REGEXP *rx;
  int     nmatch;
  char   *template;
578 579
  struct replace_list_t *next;
} REPLACE_LIST;
580

Thomas Roessler's avatar
Thomas Roessler committed
581
#define mutt_new_list() safe_calloc (1, sizeof (LIST))
582
#define mutt_new_rx_list() safe_calloc (1, sizeof (RX_LIST))
583
#define mutt_new_replace_list() safe_calloc (1, sizeof (REPLACE_LIST))
Thomas Roessler's avatar
Thomas Roessler committed
584
void mutt_free_list (LIST **);
585
void mutt_free_rx_list (RX_LIST **);
586
void mutt_free_replace_list (REPLACE_LIST **);
587
LIST *mutt_copy_list (LIST *);
Thomas Roessler's avatar
Thomas Roessler committed
588 589 590 591
int mutt_matches_ignore (const char *, LIST *);

/* add an element to a list */
LIST *mutt_add_list (LIST *, const char *);
592
LIST *mutt_add_list_n (LIST*, const void *, size_t);
593
LIST *mutt_find_list (LIST *, const char *);
594
int mutt_remove_from_rx_list (RX_LIST **l, const char *str);
Thomas Roessler's avatar
Thomas Roessler committed
595 596 597 598 599

void mutt_init (int, LIST *);

typedef struct alias
{
600
  struct alias *self;		/* XXX - ugly hack */
Thomas Roessler's avatar
Thomas Roessler committed
601 602 603 604
  char *name;
  ADDRESS *addr;
  struct alias *next;
  short tagged;
605
  short del;
Thomas Roessler's avatar
Thomas Roessler committed
606 607 608 609 610 611 612 613 614 615 616 617 618
  short num;
} ALIAS;

typedef struct envelope
{
  ADDRESS *return_path;
  ADDRESS *from;
  ADDRESS *to;
  ADDRESS *cc;
  ADDRESS *bcc;
  ADDRESS *sender;
  ADDRESS *reply_to;
  ADDRESS *mail_followup_to;
619
  char *list_post;		/* this stores a mailto URL, or nothing */
Thomas Roessler's avatar
Thomas Roessler committed
620 621
  char *subject;
  char *real_subj;		/* offset of the real subject */
622
  char *disp_subj;		/* display subject (modified copy of subject) */
Thomas Roessler's avatar
Thomas Roessler committed
623 624
  char *message_id;
  char *supersedes;
625
  char *date;
626
  char *x_label;
627
  BUFFER *spam;
Thomas Roessler's avatar
Thomas Roessler committed
628
  LIST *references;		/* message references (in reverse order) */
629
  LIST *in_reply_to;		/* in-reply-to header content */
Thomas Roessler's avatar
Thomas Roessler committed
630
  LIST *userhdrs;		/* user defined headers */
631 632 633

  unsigned int irt_changed : 1; /* In-Reply-To changed to link/break threads */
  unsigned int refs_changed : 1; /* References changed to break thread */
Thomas Roessler's avatar
Thomas Roessler committed
634 635 636 637 638 639 640 641 642 643 644 645 646 647
} ENVELOPE;

typedef struct parameter
{
  char *attribute;
  char *value;
  struct parameter *next;
} PARAMETER;

/* Information that helps in determing the Content-* of an attachment */
typedef struct content
{
  long hibin;              /* 8-bit characters */
  long lobin;              /* unprintable 7-bit chars (eg., control chars) */
648
  long crlf;		   /* '\r' and '\n' characters */
Thomas Roessler's avatar
Thomas Roessler committed
649 650 651 652 653 654
  long ascii;              /* number of ascii chars */
  long linemax;            /* length of the longest line in the file */
  unsigned int space : 1;  /* whitespace at the end of lines? */
  unsigned int binary : 1; /* long lines, or CR not in CRLF pair */
  unsigned int from : 1;   /* has a line beginning with "From "? */
  unsigned int dot : 1;    /* has a line consisting of a single dot? */
655
  unsigned int cr : 1;     /* has CR, even when in a CRLF pair */
Thomas Roessler's avatar
Thomas Roessler committed
656 657 658 659
} CONTENT;

typedef struct body
{
Thomas Roessler's avatar
Thomas Roessler committed
660
  char *xtype;			/* content-type if x-unknown */
Thomas Roessler's avatar
Thomas Roessler committed
661 662 663 664 665 666 667 668 669
  char *subtype;                /* content-type subtype */
  PARAMETER *parameter;         /* parameters of the content-type */
  char *description;            /* content-description */
  char *form_name;		/* Content-Disposition form-data name param */
  long hdr_offset;              /* offset in stream where the headers begin.
				 * this info is used when invoking metamail,
				 * where we need to send the headers of the
				 * attachment
				 */
670 671
  LOFF_T offset;                /* offset where the actual data begins */
  LOFF_T length;                /* length (in bytes) of attachment */
Thomas Roessler's avatar
Thomas Roessler committed
672 673 674 675 676 677 678 679
  char *filename;               /* when sending a message, this is the file
				 * to which this structure refers
				 */
  char *d_filename;		/* filename to be used for the 
				 * content-disposition header.
				 * If NULL, filename is used 
				 * instead.
				 */
680
  char *charset;                /* charset of attached file */
Thomas Roessler's avatar
Thomas Roessler committed
681 682 683 684 685 686 687 688 689
  CONTENT *content;             /* structure used to store detailed info about
				 * the content of the attachment.  this is used
				 * to determine what content-transfer-encoding
				 * is required when sending mail.
				 */
  struct body *next;            /* next attachment in the list */
  struct body *parts;           /* parts of a multipart or message/rfc822 */
  struct header *hdr;		/* header information for message/rfc822 */

690
  struct attachptr *aptr;	/* Menu information, used in recvattach.c */
691 692 693

  signed short attach_count;

Thomas Roessler's avatar
Thomas Roessler committed
694 695 696 697
  time_t stamp;			/* time stamp of last
				 * encoding update.
				 */
  
698
  unsigned int type : 4;        /* content-type primary type */
Thomas Roessler's avatar
Thomas Roessler committed
699 700
  unsigned int encoding : 3;    /* content-transfer-encoding */
  unsigned int disposition : 2; /* content-disposition */
701
  unsigned int use_disp : 1;    /* Content-Disposition uses filename= ? */
Thomas Roessler's avatar
Thomas Roessler committed
702 703 704 705 706 707
  unsigned int unlink : 1;      /* flag to indicate the the file named by
				 * "filename" should be unlink()ed before
				 * free()ing this structure
				 */
  unsigned int tagged : 1;
  unsigned int deleted : 1;	/* attachment marked for deletion */
708

709
  unsigned int noconv : 1;	/* don't do character set conversion */
710 711 712 713
  unsigned int force_charset : 1; 
  				/* send mode: don't adjust the character
				 * set when in send-mode.
				 */
714 715 716 717 718 719 720 721 722 723 724
  unsigned int is_signed_data : 1; /* A lot of MUAs don't indicate
                                      S/MIME signed-data correctly,
                                      e.g. they use foo.p7m even for
                                      the name of signed data.  This
                                      flag is used to keep track of
                                      the actual message type.  It
                                      gets set during the verification
                                      (which is done if the encryption
                                      try failed) and check by the
                                      function to figure the type of
                                      the message. */
Thomas Roessler's avatar
Thomas Roessler committed
725

726
  unsigned int goodsig : 1;	/* good cryptographic signature */
727
  unsigned int warnsig : 1;     /* maybe good signature */
728
  unsigned int badsig : 1;	/* bad cryptographic signature (needed to check encrypted s/mime-signatures) */
Thomas Roessler's avatar
Thomas Roessler committed
729

730
  unsigned int collapsed : 1;	/* used by recvattach */
731
  unsigned int attach_qualifies : 1;
732

Thomas Roessler's avatar
Thomas Roessler committed
733 734
} BODY;

735 736 737
/* #3279: AIX defines conflicting struct thread */
typedef struct mutt_thread THREAD;

Thomas Roessler's avatar
Thomas Roessler committed
738 739
typedef struct header
{
740 741
  unsigned int security : 12;  /* bit 0-8: flags, bit 9,10: application.
				 see: mutt_crypt.h pgplib.h, smime.h */
742

743
  unsigned int mime : 1;    		/* has a MIME-Version header? */
744
  unsigned int flagged : 1; 		/* marked important? */
Thomas Roessler's avatar
Thomas Roessler committed
745 746
  unsigned int tagged : 1;
  unsigned int deleted : 1;
747
  unsigned int purge : 1;               /* skip trash folder when deleting */
Thomas Roessler's avatar
Thomas Roessler committed
748
  unsigned int changed : 1;
749
  unsigned int attach_del : 1; 		/* has an attachment marked for deletion */
Thomas Roessler's avatar
Thomas Roessler committed
750 751
  unsigned int old : 1;
  unsigned int read : 1;
752 753
  unsigned int expired : 1; 		/* already expired? */
  unsigned int superseded : 1; 		/* got superseded? */
Thomas Roessler's avatar
Thomas Roessler committed
754
  unsigned int replied : 1;
755 756 757 758 759 760 761 762 763
  unsigned int subject_changed : 1; 	/* used for threading */
  unsigned int threaded : 1;	    	/* used for threading */
  unsigned int display_subject : 1; 	/* used for threading */
  unsigned int recip_valid : 1;  	/* is_recipient is valid */
  unsigned int active : 1;	    	/* message is not to be removed */
  unsigned int trash : 1;		/* message is marked as trashed on disk.
					 * This flag is used by the maildir_trash
					 * option.
					 */
764
  unsigned int xlabel_changed : 1;	/* editable - used for syncing */
765
  
Thomas Roessler's avatar
Thomas Roessler committed
766 767 768 769 770 771 772 773 774
  /* timezone of the sender of this message */
  unsigned int zhours : 5;
  unsigned int zminutes : 6;
  unsigned int zoccident : 1;

  /* bits used for caching when searching */
  unsigned int searched : 1;
  unsigned int matched : 1;

775 776 777
  /* tells whether the attachment count is valid */
  unsigned int attach_valid : 1;

778
  /* the following are used to support collapsing threads  */
779 780 781
  unsigned int collapsed : 1; 	/* is this message part of a collapsed thread? */
  unsigned int limited : 1;   	/* is this message in a limited view?  */
  size_t num_hidden;          	/* number of hidden messages in this view */
782

783
  short recipient;		/* user_is_recipient()'s return value, cached */
784
  
785 786 787 788
  int pair; 			/* color-pair to use when displaying in the index */

  time_t date_sent;     	/* time when the message was sent (UTC) */
  time_t received;      	/* time when the message was placed in the mailbox */
789
  LOFF_T offset;          	/* where in the stream does this message begin? */
790 791 792 793
  int lines;			/* how many lines in the body of this message? */
  int index;			/* the absolute (unsorted) message number */
  int msgno;			/* number displayed to the user */
  int virtual;			/* virtual message number */
Thomas Roessler's avatar
Thomas Roessler committed
794
  int score;
795 796
  ENVELOPE *env;		/* envelope information */
  BODY *content;		/* list of MIME parts */
Thomas Roessler's avatar
Thomas Roessler committed
797 798
  char *path;
  
799
  char *tree;           	/* character string to print thread tree */
800
  THREAD *thread;
Thomas Roessler's avatar
Thomas Roessler committed
801

802 803 804
  /* Number of qualifying attachments in message, if attach_valid */
  short attach_total;

805 806 807
#ifdef MIXMASTER
  LIST *chain;
#endif
808

809
#ifdef USE_POP
810
  int refno;			/* message number on server */
811 812 813
#endif

#if defined USE_POP || defined USE_IMAP
814
  void *data;            	/* driver-specific data */
815
#endif
816 817
  
  char *maildir_flags;		/* unknown maildir flags */
Thomas Roessler's avatar
Thomas Roessler committed
818 819
} HEADER;

820
struct mutt_thread
821 822
{
  unsigned int fake_thread : 1;
823 824 825
  unsigned int duplicate_thread : 1;
  unsigned int sort_children : 1;
  unsigned int check_subject : 1;
826 827 828 829
  unsigned int visible : 1;
  unsigned int deep : 1;
  unsigned int subtree_visible : 2;
  unsigned int next_subtree_visible : 1;
830 831 832 833
  THREAD *parent;
  THREAD *child;
  THREAD *next;
  THREAD *prev;
834 835
  HEADER *message;
  HEADER *sort_key;
836
};
837

Thomas Roessler's avatar
Thomas Roessler committed
838 839

/* flag to mutt_pattern_comp() */
840
#define MUTT_FULL_MSG	(1<<0)	/* enable body and header matching */
Thomas Roessler's avatar
Thomas Roessler committed
841 842

typedef enum {
843
  MUTT_MATCH_FULL_ADDRESS = 1
Thomas Roessler's avatar
Thomas Roessler committed
844 845
} pattern_exec_flag;

846 847 848 849 850 851 852 853 854 855 856 857 858
typedef struct group_t
{
  ADDRESS *as;
  RX_LIST *rs;
  char *name;
} group_t;

typedef struct group_context_t
{
  group_t *g;
  struct group_context_t *next;
} group_context_t;

Thomas Roessler's avatar
Thomas Roessler committed
859 860 861
typedef struct pattern_t
{
  short op;
862 863 864
  unsigned int not : 1;
  unsigned int alladdr : 1;
  unsigned int stringmatch : 1;
865
  unsigned int groupmatch : 1;
866
  unsigned int ign_case : 1;		/* ignore case for local stringmatch searches */
867
  unsigned int isalias : 1;
Thomas Roessler's avatar
Thomas Roessler committed
868 869 870 871
  int min;
  int max;
  struct pattern_t *next;
  struct pattern_t *child;		/* arguments to logical op */
872 873 874 875 876 877
  union 
  {
    regex_t *rx;
    group_t *g;
    char *str;
  } p;
Thomas Roessler's avatar
Thomas Roessler committed
878 879
} pattern_t;

880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896
/* This is used when a message is repeatedly pattern matched against.
 * e.g. for color, scoring, hooks.  It caches a few of the potentially slow
 * operations.
 * Each entry has a value of 0 = unset, 1 = false, 2 = true
 */
typedef struct
{
  int list_all;          /* ^~l */
  int list_one;          /*  ~l */
  int sub_all;           /* ^~u */
  int sub_one;           /*  ~u */
  int pers_recip_all;    /* ^~p */
  int pers_recip_one;    /*  ~p */
  int pers_from_all;     /* ^~P */
  int pers_from_one;     /*  ~P */
} pattern_cache_t;

Rocco Rutte's avatar
Rocco Rutte committed
897 898 899
/* ACL Rights */
enum
{
900 901 902 903 904 905 906 907 908 909 910
  MUTT_ACL_LOOKUP = 0,
  MUTT_ACL_READ,
  MUTT_ACL_SEEN,
  MUTT_ACL_WRITE,
  MUTT_ACL_INSERT,
  MUTT_ACL_POST,
  MUTT_ACL_CREATE,
  MUTT_ACL_DELMX,
  MUTT_ACL_DELETE,
  MUTT_ACL_EXPUNGE,
  MUTT_ACL_ADMIN,
Rocco Rutte's avatar
Rocco Rutte committed
911 912 913 914

  RIGHTSMAX
};

915
struct _context;
916
struct _message;
917

918 919 920 921 922
/*
 * struct mx_ops - a structure to store operations on a mailbox
 * The following operations are mandatory:
 *  - open
 *  - close
923
 *  - check
924 925 926 927
 *
 * Optional operations
 *  - open_new_msg
 */
928 929
struct mx_ops
{
930 931 932
  int (*open) (struct _context *);
  int (*open_append) (struct _context *, int flags);
  int (*close) (struct _context *);
933
  int (*check) (struct _context *ctx, int *index_hint);
934
  int (*sync) (struct _context *ctx, int *index_hint);
935
  int (*open_msg) (struct _context *, struct _message *, int msgno);
936
  int (*close_msg) (struct _context *, struct _message *);
937
  int (*commit_msg) (struct _context *, struct _message *);
938
  int (*open_new_msg) (struct _message *, struct _context *, HEADER *);
939 940
};

941
typedef struct _context
Thomas Roessler's avatar
Thomas Roessler committed
942 943
{
  char *path;
944
  char *realpath;               /* used for buffy comparison and the sidebar */
Thomas Roessler's avatar
Thomas Roessler committed
945
  FILE *fp;
946
  time_t atime;
Thomas Roessler's avatar
Thomas Roessler committed
947 948 949 950 951 952
  time_t mtime;
  off_t size;
  off_t vsize;
  char *pattern;                /* limit pattern string */
  pattern_t *limit_pattern;     /* compiled limit pattern */
  HEADER **hdrs;
953
  HEADER *last_tag;		/* last tagged msg. used to link threads */
954
  THREAD *tree;			/* top of thread tree */
Thomas Roessler's avatar
Thomas Roessler committed
955 956
  HASH *id_hash;		/* hash table by msg id */
  HASH *subj_hash;		/* hash table by subject */
957
  HASH *thread_hash;		/* hash table for threading */
958
  HASH *label_hash;             /* hash table for x-labels */
Thomas Roessler's avatar
Thomas Roessler committed
959 960 961 962 963 964 965 966 967 968 969 970 971
  int *v2r;			/* mapping from virtual to real msgno */
  int hdrmax;			/* number of pointers in hdrs */
  int msgcount;			/* number of messages in the mailbox */
  int vcount;			/* the number of virtual messages */
  int tagged;			/* how many messages are tagged? */
  int new;			/* how many new messages? */
  int unread;			/* how many unread messages? */
  int deleted;			/* how many deleted messages */
  int flagged;			/* how many flagged messages */
  int msgnotreadyet;		/* which msg "new" in pager, -1 if none */

  short magic;			/* mailbox type */

Rocco Rutte's avatar
Rocco Rutte committed
972 973
  unsigned char rights[(RIGHTSMAX + 7)/8];	/* ACL bits */

Thomas Roessler's avatar
Thomas Roessler committed
974 975 976
  unsigned int locked : 1;	/* is the mailbox locked? */
  unsigned int changed : 1;	/* mailbox has been modified */
  unsigned int readonly : 1;    /* don't allow changes to the mailbox */
Ondřej Bílka's avatar
Ondřej Bílka committed
977
  unsigned int dontwrite : 1;   /* don't write the mailbox on close */
Thomas Roessler's avatar
Thomas Roessler committed
978 979
  unsigned int append : 1;	/* mailbox is opened in append mode */
  unsigned int quiet : 1;	/* inhibit status messages? */
980
  unsigned int collapsed : 1;   /* are all threads collapsed? */
981
  unsigned int closing : 1;	/* mailbox is being closed */
982
  unsigned int peekonly : 1;	/* just taking a glance, revert atime */
983

984 985 986 987
#ifdef USE_COMPRESSED
  void *compress_info;		/* compressed mbox module private data */
#endif /* USE_COMPRESSED */

988 989
  /* driver hooks */
  void *data;			/* driver specific data */
990
  struct mx_ops *mx_ops;
Thomas Roessler's avatar
Thomas Roessler committed
991 992 993 994 995 996 997 998 999 1000
} CONTEXT;

typedef struct
{
  FILE *fpin;
  FILE *fpout;
  char *prefix;
  int flags;
} STATE;

1001 1002 1003 1004 1005 1006
/* used by enter.c */

typedef struct
{
  wchar_t *wbuf;
  size_t wbuflen;
1007
  size_t lastchar;
1008 1009
  size_t curpos;
  size_t begin;
1010
  int	 tabs;
1011 1012
} ENTER_STATE;

Thomas Roessler's avatar
Thomas Roessler committed
1013
/* flags for the STATE struct */
1014 1015
#define MUTT_DISPLAY       (1<<0) /* output is displayed to the user */
#define MUTT_VERIFY        (1<<1) /* perform signature verification */
1016 1017
#define MUTT_PENDINGPREFIX (1<<2) /* prefix to write, but character must follow */
#define MUTT_WEED          (1<<3) /* weed headers even when not in display mode */
1018 1019 1020 1021
#define MUTT_CHARCONV      (1<<4) /* Do character set conversions */
#define MUTT_PRINTING      (1<<5) /* are we printing? - MUTT_DISPLAY "light" */
#define MUTT_REPLYING      (1<<6) /* are we replying? */
#define MUTT_FIRSTDONE     (1<<7) /* the first attachment has been done */
1022 1023 1024

#define state_set_prefix(s) ((s)->flags |= MUTT_PENDINGPREFIX)
#define state_reset_prefix(s) ((s)->flags &= ~MUTT_PENDINGPREFIX)
Thomas Roessler's avatar
Thomas Roessler committed
1025 1026 1027
#define state_puts(x,y) fputs(x,(y)->fpout)
#define state_putc(x,y) fputc(x,(y)->fpout)

1028 1029 1030
void state_mark_attach (STATE *);
void state_attach_puts (const char *, STATE *);
void state_prefix_putc (char, STATE *);
1031
int  state_printf(STATE *, const char *, ...);
1032 1033
int state_putwc (wchar_t, STATE *);
int state_putws (const wchar_t *, STATE *);
1034

1035 1036 1037 1038 1039 1040 1041 1042 1043
/* for attachment counter */
typedef struct
{
  char   *major;
  int     major_int;
  char   *minor;
  regex_t minor_rx;
} ATTACH_MATCH;

1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054
/* multibyte character table.
 * Allows for direct access to the individual multibyte characters in a
 * string.  This is used for the Tochars and StChars option types. */
typedef struct
{
  int len;               /* number of characters */
  char **chars;          /* the array of multibyte character strings */
  char *segmented_str;   /* each chars entry points inside this string */
  char *orig_str;
} mbchar_table;

1055
#define MUTT_PARTS_TOPLEVEL	(1<<0)	/* is the top-level part */
1056

1057
#include "ascii.h"
Thomas Roessler's avatar
Thomas Roessler committed
1058
#include "protos.h"
1059
#include "lib.h"
Thomas Roessler's avatar
Thomas Roessler committed
1060
#include "globals.h"
1061 1062

#endif /*MUTT_H*/