PageRenderTime 61ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/mutt.h

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