PageRenderTime 61ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/mutt.h

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