mutt stable branch with some hacks
at master 1058 lines 30 kB view raw
1 2/* 3 * Copyright (C) 1996-2002,2010,2013 Michael R. Elkins <me@mutt.org> 4 * Copyright (C) 2004 g10 Code GmbH 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 */ 20 21#ifndef MUTT_H 22#define MUTT_H 23 24#include <stdio.h> 25#include <stdlib.h> 26#ifdef HAVE_UNISTD_H 27# include <unistd.h> /* needed for SEEK_SET */ 28#endif 29#ifdef HAVE_UNIX_H 30# include <unix.h> /* needed for snprintf on QNX. */ 31#endif 32#include <sys/types.h> 33#include <sys/stat.h> 34#include <time.h> 35#include <limits.h> 36#include <stdarg.h> 37#include <signal.h> 38/* On OS X 10.5.x, wide char functions are inlined by default breaking 39 * --without-wc-funcs compilation 40 */ 41#ifdef __APPLE_CC__ 42#define _DONT_USE_CTYPE_INLINE_ 43#endif 44#ifdef HAVE_WCHAR_H 45# include <wchar.h> 46#endif 47#if defined(HAVE_WCTYPE_H) && defined(HAVE_WC_FUNCS) 48# include <wctype.h> 49#endif 50 51#ifndef _POSIX_PATH_MAX 52#include <limits.h> 53#endif 54 55/* PATH_MAX is undefined on the hurd */ 56#if !defined(PATH_MAX) && defined(_POSIX_PATH_MAX) 57#define PATH_MAX _POSIX_PATH_MAX 58#endif 59 60#include <pwd.h> 61#include <grp.h> 62 63#include "rfc822.h" 64#include "hash.h" 65#include "charset.h" 66 67#ifndef HAVE_WC_FUNCS 68# ifdef MB_LEN_MAX 69# undef MB_LEN_MAX 70# endif 71# define MB_LEN_MAX 16 72#endif 73 74/* nifty trick I stole from ELM 2.5alpha. */ 75#ifdef MAIN_C 76#define WHERE 77#define INITVAL(x) = x 78#else 79#define WHERE extern 80#define INITVAL(x) 81#endif 82 83#define WHERE_DEFINED 1 84 85#include "mutt_regex.h" 86 87/* flags for mutt_enter_string() */ 88#define MUTT_ALIAS 1 /* do alias "completion" by calling up the alias-menu */ 89#define MUTT_FILE (1<<1) /* do file completion */ 90#define MUTT_EFILE (1<<2) /* do file completion, plus incoming folders */ 91#define MUTT_CMD (1<<3) /* do completion on previous word */ 92#define MUTT_PASS (1<<4) /* password mode (no echo) */ 93#define MUTT_CLEAR (1<<5) /* clear input if printable character is pressed */ 94#define MUTT_COMMAND (1<<6) /* do command completion */ 95#define MUTT_PATTERN (1<<7) /* pattern mode - only used for history classes */ 96 97/* flags for mutt_get_token() */ 98#define MUTT_TOKEN_EQUAL 1 /* treat '=' as a special */ 99#define MUTT_TOKEN_CONDENSE (1<<1) /* ^(char) to control chars (macros) */ 100#define MUTT_TOKEN_SPACE (1<<2) /* don't treat whitespace as a term */ 101#define MUTT_TOKEN_QUOTE (1<<3) /* don't interpret quotes */ 102#define MUTT_TOKEN_PATTERN (1<<4) /* !)|~ are terms (for patterns) */ 103#define MUTT_TOKEN_COMMENT (1<<5) /* don't reap comments */ 104#define MUTT_TOKEN_SEMICOLON (1<<6) /* don't treat ; as special */ 105 106typedef struct 107{ 108 char *data; /* pointer to data */ 109 char *dptr; /* current read/write position */ 110 size_t dsize; /* length of data */ 111 int destroy; /* destroy `data' when done? */ 112} BUFFER; 113 114typedef struct 115{ 116 int ch; /* raw key pressed */ 117 int op; /* function op */ 118} event_t; 119 120/* flags for _mutt_system() */ 121#define MUTT_DETACH_PROCESS 1 /* detach subprocess from group */ 122 123/* flags for mutt_FormatString() */ 124typedef enum 125{ 126 MUTT_FORMAT_FORCESUBJ = (1<<0), /* print the subject even if unchanged */ 127 MUTT_FORMAT_TREE = (1<<1), /* draw the thread tree */ 128 MUTT_FORMAT_MAKEPRINT = (1<<2), /* make sure that all chars are printable */ 129 MUTT_FORMAT_OPTIONAL = (1<<3), 130 MUTT_FORMAT_STAT_FILE = (1<<4), /* used by mutt_attach_fmt */ 131 MUTT_FORMAT_ARROWCURSOR = (1<<5), /* reserve space for arrow_cursor */ 132 MUTT_FORMAT_INDEX = (1<<6), /* this is a main index entry */ 133 MUTT_FORMAT_NOFILTER = (1<<7) /* do not allow filtering on this pass */ 134} format_flag; 135 136/* types for mutt_add_hook() */ 137#define MUTT_FOLDERHOOK 1 138#define MUTT_MBOXHOOK (1<<1) 139#define MUTT_SENDHOOK (1<<2) 140#define MUTT_FCCHOOK (1<<3) 141#define MUTT_SAVEHOOK (1<<4) 142#define MUTT_CHARSETHOOK (1<<5) 143#define MUTT_ICONVHOOK (1<<6) 144#define MUTT_MESSAGEHOOK (1<<7) 145#define MUTT_CRYPTHOOK (1<<8) 146#define MUTT_ACCOUNTHOOK (1<<9) 147#define MUTT_REPLYHOOK (1<<10) 148#define MUTT_SEND2HOOK (1<<11) 149#ifdef USE_COMPRESSED 150#define MUTT_OPENHOOK (1<<12) 151#define MUTT_APPENDHOOK (1<<13) 152#define MUTT_CLOSEHOOK (1<<14) 153#endif 154 155/* tree characters for linearize_tree and print_enriched_string */ 156#define MUTT_TREE_LLCORNER 1 157#define MUTT_TREE_ULCORNER 2 158#define MUTT_TREE_LTEE 3 159#define MUTT_TREE_HLINE 4 160#define MUTT_TREE_VLINE 5 161#define MUTT_TREE_SPACE 6 162#define MUTT_TREE_RARROW 7 163#define MUTT_TREE_STAR 8 164#define MUTT_TREE_HIDDEN 9 165#define MUTT_TREE_EQUALS 10 166#define MUTT_TREE_TTEE 11 167#define MUTT_TREE_BTEE 12 168#define MUTT_TREE_MISSING 13 169#define MUTT_TREE_MAX 14 170 171#define MUTT_THREAD_COLLAPSE (1<<0) 172#define MUTT_THREAD_UNCOLLAPSE (1<<1) 173#define MUTT_THREAD_GET_HIDDEN (1<<2) 174#define MUTT_THREAD_UNREAD (1<<3) 175#define MUTT_THREAD_NEXT_UNREAD (1<<4) 176 177enum 178{ 179 /* modes for mutt_view_attachment() */ 180 MUTT_REGULAR = 1, 181 MUTT_MAILCAP, 182 MUTT_AS_TEXT, 183 184 /* action codes used by mutt_set_flag() and mutt_pattern_function() */ 185 MUTT_ALL, 186 MUTT_NONE, 187 MUTT_NEW, 188 MUTT_OLD, 189 MUTT_REPLIED, 190 MUTT_READ, 191 MUTT_UNREAD, 192 MUTT_DELETE, 193 MUTT_UNDELETE, 194 MUTT_PURGE, 195 MUTT_DELETED, 196 MUTT_FLAG, 197 MUTT_TAG, 198 MUTT_UNTAG, 199 MUTT_LIMIT, 200 MUTT_EXPIRED, 201 MUTT_SUPERSEDED, 202 MUTT_TRASH, 203 204 /* actions for mutt_pattern_comp/mutt_pattern_exec */ 205 MUTT_AND, 206 MUTT_OR, 207 MUTT_THREAD, 208 MUTT_TO, 209 MUTT_CC, 210 MUTT_COLLAPSED, 211 MUTT_SUBJECT, 212 MUTT_FROM, 213 MUTT_DATE, 214 MUTT_DATE_RECEIVED, 215 MUTT_DUPLICATED, 216 MUTT_UNREFERENCED, 217 MUTT_ID, 218 MUTT_BODY, 219 MUTT_HEADER, 220 MUTT_HORMEL, 221 MUTT_WHOLE_MSG, 222 MUTT_SENDER, 223 MUTT_MESSAGE, 224 MUTT_SCORE, 225 MUTT_SIZE, 226 MUTT_REFERENCE, 227 MUTT_RECIPIENT, 228 MUTT_LIST, 229 MUTT_SUBSCRIBED_LIST, 230 MUTT_PERSONAL_RECIP, 231 MUTT_PERSONAL_FROM, 232 MUTT_ADDRESS, 233 MUTT_CRYPT_SIGN, 234 MUTT_CRYPT_VERIFIED, 235 MUTT_CRYPT_ENCRYPT, 236 MUTT_PGP_KEY, 237 MUTT_XLABEL, 238 MUTT_MIMEATTACH, 239 240 /* Options for Mailcap lookup */ 241 MUTT_EDIT, 242 MUTT_COMPOSE, 243 MUTT_PRINT, 244 MUTT_AUTOVIEW, 245 246 /* options for socket code */ 247 MUTT_NEW_SOCKET, 248#ifdef USE_SSL_OPENSSL 249 MUTT_NEW_SSL_SOCKET, 250#endif 251 252 /* Options for mutt_save_attachment */ 253 MUTT_SAVE_APPEND, 254 MUTT_SAVE_OVERWRITE 255}; 256 257/* possible arguments to set_quadoption() */ 258enum 259{ 260 MUTT_NO, 261 MUTT_YES, 262 MUTT_ASKNO, 263 MUTT_ASKYES 264}; 265 266/* quad-option vars */ 267enum 268{ 269 OPT_ABORT, 270 OPT_BOUNCE, 271 OPT_COPY, 272 OPT_DELETE, 273 OPT_FORWEDIT, 274 OPT_FCCATTACH, 275 OPT_INCLUDE, 276 OPT_MFUPTO, 277 OPT_MIMEFWD, 278 OPT_MIMEFWDREST, 279 OPT_MOVE, 280 OPT_PGPMIMEAUTO, /* ask to revert to PGP/MIME when inline fails */ 281#ifdef USE_POP 282 OPT_POPDELETE, 283 OPT_POPRECONNECT, 284#endif 285 OPT_POSTPONE, 286 OPT_PRINT, 287 OPT_QUIT, 288 OPT_REPLYTO, 289 OPT_RECALL, 290#if defined(USE_SSL) 291 OPT_SSLSTARTTLS, 292#endif 293 OPT_SUBJECT, 294 OPT_VERIFYSIG, /* verify PGP signatures */ 295 296 /* THIS MUST BE THE LAST VALUE. */ 297 OPT_MAX 298}; 299 300/* flags to ci_send_message() */ 301#define SENDREPLY (1<<0) 302#define SENDGROUPREPLY (1<<1) 303#define SENDLISTREPLY (1<<2) 304#define SENDFORWARD (1<<3) 305#define SENDPOSTPONED (1<<4) 306#define SENDBATCH (1<<5) 307#define SENDMAILX (1<<6) 308#define SENDKEY (1<<7) 309#define SENDRESEND (1<<8) 310#define SENDPOSTPONEDFCC (1<<9) /* used by mutt_get_postponed() to signal that the x-mutt-fcc header field was present */ 311#define SENDNOFREEHEADER (1<<10) /* Used by the -E flag */ 312#define SENDDRAFTFILE (1<<11) /* Used by the -H flag */ 313 314/* flags for mutt_compose_menu() */ 315#define MUTT_COMPOSE_NOFREEHEADER (1<<0) 316 317/* flags to _mutt_select_file() */ 318#define MUTT_SEL_BUFFY (1<<0) 319#define MUTT_SEL_MULTI (1<<1) 320#define MUTT_SEL_FOLDER (1<<2) 321 322/* flags for parse_spam_list */ 323#define MUTT_SPAM 1 324#define MUTT_NOSPAM 2 325 326/* boolean vars */ 327enum 328{ 329 OPTALLOW8BIT, 330 OPTALLOWANSI, 331 OPTARROWCURSOR, 332 OPTASCIICHARS, 333 OPTASKBCC, 334 OPTASKCC, 335 OPTATTACHSPLIT, 336 OPTAUTOEDIT, 337 OPTAUTOTAG, 338 OPTBEEP, 339 OPTBEEPNEW, 340 OPTBOUNCEDELIVERED, 341 OPTBRAILLEFRIENDLY, 342 OPTCHECKMBOXSIZE, 343 OPTCHECKNEW, 344 OPTCOLLAPSEUNREAD, 345 OPTCONFIRMAPPEND, 346 OPTCONFIRMCREATE, 347 OPTDELETEUNTAG, 348 OPTDIGESTCOLLAPSE, 349 OPTDUPTHREADS, 350 OPTEDITHDRS, 351 OPTENCODEFROM, 352 OPTENVFROM, 353 OPTFASTREPLY, 354 OPTFCCCLEAR, 355 OPTFLAGSAFE, 356 OPTFOLLOWUPTO, 357 OPTFORCENAME, 358 OPTFORWDECODE, 359 OPTFORWQUOTE, 360#ifdef USE_HCACHE 361 OPTHCACHEVERIFY, 362#if defined(HAVE_QDBM) || defined(HAVE_TC) 363 OPTHCACHECOMPRESS, 364#endif /* HAVE_QDBM */ 365#endif 366 OPTHDRS, 367 OPTHEADER, 368 OPTHELP, 369 OPTHIDDENHOST, 370 OPTHIDELIMITED, 371 OPTHIDEMISSING, 372 OPTHIDETHREADSUBJECT, 373 OPTHIDETOPLIMITED, 374 OPTHIDETOPMISSING, 375 OPTHONORDISP, 376 OPTIGNORELWS, 377 OPTIGNORELISTREPLYTO, 378#ifdef USE_IMAP 379 OPTIMAPCHECKSUBSCRIBED, 380 OPTIMAPIDLE, 381 OPTIMAPLSUB, 382 OPTIMAPPASSIVE, 383 OPTIMAPPEEK, 384 OPTIMAPSERVERNOISE, 385#endif 386#if defined(USE_SSL) 387# ifndef USE_SSL_GNUTLS 388 OPTSSLSYSTEMCERTS, 389 OPTSSLV2, 390# endif /* USE_SSL_GNUTLS */ 391 OPTSSLV3, 392 OPTTLSV1, 393 OPTTLSV1_1, 394 OPTTLSV1_2, 395 OPTSSLFORCETLS, 396 OPTSSLVERIFYDATES, 397 OPTSSLVERIFYHOST, 398#endif /* defined(USE_SSL) */ 399 OPTIMPLICITAUTOVIEW, 400 OPTINCLUDEONLYFIRST, 401 OPTKEEPFLAGGED, 402 OPTMAILCAPSANITIZE, 403 OPTMAILCHECKRECENT, 404 OPTMAILCHECKSTATS, 405 OPTMAILDIRTRASH, 406 OPTMAILDIRCHECKCUR, 407 OPTMARKERS, 408 OPTMARKOLD, 409 OPTMENUSCROLL, /* scroll menu instead of implicit next-page */ 410 OPTMENUMOVEOFF, /* allow menu to scroll past last entry */ 411#if defined(USE_IMAP) || defined(USE_POP) 412 OPTMESSAGECACHECLEAN, 413#endif 414 OPTMETAKEY, /* interpret ALT-x as ESC-x */ 415 OPTMETOO, 416 OPTMHPURGE, 417 OPTMIMEFORWDECODE, 418 OPTNARROWTREE, 419 OPTPAGERSTOP, 420 OPTPIPEDECODE, 421 OPTPIPESPLIT, 422#ifdef USE_POP 423 OPTPOPAUTHTRYALL, 424 OPTPOPLAST, 425#endif 426 OPTPOSTPONEENCRYPT, 427 OPTPRINTDECODE, 428 OPTPRINTSPLIT, 429 OPTPROMPTAFTER, 430 OPTREADONLY, 431 OPTREFLOWSPACEQUOTES, 432 OPTREFLOWTEXT, 433 OPTREPLYSELF, 434 OPTRESOLVE, 435 OPTRESUMEDRAFTFILES, 436 OPTRESUMEEDITEDDRAFTFILES, 437 OPTREVALIAS, 438 OPTREVNAME, 439 OPTREVREAL, 440 OPTRFC2047PARAMS, 441 OPTSAVEADDRESS, 442 OPTSAVEEMPTY, 443 OPTSAVENAME, 444 OPTSCORE, 445#ifdef USE_SIDEBAR 446 OPTSIDEBAR, 447 OPTSIDEBARFOLDERINDENT, 448 OPTSIDEBARNEWMAILONLY, 449 OPTSIDEBARNEXTNEWWRAP, 450 OPTSIDEBARSHORTPATH, 451#endif 452 OPTSIGDASHES, 453 OPTSIGONTOP, 454 OPTSORTRE, 455 OPTSPAMSEP, 456 OPTSTATUSONTOP, 457 OPTSTRICTTHREADS, 458 OPTSUSPEND, 459 OPTTEXTFLOWED, 460 OPTTHOROUGHSRC, 461 OPTTHREADRECEIVED, 462 OPTTILDE, 463 OPTTSENABLED, 464 OPTUNCOLLAPSEJUMP, 465 OPTUNCOLLAPSENEW, 466 OPTUSE8BITMIME, 467 OPTUSEDOMAIN, 468 OPTUSEFROM, 469 OPTUSEGPGAGENT, 470#ifdef HAVE_LIBIDN 471 OPTIDNDECODE, 472 OPTIDNENCODE, 473#endif 474#ifdef HAVE_GETADDRINFO 475 OPTUSEIPV6, 476#endif 477 OPTWAITKEY, 478 OPTWEED, 479 OPTWRAP, 480 OPTWRAPSEARCH, 481 OPTWRITEBCC, /* write out a bcc header? */ 482 OPTXMAILER, 483 484 OPTCRYPTUSEGPGME, 485 OPTCRYPTUSEPKA, 486 487 /* PGP options */ 488 489 OPTCRYPTAUTOSIGN, 490 OPTCRYPTAUTOENCRYPT, 491 OPTCRYPTAUTOPGP, 492 OPTCRYPTAUTOSMIME, 493 OPTCRYPTCONFIRMHOOK, 494 OPTCRYPTOPPORTUNISTICENCRYPT, 495 OPTCRYPTREPLYENCRYPT, 496 OPTCRYPTREPLYSIGN, 497 OPTCRYPTREPLYSIGNENCRYPTED, 498 OPTCRYPTTIMESTAMP, 499 OPTSMIMEISDEFAULT, 500 OPTASKCERTLABEL, 501 OPTSDEFAULTDECRYPTKEY, 502 OPTPGPIGNORESUB, 503 OPTPGPCHECKEXIT, 504 OPTPGPLONGIDS, 505 OPTPGPAUTODEC, 506#if 0 507 OPTPGPENCRYPTSELF, 508#endif 509 OPTPGPRETAINABLESIG, 510 OPTPGPSTRICTENC, 511 OPTFORWDECRYPT, 512 OPTPGPSHOWUNUSABLE, 513 OPTPGPAUTOINLINE, 514 OPTPGPREPLYINLINE, 515 516 /* pseudo options */ 517 518 OPTAUXSORT, /* (pseudo) using auxiliary sort function */ 519 OPTFORCEREFRESH, /* (pseudo) refresh even during macros */ 520 OPTLOCALES, /* (pseudo) set if user has valid locale definition */ 521 OPTNOCURSES, /* (pseudo) when sending in batch mode */ 522 OPTNEEDREDRAW, /* (pseudo) to notify caller of a submenu */ 523 OPTSEARCHREVERSE, /* (pseudo) used by ci_search_command */ 524 OPTMSGERR, /* (pseudo) used by mutt_error/mutt_message */ 525 OPTSEARCHINVALID, /* (pseudo) used to invalidate the search pat */ 526 OPTSIGNALSBLOCKED, /* (pseudo) using by mutt_block_signals () */ 527 OPTSYSSIGNALSBLOCKED, /* (pseudo) using by mutt_block_signals_system () */ 528 OPTNEEDRESORT, /* (pseudo) used to force a re-sort */ 529 OPTRESORTINIT, /* (pseudo) used to force the next resort to be from scratch */ 530 OPTVIEWATTACH, /* (pseudo) signals that we are viewing attachments */ 531 OPTFORCEREDRAWINDEX, /* (pseudo) used to force a redraw in the main index */ 532 OPTFORCEREDRAWPAGER, /* (pseudo) used to force a redraw in the pager */ 533 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */ 534 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */ 535 OPTATTACHMSG, /* (pseudo) used by attach-message */ 536 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh 537 * functions while we are executing an 538 * external program. 539 */ 540 OPTMENUCALLER, /* (pseudo) tell menu to give caller a take */ 541 OPTREDRAWTREE, /* (pseudo) redraw the thread tree */ 542 OPTPGPCHECKTRUST, /* (pseudo) used by pgp_select_key () */ 543 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */ 544 OPTIGNOREMACROEVENTS, /* (pseudo) don't process macro/push/exec events while set */ 545 546 OPTMAX 547}; 548 549#define mutt_bit_alloc(n) calloc ((n + 7) / 8, sizeof (char)) 550#define mutt_bit_set(v,n) v[n/8] |= (1 << (n % 8)) 551#define mutt_bit_unset(v,n) v[n/8] &= ~(1 << (n % 8)) 552#define mutt_bit_toggle(v,n) v[n/8] ^= (1 << (n % 8)) 553#define mutt_bit_isset(v,n) (v[n/8] & (1 << (n % 8))) 554 555#define set_option(x) mutt_bit_set(Options,x) 556#define unset_option(x) mutt_bit_unset(Options,x) 557#define toggle_option(x) mutt_bit_toggle(Options,x) 558#define option(x) mutt_bit_isset(Options,x) 559 560typedef struct list_t 561{ 562 char *data; 563 struct list_t *next; 564} LIST; 565 566typedef struct rx_list_t 567{ 568 REGEXP *rx; 569 struct rx_list_t *next; 570} RX_LIST; 571 572typedef struct spam_list_t 573{ 574 REGEXP *rx; 575 int nmatch; 576 char *template; 577 struct spam_list_t *next; 578} SPAM_LIST; 579 580#define mutt_new_list() safe_calloc (1, sizeof (LIST)) 581#define mutt_new_rx_list() safe_calloc (1, sizeof (RX_LIST)) 582#define mutt_new_spam_list() safe_calloc (1, sizeof (SPAM_LIST)) 583void mutt_free_list (LIST **); 584void mutt_free_rx_list (RX_LIST **); 585void mutt_free_spam_list (SPAM_LIST **); 586LIST *mutt_copy_list (LIST *); 587int mutt_matches_ignore (const char *, LIST *); 588 589/* add an element to a list */ 590LIST *mutt_add_list (LIST *, const char *); 591LIST *mutt_add_list_n (LIST*, const void *, size_t); 592LIST *mutt_find_list (LIST *, const char *); 593int mutt_remove_from_rx_list (RX_LIST **l, const char *str); 594 595void mutt_init (int, LIST *); 596 597typedef struct alias 598{ 599 struct alias *self; /* XXX - ugly hack */ 600 char *name; 601 ADDRESS *addr; 602 struct alias *next; 603 short tagged; 604 short del; 605 short num; 606} ALIAS; 607 608typedef struct envelope 609{ 610 ADDRESS *return_path; 611 ADDRESS *from; 612 ADDRESS *to; 613 ADDRESS *cc; 614 ADDRESS *bcc; 615 ADDRESS *sender; 616 ADDRESS *reply_to; 617 ADDRESS *mail_followup_to; 618 char *list_post; /* this stores a mailto URL, or nothing */ 619 char *subject; 620 char *real_subj; /* offset of the real subject */ 621 char *message_id; 622 char *supersedes; 623 char *date; 624 char *x_label; 625 BUFFER *spam; 626 LIST *references; /* message references (in reverse order) */ 627 LIST *in_reply_to; /* in-reply-to header content */ 628 LIST *userhdrs; /* user defined headers */ 629 630 unsigned int irt_changed : 1; /* In-Reply-To changed to link/break threads */ 631 unsigned int refs_changed : 1; /* References changed to break thread */ 632} ENVELOPE; 633 634typedef struct parameter 635{ 636 char *attribute; 637 char *value; 638 struct parameter *next; 639} PARAMETER; 640 641/* Information that helps in determing the Content-* of an attachment */ 642typedef struct content 643{ 644 long hibin; /* 8-bit characters */ 645 long lobin; /* unprintable 7-bit chars (eg., control chars) */ 646 long crlf; /* '\r' and '\n' characters */ 647 long ascii; /* number of ascii chars */ 648 long linemax; /* length of the longest line in the file */ 649 unsigned int space : 1; /* whitespace at the end of lines? */ 650 unsigned int binary : 1; /* long lines, or CR not in CRLF pair */ 651 unsigned int from : 1; /* has a line beginning with "From "? */ 652 unsigned int dot : 1; /* has a line consisting of a single dot? */ 653 unsigned int cr : 1; /* has CR, even when in a CRLF pair */ 654} CONTENT; 655 656typedef struct body 657{ 658 char *xtype; /* content-type if x-unknown */ 659 char *subtype; /* content-type subtype */ 660 PARAMETER *parameter; /* parameters of the content-type */ 661 char *description; /* content-description */ 662 char *form_name; /* Content-Disposition form-data name param */ 663 long hdr_offset; /* offset in stream where the headers begin. 664 * this info is used when invoking metamail, 665 * where we need to send the headers of the 666 * attachment 667 */ 668 LOFF_T offset; /* offset where the actual data begins */ 669 LOFF_T length; /* length (in bytes) of attachment */ 670 char *filename; /* when sending a message, this is the file 671 * to which this structure refers 672 */ 673 char *d_filename; /* filename to be used for the 674 * content-disposition header. 675 * If NULL, filename is used 676 * instead. 677 */ 678 char *charset; /* charset of attached file */ 679 CONTENT *content; /* structure used to store detailed info about 680 * the content of the attachment. this is used 681 * to determine what content-transfer-encoding 682 * is required when sending mail. 683 */ 684 struct body *next; /* next attachment in the list */ 685 struct body *parts; /* parts of a multipart or message/rfc822 */ 686 struct header *hdr; /* header information for message/rfc822 */ 687 688 struct attachptr *aptr; /* Menu information, used in recvattach.c */ 689 690 signed short attach_count; 691 692 time_t stamp; /* time stamp of last 693 * encoding update. 694 */ 695 696 unsigned int type : 4; /* content-type primary type */ 697 unsigned int encoding : 3; /* content-transfer-encoding */ 698 unsigned int disposition : 2; /* content-disposition */ 699 unsigned int use_disp : 1; /* Content-Disposition uses filename= ? */ 700 unsigned int unlink : 1; /* flag to indicate the the file named by 701 * "filename" should be unlink()ed before 702 * free()ing this structure 703 */ 704 unsigned int tagged : 1; 705 unsigned int deleted : 1; /* attachment marked for deletion */ 706 707 unsigned int noconv : 1; /* don't do character set conversion */ 708 unsigned int force_charset : 1; 709 /* send mode: don't adjust the character 710 * set when in send-mode. 711 */ 712 unsigned int is_signed_data : 1; /* A lot of MUAs don't indicate 713 S/MIME signed-data correctly, 714 e.g. they use foo.p7m even for 715 the name of signed data. This 716 flag is used to keep track of 717 the actual message type. It 718 gets set during the verification 719 (which is done if the encryption 720 try failed) and check by the 721 function to figure the type of 722 the message. */ 723 724 unsigned int goodsig : 1; /* good cryptographic signature */ 725 unsigned int warnsig : 1; /* maybe good signature */ 726 unsigned int badsig : 1; /* bad cryptographic signature (needed to check encrypted s/mime-signatures) */ 727 728 unsigned int collapsed : 1; /* used by recvattach */ 729 unsigned int attach_qualifies : 1; 730 731} BODY; 732 733/* #3279: AIX defines conflicting struct thread */ 734typedef struct mutt_thread THREAD; 735 736typedef struct header 737{ 738 unsigned int security : 12; /* bit 0-8: flags, bit 9,10: application. 739 see: mutt_crypt.h pgplib.h, smime.h */ 740 741 unsigned int mime : 1; /* has a MIME-Version header? */ 742 unsigned int flagged : 1; /* marked important? */ 743 unsigned int tagged : 1; 744 unsigned int deleted : 1; 745 unsigned int purge : 1; /* skip trash folder when deleting */ 746 unsigned int changed : 1; 747 unsigned int attach_del : 1; /* has an attachment marked for deletion */ 748 unsigned int old : 1; 749 unsigned int read : 1; 750 unsigned int expired : 1; /* already expired? */ 751 unsigned int superseded : 1; /* got superseded? */ 752 unsigned int replied : 1; 753 unsigned int subject_changed : 1; /* used for threading */ 754 unsigned int threaded : 1; /* used for threading */ 755 unsigned int display_subject : 1; /* used for threading */ 756 unsigned int recip_valid : 1; /* is_recipient is valid */ 757 unsigned int active : 1; /* message is not to be removed */ 758 unsigned int trash : 1; /* message is marked as trashed on disk. 759 * This flag is used by the maildir_trash 760 * option. 761 */ 762 763 /* timezone of the sender of this message */ 764 unsigned int zhours : 5; 765 unsigned int zminutes : 6; 766 unsigned int zoccident : 1; 767 768 /* bits used for caching when searching */ 769 unsigned int searched : 1; 770 unsigned int matched : 1; 771 772 /* tells whether the attachment count is valid */ 773 unsigned int attach_valid : 1; 774 775 /* the following are used to support collapsing threads */ 776 unsigned int collapsed : 1; /* is this message part of a collapsed thread? */ 777 unsigned int limited : 1; /* is this message in a limited view? */ 778 size_t num_hidden; /* number of hidden messages in this view */ 779 780 short recipient; /* user_is_recipient()'s return value, cached */ 781 782 int pair; /* color-pair to use when displaying in the index */ 783 784 time_t date_sent; /* time when the message was sent (UTC) */ 785 time_t received; /* time when the message was placed in the mailbox */ 786 LOFF_T offset; /* where in the stream does this message begin? */ 787 int lines; /* how many lines in the body of this message? */ 788 int index; /* the absolute (unsorted) message number */ 789 int msgno; /* number displayed to the user */ 790 int virtual; /* virtual message number */ 791 int score; 792 ENVELOPE *env; /* envelope information */ 793 BODY *content; /* list of MIME parts */ 794 char *path; 795 796 char *tree; /* character string to print thread tree */ 797 THREAD *thread; 798 799 /* Number of qualifying attachments in message, if attach_valid */ 800 short attach_total; 801 802#ifdef MIXMASTER 803 LIST *chain; 804#endif 805 806#ifdef USE_POP 807 int refno; /* message number on server */ 808#endif 809 810#if defined USE_POP || defined USE_IMAP 811 void *data; /* driver-specific data */ 812#endif 813 814 char *maildir_flags; /* unknown maildir flags */ 815} HEADER; 816 817struct mutt_thread 818{ 819 unsigned int fake_thread : 1; 820 unsigned int duplicate_thread : 1; 821 unsigned int sort_children : 1; 822 unsigned int check_subject : 1; 823 unsigned int visible : 1; 824 unsigned int deep : 1; 825 unsigned int subtree_visible : 2; 826 unsigned int next_subtree_visible : 1; 827 THREAD *parent; 828 THREAD *child; 829 THREAD *next; 830 THREAD *prev; 831 HEADER *message; 832 HEADER *sort_key; 833}; 834 835 836/* flag to mutt_pattern_comp() */ 837#define MUTT_FULL_MSG (1<<0) /* enable body and header matching */ 838 839typedef enum { 840 MUTT_MATCH_FULL_ADDRESS = 1 841} pattern_exec_flag; 842 843typedef struct group_t 844{ 845 ADDRESS *as; 846 RX_LIST *rs; 847 char *name; 848} group_t; 849 850typedef struct group_context_t 851{ 852 group_t *g; 853 struct group_context_t *next; 854} group_context_t; 855 856typedef struct pattern_t 857{ 858 short op; 859 unsigned int not : 1; 860 unsigned int alladdr : 1; 861 unsigned int stringmatch : 1; 862 unsigned int groupmatch : 1; 863 unsigned int ign_case : 1; /* ignore case for local stringmatch searches */ 864 unsigned int isalias : 1; 865 int min; 866 int max; 867 struct pattern_t *next; 868 struct pattern_t *child; /* arguments to logical op */ 869 union 870 { 871 regex_t *rx; 872 group_t *g; 873 char *str; 874 } p; 875} pattern_t; 876 877/* This is used when a message is repeatedly pattern matched against. 878 * e.g. for color, scoring, hooks. It caches a few of the potentially slow 879 * operations. 880 * Each entry has a value of 0 = unset, 1 = false, 2 = true 881 */ 882typedef struct 883{ 884 int list_all; /* ^~l */ 885 int list_one; /* ~l */ 886 int sub_all; /* ^~u */ 887 int sub_one; /* ~u */ 888 int pers_recip_all; /* ^~p */ 889 int pers_recip_one; /* ~p */ 890 int pers_from_all; /* ^~P */ 891 int pers_from_one; /* ~P */ 892} pattern_cache_t; 893 894/* ACL Rights */ 895enum 896{ 897 MUTT_ACL_LOOKUP = 0, 898 MUTT_ACL_READ, 899 MUTT_ACL_SEEN, 900 MUTT_ACL_WRITE, 901 MUTT_ACL_INSERT, 902 MUTT_ACL_POST, 903 MUTT_ACL_CREATE, 904 MUTT_ACL_DELMX, 905 MUTT_ACL_DELETE, 906 MUTT_ACL_EXPUNGE, 907 MUTT_ACL_ADMIN, 908 909 RIGHTSMAX 910}; 911 912struct _context; 913struct _message; 914 915/* 916 * struct mx_ops - a structure to store operations on a mailbox 917 * The following operations are mandatory: 918 * - open 919 * - close 920 * - check 921 * 922 * Optional operations 923 * - open_new_msg 924 */ 925struct mx_ops 926{ 927 int (*open) (struct _context *); 928 int (*open_append) (struct _context *, int flags); 929 int (*close) (struct _context *); 930 int (*check) (struct _context *ctx, int *index_hint); 931 int (*sync) (struct _context *ctx, int *index_hint); 932 int (*open_msg) (struct _context *, struct _message *, int msgno); 933 int (*close_msg) (struct _context *, struct _message *); 934 int (*commit_msg) (struct _context *, struct _message *); 935 int (*open_new_msg) (struct _message *, struct _context *, HEADER *); 936}; 937 938typedef struct _context 939{ 940 char *path; 941 char *realpath; /* used for buffy comparison and the sidebar */ 942 FILE *fp; 943 time_t atime; 944 time_t mtime; 945 off_t size; 946 off_t vsize; 947 char *pattern; /* limit pattern string */ 948 pattern_t *limit_pattern; /* compiled limit pattern */ 949 HEADER **hdrs; 950 HEADER *last_tag; /* last tagged msg. used to link threads */ 951 THREAD *tree; /* top of thread tree */ 952 HASH *id_hash; /* hash table by msg id */ 953 HASH *subj_hash; /* hash table by subject */ 954 HASH *thread_hash; /* hash table for threading */ 955 int *v2r; /* mapping from virtual to real msgno */ 956 int hdrmax; /* number of pointers in hdrs */ 957 int msgcount; /* number of messages in the mailbox */ 958 int vcount; /* the number of virtual messages */ 959 int tagged; /* how many messages are tagged? */ 960 int new; /* how many new messages? */ 961 int unread; /* how many unread messages? */ 962 int deleted; /* how many deleted messages */ 963 int flagged; /* how many flagged messages */ 964 int msgnotreadyet; /* which msg "new" in pager, -1 if none */ 965 966 short magic; /* mailbox type */ 967 968 unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */ 969 970 unsigned int locked : 1; /* is the mailbox locked? */ 971 unsigned int changed : 1; /* mailbox has been modified */ 972 unsigned int readonly : 1; /* don't allow changes to the mailbox */ 973 unsigned int dontwrite : 1; /* don't write the mailbox on close */ 974 unsigned int append : 1; /* mailbox is opened in append mode */ 975 unsigned int quiet : 1; /* inhibit status messages? */ 976 unsigned int collapsed : 1; /* are all threads collapsed? */ 977 unsigned int closing : 1; /* mailbox is being closed */ 978 unsigned int peekonly : 1; /* just taking a glance, revert atime */ 979 980#ifdef USE_COMPRESSED 981 void *compress_info; /* compressed mbox module private data */ 982#endif /* USE_COMPRESSED */ 983 984 /* driver hooks */ 985 void *data; /* driver specific data */ 986 struct mx_ops *mx_ops; 987} CONTEXT; 988 989typedef struct 990{ 991 FILE *fpin; 992 FILE *fpout; 993 char *prefix; 994 int flags; 995} STATE; 996 997/* used by enter.c */ 998 999typedef struct 1000{ 1001 wchar_t *wbuf; 1002 size_t wbuflen; 1003 size_t lastchar; 1004 size_t curpos; 1005 size_t begin; 1006 int tabs; 1007} ENTER_STATE; 1008 1009/* flags for the STATE struct */ 1010#define MUTT_DISPLAY (1<<0) /* output is displayed to the user */ 1011#define MUTT_VERIFY (1<<1) /* perform signature verification */ 1012#define MUTT_PENDINGPREFIX (1<<2) /* prefix to write, but character must follow */ 1013#define MUTT_WEED (1<<3) /* weed headers even when not in display mode */ 1014#define MUTT_CHARCONV (1<<4) /* Do character set conversions */ 1015#define MUTT_PRINTING (1<<5) /* are we printing? - MUTT_DISPLAY "light" */ 1016#define MUTT_REPLYING (1<<6) /* are we replying? */ 1017#define MUTT_FIRSTDONE (1<<7) /* the first attachment has been done */ 1018 1019#define state_set_prefix(s) ((s)->flags |= MUTT_PENDINGPREFIX) 1020#define state_reset_prefix(s) ((s)->flags &= ~MUTT_PENDINGPREFIX) 1021#define state_puts(x,y) fputs(x,(y)->fpout) 1022#define state_putc(x,y) fputc(x,(y)->fpout) 1023 1024void state_mark_attach (STATE *); 1025void state_attach_puts (const char *, STATE *); 1026void state_prefix_putc (char, STATE *); 1027int state_printf(STATE *, const char *, ...); 1028int state_putwc (wchar_t, STATE *); 1029int state_putws (const wchar_t *, STATE *); 1030 1031/* for attachment counter */ 1032typedef struct 1033{ 1034 char *major; 1035 int major_int; 1036 char *minor; 1037 regex_t minor_rx; 1038} ATTACH_MATCH; 1039 1040/* multibyte character table. 1041 * Allows for direct access to the individual multibyte characters in a 1042 * string. This is used for the Tochars and StChars option types. */ 1043typedef struct 1044{ 1045 int len; /* number of characters */ 1046 char **chars; /* the array of multibyte character strings */ 1047 char *segmented_str; /* each chars entry points inside this string */ 1048 char *orig_str; 1049} mbchar_table; 1050 1051#define MUTT_PARTS_TOPLEVEL (1<<0) /* is the top-level part */ 1052 1053#include "ascii.h" 1054#include "protos.h" 1055#include "lib.h" 1056#include "globals.h" 1057 1058#endif /*MUTT_H*/