2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>
4 * Copyright (C) 2004 g10 Code GmbH
6 * This file is part of mutt-ng, see http://www.muttng.org/.
7 * It's licensed under the GNU General Public License,
8 * please see the file GPL in the top level source directory.
14 #include <lib-lib/lib-lib.h>
15 #include <lib-mime/mime.h>
17 #define MUTT_VERSION (VERSION)
19 /* nifty trick I stole from ELM 2.5alpha. */
22 #define INITVAL(x) = x
29 int ch; /* raw key pressed */
30 int op; /* function op */
33 /* flags for mutt_FormatString() */
35 M_FORMAT_FORCESUBJ = (1 << 0), /* print the subject even if unchanged */
36 M_FORMAT_TREE = (1 << 1), /* draw the thread tree */
37 M_FORMAT_MAKEPRINT = (1 << 2), /* make sure that all chars are printable */
38 M_FORMAT_OPTIONAL = (1 << 3),
39 M_FORMAT_STAT_FILE = (1 << 4), /* used by mutt_attach_fmt */
40 M_FORMAT_ARROWCURSOR = (1 << 5), /* reserve space for arrow_cursor */
41 M_FORMAT_INDEX = (1 << 6) /* this is a main index entry */
44 /* types for mutt_add_hook() */
45 #define M_FOLDERHOOK 1
46 #define M_MBOXHOOK (1<<1)
47 #define M_SENDHOOK (1<<2)
48 #define M_FCCHOOK (1<<3)
49 #define M_SAVEHOOK (1<<4)
50 #define M_CHARSETHOOK (1<<5)
51 #define M_ICONVHOOK (1<<6)
52 #define M_MESSAGEHOOK (1<<7)
53 #define M_CRYPTHOOK (1<<8)
54 #define M_ACCOUNTHOOK (1<<9)
55 #define M_REPLYHOOK (1<<10)
56 #define M_SEND2HOOK (1<<11)
58 #define M_OPENHOOK (1<<12)
59 #define M_APPENDHOOK (1<<13)
60 #define M_CLOSEHOOK (1<<14)
62 /* tree characters for linearize_tree and print_enriched_string */
63 #define M_TREE_LLCORNER 1
64 #define M_TREE_ULCORNER 2
66 #define M_TREE_HLINE 4
67 #define M_TREE_VLINE 5
68 #define M_TREE_SPACE 6
69 #define M_TREE_RARROW 7
71 #define M_TREE_HIDDEN 9
72 #define M_TREE_EQUALS 10
73 #define M_TREE_TTEE 11
74 #define M_TREE_BTEE 12
75 #define M_TREE_MISSING 13
78 #define M_THREAD_COLLAPSE (1<<0)
79 #define M_THREAD_UNCOLLAPSE (1<<1)
80 #define M_THREAD_GET_HIDDEN (1<<2)
81 #define M_THREAD_UNREAD (1<<3)
82 #define M_THREAD_NEXT_UNREAD (1<<4)
85 /* modes for mutt_view_attachment() */
90 /* action codes used by mutt_set_flag() and mutt_pattern_function() */
110 /* actions for mutt_pattern_comp/mutt_pattern_exec */
150 /* Options for Mailcap lookup */
156 /* options for socket code */
162 /* Options for mutt_save_attachment */
167 /* possible arguments to set_quadoption() */
175 /* quad-option vars */
189 OPT_PGPMIMEAUTO, /* ask to revert to PGP/MIME when inline fails */
197 #if defined(USE_SSL) || defined(USE_GNUTLS)
201 OPT_VERIFYSIG, /* verify PGP signatures */
207 OPT_FOLLOWUPTOPOSTER,
208 #endif /* USE_NNTP */
210 /* THIS MUST BE THE LAST VALUE. */
214 /* flags to ci_send_message() */
215 #define SENDREPLY (1<<0)
216 #define SENDGROUPREPLY (1<<1)
217 #define SENDLISTREPLY (1<<2)
218 #define SENDFORWARD (1<<3)
219 #define SENDPOSTPONED (1<<4)
220 #define SENDBATCH (1<<5)
221 #define SENDKEY (1<<6)
222 #define SENDRESEND (1<<7)
223 #define SENDNEWS (1<<8)
225 /* flags to _mutt_select_file() */
226 #define M_SEL_BUFFY (1<<0)
227 #define M_SEL_MULTI (1<<1)
228 #define M_SEL_FOLDER (1<<2)
230 /* flags for parse_spam_list */
275 #endif /* HAVE_QDBM */
283 OPTHIDETHREADSUBJECT,
286 OPTIGNORELISTREPLYTO,
287 OPTIMAPCHECKSUBSCRIBED,
292 #if defined(USE_SSL) || defined(USE_GNUTLS)
296 # endif /* !USE_GNUTLS */
300 #endif /* USE_SSL || USE_GNUTLS */
309 OPTMENUSCROLL, /* scroll menu instead of implicit next-page */
311 OPTMETAKEY, /* interpret ALT-x as ESC-x */
316 OPTMIMESUBJECT, /* encode subject line with RFC2047 */
363 #ifdef HAVE_GETADDRINFO
370 OPTWRITEBCC, /* write out a bcc header? */
372 OPTXMAILTO, /* 1 if $edit_header is forcebly set */
383 OPTCRYPTREPLYENCRYPT,
385 OPTCRYPTREPLYSIGNENCRYPTED,
389 OPTSDEFAULTDECRYPTKEY,
412 #endif /* USE_NNTP */
416 OPTAUXSORT, /* (pseudo) using auxillary sort function */
417 OPTFORCEREFRESH, /* (pseudo) refresh even during macros */
418 OPTNOCURSES, /* (pseudo) when sending in batch mode */
419 OPTNEEDREDRAW, /* (pseudo) to notify caller of a submenu */
420 OPTSEARCHREVERSE, /* (pseudo) used by ci_search_command */
421 OPTMSGERR, /* (pseudo) used by mutt_error/mutt_message */
422 OPTSEARCHINVALID, /* (pseudo) used to invalidate the search pat */
423 OPTSIGNALSBLOCKED, /* (pseudo) using by mutt_block_signals () */
424 OPTSYSSIGNALSBLOCKED, /* (pseudo) using by mutt_block_signals_system () */
425 OPTNEEDRESORT, /* (pseudo) used to force a re-sort */
426 OPTRESORTINIT, /* (pseudo) used to force the next resort to be from scratch */
427 OPTVIEWATTACH, /* (pseudo) signals that we are viewing attachments */
428 OPTFORCEREDRAWINDEX, /* (pseudo) used to force a redraw in the main index */
429 OPTFORCEREDRAWPAGER, /* (pseudo) used to force a redraw in the pager */
430 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
431 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
432 OPTATTACHMSG, /* (pseudo) used by attach-message */
433 OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
434 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
435 * functions while we are executing an
438 OPTMENUCALLER, /* (pseudo) tell menu to give caller a take */
439 OPTREDRAWTREE, /* (pseudo) redraw the thread tree */
440 OPTPGPCHECKTRUST, /* (pseudo) used by pgp_select_key () */
441 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
442 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
445 OPTNEWS, /* (pseudo) used to change reader mode */
446 OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
447 OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
449 OPTSHORTENHIERARCHY, /* set when to shorten "hierarchies" in the sidebar */
450 OPTSIDEBARNEWMAILONLY,
454 #define mutt_bit_alloc(n) p_new(char, (n + 7) / 8)
455 #define mutt_bit_set(v,n) v[n/8] |= (1 << (n % 8))
456 #define mutt_bit_unset(v,n) v[n/8] &= ~(1 << (n % 8))
457 #define mutt_bit_toggle(v,n) v[n/8] ^= (1 << (n % 8))
458 #define mutt_bit_isset(v,n) (v[n/8] & (1 << (n % 8)))
460 #define set_option(x) mutt_bit_set(Options,x)
461 #define unset_option(x) mutt_bit_unset(Options,x)
462 #define toggle_option(x) mutt_bit_toggle(Options,x)
463 #define option(x) mutt_bit_isset(Options,x)
465 typedef struct spam_list_t {
469 struct spam_list_t *next;
473 #define mutt_new_spam_list() p_new(SPAM_LIST, 1)
474 void mutt_free_spam_list (SPAM_LIST **);
476 int mutt_matches_ignore (const char *, string_list_t *);
478 void mutt_init (int, string_list_t *);
480 typedef struct thread {
481 unsigned int fake_thread:1;
482 unsigned int duplicate_thread:1;
483 unsigned int sort_children:1;
484 unsigned int check_subject:1;
485 unsigned int visible:1;
487 unsigned int subtree_visible:2;
488 unsigned int next_subtree_visible:1;
489 struct thread *parent;
490 struct thread *child;
498 /* flag to mutt_pattern_comp() */
499 #define M_FULL_MSG (1<<0) /* enable body and header matching */
502 M_MATCH_FULL_ADDRESS = 1
505 typedef struct pattern_t {
507 unsigned int not : 1;
508 unsigned int alladdr : 1;
509 unsigned int stringmatch : 1;
512 struct pattern_t *next;
513 struct pattern_t *child; /* arguments to logical op */
522 time_t mtime_cur; /* used with maildir folders */
525 char *pattern; /* limit pattern string */
526 pattern_t *limit_pattern; /* compiled limit pattern */
528 HEADER *last_tag; /* last tagged msg. used to link threads */
529 THREAD *tree; /* top of thread tree */
530 HASH *id_hash; /* hash table by msg id */
531 HASH *subj_hash; /* hash table by subject */
532 HASH *thread_hash; /* hash table for threading */
533 int *v2r; /* mapping from virtual to real msgno */
534 int hdrmax; /* number of pointers in hdrs */
535 int msgcount; /* number of messages in the mailbox */
536 int vcount; /* the number of virtual messages */
537 int tagged; /* how many messages are tagged? */
538 int new; /* how many new messages? */
539 int unread; /* how many unread messages? */
540 int deleted; /* how many deleted messages */
541 int appended; /* how many saved messages? */
542 int flagged; /* how many flagged messages */
543 int msgnotreadyet; /* which msg "new" in pager, -1 if none */
544 void *data; /* driver specific data */
546 short magic; /* mailbox type */
548 void *compressinfo; /* compressed mbox module private data */
549 char *realpath; /* path to compressed mailbox */
551 unsigned int locked:1; /* is the mailbox locked? */
552 unsigned int changed:1; /* mailbox has been modified */
553 unsigned int readonly:1; /* don't allow changes to the mailbox */
554 unsigned int dontwrite:1; /* dont write the mailbox on close */
555 unsigned int append:1; /* mailbox is opened in append mode */
556 unsigned int quiet:1; /* inhibit status messages? */
557 unsigned int collapsed:1; /* are all threads collapsed? */
558 unsigned int closing:1; /* mailbox is being closed */
559 unsigned int counting:1; /* do we just want to cound? */
562 /* for attachment counter */
570 /* Flags for mutt_count_body_parts() */
571 #define M_PARTS_TOPLEVEL (1<<0) /* is the top-level part */
572 #define M_PARTS_RECOUNT (1<<1) /* force recount */
577 #endif /* !_MUTT_H */