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,
409 #endif /* USE_NNTP */
413 OPTAUXSORT, /* (pseudo) using auxillary sort function */
414 OPTFORCEREFRESH, /* (pseudo) refresh even during macros */
415 OPTNOCURSES, /* (pseudo) when sending in batch mode */
416 OPTNEEDREDRAW, /* (pseudo) to notify caller of a submenu */
417 OPTSEARCHREVERSE, /* (pseudo) used by ci_search_command */
418 OPTMSGERR, /* (pseudo) used by mutt_error/mutt_message */
419 OPTSEARCHINVALID, /* (pseudo) used to invalidate the search pat */
420 OPTSIGNALSBLOCKED, /* (pseudo) using by mutt_block_signals () */
421 OPTSYSSIGNALSBLOCKED, /* (pseudo) using by mutt_block_signals_system () */
422 OPTNEEDRESORT, /* (pseudo) used to force a re-sort */
423 OPTRESORTINIT, /* (pseudo) used to force the next resort to be from scratch */
424 OPTVIEWATTACH, /* (pseudo) signals that we are viewing attachments */
425 OPTFORCEREDRAWINDEX, /* (pseudo) used to force a redraw in the main index */
426 OPTFORCEREDRAWPAGER, /* (pseudo) used to force a redraw in the pager */
427 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
428 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
429 OPTATTACHMSG, /* (pseudo) used by attach-message */
430 OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
431 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
432 * functions while we are executing an
435 OPTMENUCALLER, /* (pseudo) tell menu to give caller a take */
436 OPTREDRAWTREE, /* (pseudo) redraw the thread tree */
437 OPTPGPCHECKTRUST, /* (pseudo) used by pgp_select_key () */
438 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
439 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
442 OPTNEWS, /* (pseudo) used to change reader mode */
443 OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
444 OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
446 OPTSHORTENHIERARCHY, /* set when to shorten "hierarchies" in the sidebar */
447 OPTSIDEBARNEWMAILONLY,
451 #define mutt_bit_alloc(n) p_new(char, (n + 7) / 8)
452 #define mutt_bit_set(v,n) v[n/8] |= (1 << (n % 8))
453 #define mutt_bit_unset(v,n) v[n/8] &= ~(1 << (n % 8))
454 #define mutt_bit_toggle(v,n) v[n/8] ^= (1 << (n % 8))
455 #define mutt_bit_isset(v,n) (v[n/8] & (1 << (n % 8)))
457 #define set_option(x) mutt_bit_set(Options,x)
458 #define unset_option(x) mutt_bit_unset(Options,x)
459 #define toggle_option(x) mutt_bit_toggle(Options,x)
460 #define option(x) mutt_bit_isset(Options,x)
462 int mutt_matches_ignore (const char *, string_list_t *);
464 void mutt_init (int, string_list_t *);
466 typedef struct thread {
467 unsigned int fake_thread:1;
468 unsigned int duplicate_thread:1;
469 unsigned int sort_children:1;
470 unsigned int check_subject:1;
471 unsigned int visible:1;
473 unsigned int subtree_visible:2;
474 unsigned int next_subtree_visible:1;
475 struct thread *parent;
476 struct thread *child;
484 /* flag to mutt_pattern_comp() */
485 #define M_FULL_MSG (1<<0) /* enable body and header matching */
488 M_MATCH_FULL_ADDRESS = 1
491 typedef struct pattern_t {
493 unsigned int not : 1;
494 unsigned int alladdr : 1;
495 unsigned int stringmatch : 1;
498 struct pattern_t *next;
499 struct pattern_t *child; /* arguments to logical op */
504 typedef struct compress_info compress_info;
510 time_t mtime_cur; /* used with maildir folders */
513 char *pattern; /* limit pattern string */
514 pattern_t *limit_pattern; /* compiled limit pattern */
516 HEADER *last_tag; /* last tagged msg. used to link threads */
517 THREAD *tree; /* top of thread tree */
518 HASH *id_hash; /* hash table by msg id */
519 HASH *subj_hash; /* hash table by subject */
520 HASH *thread_hash; /* hash table for threading */
521 int *v2r; /* mapping from virtual to real msgno */
522 int hdrmax; /* number of pointers in hdrs */
523 int msgcount; /* number of messages in the mailbox */
524 int vcount; /* the number of virtual messages */
525 int tagged; /* how many messages are tagged? */
526 int new; /* how many new messages? */
527 int unread; /* how many unread messages? */
528 int deleted; /* how many deleted messages */
529 int appended; /* how many saved messages? */
530 int flagged; /* how many flagged messages */
531 int msgnotreadyet; /* which msg "new" in pager, -1 if none */
532 void *data; /* driver specific data */
534 short magic; /* mailbox type */
536 compress_info *cinfo; /* compressed mbox module private data */
537 char *realpath; /* path to compressed mailbox */
539 unsigned int locked:1; /* is the mailbox locked? */
540 unsigned int changed:1; /* mailbox has been modified */
541 unsigned int readonly:1; /* don't allow changes to the mailbox */
542 unsigned int dontwrite:1; /* dont write the mailbox on close */
543 unsigned int append:1; /* mailbox is opened in append mode */
544 unsigned int quiet:1; /* inhibit status messages? */
545 unsigned int collapsed:1; /* are all threads collapsed? */
546 unsigned int closing:1; /* mailbox is being closed */
547 unsigned int counting:1; /* do we just want to cound? */
550 /* for attachment counter */
558 /* Flags for mutt_count_body_parts() */
559 #define M_PARTS_TOPLEVEL (1<<0) /* is the top-level part */
560 #define M_PARTS_RECOUNT (1<<1) /* force recount */
565 #endif /* !_MUTT_H */