NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
protos.h File Reference
#include "config.h"
#include <stddef.h>
#include <stdbool.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "mutt.h"
#include "ncrypt/lib.h"
#include "keymap.h"
+ Include dependency graph for protos.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define mutt_set_flag(m, e, flag, bf)   mutt_set_flag_update(m, e, flag, bf, true)
 

Enumerations

enum  XdgType { XDG_CONFIG_HOME, XDG_CONFIG_DIRS }
 XDG variable types. More...
 
enum  EvMessage { EVM_VIEW, EVM_EDIT }
 Edit or View a message. More...
 

Functions

int mutt_ev_message (struct Mailbox *m, struct EmailList *el, enum EvMessage action)
 Edit or view a message. More...
 
int mutt_system (const char *cmd)
 Run an external command. More...
 
int mutt_set_xdg_path (enum XdgType type, struct Buffer *buf)
 Find an XDG path or its fallback. More...
 
void mutt_help (enum MenuType menu)
 Display the help menu. More...
 
void mutt_set_flag_update (struct Mailbox *m, struct Email *e, enum MessageType flag, bool bf, bool upd_mbox)
 Set a flag on an email. More...
 
void mutt_signal_init (void)
 Initialise the signal handling. More...
 
void mutt_emails_set_flag (struct Mailbox *m, struct EmailList *el, enum MessageType flag, bool bf)
 Set flag on messages. More...
 
int mutt_change_flag (struct Mailbox *m, struct EmailList *el, bool bf)
 Change the flag on a Message. More...
 
int mutt_complete (char *buf, size_t buflen)
 Attempt to complete a partial pathname. More...
 
int mutt_prepare_template (FILE *fp, struct Mailbox *m, struct Email *e_new, struct Email *e, bool resend)
 Prepare a message template. More...
 
int mutt_enter_string (char *buf, size_t buflen, int col, CompletionFlags flags)
 Ask the user for a string. More...
 
int mutt_enter_string_full (char *buf, size_t buflen, int col, CompletionFlags flags, bool multiple, struct Mailbox *m, char ***files, int *numfiles, struct EnterState *state)
 Ask the user for a string. More...
 
int mutt_get_postponed (struct Context *ctx, struct Email *hdr, struct Email **cur, struct Buffer *fcc)
 Recall a postponed message. More...
 
SecurityFlags mutt_parse_crypt_hdr (const char *p, bool set_empty_signas, SecurityFlags crypt_app)
 Parse a crypto header string. More...
 
int mutt_num_postponed (struct Mailbox *m, bool force)
 Return the number of postponed messages. More...
 
int mutt_thread_set_flag (struct Mailbox *m, struct Email *e, enum MessageType flag, bool bf, bool subthread)
 Set a flag on an entire thread. More...
 
void mutt_update_num_postponed (void)
 Force the update of the number of postponed messages. More...
 
int mutt_is_quote_line (char *buf, regmatch_t *pmatch)
 Is a line of message text a quote? More...
 
int wcscasecmp (const wchar_t *a, const wchar_t *b)
 Compare two wide-character strings, ignoring case. More...
 
int mutt_reply_observer (struct NotifyCallback *nc)
 

Detailed Description

Prototypes for many functions

Authors
  • Michael R. Elkins
  • Karel Zak

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file protos.h.

Macro Definition Documentation

◆ mutt_set_flag

#define mutt_set_flag (   m,
  e,
  flag,
  bf 
)    mutt_set_flag_update(m, e, flag, bf, true)

Definition at line 67 of file protos.h.

Enumeration Type Documentation

◆ XdgType

enum XdgType

XDG variable types.

Enumerator
XDG_CONFIG_HOME 

XDG home dir: ~/.config.

XDG_CONFIG_DIRS 

XDG system dir: /etc/xdg.

Definition at line 45 of file protos.h.

46 {
49 };

◆ EvMessage

enum EvMessage

Edit or View a message.

Enumerator
EVM_VIEW 

View the message.

EVM_EDIT 

Edit the message.

Definition at line 54 of file protos.h.

55 {
56  EVM_VIEW,
57  EVM_EDIT,
58 };

Function Documentation

◆ mutt_ev_message()

int mutt_ev_message ( struct Mailbox m,
struct EmailList *  el,
enum EvMessage  action 
)

Edit or view a message.

Parameters
mMailbox
elList of Emails
actionAction to perform, e.g. EVM_EDIT
Return values
1Message not modified
0Message edited successfully
-1Error

Definition at line 280 of file editmsg.c.

281 {
282  struct EmailNode *en = NULL;
283  STAILQ_FOREACH(en, el, entries)
284  {
285  if (ev_message(action, m, en->email) == -1)
286  return -1;
287  }
288 
289  return 0;
290 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_system()

int mutt_system ( const char *  cmd)

Run an external command.

Parameters
cmdCommand and arguments
Return values
-1Error
>=0Success (command's return code)

Fork and run an external command with arguments.

Note
This function won't return until the command finishes.

Definition at line 51 of file system.c.

52 {
53  int rc = -1;
54  struct sigaction act;
55  struct sigaction oldtstp;
56  struct sigaction oldcont;
57  pid_t pid;
58 
59  if (!cmd || (*cmd == '\0'))
60  return 0;
61 
62  /* must ignore SIGINT and SIGQUIT */
63 
65 
66  act.sa_handler = SIG_DFL;
67 /* we want to restart the waitpid() below */
68 #ifdef SA_RESTART
69  act.sa_flags = SA_RESTART;
70 #endif
71  sigemptyset(&act.sa_mask);
72  sigaction(SIGTSTP, &act, &oldtstp);
73  sigaction(SIGCONT, &act, &oldcont);
74 
75  pid = fork();
76  if (pid == 0)
77  {
78  act.sa_flags = 0;
79 
80  /* reset signals for the child; not really needed, but... */
82  act.sa_handler = SIG_DFL;
83  act.sa_flags = 0;
84  sigemptyset(&act.sa_mask);
85  sigaction(SIGTERM, &act, NULL);
86  sigaction(SIGTSTP, &act, NULL);
87  sigaction(SIGCONT, &act, NULL);
88 
89  execle(EXEC_SHELL, "sh", "-c", cmd, NULL, mutt_envlist_getlist());
90  _exit(127); /* execl error */
91  }
92  else if (pid != -1)
93  {
94 #ifdef USE_IMAP
95  rc = imap_wait_keepalive(pid);
96 #endif
97  }
98 
99  sigaction(SIGCONT, &oldcont, NULL);
100  sigaction(SIGTSTP, &oldtstp, NULL);
101 
102  /* reset SIGINT, SIGQUIT and SIGCHLD */
104 
105  rc = (pid != -1) ? (WIFEXITED(rc) ? WEXITSTATUS(rc) : -1) : -1;
106 
107  return rc;
108 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_set_xdg_path()

int mutt_set_xdg_path ( enum XdgType  type,
struct Buffer buf 
)

Find an XDG path or its fallback.

Parameters
typeType of XDG variable, e.g. XDG_CONFIG_HOME
bufBuffer to save path
Return values
1if an entry was found that actually exists on disk and 0 otherwise

Process an XDG environment variable or its fallback.

Definition at line 1501 of file muttlib.c.

1502 {
1503  const char *xdg_env = mutt_str_getenv(xdg_env_vars[type]);
1504  char *xdg = xdg_env ? mutt_str_dup(xdg_env) : mutt_str_dup(xdg_defaults[type]);
1505  char *x = xdg; /* strsep() changes xdg, so free x instead later */
1506  char *token = NULL;
1507  int rc = 0;
1508 
1509  while ((token = strsep(&xdg, ":")))
1510  {
1511  if (mutt_buffer_printf(buf, "%s/%s/neomuttrc", token, PACKAGE) < 0)
1512  continue;
1514  if (access(mutt_buffer_string(buf), F_OK) == 0)
1515  {
1516  rc = 1;
1517  break;
1518  }
1519 
1520  if (mutt_buffer_printf(buf, "%s/%s/Muttrc", token, PACKAGE) < 0)
1521  continue;
1523  if (access(mutt_buffer_string(buf), F_OK) == 0)
1524  {
1525  rc = 1;
1526  break;
1527  }
1528  }
1529 
1530  FREE(&x);
1531  return rc;
1532 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_help()

void mutt_help ( enum MenuType  menu)

Display the help menu.

Parameters
menuCurrent Menu

Definition at line 385 of file help.c.

386 {
387  const int wraplen = AllDialogsWindow->state.cols;
388  char buf[128];
389  FILE *fp = NULL;
390 
391  /* We don't use the buffer pool because of the extended lifetime of t */
392  struct Buffer t = mutt_buffer_make(PATH_MAX);
393  mutt_buffer_mktemp(&t);
394 
395  const struct Binding *funcs = km_get_table(menu);
396  const char *desc = mutt_map_get_name(menu, Menus);
397  if (!desc)
398  desc = _("<UNKNOWN>");
399 
400  do
401  {
402  fp = mutt_file_fopen(mutt_buffer_string(&t), "w");
403  if (!fp)
404  {
406  goto cleanup;
407  }
408 
409  dump_menu(fp, menu, wraplen);
410  if ((menu != MENU_EDITOR) && (menu != MENU_PAGER))
411  {
412  fprintf(fp, "\n%s\n\n", _("Generic bindings:"));
413  dump_menu(fp, MENU_GENERIC, wraplen);
414  }
415 
416  fprintf(fp, "\n%s\n\n", _("Unbound functions:"));
417  if (funcs)
418  dump_unbound(fp, funcs, &Keymaps[menu], NULL, wraplen);
419  if (menu != MENU_PAGER)
420  dump_unbound(fp, OpGeneric, &Keymaps[MENU_GENERIC], &Keymaps[menu], wraplen);
421 
422  mutt_file_fclose(&fp);
423 
424  snprintf(buf, sizeof(buf), _("Help for %s"), desc);
425  } while (mutt_do_pager(buf, mutt_buffer_string(&t),
427  NULL) == OP_REFORMAT_WINCH);
428 
429 cleanup:
431 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_set_flag_update()

void mutt_set_flag_update ( struct Mailbox m,
struct Email e,
enum MessageType  flag,
bool  bf,
bool  upd_mbox 
)

Set a flag on an email.

Parameters
mMailbox
eEmail
flagFlag to set, e.g. MUTT_DELETE
bftrue: set the flag; false: clear the flag
upd_mboxtrue: update the Mailbox

Definition at line 54 of file flags.c.

56 {
57  if (!m || !e)
58  return;
59 
60  bool changed = e->changed;
61  int deleted = m->msg_deleted;
62  int tagged = m->msg_tagged;
63  int flagged = m->msg_flagged;
64  int update = false;
65 
66  if (m->readonly && (flag != MUTT_TAG))
67  return; /* don't modify anything if we are read-only */
68 
69  switch (flag)
70  {
71  case MUTT_DELETE:
72 
73  if (!(m->rights & MUTT_ACL_DELETE))
74  return;
75 
76  if (bf)
77  {
78  if (!e->deleted && !m->readonly && (!e->flagged || !C_FlagSafe))
79  {
80  e->deleted = true;
81  update = true;
82  if (upd_mbox)
83  m->msg_deleted++;
84 #ifdef USE_IMAP
85  /* deleted messages aren't treated as changed elsewhere so that the
86  * purge-on-sync option works correctly. This isn't applicable here */
87  if (m->type == MUTT_IMAP)
88  {
89  e->changed = true;
90  if (upd_mbox)
91  m->changed = true;
92  }
93 #endif
94  }
95  }
96  else if (e->deleted)
97  {
98  e->deleted = false;
99  update = true;
100  if (upd_mbox)
101  m->msg_deleted--;
102 #ifdef USE_IMAP
103  /* see my comment above */
104  if (m->type == MUTT_IMAP)
105  {
106  e->changed = true;
107  if (upd_mbox)
108  m->changed = true;
109  }
110 #endif
111  /* If the user undeletes a message which is marked as
112  * "trash" in the maildir folder on disk, the folder has
113  * been changed, and is marked accordingly. However, we do
114  * _not_ mark the message itself changed, because trashing
115  * is checked in specific code in the maildir folder
116  * driver. */
117  if ((m->type == MUTT_MAILDIR) && upd_mbox && e->trash)
118  m->changed = true;
119  }
120  break;
121 
122  case MUTT_PURGE:
123 
124  if (!(m->rights & MUTT_ACL_DELETE))
125  return;
126 
127  if (bf)
128  {
129  if (!e->purge && !m->readonly)
130  e->purge = true;
131  }
132  else if (e->purge)
133  e->purge = false;
134  break;
135 
136  case MUTT_NEW:
137 
138  if (!(m->rights & MUTT_ACL_SEEN))
139  return;
140 
141  if (bf)
142  {
143  if (e->read || e->old)
144  {
145  update = true;
146  e->old = false;
147  if (upd_mbox)
148  m->msg_new++;
149  if (e->read)
150  {
151  e->read = false;
152  if (upd_mbox)
153  m->msg_unread++;
154  }
155  e->changed = true;
156  if (upd_mbox)
157  m->changed = true;
158  }
159  }
160  else if (!e->read)
161  {
162  update = true;
163  if (!e->old)
164  if (upd_mbox)
165  m->msg_new--;
166  e->read = true;
167  if (upd_mbox)
168  m->msg_unread--;
169  e->changed = true;
170  if (upd_mbox)
171  m->changed = true;
172  }
173  break;
174 
175  case MUTT_OLD:
176 
177  if (!(m->rights & MUTT_ACL_SEEN))
178  return;
179 
180  if (bf)
181  {
182  if (!e->old)
183  {
184  update = true;
185  e->old = true;
186  if (!e->read)
187  if (upd_mbox)
188  m->msg_new--;
189  e->changed = true;
190  if (upd_mbox)
191  m->changed = true;
192  }
193  }
194  else if (e->old)
195  {
196  update = true;
197  e->old = false;
198  if (!e->read)
199  if (upd_mbox)
200  m->msg_new++;
201  e->changed = true;
202  if (upd_mbox)
203  m->changed = true;
204  }
205  break;
206 
207  case MUTT_READ:
208 
209  if (!(m->rights & MUTT_ACL_SEEN))
210  return;
211 
212  if (bf)
213  {
214  if (!e->read)
215  {
216  update = true;
217  e->read = true;
218  if (upd_mbox)
219  m->msg_unread--;
220  if (!e->old)
221  if (upd_mbox)
222  m->msg_new--;
223  e->changed = true;
224  if (upd_mbox)
225  m->changed = true;
226  }
227  }
228  else if (e->read)
229  {
230  update = true;
231  e->read = false;
232  if (upd_mbox)
233  m->msg_unread++;
234  if (!e->old)
235  if (upd_mbox)
236  m->msg_new++;
237  e->changed = true;
238  if (upd_mbox)
239  m->changed = true;
240  }
241  break;
242 
243  case MUTT_REPLIED:
244 
245  if (!(m->rights & MUTT_ACL_WRITE))
246  return;
247 
248  if (bf)
249  {
250  if (!e->replied)
251  {
252  update = true;
253  e->replied = true;
254  if (!e->read)
255  {
256  e->read = true;
257  if (upd_mbox)
258  m->msg_unread--;
259  if (!e->old)
260  if (upd_mbox)
261  m->msg_new--;
262  }
263  e->changed = true;
264  if (upd_mbox)
265  m->changed = true;
266  }
267  }
268  else if (e->replied)
269  {
270  update = true;
271  e->replied = false;
272  e->changed = true;
273  if (upd_mbox)
274  m->changed = true;
275  }
276  break;
277 
278  case MUTT_FLAG:
279 
280  if (!(m->rights & MUTT_ACL_WRITE))
281  return;
282 
283  if (bf)
284  {
285  if (!e->flagged)
286  {
287  update = true;
288  e->flagged = bf;
289  if (upd_mbox)
290  m->msg_flagged++;
291  e->changed = true;
292  if (upd_mbox)
293  m->changed = true;
294  }
295  }
296  else if (e->flagged)
297  {
298  update = true;
299  e->flagged = false;
300  if (upd_mbox)
301  m->msg_flagged--;
302  e->changed = true;
303  if (upd_mbox)
304  m->changed = true;
305  }
306  break;
307 
308  case MUTT_TAG:
309  if (bf)
310  {
311  if (!e->tagged)
312  {
313  update = true;
314  e->tagged = true;
315  if (upd_mbox)
316  m->msg_tagged++;
317  }
318  }
319  else if (e->tagged)
320  {
321  update = true;
322  e->tagged = false;
323  if (upd_mbox)
324  m->msg_tagged--;
325  }
326  break;
327 
328  default:
329  break;
330  }
331 
332  if (update)
333  {
334  mutt_set_header_color(m, e);
335  }
336 
337  /* if the message status has changed, we need to invalidate the cached
338  * search results so that any future search will match the current status
339  * of this message and not what it was at the time it was last searched. */
340  if (e->searched && ((changed != e->changed) || (deleted != m->msg_deleted) ||
341  (tagged != m->msg_tagged) || (flagged != m->msg_flagged)))
342  {
343  e->searched = false;
344  }
345 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_signal_init()

void mutt_signal_init ( void  )

Initialise the signal handling.

Definition at line 132 of file mutt_signal.c.

133 {
135 
136 #ifdef USE_SLANG_CURSES
137  /* This bit of code is required because of the implementation of
138  * SLcurses_wgetch(). If a signal is received (like SIGWINCH) when we
139  * are in blocking mode, SLsys_getkey() will not return an error unless
140  * a handler function is defined and it returns -1. This is needed so
141  * that if the user resizes the screen while at a prompt, it will just
142  * abort and go back to the main-menu. */
143  SLang_getkey_intr_hook = mutt_intr_hook;
144 #endif
145 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_emails_set_flag()

void mutt_emails_set_flag ( struct Mailbox m,
struct EmailList *  el,
enum MessageType  flag,
bool  bf 
)

Set flag on messages.

Parameters
mMailbox
elList of Emails to flag
flagFlag to set, e.g. MUTT_DELETE
bftrue: set the flag; false: clear the flag

Definition at line 354 of file flags.c.

356 {
357  if (!m || !el || STAILQ_EMPTY(el))
358  return;
359 
360  struct EmailNode *en = NULL;
361  STAILQ_FOREACH(en, el, entries)
362  {
363  mutt_set_flag(m, en->email, flag, bf);
364  }
365 }
+ Here is the caller graph for this function:

◆ mutt_change_flag()

int mutt_change_flag ( struct Mailbox m,
struct EmailList *  el,
bool  bf 
)

Change the flag on a Message.

Parameters
mMailbox
elList of Emails to change
bftrue: set the flag; false: clear the flag
Return values
0Success
-1Failure

Definition at line 436 of file flags.c.

437 {
438  if (!m || !el || STAILQ_EMPTY(el))
439  return -1;
440 
441  enum MessageType flag = MUTT_NONE;
442  struct KeyEvent event;
443 
445  "%s? (D/N/O/r/*/!): ", bf ? _("Set flag") : _("Clear flag"));
447  mutt_refresh();
448 
449  do
450  {
451  event = mutt_getch();
452  } while (event.ch == -2);
453  int i = event.ch;
454  if (i < 0)
455  {
457  return -1;
458  }
459 
461 
462  switch (i)
463  {
464  case 'd':
465  case 'D':
466  if (!bf)
467  mutt_emails_set_flag(m, el, MUTT_PURGE, bf);
468  flag = MUTT_DELETE;
469  break;
470 
471  case 'N':
472  case 'n':
473  flag = MUTT_NEW;
474  break;
475 
476  case 'o':
477  case 'O':
478  mutt_emails_set_flag(m, el, MUTT_READ, !bf);
479  flag = MUTT_OLD;
480  break;
481 
482  case 'r':
483  case 'R':
484  flag = MUTT_REPLIED;
485  break;
486 
487  case '*':
488  flag = MUTT_TAG;
489  break;
490 
491  case '!':
492  flag = MUTT_FLAG;
493  break;
494 
495  default:
496  mutt_beep(false);
497  return -1;
498  }
499 
500  mutt_emails_set_flag(m, el, flag, bf);
501  return 0;
502 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_complete()

int mutt_complete ( char *  buf,
size_t  buflen 
)

Attempt to complete a partial pathname.

Parameters
bufBuffer containing pathname
buflenLength of buffer
Return values
0if ok
-1if no matches

Given a partial pathname, fill in as much of the rest of the path as is unique.

Definition at line 57 of file complete.c.

58 {
59  char *p = NULL;
60  DIR *dirp = NULL;
61  struct dirent *de = NULL;
62  int init = 0;
63  size_t len;
64  struct Buffer *dirpart = NULL;
65  struct Buffer *exp_dirpart = NULL;
66  struct Buffer *filepart = NULL;
67  struct Buffer *tmp = NULL;
68 #ifdef USE_IMAP
69  struct Buffer *imap_path = NULL;
70  int rc;
71 #endif
72 
73  mutt_debug(LL_DEBUG2, "completing %s\n", buf);
74 
75 #ifdef USE_NNTP
76  if (OptNews)
77  return nntp_complete(buf, buflen);
78 #endif
79 
80 #ifdef USE_IMAP
81  imap_path = mutt_buffer_pool_get();
82  /* we can use '/' as a delimiter, imap_complete rewrites it */
83  if ((*buf == '=') || (*buf == '+') || (*buf == '!'))
84  {
85  if (*buf == '!')
86  p = NONULL(C_SpoolFile);
87  else
88  p = NONULL(C_Folder);
89 
90  mutt_buffer_concat_path(imap_path, p, buf + 1);
91  }
92  else
93  mutt_buffer_strcpy(imap_path, buf);
94 
95  if (imap_path_probe(mutt_buffer_string(imap_path), NULL) == MUTT_IMAP)
96  {
97  rc = imap_complete(buf, buflen, mutt_buffer_string(imap_path));
98  mutt_buffer_pool_release(&imap_path);
99  return rc;
100  }
101 
102  mutt_buffer_pool_release(&imap_path);
103 #endif
104 
105  dirpart = mutt_buffer_pool_get();
106  exp_dirpart = mutt_buffer_pool_get();
107  filepart = mutt_buffer_pool_get();
108  tmp = mutt_buffer_pool_get();
109 
110  if ((*buf == '=') || (*buf == '+') || (*buf == '!'))
111  {
112  mutt_buffer_addch(dirpart, *buf);
113  if (*buf == '!')
114  mutt_buffer_strcpy(exp_dirpart, NONULL(C_SpoolFile));
115  else
116  mutt_buffer_strcpy(exp_dirpart, NONULL(C_Folder));
117  p = strrchr(buf, '/');
118  if (p)
119  {
121  mutt_buffer_len(exp_dirpart), buf + 1,
122  (size_t)(p - buf - 1));
123  mutt_buffer_copy(exp_dirpart, tmp);
124  mutt_buffer_substrcpy(dirpart, buf, p + 1);
125  mutt_buffer_strcpy(filepart, p + 1);
126  }
127  else
128  mutt_buffer_strcpy(filepart, buf + 1);
129  dirp = opendir(mutt_buffer_string(exp_dirpart));
130  }
131  else
132  {
133  p = strrchr(buf, '/');
134  if (p)
135  {
136  if (p == buf) /* absolute path */
137  {
138  p = buf + 1;
139  mutt_buffer_strcpy(dirpart, "/");
140  mutt_buffer_strcpy(filepart, p);
141  dirp = opendir(mutt_buffer_string(dirpart));
142  }
143  else
144  {
145  mutt_buffer_substrcpy(dirpart, buf, p);
146  mutt_buffer_strcpy(filepart, p + 1);
147  mutt_buffer_copy(exp_dirpart, dirpart);
148  mutt_buffer_expand_path(exp_dirpart);
149  dirp = opendir(mutt_buffer_string(exp_dirpart));
150  }
151  }
152  else
153  {
154  /* no directory name, so assume current directory. */
155  mutt_buffer_strcpy(filepart, buf);
156  dirp = opendir(".");
157  }
158  }
159 
160  if (!dirp)
161  {
162  mutt_debug(LL_DEBUG1, "%s: %s (errno %d)\n",
163  mutt_buffer_string(exp_dirpart), strerror(errno), errno);
164  goto cleanup;
165  }
166 
167  /* special case to handle when there is no filepart yet. find the first
168  * file/directory which is not "." or ".." */
169  len = mutt_buffer_len(filepart);
170  if (len == 0)
171  {
172  while ((de = readdir(dirp)))
173  {
174  if (!mutt_str_equal(".", de->d_name) && !mutt_str_equal("..", de->d_name))
175  {
176  mutt_buffer_strcpy(filepart, de->d_name);
177  init++;
178  break;
179  }
180  }
181  }
182 
183  while ((de = readdir(dirp)))
184  {
185  if (mutt_strn_equal(de->d_name, mutt_buffer_string(filepart), len))
186  {
187  if (init)
188  {
189  char *cp = filepart->data;
190 
191  for (int i = 0; (*cp != '\0') && (de->d_name[i] != '\0'); i++, cp++)
192  {
193  if (*cp != de->d_name[i])
194  break;
195  }
196  *cp = '\0';
197  mutt_buffer_fix_dptr(filepart);
198  }
199  else
200  {
201  struct stat st;
202 
203  mutt_buffer_strcpy(filepart, de->d_name);
204 
205  /* check to see if it is a directory */
206  if (mutt_buffer_is_empty(dirpart))
207  {
208  mutt_buffer_reset(tmp);
209  }
210  else
211  {
212  mutt_buffer_copy(tmp, exp_dirpart);
213  mutt_buffer_addch(tmp, '/');
214  }
215  mutt_buffer_addstr(tmp, mutt_buffer_string(filepart));
216  if ((stat(mutt_buffer_string(tmp), &st) != -1) && (st.st_mode & S_IFDIR))
217  mutt_buffer_addch(filepart, '/');
218  init = 1;
219  }
220  }
221  }
222  closedir(dirp);
223 
224  if (!mutt_buffer_is_empty(dirpart))
225  {
226  mutt_str_copy(buf, mutt_buffer_string(dirpart), buflen);
227  if (!mutt_str_equal("/", mutt_buffer_string(dirpart)) &&
228  (mutt_buffer_string(dirpart)[0] != '=') && (mutt_buffer_string(dirpart)[0] != '+'))
229  {
230  mutt_str_copy(buf + strlen(buf), "/", buflen - strlen(buf));
231  }
232  mutt_str_copy(buf + strlen(buf), mutt_buffer_string(filepart), buflen - strlen(buf));
233  }
234  else
235  mutt_str_copy(buf, mutt_buffer_string(filepart), buflen);
236 
237 cleanup:
238  mutt_buffer_pool_release(&dirpart);
239  mutt_buffer_pool_release(&exp_dirpart);
240  mutt_buffer_pool_release(&filepart);
242 
243  return init ? 0 : -1;
244 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_prepare_template()

int mutt_prepare_template ( FILE *  fp,
struct Mailbox m,
struct Email e_new,
struct Email e,
bool  resend 
)

Prepare a message template.

Parameters
fpIf not NULL, file containing the template
mIf fp is NULL, the Mailbox containing the header with the template
e_newThe template is read into this Header
eEmail to recall/resend
resendSet if resending (as opposed to recalling a postponed msg) Resent messages enable header weeding, and also discard any existing Message-ID and Mail-Followup-To
Return values
0Success
-1Error

Definition at line 664 of file postpone.c.

666 {
667  struct Message *msg = NULL;
668  struct Body *b = NULL;
669  FILE *fp_body = NULL;
670  int rc = -1;
671  struct State s = { 0 };
672  SecurityFlags sec_type;
673  struct Envelope *protected_headers = NULL;
674 
675  if (!fp && !(msg = mx_msg_open(m, e->msgno)))
676  return -1;
677 
678  if (!fp)
679  fp = msg->fp;
680 
681  fp_body = fp;
682 
683  /* parse the message header and MIME structure */
684 
685  fseeko(fp, e->offset, SEEK_SET);
686  e_new->offset = e->offset;
687  /* enable header weeding for resent messages */
688  e_new->env = mutt_rfc822_read_header(fp, e_new, true, resend);
689  e_new->body->length = e->body->length;
690  mutt_parse_part(fp, e_new->body);
691 
692  /* If resending a message, don't keep message_id or mail_followup_to.
693  * Otherwise, we are resuming a postponed message, and want to keep those
694  * headers if they exist. */
695  if (resend)
696  {
697  FREE(&e_new->env->message_id);
698  FREE(&e_new->env->mail_followup_to);
699  }
700 
701  /* decrypt pgp/mime encoded messages */
702 
703  if (((WithCrypto & APPLICATION_PGP) != 0) &&
704  (sec_type = mutt_is_multipart_encrypted(e_new->body)))
705  {
706  e_new->security |= sec_type;
707  if (!crypt_valid_passphrase(sec_type))
708  goto bail;
709 
710  mutt_message(_("Decrypting message..."));
711  if ((crypt_pgp_decrypt_mime(fp, &fp_body, e_new->body, &b) == -1) || !b)
712  {
713  goto bail;
714  }
715 
716  mutt_body_free(&e_new->body);
717  e_new->body = b;
718 
719  if (b->mime_headers)
720  {
721  protected_headers = b->mime_headers;
722  b->mime_headers = NULL;
723  }
724 
726  }
727 
728  /* remove a potential multipart/signed layer - useful when
729  * resending messages */
730  if ((WithCrypto != 0) && mutt_is_multipart_signed(e_new->body))
731  {
732  e_new->security |= SEC_SIGN;
733  if (((WithCrypto & APPLICATION_PGP) != 0) &&
734  mutt_istr_equal(mutt_param_get(&e_new->body->parameter, "protocol"),
735  "application/pgp-signature"))
736  {
737  e_new->security |= APPLICATION_PGP;
738  }
739  else if (WithCrypto & APPLICATION_SMIME)
740  e_new->security |= APPLICATION_SMIME;
741 
742  /* destroy the signature */
743  mutt_body_free(&e_new->body->parts->next);
744  e_new->body = mutt_remove_multipart(e_new->body);
745 
746  if (e_new->body->mime_headers)
747  {
748  mutt_env_free(&protected_headers);
749  protected_headers = e_new->body->mime_headers;
750  e_new->body->mime_headers = NULL;
751  }
752  }
753 
754  /* We don't need no primary multipart.
755  * Note: We _do_ preserve messages!
756  *
757  * XXX - we don't handle multipart/alternative in any
758  * smart way when sending messages. However, one may
759  * consider this a feature. */
760  if (e_new->body->type == TYPE_MULTIPART)
761  e_new->body = mutt_remove_multipart(e_new->body);
762 
763  s.fp_in = fp_body;
764 
765  struct Buffer *file = mutt_buffer_pool_get();
766 
767  /* create temporary files for all attachments */
768  for (b = e_new->body; b; b = b->next)
769  {
770  /* what follows is roughly a receive-mode variant of
771  * mutt_get_tmp_attachment () from muttlib.c */
772 
773  mutt_buffer_reset(file);
774  if (b->filename)
775  {
776  mutt_buffer_strcpy(file, b->filename);
778  }
779  else
780  {
781  /* avoid Content-Disposition: header with temporary filename */
782  b->use_disp = false;
783  }
784 
785  /* set up state flags */
786 
787  s.flags = 0;
788 
789  if (b->type == TYPE_TEXT)
790  {
791  if (mutt_istr_equal("yes",
792  mutt_param_get(&b->parameter, "x-mutt-noconv")))
793  {
794  b->noconv = true;
795  }
796  else
797  {
798  s.flags |= MUTT_CHARCONV;
799  b->noconv = false;
800  }
801 
802  mutt_param_delete(&b->parameter, "x-mutt-noconv");
803  }
804 
805  mutt_adv_mktemp(file);
806  s.fp_out = mutt_file_fopen(mutt_buffer_string(file), "w");
807  if (!s.fp_out)
808  goto bail;
809 
810  if (((WithCrypto & APPLICATION_PGP) != 0) &&
811  ((sec_type = mutt_is_application_pgp(b)) & (SEC_ENCRYPT | SEC_SIGN)))
812  {
813  if (sec_type & SEC_ENCRYPT)
814  {
816  goto bail;
817  mutt_message(_("Decrypting message..."));
818  }
819 
820  if (mutt_body_handler(b, &s) < 0)
821  {
822  mutt_error(_("Decryption failed"));
823  goto bail;
824  }
825 
826  if ((b == e_new->body) && !protected_headers)
827  {
828  protected_headers = b->mime_headers;
829  b->mime_headers = NULL;
830  }
831 
832  e_new->security |= sec_type;
833  b->type = TYPE_TEXT;
834  mutt_str_replace(&b->subtype, "plain");
835  mutt_param_delete(&b->parameter, "x-action");
836  }
837  else if (((WithCrypto & APPLICATION_SMIME) != 0) &&
838  ((sec_type = mutt_is_application_smime(b)) & (SEC_ENCRYPT | SEC_SIGN)))
839  {
840  if (sec_type & SEC_ENCRYPT)
841  {
843  goto bail;
844  crypt_smime_getkeys(e_new->env);
845  mutt_message(_("Decrypting message..."));
846  }
847 
848  if (mutt_body_handler(b, &s) < 0)
849  {
850  mutt_error(_("Decryption failed"));
851  goto bail;
852  }
853 
854  e_new->security |= sec_type;
855  b->type = TYPE_TEXT;
856  mutt_str_replace(&b->subtype, "plain");
857  }
858  else
859  mutt_decode_attachment(b, &s);
860 
861  if (mutt_file_fclose(&s.fp_out) != 0)
862  goto bail;
863 
865  b->unlink = true;
866 
868 
869  mutt_body_free(&b->parts);
870  if (b->email)
871  b->email->body = NULL; /* avoid dangling pointer */
872  }
873 
874  if (C_CryptProtectedHeadersRead && protected_headers && protected_headers->subject &&
875  !mutt_str_equal(e_new->env->subject, protected_headers->subject))
876  {
877  mutt_str_replace(&e_new->env->subject, protected_headers->subject);
878  }
879  mutt_env_free(&protected_headers);
880 
881  /* Fix encryption flags. */
882 
883  /* No inline if multipart. */
884  if ((WithCrypto != 0) && (e_new->security & SEC_INLINE) && e_new->body->next)
885  e_new->security &= ~SEC_INLINE;
886 
887  /* Do we even support multiple mechanisms? */
889 
890  /* Theoretically, both could be set. Take the one the user wants to set by default. */
891  if ((e_new->security & APPLICATION_PGP) && (e_new->security & APPLICATION_SMIME))
892  {
893  if (C_SmimeIsDefault)
894  e_new->security &= ~APPLICATION_PGP;
895  else
896  e_new->security &= ~APPLICATION_SMIME;
897  }
898 
900 
901  rc = 0;
902 
903 bail:
904 
905  /* that's it. */
907  if (fp_body != fp)
908  mutt_file_fclose(&fp_body);
909  if (msg)
910  mx_msg_close(m, &msg);
911 
912  if (rc == -1)
913  {
914  mutt_env_free(&e_new->env);
915  mutt_body_free(&e_new->body);
916  }
917 
918  return rc;
919 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_enter_string()

int mutt_enter_string ( char *  buf,
size_t  buflen,
int  col,
CompletionFlags  flags 
)

Ask the user for a string.

Parameters
bufBuffer to store the string
buflenBuffer length
colInitial cursor position
flagsFlags, see CompletionFlags
Return values
0if input was given
-1if abort

This function is for very basic input, currently used only by the built-in editor. It does not handle screen redrawing on resizes well, because there is no active menu for the built-in editor. Most callers should prefer mutt_get_field() instead.

Definition at line 147 of file enter.c.

148 {
149  int rc;
150  struct EnterState *es = mutt_enter_state_new();
151  do
152  {
153  if (SigWinch)
154  {
155  SigWinch = 0;
157  clearok(stdscr, true);
158  }
159  rc = mutt_enter_string_full(buf, buflen, col, flags, false, NULL, NULL, NULL, es);
160  } while (rc == 1);
162  return rc;
163 }
+ Here is the call graph for this function:

◆ mutt_enter_string_full()

int mutt_enter_string_full ( char *  buf,
size_t  buflen,
int  col,
CompletionFlags  flags,
bool  multiple,
struct Mailbox m,
char ***  files,
int *  numfiles,
struct EnterState state 
)

Ask the user for a string.

Parameters
[in]bufBuffer to store the string
[in]buflenBuffer length
[in]colInitial cursor position
[in]flagsFlags, see CompletionFlags
[in]multipleAllow multiple matches
[in]mMailbox
[out]filesList of files selected
[out]numfilesNumber of files selected
[out]stateCurrent state (if function is called repeatedly)
Return values
1Redraw the screen and call the function again
0Selection made
-1Aborted

Definition at line 180 of file enter.c.

183 {
184  int width = MessageWindow->state.cols - col - 1;
185  enum EnterRedrawFlags redraw = ENTER_REDRAW_NONE;
186  bool pass = (flags & MUTT_PASS);
187  bool first = true;
188  int ch;
189  wchar_t *tempbuf = NULL;
190  size_t templen = 0;
191  enum HistoryClass hclass;
192  int rc = 0;
193  mbstate_t mbstate;
194  memset(&mbstate, 0, sizeof(mbstate));
195 
196  if (state->wbuf)
197  {
198  /* Coming back after return 1 */
199  redraw = ENTER_REDRAW_LINE;
200  first = false;
201  }
202  else
203  {
204  /* Initialise wbuf from buf */
205  state->wbuflen = 0;
206  state->lastchar = mutt_mb_mbstowcs(&state->wbuf, &state->wbuflen, 0, buf);
207  redraw = ENTER_REDRAW_INIT;
208  }
209 
210  if (flags & MUTT_FILE)
211  hclass = HC_FILE;
212  else if (flags & MUTT_EFILE)
213  hclass = HC_MBOX;
214  else if (flags & MUTT_CMD)
215  hclass = HC_CMD;
216  else if (flags & MUTT_ALIAS)
217  hclass = HC_ALIAS;
218  else if (flags & MUTT_COMMAND)
219  hclass = HC_COMMAND;
220  else if (flags & MUTT_PATTERN)
221  hclass = HC_PATTERN;
222  else
223  hclass = HC_OTHER;
224 
225  while (true)
226  {
227  if (!pass)
228  {
229  if (redraw == ENTER_REDRAW_INIT)
230  {
231  /* Go to end of line */
232  state->curpos = state->lastchar;
233  state->begin = mutt_mb_width_ceiling(
234  state->wbuf, state->lastchar,
235  mutt_mb_wcswidth(state->wbuf, state->lastchar) - width + 1);
236  }
237  if ((state->curpos < state->begin) ||
238  (mutt_mb_wcswidth(state->wbuf + state->begin, state->curpos - state->begin) >= width))
239  {
240  state->begin = mutt_mb_width_ceiling(
241  state->wbuf, state->lastchar,
242  mutt_mb_wcswidth(state->wbuf, state->curpos) - (width / 2));
243  }
245  int w = 0;
246  for (size_t i = state->begin; i < state->lastchar; i++)
247  {
248  w += mutt_mb_wcwidth(state->wbuf[i]);
249  if (w > width)
250  break;
251  my_addwch(state->wbuf[i]);
252  }
255  col + mutt_mb_wcswidth(state->wbuf + state->begin,
256  state->curpos - state->begin),
257  0);
258  }
259  mutt_refresh();
260 
261  ch = km_dokey(MENU_EDITOR);
262  if (ch < 0)
263  {
264  rc = (SigWinch && (ch == -2)) ? 1 : -1;
265  goto bye;
266  }
267 
268  if (ch != OP_NULL)
269  {
270  first = false;
271  if ((ch != OP_EDITOR_COMPLETE) && (ch != OP_EDITOR_COMPLETE_QUERY))
272  state->tabs = 0;
273  redraw = ENTER_REDRAW_LINE;
274  switch (ch)
275  {
276  case OP_EDITOR_HISTORY_UP:
277  state->curpos = state->lastchar;
278  if (mutt_hist_at_scratch(hclass))
279  {
280  mutt_mb_wcstombs(buf, buflen, state->wbuf, state->curpos);
281  mutt_hist_save_scratch(hclass, buf);
282  }
283  replace_part(state, 0, mutt_hist_prev(hclass));
284  redraw = ENTER_REDRAW_INIT;
285  break;
286 
287  case OP_EDITOR_HISTORY_DOWN:
288  state->curpos = state->lastchar;
289  if (mutt_hist_at_scratch(hclass))
290  {
291  mutt_mb_wcstombs(buf, buflen, state->wbuf, state->curpos);
292  mutt_hist_save_scratch(hclass, buf);
293  }
294  replace_part(state, 0, mutt_hist_next(hclass));
295  redraw = ENTER_REDRAW_INIT;
296  break;
297 
298  case OP_EDITOR_HISTORY_SEARCH:
299  state->curpos = state->lastchar;
300  mutt_mb_wcstombs(buf, buflen, state->wbuf, state->curpos);
301  mutt_hist_complete(buf, buflen, hclass);
302  replace_part(state, 0, buf);
303  rc = 1;
304  goto bye;
305  break;
306 
307  case OP_EDITOR_BACKSPACE:
308  if (state->curpos == 0)
309  {
310  // Pressing backspace when no text is in the command prompt should exit the prompt
311  if (C_AbortBackspace && (state->lastchar == 0))
312  goto bye;
313  // Pressing backspace with text in the command prompt should just beep
314  mutt_beep(false);
315  }
316  else
317  {
318  size_t i = state->curpos;
319  while ((i > 0) && COMB_CHAR(state->wbuf[i - 1]))
320  i--;
321  if (i > 0)
322  i--;
323  memmove(state->wbuf + i, state->wbuf + state->curpos,
324  (state->lastchar - state->curpos) * sizeof(wchar_t));
325  state->lastchar -= state->curpos - i;
326  state->curpos = i;
327  }
328  break;
329 
330  case OP_EDITOR_BOL:
331  state->curpos = 0;
332  break;
333 
334  case OP_EDITOR_EOL:
335  redraw = ENTER_REDRAW_INIT;
336  break;
337 
338  case OP_EDITOR_KILL_LINE:
339  state->curpos = 0;
340  state->lastchar = 0;
341  break;
342 
343  case OP_EDITOR_KILL_EOL:
344  state->lastchar = state->curpos;
345  break;
346 
347  case OP_EDITOR_BACKWARD_CHAR:
348  if (state->curpos == 0)
349  mutt_beep(false);
350  else
351  {
352  while (state->curpos && COMB_CHAR(state->wbuf[state->curpos - 1]))
353  state->curpos--;
354  if (state->curpos)
355  state->curpos--;
356  }
357  break;
358 
359  case OP_EDITOR_FORWARD_CHAR:
360  if (state->curpos == state->lastchar)
361  mutt_beep(false);
362  else
363  {
364  state->curpos++;
365  while ((state->curpos < state->lastchar) &&
366  COMB_CHAR(state->wbuf[state->curpos]))
367  {
368  state->curpos++;
369  }
370  }
371  break;
372 
373  case OP_EDITOR_BACKWARD_WORD:
374  if (state->curpos == 0)
375  mutt_beep(false);
376  else
377  {
378  while (state->curpos && iswspace(state->wbuf[state->curpos - 1]))
379  state->curpos--;
380  while (state->curpos && !iswspace(state->wbuf[state->curpos - 1]))
381  state->curpos--;
382  }
383  break;
384 
385  case OP_EDITOR_FORWARD_WORD:
386  if (state->curpos == state->lastchar)
387  mutt_beep(false);
388  else
389  {
390  while ((state->curpos < state->lastchar) &&
391  iswspace(state->wbuf[state->curpos]))
392  {
393  state->curpos++;
394  }
395  while ((state->curpos < state->lastchar) &&
396  !iswspace(state->wbuf[state->curpos]))
397  {
398  state->curpos++;
399  }
400  }
401  break;
402 
403  case OP_EDITOR_CAPITALIZE_WORD:
404  case OP_EDITOR_UPCASE_WORD:
405  case OP_EDITOR_DOWNCASE_WORD:
406  if (state->curpos == state->lastchar)
407  {
408  mutt_beep(false);
409  break;
410  }
411  while (state->curpos && !iswspace(state->wbuf[state->curpos]))
412  state->curpos--;
413  while ((state->curpos < state->lastchar) && iswspace(state->wbuf[state->curpos]))
414  state->curpos++;
415  while ((state->curpos < state->lastchar) &&
416  !iswspace(state->wbuf[state->curpos]))
417  {
418  if (ch == OP_EDITOR_DOWNCASE_WORD)
419  state->wbuf[state->curpos] = towlower(state->wbuf[state->curpos]);
420  else
421  {
422  state->wbuf[state->curpos] = towupper(state->wbuf[state->curpos]);
423  if (ch == OP_EDITOR_CAPITALIZE_WORD)
424  ch = OP_EDITOR_DOWNCASE_WORD;
425  }
426  state->curpos++;
427  }
428  break;
429 
430  case OP_EDITOR_DELETE_CHAR:
431  if (state->curpos == state->lastchar)
432  mutt_beep(false);
433  else
434  {
435  size_t i = state->curpos;
436  while ((i < state->lastchar) && COMB_CHAR(state->wbuf[i]))
437  i++;
438  if (i < state->lastchar)
439  i++;
440  while ((i < state->lastchar) && COMB_CHAR(state->wbuf[i]))
441  i++;
442  memmove(state->wbuf + state->curpos, state->wbuf + i,
443  (state->lastchar - i) * sizeof(wchar_t));
444  state->lastchar -= i - state->curpos;
445  }
446  break;
447 
448  case OP_EDITOR_KILL_WORD:
449  /* delete to beginning of word */
450  if (state->curpos != 0)
451  {
452  size_t i = state->curpos;
453  while (i && iswspace(state->wbuf[i - 1]))
454  i--;
455  if (i > 0)
456  {
457  if (iswalnum(state->wbuf[i - 1]))
458  {
459  for (--i; (i > 0) && iswalnum(state->wbuf[i - 1]); i--)
460  ; // do nothing
461  }
462  else
463  i--;
464  }
465  memmove(state->wbuf + i, state->wbuf + state->curpos,
466  (state->lastchar - state->curpos) * sizeof(wchar_t));
467  state->lastchar += i - state->curpos;
468  state->curpos = i;
469  }
470  break;
471 
472  case OP_EDITOR_KILL_EOW:
473  {
474  /* delete to end of word */
475 
476  /* first skip over whitespace */
477  size_t i;
478  for (i = state->curpos; (i < state->lastchar) && iswspace(state->wbuf[i]); i++)
479  ; // do nothing
480 
481  /* if there are any characters left.. */
482  if (i < state->lastchar)
483  {
484  /* if the current character is alphanumeric.. */
485  if (iswalnum(state->wbuf[i]))
486  {
487  /* skip over the rest of the word consistent of only alphanumerics */
488  for (; (i < state->lastchar) && iswalnum(state->wbuf[i]); i++)
489  ; // do nothing
490  }
491  else
492  {
493  /* skip over one non-alphanumeric character */
494  i++;
495  }
496  }
497 
498  memmove(state->wbuf + state->curpos, state->wbuf + i,
499  (state->lastchar - i) * sizeof(wchar_t));
500  state->lastchar += state->curpos - i;
501  break;
502  }
503 
504  case OP_EDITOR_MAILBOX_CYCLE:
505  if (flags & MUTT_EFILE)
506  {
507  first = true; /* clear input if user types a real key later */
508  mutt_mb_wcstombs(buf, buflen, state->wbuf, state->curpos);
509 
510  struct Buffer *pool = mutt_buffer_pool_get();
511  mutt_buffer_addstr(pool, buf);
512  mutt_mailbox_next(m, pool);
513  mutt_str_copy(buf, mutt_buffer_string(pool), buflen);
515 
516  state->curpos = state->lastchar =
517  mutt_mb_mbstowcs(&state->wbuf, &state->wbuflen, 0, buf);
518  break;
519  }
520  else if (!(flags & MUTT_FILE))
521  {
522  goto self_insert;
523  }
524  /* fallthrough */
525 
526  case OP_EDITOR_COMPLETE:
527  case OP_EDITOR_COMPLETE_QUERY:
528  state->tabs++;
529  if (flags & MUTT_CMD)
530  {
531  size_t i;
532  for (i = state->curpos;
533  (i > 0) && !mutt_mb_is_shell_char(state->wbuf[i - 1]); i--)
534  {
535  }
536  mutt_mb_wcstombs(buf, buflen, state->wbuf + i, state->curpos - i);
537  if (tempbuf && (templen == (state->lastchar - i)) &&
538  (memcmp(tempbuf, state->wbuf + i, (state->lastchar - i) * sizeof(wchar_t)) == 0))
539  {
541  m, NULL, NULL);
542  if (buf[0] != '\0')
543  replace_part(state, i, buf);
544  rc = 1;
545  goto bye;
546  }
547  if (mutt_complete(buf, buflen) == 0)
548  {
549  templen = state->lastchar - i;
550  mutt_mem_realloc(&tempbuf, templen * sizeof(wchar_t));
551  }
552  else
553  mutt_beep(false);
554 
555  replace_part(state, i, buf);
556  }
557  else if ((flags & MUTT_ALIAS) && (ch == OP_EDITOR_COMPLETE))
558  {
559  /* invoke the alias-menu to get more addresses */
560  size_t i;
561  for (i = state->curpos;
562  (i > 0) && (state->wbuf[i - 1] != ',') && (state->wbuf[i - 1] != ':'); i--)
563  {
564  }
565  for (; (i < state->lastchar) && (state->wbuf[i] == ' '); i++)
566  ; // do nothing
567 
568  mutt_mb_wcstombs(buf, buflen, state->wbuf + i, state->curpos - i);
569  int rc2 = alias_complete(buf, buflen, NeoMutt->sub);
570  replace_part(state, i, buf);
571  if (rc2 != 1)
572  {
573  rc = 1;
574  goto bye;
575  }
576  break;
577  }
578  else if ((flags & MUTT_LABEL) && (ch == OP_EDITOR_COMPLETE))
579  {
580  size_t i;
581  for (i = state->curpos;
582  (i > 0) && (state->wbuf[i - 1] != ',') && (state->wbuf[i - 1] != ':'); i--)
583  {
584  }
585  for (; (i < state->lastchar) && (state->wbuf[i] == ' '); i++)
586  ; // do nothing
587 
588  mutt_mb_wcstombs(buf, buflen, state->wbuf + i, state->curpos - i);
589  int rc2 = mutt_label_complete(buf, buflen, state->tabs);
590  replace_part(state, i, buf);
591  if (rc2 != 1)
592  {
593  rc = 1;
594  goto bye;
595  }
596  break;
597  }
598  else if ((flags & MUTT_PATTERN) && (ch == OP_EDITOR_COMPLETE))
599  {
600  size_t i = state->curpos;
601  if (i && (state->wbuf[i - 1] == '~'))
602  {
603  if (dlg_select_pattern(buf, buflen))
604  replace_part(state, i - 1, buf);
605  rc = 1;
606  goto bye;
607  }
608  for (; (i > 0) && (state->wbuf[i - 1] != '~'); i--)
609  ; // do nothing
610 
611  if ((i > 0) && (i < state->curpos) && (state->wbuf[i - 1] == '~') &&
612  (state->wbuf[i] == 'y'))
613  {
614  i++;
615  mutt_mb_wcstombs(buf, buflen, state->wbuf + i, state->curpos - i);
616  int rc2 = mutt_label_complete(buf, buflen, state->tabs);
617  replace_part(state, i, buf);
618  if (rc2 != 1)
619  {
620  rc = 1;
621  goto bye;
622  }
623  }
624  else
625  goto self_insert;
626  break;
627  }
628  else if ((flags & MUTT_ALIAS) && (ch == OP_EDITOR_COMPLETE_QUERY))
629  {
630  size_t i = state->curpos;
631  if (i != 0)
632  {
633  for (; (i > 0) && (state->wbuf[i - 1] != ','); i--)
634  ; // do nothing
635 
636  for (; (i < state->curpos) && (state->wbuf[i] == ' '); i++)
637  ; // do nothing
638  }
639 
640  mutt_mb_wcstombs(buf, buflen, state->wbuf + i, state->curpos - i);
641  query_complete(buf, buflen, NeoMutt->sub);
642  replace_part(state, i, buf);
643 
644  rc = 1;
645  goto bye;
646  }
647  else if (flags & MUTT_COMMAND)
648  {
649  mutt_mb_wcstombs(buf, buflen, state->wbuf, state->curpos);
650  size_t i = strlen(buf);
651  if ((i != 0) && (buf[i - 1] == '=') &&
652  (mutt_var_value_complete(buf, buflen, i) != 0))
653  {
654  state->tabs = 0;
655  }
656  else if (mutt_command_complete(buf, buflen, i, state->tabs) == 0)
657  mutt_beep(false);
658  replace_part(state, 0, buf);
659  }
660  else if (flags & (MUTT_FILE | MUTT_EFILE))
661  {
662  mutt_mb_wcstombs(buf, buflen, state->wbuf, state->curpos);
663 
664  /* see if the path has changed from the last time */
665  if ((!tempbuf && !state->lastchar) ||
666  (tempbuf && (templen == state->lastchar) &&
667  (memcmp(tempbuf, state->wbuf, state->lastchar * sizeof(wchar_t)) == 0)))
668  {
669  mutt_select_file(buf, buflen,
671  (multiple ? MUTT_SEL_MULTI : MUTT_SEL_NO_FLAGS),
672  m, files, numfiles);
673  if (buf[0] != '\0')
674  {
675  mutt_pretty_mailbox(buf, buflen);
676  if (!pass)
677  mutt_hist_add(hclass, buf, true);
678  rc = 0;
679  goto bye;
680  }
681 
682  /* file selection cancelled */
683  rc = 1;
684  goto bye;
685  }
686 
687  if (mutt_complete(buf, buflen) == 0)
688  {
689  templen = state->lastchar;
690  mutt_mem_realloc(&tempbuf, templen * sizeof(wchar_t));
691  memcpy(tempbuf, state->wbuf, templen * sizeof(wchar_t));
692  }
693  else
694  mutt_beep(false); /* let the user know that nothing matched */
695  replace_part(state, 0, buf);
696  }
697 #ifdef USE_NOTMUCH
698  else if (flags & MUTT_NM_QUERY)
699  {
700  mutt_mb_wcstombs(buf, buflen, state->wbuf, state->curpos);
701  size_t len = strlen(buf);
702  if (!mutt_nm_query_complete(buf, buflen, len, state->tabs))
703  mutt_beep(false);
704 
705  replace_part(state, 0, buf);
706  }
707  else if (flags & MUTT_NM_TAG)
708  {
709  mutt_mb_wcstombs(buf, buflen, state->wbuf, state->curpos);
710  if (!mutt_nm_tag_complete(buf, buflen, state->tabs))
711  mutt_beep(false);
712 
713  replace_part(state, 0, buf);
714  }
715 #endif
716  else
717  goto self_insert;
718  break;
719 
720  case OP_EDITOR_QUOTE_CHAR:
721  {
722  struct KeyEvent event;
723  do
724  {
725  event = mutt_getch();
726  } while (event.ch == -2);
727  if (event.ch >= 0)
728  {
729  LastKey = event.ch;
730  goto self_insert;
731  }
732  break;
733  }
734 
735  case OP_EDITOR_TRANSPOSE_CHARS:
736  if (state->lastchar < 2)
737  mutt_beep(false);
738  else
739  {
740  wchar_t t;
741 
742  if (state->curpos == 0)
743  state->curpos = 2;
744  else if (state->curpos < state->lastchar)
745  state->curpos++;
746 
747  t = state->wbuf[state->curpos - 2];
748  state->wbuf[state->curpos - 2] = state->wbuf[state->curpos - 1];
749  state->wbuf[state->curpos - 1] = t;
750  }
751  break;
752 
753  default:
754  mutt_beep(false);
755  }
756  }
757  else
758  {
759  self_insert:
760  state->tabs = 0;
761  wchar_t wc;
762  /* use the raw keypress */
763  ch = LastKey;
764 
765  /* quietly ignore all other function keys */
766  if (ch & ~0xff)
767  continue;
768 
769  /* gather the octets into a wide character */
770  {
771  char c = ch;
772  size_t k = mbrtowc(&wc, &c, 1, &mbstate);
773  if (k == (size_t)(-2))
774  continue;
775  else if ((k != 0) && (k != 1))
776  {
777  memset(&mbstate, 0, sizeof(mbstate));
778  continue;
779  }
780  }
781 
782  if (first && (flags & MUTT_CLEAR))
783  {
784  first = false;
785  if (IsWPrint(wc)) /* why? */
786  {
787  state->curpos = 0;
788  state->lastchar = 0;
789  }
790  }
791 
792  if ((wc == '\r') || (wc == '\n'))
793  {
794  /* Convert from wide characters */
795  mutt_mb_wcstombs(buf, buflen, state->wbuf, state->lastchar);
796  if (!pass)
797  mutt_hist_add(hclass, buf, true);
798 
799  if (multiple)
800  {
801  char **tfiles = NULL;
802  *numfiles = 1;
803  tfiles = mutt_mem_calloc(*numfiles, sizeof(char *));
804  mutt_expand_path(buf, buflen);
805  tfiles[0] = mutt_str_dup(buf);
806  *files = tfiles;
807  }
808  rc = 0;
809  goto bye;
810  }
811  else if (wc && ((wc < ' ') || IsWPrint(wc))) /* why? */
812  {
813  if (state->lastchar >= state->wbuflen)
814  {
815  state->wbuflen = state->lastchar + 20;
816  mutt_mem_realloc(&state->wbuf, state->wbuflen * sizeof(wchar_t));
817  }
818  memmove(state->wbuf + state->curpos + 1, state->wbuf + state->curpos,
819  (state->lastchar - state->curpos) * sizeof(wchar_t));
820  state->wbuf[state->curpos++] = wc;
821  state->lastchar++;
822  }
823  else
824  {
825  mutt_flushinp();
826  mutt_beep(false);
827  }
828  }
829  }
830 
831 bye:
832 
833  mutt_hist_reset_state(hclass);
834  FREE(&tempbuf);
835  return rc;
836 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_get_postponed()

int mutt_get_postponed ( struct Context ctx,
struct Email hdr,
struct Email **  cur,
struct Buffer fcc 
)

Recall a postponed message.

Parameters
[in]ctxContext info, used when recalling a message to which we reply
[in]hdrenvelope/attachment info for recalled message
[out]curif message was a reply, 'cur' is set to the message which 'hdr' is in reply to
[in]fccfcc for the recalled message
Return values
-1Error/no messages
0Normal exit
SEND_REPLYRecalled message is a reply

Definition at line 331 of file postpone.c.

333 {
334  if (!C_Postponed)
335  return -1;
336 
337  struct Email *e = NULL;
338  int rc = SEND_POSTPONED;
339  const char *p = NULL;
340  struct Context *ctx_post = NULL;
341 
342  struct Mailbox *m = mx_path_resolve(C_Postponed);
343  if (ctx && (ctx->mailbox == m))
344  ctx_post = ctx;
345  else
346  ctx_post = mx_mbox_open(m, MUTT_NOSORT);
347 
348  if (!ctx_post)
349  {
350  PostCount = 0;
351  mutt_error(_("No postponed messages"));
352  mailbox_free(&m);
353  return -1;
354  }
355 
356  /* TODO:
357  * mx_mbox_open() for IMAP leaves IMAP_REOPEN_ALLOW set. For the
358  * index this is papered-over because it calls mx_check_mailbox()
359  * every event loop(which resets that flag).
360  *
361  * For a stable-branch fix, I'm doing the same here, to prevent
362  * context changes from occuring behind the scenes and causing
363  * segvs, but probably the flag needs to be reset after downloading
364  * headers in imap_open_mailbox().
365  */
366  mx_mbox_check(ctx_post->mailbox);
367 
368  if (ctx_post->mailbox->msg_count == 0)
369  {
370  PostCount = 0;
371  if (ctx_post == ctx)
372  ctx_post = NULL;
373  else
374  mx_fastclose_mailbox(ctx_post->mailbox);
375  mutt_error(_("No postponed messages"));
376  return -1;
377  }
378 
379  if (ctx_post->mailbox->msg_count == 1)
380  {
381  /* only one message, so just use that one. */
382  e = ctx_post->mailbox->emails[0];
383  }
384  else if (!(e = dlg_select_postponed_email(ctx_post)))
385  {
386  if (ctx_post == ctx)
387  {
388  ctx_post = NULL;
389  }
390  else
391  {
392  hardclose(&ctx_post);
393  }
394  return -1;
395  }
396 
397  if (mutt_prepare_template(NULL, ctx_post->mailbox, hdr, e, false) < 0)
398  {
399  if (ctx_post != ctx)
400  {
401  mx_fastclose_mailbox(ctx_post->mailbox);
402  FREE(&ctx_post);
403  }
404  return -1;
405  }
406 
407  /* finished with this message, so delete it. */
408  mutt_set_flag(ctx_post->mailbox, e, MUTT_DELETE, true);
409  mutt_set_flag(ctx_post->mailbox, e, MUTT_PURGE, true);
410 
411  /* update the count for the status display */
412  PostCount = ctx_post->mailbox->msg_count - ctx_post->mailbox->msg_deleted;
413 
414  /* avoid the "purge deleted messages" prompt */
415  int opt_delete = C_Delete;
416  C_Delete = MUTT_YES;
417  if (ctx_post == ctx)
418  {
419  ctx_post = NULL;
420  }
421  else
422  {
423  hardclose(&ctx_post);
424  }
425  C_Delete = opt_delete;
426 
427  struct ListNode *np = NULL, *tmp = NULL;
428  STAILQ_FOREACH_SAFE(np, &hdr->env->userhdrs, entries, tmp)
429  {
430  size_t plen = mutt_istr_startswith(np->data, "X-Mutt-References:");
431  if (plen)
432  {
433  /* if a mailbox is currently open, look to see if the original message
434  * the user attempted to reply to is in this mailbox */
435  p = mutt_str_skip_email_wsp(np->data + plen);
436  if (!ctx->mailbox->id_hash)
438  *cur = mutt_hash_find(ctx->mailbox->id_hash, p);
439 
440  if (*cur)
441  rc |= SEND_REPLY;
442  }
443  else if ((plen = mutt_istr_startswith(np->data, "X-Mutt-Fcc:")))
444  {
445  p = mutt_str_skip_email_wsp(np->data + plen);
446  mutt_buffer_strcpy(fcc, p);
448 
449  /* note that x-mutt-fcc was present. we do this because we want to add a
450  * default fcc if the header was missing, but preserve the request of the
451  * user to not make a copy if the header field is present, but empty.
452  * see http://dev.mutt.org/trac/ticket/3653 */
453  rc |= SEND_POSTPONED_FCC;
454  }
455  else if (((WithCrypto & APPLICATION_PGP) != 0) &&
456  /* this is generated by old neomutt versions */
457  (mutt_str_startswith(np->data, "Pgp:") ||
458  /* this is the new way */
459  mutt_str_startswith(np->data, "X-Mutt-PGP:")))
460  {
461  hdr->security = mutt_parse_crypt_hdr(strchr(np->data, ':') + 1, true, APPLICATION_PGP);
462  hdr->security |= APPLICATION_PGP;
463  }
464  else if (((WithCrypto & APPLICATION_SMIME) != 0) &&
465  mutt_str_startswith(np->data, "X-Mutt-SMIME:"))
466  {
467  hdr->security = mutt_parse_crypt_hdr(strchr(np->data, ':') + 1, true, APPLICATION_SMIME);
468  hdr->security |= APPLICATION_SMIME;
469  }
470 #ifdef MIXMASTER
471  else if (mutt_str_startswith(np->data, "X-Mutt-Mix:"))
472  {
473  mutt_list_free(&hdr->chain);
474 
475  char *t = strtok(np->data + 11, " \t\n");
476  while (t)
477  {
479  t = strtok(NULL, " \t\n");
480  }
481  }
482 #endif
483  else
484  {
485  // skip header removal
486  continue;
487  }
488 
489  // remove the header
490  STAILQ_REMOVE(&hdr->env->userhdrs, np, ListNode, entries);
491  FREE(&np->data);
492  FREE(&np);
493  }
494 
497 
498  return rc;
499 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_parse_crypt_hdr()

SecurityFlags mutt_parse_crypt_hdr ( const char *  p,
bool  set_empty_signas,
SecurityFlags  crypt_app 
)

Parse a crypto header string.

Parameters
pHeader string to parse
set_empty_signasAllow an empty "Sign as"
crypt_appApp, e.g. APPLICATION_PGP
Return values
numSecurityFlags, see SecurityFlags

Definition at line 508 of file postpone.c.

509 {
510  char smime_cryptalg[1024] = { 0 };
511  char sign_as[1024] = { 0 };
512  char *q = NULL;
513  SecurityFlags flags = SEC_NO_FLAGS;
514 
515  if (!WithCrypto)
516  return SEC_NO_FLAGS;
517 
519  for (; p[0] != '\0'; p++)
520  {
521  switch (p[0])
522  {
523  case 'c':
524  case 'C':
525  q = smime_cryptalg;
526 
527  if (p[1] == '<')
528  {
529  for (p += 2; (p[0] != '\0') && (p[0] != '>') &&
530  (q < (smime_cryptalg + sizeof(smime_cryptalg) - 1));
531  *q++ = *p++)
532  {
533  }
534 
535  if (p[0] != '>')
536  {
537  mutt_error(_("Illegal S/MIME header"));
538  return SEC_NO_FLAGS;
539  }
540  }
541 
542  *q = '\0';
543  break;
544 
545  case 'e':
546  case 'E':
547  flags |= SEC_ENCRYPT;
548  break;
549 
550  case 'i':
551  case 'I':
552  flags |= SEC_INLINE;
553  break;
554 
555  /* This used to be the micalg parameter.
556  *
557  * It's no longer needed, so we just skip the parameter in order
558  * to be able to recall old messages. */
559  case 'm':
560  case 'M':
561  if (p[1] != '<')
562  break;
563 
564  for (p += 2; (p[0] != '\0') && (p[0] != '>'); p++)
565  ; // do nothing
566 
567  if (p[0] != '>')
568  {
569  mutt_error(_("Illegal crypto header"));
570  return SEC_NO_FLAGS;
571  }
572  break;
573 
574  case 'o':
575  case 'O':
576  flags |= SEC_OPPENCRYPT;
577  break;
578 
579  case 'a':
580  case 'A':
581 #ifdef USE_AUTOCRYPT
582  flags |= SEC_AUTOCRYPT;
583 #endif
584  break;
585 
586  case 'z':
587  case 'Z':
588 #ifdef USE_AUTOCRYPT
589  flags |= SEC_AUTOCRYPT_OVERRIDE;
590 #endif
591  break;
592 
593  case 's':
594  case 'S':
595  flags |= SEC_SIGN;
596  q = sign_as;
597 
598  if (p[1] == '<')
599  {
600  for (p += 2;
601  (p[0] != '\0') && (*p != '>') && (q < (sign_as + sizeof(sign_as) - 1));
602  *q++ = *p++)
603  {
604  }
605 
606  if (p[0] != '>')
607  {
608  mutt_error(_("Illegal crypto header"));
609  return SEC_NO_FLAGS;
610  }
611  }
612 
613  q[0] = '\0';
614  break;
615 
616  default:
617  mutt_error(_("Illegal crypto header"));
618  return SEC_NO_FLAGS;
619  }
620  }
621 
622  /* the cryptalg field must not be empty */
623  if (((WithCrypto & APPLICATION_SMIME) != 0) && *smime_cryptalg)
624  {
625  struct Buffer errmsg = mutt_buffer_make(0);
626  int rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
627  smime_cryptalg, &errmsg);
628 
629  if ((CSR_RESULT(rc) != CSR_SUCCESS) && !mutt_buffer_is_empty(&errmsg))
630  mutt_error("%s", mutt_buffer_string(&errmsg));
631 
632  mutt_buffer_dealloc(&errmsg);
633  }
634 
635  /* Set {Smime,Pgp}SignAs, if desired. */
636 
637  if (((WithCrypto & APPLICATION_PGP) != 0) && (crypt_app == APPLICATION_PGP) &&
638  (flags & SEC_SIGN) && (set_empty_signas || *sign_as))
639  {
640  mutt_str_replace(&C_PgpSignAs, sign_as);
641  }
642 
643  if (((WithCrypto & APPLICATION_SMIME) != 0) && (crypt_app == APPLICATION_SMIME) &&
644  (flags & SEC_SIGN) && (set_empty_signas || *sign_as))
645  {
646  mutt_str_replace(&C_SmimeSignAs, sign_as);
647  }
648 
649  return flags;
650 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_num_postponed()

int mutt_num_postponed ( struct Mailbox m,
bool  force 
)

Return the number of postponed messages.

Parameters
mcurrently selected mailbox
force
  • false Use a cached value if costly to get a fresh count (IMAP)
  • true Force check
Return values
numPostponed messages

Definition at line 89 of file postpone.c.

90 {
91  struct stat st;
92 
93  static time_t LastModify = 0;
94  static char *OldPostponed = NULL;
95 
97  {
98  UpdateNumPostponed = false;
99  force = true;
100  }
101 
102  if (!mutt_str_equal(C_Postponed, OldPostponed))
103  {
104  FREE(&OldPostponed);
105  OldPostponed = mutt_str_dup(C_Postponed);
106  LastModify = 0;
107  force = true;
108  }
109 
110  if (!C_Postponed)
111  return 0;
112 
113  // We currently are in the `$postponed` mailbox so just pick the current status
114  if (m && mutt_str_equal(C_Postponed, m->realpath))
115  {
116  PostCount = m->msg_count - m->msg_deleted;
117  return PostCount;
118  }
119 
120 #ifdef USE_IMAP
121  /* LastModify is useless for IMAP */
122  if (imap_path_probe(C_Postponed, NULL) == MUTT_IMAP)
123  {
124  if (force)
125  {
126  short newpc;
127 
128  newpc = imap_path_status(C_Postponed, false);
129  if (newpc >= 0)
130  {
131  PostCount = newpc;
132  mutt_debug(LL_DEBUG3, "%d postponed IMAP messages found\n", PostCount);
133  }
134  else
135  mutt_debug(LL_DEBUG3, "using old IMAP postponed count\n");
136  }
137  return PostCount;
138  }
139 #endif
140 
141  if (stat(C_Postponed, &st) == -1)
142  {
143  PostCount = 0;
144  LastModify = 0;
145  return 0;
146  }
147 
148  if (S_ISDIR(st.st_mode))
149  {
150  /* if we have a maildir mailbox, we need to stat the "new" dir */
151  struct Buffer *buf = mutt_buffer_pool_get();
152 
153  mutt_buffer_printf(buf, "%s/new", C_Postponed);
154  if ((access(mutt_buffer_string(buf), F_OK) == 0) &&
155  (stat(mutt_buffer_string(buf), &st) == -1))
156  {
157  PostCount = 0;
158  LastModify = 0;
160  return 0;
161  }
163  }
164 
165  if (LastModify < st.st_mtime)
166  {
167 #ifdef USE_NNTP
168  int optnews = OptNews;
169 #endif
170  LastModify = st.st_mtime;
171 
172  if (access(C_Postponed, R_OK | F_OK) != 0)
173  return PostCount = 0;
174 #ifdef USE_NNTP
175  if (optnews)
176  OptNews = false;
177 #endif
178  struct Mailbox *m_post = mx_path_resolve(C_Postponed);
179  struct Context *ctx = mx_mbox_open(m_post, MUTT_NOSORT | MUTT_QUIET);
180  if (ctx)
181  {
182  PostCount = ctx->mailbox->msg_count;
183  }
184  else
185  {
186  mailbox_free(&m_post);
187  PostCount = 0;
188  }
189  mx_fastclose_mailbox(m_post);
190  ctx_free(&ctx);
191 #ifdef USE_NNTP
192  if (optnews)
193  OptNews = true;
194 #endif
195  }
196 
197  return PostCount;
198 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_thread_set_flag()

int mutt_thread_set_flag ( struct Mailbox m,
struct Email e,
enum MessageType  flag,
bool  bf,
bool  subthread 
)

Set a flag on an entire thread.

Parameters
mMailbox
eEmail
flagFlag to set, e.g. MUTT_DELETE
bftrue: set the flag; false: clear the flag
subthreadIf true apply to all of the thread
Return values
0Success
-1Failure

Definition at line 377 of file flags.c.

379 {
380  struct MuttThread *start = NULL;
381  struct MuttThread *cur = e->thread;
382 
383  if ((C_Sort & SORT_MASK) != SORT_THREADS)
384  {
385  mutt_error(_("Threading is not enabled"));
386  return -1;
387  }
388 
389  if (!subthread)
390  while (cur->parent)
391  cur = cur->parent;
392  start = cur;
393 
394  if (cur->message && (cur != e->thread))
395  mutt_set_flag(m, cur->message, flag, bf);
396 
397  cur = cur->child;
398  if (!cur)
399  goto done;
400 
401  while (true)
402  {
403  if (cur->message && (cur != e->thread))
404  mutt_set_flag(m, cur->message, flag, bf);
405 
406  if (cur->child)
407  cur = cur->child;
408  else if (cur->next)
409  cur = cur->next;
410  else
411  {
412  while (!cur->next)
413  {
414  cur = cur->parent;
415  if (cur == start)
416  goto done;
417  }
418  cur = cur->next;
419  }
420  }
421 done:
422  cur = e->thread;
423  if (cur->message)
424  mutt_set_flag(m, cur->message, flag, bf);
425  return 0;
426 }
+ Here is the caller graph for this function:

◆ mutt_update_num_postponed()

void mutt_update_num_postponed ( void  )

Force the update of the number of postponed messages.

Definition at line 203 of file postpone.c.

204 {
205  UpdateNumPostponed = true;
206 }
+ Here is the caller graph for this function:

◆ mutt_is_quote_line()

int mutt_is_quote_line ( char *  line,
regmatch_t *  pmatch 
)

Is a line of message text a quote?

Parameters
[in]lineLine to test
[out]pmatchRegex sub-matches
Return values
trueLine is quoted

Checks if line matches the $quote_regex and doesn't match $smileys. This is used by the pager for calling classify_quote.

Definition at line 1047 of file pager.c.

1048 {
1049  bool is_quote = false;
1050  const struct Regex *c_smileys = cs_subset_regex(NeoMutt->sub, "smileys");
1051  regmatch_t pmatch_internal[1], smatch[1];
1052 
1053  if (!pmatch)
1054  pmatch = pmatch_internal;
1055 
1056  if (mutt_regex_capture(C_QuoteRegex, line, 1, pmatch))
1057  {
1058  if (mutt_regex_capture(c_smileys, line, 1, smatch))
1059  {
1060  if (smatch[0].rm_so > 0)
1061  {
1062  char c = line[smatch[0].rm_so];
1063  line[smatch[0].rm_so] = 0;
1064 
1065  if (mutt_regex_capture(C_QuoteRegex, line, 1, pmatch))
1066  is_quote = true;
1067 
1068  line[smatch[0].rm_so] = c;
1069  }
1070  }
1071  else
1072  is_quote = true;
1073  }
1074 
1075  return is_quote;
1076 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wcscasecmp()

int wcscasecmp ( const wchar_t *  a,
const wchar_t *  b 
)

Compare two wide-character strings, ignoring case.

Parameters
aFirst string
bSecond string
Return values
-1a precedes b
0a and b are identical
1b precedes a

Definition at line 41 of file wcscasecmp.c.

42 {
43  if (!a && !b)
44  return 0;
45  if (!a && b)
46  return -1;
47  if (a && !b)
48  return 1;
49 
50  for (; *a || *b; a++, b++)
51  {
52  int i = towlower(*a);
53  if ((i - towlower(*b)) != 0)
54  return i;
55  }
56  return 0;
57 }
+ Here is the caller graph for this function:

◆ mutt_reply_observer()

int mutt_reply_observer ( struct NotifyCallback nc)
ctx_free
void ctx_free(struct Context **ptr)
Free a Context.
Definition: context.c:50
Envelope
The header of an Email.
Definition: envelope.h:54
MENU_GENERIC
@ MENU_GENERIC
Generic selection list.
Definition: keymap.h:79
Email::msgno
int msgno
Number displayed to the user.
Definition: email.h:87
Envelope::subject
char * subject
Email's subject.
Definition: envelope.h:66
mutt_mb_wcswidth
int mutt_mb_wcswidth(const wchar_t *s, size_t n)
Measure the screen width of a string.
Definition: mbyte.c:196
mutt_hist_reset_state
void mutt_hist_reset_state(enum HistoryClass hclass)
Move the 'current' position to the end of the History.
Definition: history.c:554
mutt_beep
void mutt_beep(bool force)
Irritate the user.
Definition: curs_lib.c:99
mx_mbox_check
enum MxStatus mx_mbox_check(struct Mailbox *m)
Check for new mail - Wrapper for MxOps::mbox_check()
Definition: mx.c:1137
mutt_window_clrtoeol
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:244
Mailbox::rights
AclFlags rights
ACL bits, see AclFlags.
Definition: mailbox.h:121
Body::noconv
bool noconv
Don't do character set conversion.
Definition: body.h:73
MUTT_FLAG
@ MUTT_FLAG
Flagged messages.
Definition: mutt.h:102
SEND_REPLY
#define SEND_REPLY
Reply to sender.
Definition: send.h:41
ev_message
static int ev_message(enum EvMessage action, struct Mailbox *m, struct Email *e)
Edit an email or view it in an external editor.
Definition: editmsg.c:58
mutt_window_move
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:382
State::fp_in
FILE * fp_in
File to read from.
Definition: state.h:46
MUTT_NONE
@ MUTT_NONE
No messages.
Definition: mutt.h:92
curses_segv_handler
static void curses_segv_handler(int sig)
Catch a segfault and print a backtrace - Implements sig_handler_t.
Definition: mutt_signal.c:98
SigWinch
WHERE SIG_ATOMIC_VOLATILE_T SigWinch
true after SIGWINCH is received
Definition: mutt_globals.h:75
mutt_mem_calloc
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
crypt_smime_getkeys
void crypt_smime_getkeys(struct Envelope *env)
Wrapper for CryptModuleSpecs::smime_getkeys()
Definition: cryptglue.c:458
dlg_select_postponed_email
static struct Email * dlg_select_postponed_email(struct Context *ctx)
Create a Menu to select a postponed message.
Definition: postpone.c:225
mutt_stamp_attachment
void mutt_stamp_attachment(struct Body *a)
Timestamp an Attachment.
Definition: sendlib.c:893
MessageWindow
struct MuttWindow * MessageWindow
Message Window, ":set", etc.
Definition: mutt_window.c:47
_
#define _(a)
Definition: message.h:28
NONULL
#define NONULL(x)
Definition: string2.h:37
Mailbox
A mailbox.
Definition: mailbox.h:81
SORT_THREADS
@ SORT_THREADS
Sort by email threads.
Definition: sort2.h:51
Binding
Mapping between a user key and a function.
Definition: keymap.h:120
Envelope::message_id
char * message_id
Message ID.
Definition: envelope.h:69
EnterState::lastchar
size_t lastchar
Definition: enter_state.h:36
curses_exit_handler
static void curses_exit_handler(int sig)
Notify the user and shutdown gracefully - Implements sig_handler_t.
Definition: mutt_signal.c:86
COMB_CHAR
#define COMB_CHAR(wc)
Definition: enter.c:66
APPLICATION_SMIME
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: lib.h:98
mutt_window_mvprintw
int mutt_window_mvprintw(struct MuttWindow *win, int col, int row, const char *fmt,...)
Move the cursor and write a formatted string to a Window.
Definition: mutt_window.c:415
Mailbox::emails
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
dump_unbound
static void dump_unbound(FILE *fp, const struct Binding *funcs, struct KeymapList *km_list, struct KeymapList *aux, int wraplen)
Write out all the operations with no key bindings.
Definition: help.c:371
mutt_strn_equal
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
Definition: string.c:593
XDG_CONFIG_DIRS
@ XDG_CONFIG_DIRS
XDG system dir: /etc/xdg.
Definition: protos.h:48
Keymaps
struct KeymapList Keymaps[MENU_MAX]
Array of Keymap keybindings, one for each Menu.
Definition: keymap.c:149
ListNode
A List node for strings.
Definition: list.h:34
Buffer
String manipulation buffer.
Definition: buffer.h:33
Email::thread
struct MuttThread * thread
Thread of Emails.
Definition: email.h:95
LL_DEBUG3
@ LL_DEBUG3
Log at debug level 3.
Definition: logging.h:42
mutt_hist_complete
void mutt_hist_complete(char *buf, size_t buflen, enum HistoryClass hclass)
Complete a string from a history list.
Definition: mutt_history.c:42
STAILQ_REMOVE
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:399
Mailbox::msg_deleted
int msg_deleted
Number of deleted messages.
Definition: mailbox.h:96
SEC_OPPENCRYPT
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
Definition: lib.h:93
MUTT_PATTERN
#define MUTT_PATTERN
Pattern mode - only used for history classes.
Definition: mutt.h:64
mutt_file_fclose
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:153
mutt_buffer_pretty_mailbox
void mutt_buffer_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
Definition: muttlib.c:599
SEC_AUTOCRYPT_OVERRIDE
#define SEC_AUTOCRYPT_OVERRIDE
(Autocrypt) Indicates manual set/unset of encryption
Definition: lib.h:95
C_PgpSignAs
char * C_PgpSignAs
Config: Use this alternative key for signing messages.
Definition: config.c:65
Body::next
struct Body * next
next attachment in the list
Definition: body.h:53
mutt_buffer_is_empty
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
MUTT_ACL_DELETE
#define MUTT_ACL_DELETE
Delete a message.
Definition: mailbox.h:66
mutt_buffer_dealloc
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
km_get_table
const struct Binding * km_get_table(enum MenuType menu)
Lookup a menu's keybindings.
Definition: keymap.c:1306
Body
The body of an email.
Definition: body.h:34
SEC_ENCRYPT
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:85
CSR_SUCCESS
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
mutt_remove_multipart
struct Body * mutt_remove_multipart(struct Body *b)
Extract the multipart body if it exists.
Definition: multipart.c:126
SEC_SIGN
#define SEC_SIGN
Email is signed.
Definition: lib.h:86
mutt_window_clearline
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:232
CSR_RESULT
#define CSR_RESULT(x)
Definition: set.h:52
MUTT_SEL_NO_FLAGS
#define MUTT_SEL_NO_FLAGS
No flags are set.
Definition: browser.h:41
mutt_buffer_mktemp
#define mutt_buffer_mktemp(buf)
Definition: muttlib.h:77
mutt_parse_crypt_hdr
SecurityFlags mutt_parse_crypt_hdr(const char *p, bool set_empty_signas, SecurityFlags crypt_app)
Parse a crypto header string.
Definition: postpone.c:508
EVM_VIEW
@ EVM_VIEW
View the message.
Definition: protos.h:56
mutt_parse_part
void mutt_parse_part(FILE *fp, struct Body *b)
Parse a MIME part.
Definition: parse.c:1659
Email::offset
LOFF_T offset
Where in the stream does this message begin?
Definition: email.h:84
EmailNode::email
struct Email * email
Email in the list.
Definition: email.h:127
Regex
Cached regular expression.
Definition: regex3.h:89
EnterState::wbuflen
size_t wbuflen
Definition: enter_state.h:35
AllDialogsWindow
struct MuttWindow * AllDialogsWindow
Parent of all Dialogs.
Definition: mutt_window.c:46
crypt_pgp_decrypt_mime
int crypt_pgp_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
Wrapper for CryptModuleSpecs::decrypt_mime()
Definition: cryptglue.c:209
MUTT_YES
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:40
Context
The "current" mailbox.
Definition: context.h:38
mutt_hist_add
void mutt_hist_add(enum HistoryClass hclass, const char *str, bool save)
Add a string to a history.
Definition: history.c:464
mutt_str_dup
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
mutt_file_fopen
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:589
LL_DEBUG1
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
mutt_enter_state_new
struct EnterState * mutt_enter_state_new(void)
Create a new EnterState.
Definition: enter.c:128
FREE
#define FREE(x)
Definition: memory.h:40
EmailNode
List of Emails.
Definition: email.h:125
ENTER_REDRAW_INIT
@ ENTER_REDRAW_INIT
Go to end of line and redraw.
Definition: enter.c:61
mutt_perror
#define mutt_perror(...)
Definition: logging.h:85
SORT_MASK
#define SORT_MASK
Mask for the sort id.
Definition: sort2.h:80
mutt_regex_capture
bool mutt_regex_capture(const struct Regex *regex, const char *str, size_t nmatch, regmatch_t matches[])
match a regex against a string, with provided options
Definition: regex.c:595
dump_menu
static void dump_menu(FILE *fp, enum MenuType menu, int wraplen)
Write all the key bindings to a file.
Definition: help.c:317
LastKey
int LastKey
contains the last key the user pressed
Definition: keymap.c:146
SecurityFlags
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
Definition: lib.h:83
nntp_complete
int nntp_complete(char *buf, size_t buflen)
Auto-complete NNTP newsgroups.
Definition: complete.c:47
PATH_MAX
#define PATH_MAX
Definition: mutt.h:44
MUTT_LABEL
#define MUTT_LABEL
Do label completion.
Definition: mutt.h:65
mutt_buffer_reset
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
mutt_mailbox_next
struct Mailbox * mutt_mailbox_next(struct Mailbox *m_cur, struct Buffer *s)
incoming folders completion routine
Definition: mutt_mailbox.c:312
mutt_buffer_pool_release
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
ENTER_REDRAW_LINE
@ ENTER_REDRAW_LINE
Redraw entire line.
Definition: enter.c:62
STAILQ_EMPTY
#define STAILQ_EMPTY(head)
Definition: queue.h:345
mailbox_free
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:71
HC_FILE
@ HC_FILE
Files.
Definition: lib.h:57
mutt_body_free
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
query_complete
int query_complete(char *buf, size_t buflen, struct ConfigSubset *sub)
Perform auto-complete using an Address Query.
Definition: dlgquery.c:606
Body::subtype
char * subtype
content-type subtype
Definition: body.h:37
mx_path_resolve
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
Definition: mx.c:1681
mutt_list_insert_tail
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:64
STAILQ_FOREACH
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
State::fp_out
FILE * fp_out
File to write to.
Definition: state.h:47
mutt_getch
struct KeyEvent mutt_getch(void)
Read a character from the input buffer.
Definition: curs_lib.c:189
EnterState::begin
size_t begin
Definition: enter_state.h:38
xdg_env_vars
static const char * xdg_env_vars[]
Definition: muttlib.c:72
MUTT_READ
@ MUTT_READ
Messages that have been read.
Definition: mutt.h:96
C_CryptProtectedHeadersRead
bool C_CryptProtectedHeadersRead
Config: Display protected headers (Memory Hole) in the pager.
Definition: config.c:56
mutt_istr_equal
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
mutt_hash_find
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Definition: hash.c:354
EnterState::tabs
int tabs
Definition: enter_state.h:39
MuttThread::parent
struct MuttThread * parent
Parent of this Thread.
Definition: thread.h:45
mutt_str_equal
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
MuttThread::child
struct MuttThread * child
Child of this Thread.
Definition: thread.h:46
MUTT_ALIAS
#define MUTT_ALIAS
Do alias "completion" by calling up the alias-menu.
Definition: mutt.h:57
mutt_label_complete
int mutt_label_complete(char *buf, size_t buflen, int numtabs)
Complete a label name.
Definition: init.c:1313
mutt_hist_at_scratch
bool mutt_hist_at_scratch(enum HistoryClass hclass)
Is the current History position at the 'scratch' place?
Definition: history.c:618
C_SmimeSignAs
char * C_SmimeSignAs
Config: Use this alternative key for signing messages.
Definition: config.c:68
mutt_sig_unblock_system
void mutt_sig_unblock_system(bool restore)
Restore previously blocked signals.
Definition: signal.c:207
MUTT_PAGER_RETWINCH
#define MUTT_PAGER_RETWINCH
Need reformatting on SIGWINCH.
Definition: lib.h:53
Email::old
bool old
Email is seen, but unread.
Definition: email.h:50
MUTT_FILE
#define MUTT_FILE
Do file completion.
Definition: mutt.h:58
MUTT_PURGE
@ MUTT_PURGE
Messages to be purged (bypass trash)
Definition: mutt.h:100
mutt_buffer_addch
size_t mutt_buffer_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:240
mutt_expand_path
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:128
mutt_env_free
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
Definition: envelope.c:96
mutt_buffer_pool_get
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
mutt_is_application_pgp
SecurityFlags mutt_is_application_pgp(struct Body *m)
Does the message use PGP?
Definition: crypt.c:554
imap_wait_keepalive
int imap_wait_keepalive(pid_t pid)
Wait for a process to change state.
Definition: util.c:967
HistoryClass
HistoryClass
Type to differentiate different histories.
Definition: lib.h:52
Mailbox::type
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
MUTT_EFILE
#define MUTT_EFILE
Do file completion, plus incoming folders.
Definition: mutt.h:59
MUTT_PAGER_NOWRAP
#define MUTT_PAGER_NOWRAP
Format for term width, ignore $wrap.
Definition: lib.h:55
mutt_buffer_copy
size_t mutt_buffer_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
Definition: buffer.c:445
SEND_POSTPONED
#define SEND_POSTPONED
Recall a postponed email.
Definition: send.h:45
SEND_POSTPONED_FCC
#define SEND_POSTPONED_FCC
Used by mutt_get_postponed() to signal that the x-mutt-fcc header field was present.
Definition: send.h:49
mutt_do_pager
int mutt_do_pager(const char *banner, const char *tempfile, PagerFlags do_color, struct Pager *info)
Display some page-able text to the user.
Definition: curs_lib.c:691
MUTT_NEW
@ MUTT_NEW
New messages.
Definition: mutt.h:93
mutt_mb_width_ceiling
size_t mutt_mb_width_ceiling(const wchar_t *s, size_t n, int w1)
Keep the end of the string on-screen.
Definition: mbyte.c:217
MUTT_CHARCONV
#define MUTT_CHARCONV
Do character set conversions.
Definition: state.h:36
C_Folder
WHERE char * C_Folder
Config: Base folder for a set of mailboxes.
Definition: mutt_globals.h:96
Email::tagged
bool tagged
Email is tagged.
Definition: email.h:44
mutt_is_multipart_encrypted
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
Definition: crypt.c:449
mutt_command_complete
int mutt_command_complete(char *buf, size_t buflen, int pos, int numtabs)
Complete a command name.
Definition: init.c:1131
C_QuoteRegex
WHERE struct Regex * C_QuoteRegex
Config: Regex to match quoted text in a reply.
Definition: mutt_globals.h:120
Body::length
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
MUTT_SEL_FOLDER
#define MUTT_SEL_FOLDER
Select a local directory.
Definition: browser.h:44
Mailbox::changed
bool changed
Mailbox has been modified.
Definition: mailbox.h:114
APPLICATION_PGP
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:97
mutt_rfc3676_space_unstuff
void mutt_rfc3676_space_unstuff(struct Email *e)
Remove RFC3676 space stuffing.
Definition: rfc3676.c:492
mutt_nm_tag_complete
bool mutt_nm_tag_complete(char *buf, size_t buflen, int numtabs)
Complete to the nearest notmuch tag.
Definition: init.c:1434
C_CryptOpportunisticEncrypt
bool C_CryptOpportunisticEncrypt
Config: Enable encryption when the recipient's key is available.
Definition: config.c:54
mutt_mb_is_shell_char
bool mutt_mb_is_shell_char(wchar_t ch)
Is character not typically part of a pathname.
Definition: mbyte.c:344
MuttThread::message
struct Email * message
Email this Thread refers to.
Definition: thread.h:49
cs_subset_str_string_set
int cs_subset_str_string_set(const struct ConfigSubset *sub, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
Definition: subset.c:395
Mailbox::msg_count
int msg_count
Total number of messages.
Definition: mailbox.h:91
HC_PATTERN
@ HC_PATTERN
Patterns.
Definition: lib.h:58
cs_subset_regex
const struct Regex * cs_subset_regex(const struct ConfigSubset *sub, const char *name)
Get a regex config item by name.
Definition: helpers.c:176
HC_ALIAS
@ HC_ALIAS
Aliases.
Definition: lib.h:55
mutt_clear_error
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
mutt_str_skip_email_wsp
char * mutt_str_skip_email_wsp(const char *s)
Skip over whitespace as defined by RFC5322.
Definition: string.c:743
mutt_sig_init
void mutt_sig_init(sig_handler_t sig_fn, sig_handler_t exit_fn, sig_handler_t segv_fn)
Initialise the signal handling.
Definition: signal.c:88
mutt_resize_screen
void mutt_resize_screen(void)
Update NeoMutt's opinion about the window size (CURSES)
Definition: resize.c:101
MUTT_SEL_MULTI
#define MUTT_SEL_MULTI
Multi-selection is enabled.
Definition: browser.h:43
UpdateNumPostponed
static bool UpdateNumPostponed
Definition: postpone.c:79
mutt_complete
int mutt_complete(char *buf, size_t buflen)
Attempt to complete a partial pathname.
Definition: complete.c:57
MUTT_IMAP
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:53
MUTT_NOSORT
#define MUTT_NOSORT
Do not sort the mailbox after opening it.
Definition: mx.h:52
Menus
const struct Mapping Menus[]
Menu name lookup table.
Definition: keymap.c:61
Body::parts
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
Context::mailbox
struct Mailbox * mailbox
Definition: context.h:50
KeyEvent
An event such as a keypress.
Definition: keymap.h:63
mutt_mem_realloc
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
mutt_buffer_concat_path
size_t mutt_buffer_concat_path(struct Buffer *buf, const char *dir, const char *fname)
Join a directory name and a filename.
Definition: buffer.c:374
Email::env
struct Envelope * env
Envelope information.
Definition: email.h:90
imap_complete
int imap_complete(char *buf, size_t buflen, const char *path)
Try to complete an IMAP folder path.
Definition: imap.c:1327
mutt_debug
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
MuttThread
An Email conversation.
Definition: thread.h:34
MUTT_REPLIED
@ MUTT_REPLIED
Messages that have been replied to.
Definition: mutt.h:95
Email::purge
bool purge
Skip trash folder when deleting.
Definition: email.h:46
C_FlagSafe
WHERE bool C_FlagSafe
Config: Protect flagged messages from deletion.
Definition: mutt_globals.h:146
mutt_set_header_color
void mutt_set_header_color(struct Mailbox *m, struct Email *e)
Select a colour for a message.
Definition: index.c:4091
Mailbox::msg_flagged
int msg_flagged
Number of flagged messages.
Definition: mailbox.h:93
Mailbox::realpath
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:84
mutt_buffer_expand_path
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:323
Message::fp
FILE * fp
pointer to the message data
Definition: mx.h:96
MUTT_QUIET
#define MUTT_QUIET
Do not print any messages.
Definition: mx.h:55
Email::flagged
bool flagged
Marked important?
Definition: email.h:43
mutt_prepare_template
int mutt_prepare_template(FILE *fp, struct Mailbox *m, struct Email *e_new, struct Email *e, bool resend)
Prepare a message template.
Definition: postpone.c:664
mutt_str_getenv
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:991
mutt_buffer_string
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
STAILQ_FOREACH_SAFE
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:359
Email::chain
struct ListHead chain
Mixmaster chain.
Definition: email.h:102
hardclose
static void hardclose(struct Context **pctx)
try hard to close a mailbox
Definition: postpone.c:310
Email::security
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition: email.h:39
mutt_hist_save_scratch
void mutt_hist_save_scratch(enum HistoryClass hclass, const char *str)
Save a temporary string to the History.
Definition: history.c:635
EnterRedrawFlags
EnterRedrawFlags
redraw flags for mutt_enter_string_full()
Definition: enter.c:58
Email::trash
bool trash
Message is marked as trashed on disk (used by the maildir_trash option)
Definition: email.h:60
MUTT_ACL_WRITE
#define MUTT_ACL_WRITE
Write to a message (for flagging or linking threads)
Definition: mailbox.h:74
mutt_str_replace
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
MUTT_OLD
@ MUTT_OLD
Old messages.
Definition: mutt.h:94
mutt_adv_mktemp
void mutt_adv_mktemp(struct Buffer *buf)
Create a temporary file.
Definition: muttlib.c:90
WithCrypto
#define WithCrypto
Definition: lib.h:123
mutt_flushinp
void mutt_flushinp(void)
Empty all the keyboard buffers.
Definition: curs_lib.c:923
mutt_param_delete
void mutt_param_delete(struct ParameterList *pl, const char *attribute)
Delete a matching Parameter.
Definition: parameter.c:142
MuttWindow::state
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:120
mutt_param_get
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
Email::deleted
bool deleted
Email is deleted.
Definition: email.h:45
EXEC_SHELL
#define EXEC_SHELL
Definition: filter.h:27
mutt_nm_query_complete
bool mutt_nm_query_complete(char *buf, size_t buflen, int pos, int numtabs)
Complete to the nearest notmuch tag.
Definition: init.c:1377
HC_MBOX
@ HC_MBOX
Mailboxes.
Definition: lib.h:60
MUTT_PASS
#define MUTT_PASS
Password mode (no echo)
Definition: mutt.h:61
Mailbox::readonly
bool readonly
Don't allow changes to the mailbox.
Definition: mailbox.h:119
PostCount
static short PostCount
Definition: postpone.c:78
curses_signal_handler
static void curses_signal_handler(int sig)
Catch signals and relay the info to the main program - Implements sig_handler_t.
Definition: mutt_signal.c:46
imap_path_status
int imap_path_status(const char *path, bool queue)
Refresh the number of total and new messages.
Definition: imap.c:1222
Envelope::userhdrs
struct ListHead userhdrs
user defined headers
Definition: envelope.h:83
State
Keep track when processing files.
Definition: state.h:44
Body::d_filename
char * d_filename
filename to be used for the content-disposition header.
Definition: body.h:47
MUTT_DELETE
@ MUTT_DELETE
Messages to be deleted.
Definition: mutt.h:98
C_Sort
WHERE short C_Sort
Config: Sort method for the index.
Definition: sort.h:60
MUTT_NM_TAG
#define MUTT_NM_TAG
Notmuch tag +/- mode.
Definition: mutt.h:67
mutt_make_id_hash
struct HashTable * mutt_make_id_hash(struct Mailbox *m)
Create a Hash Table for message-ids.
Definition: mutt_thread.c:1518
MUTT_PAGER_MARKER
#define MUTT_PAGER_MARKER
Use markers if option is set.
Definition: lib.h:52
TYPE_TEXT
@ TYPE_TEXT
Type: 'text/*'.
Definition: mime.h:38
my_addwch
static int my_addwch(wchar_t wc)
Display one wide character on screen.
Definition: enter.c:74
EnterState
Keep our place when entering a string.
Definition: enter_state.h:32
MUTT_PAGER_NSKIP
#define MUTT_PAGER_NSKIP
Preserve whitespace with smartwrap.
Definition: lib.h:51
MUTT_TAG
@ MUTT_TAG
Tagged messages.
Definition: mutt.h:103
EVM_EDIT
@ EVM_EDIT
Edit the message.
Definition: protos.h:57
mutt_buffer_fix_dptr
void mutt_buffer_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
Definition: buffer.c:181
C_SpoolFile
WHERE char * C_SpoolFile
Config: Inbox.
Definition: mutt_globals.h:108
NeoMutt
Container for Accounts, Notifications.
Definition: neomutt.h:36
SEC_INLINE
#define SEC_INLINE
Email has an inline signature.
Definition: lib.h:92
crypt_opportunistic_encrypt
void crypt_opportunistic_encrypt(struct Email *e)
Can all recipients be determined.
Definition: crypt.c:1024
mutt_enter_string_full
int mutt_enter_string_full(char *buf, size_t buflen, int col, CompletionFlags flags, bool multiple, struct Mailbox *m, char ***files, int *numfiles, struct EnterState *state)
Ask the user for a string.
Definition: enter.c:180
mutt_mb_wcwidth
int mutt_mb_wcwidth(wchar_t wc)
Measure the screen width of a character.
Definition: mbyte.c:178
mutt_istr_startswith
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition: string.c:172
C_Delete
WHERE unsigned char C_Delete
Config: Really delete messages, when the mailbox is closed.
Definition: mutt_globals.h:125
mutt_buffer_substrcpy
size_t mutt_buffer_substrcpy(struct Buffer *buf, const char *beg, const char *end)
Copy a partial string into a Buffer.
Definition: buffer.c:342
replace_part
static void replace_part(struct EnterState *state, size_t from, char *buf)
Search and replace on a buffer.
Definition: enter.c:92
Body::type
unsigned int type
content-type primary type, ContentType
Definition: body.h:65
C_Postponed
WHERE char * C_Postponed
Config: Folder to store postponed messages.
Definition: mutt_globals.h:101
mx_mbox_open
struct Context * mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
Definition: mx.c:309
MessageType
MessageType
To set flags or match patterns.
Definition: mutt.h:89
C_AbortBackspace
WHERE bool C_AbortBackspace
Config: Hitting backspace against an empty prompt aborts the prompt.
Definition: mutt_globals.h:83
HC_OTHER
@ HC_OTHER
Miscellaneous strings.
Definition: lib.h:59
Email::searched
bool searched
Email has been searched.
Definition: email.h:67
MUTT_CMD
#define MUTT_CMD
Do completion on previous word.
Definition: mutt.h:60
MENU_EDITOR
@ MENU_EDITOR
Text entry area.
Definition: keymap.h:77
mutt_body_handler
int mutt_body_handler(struct Body *b, struct State *s)
Handler for the Body of an email.
Definition: handler.c:1595
imap_path_probe
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox? - Implements MxOps::path_probe()
Definition: imap.c:2372
mutt_buffer_len
size_t mutt_buffer_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition: buffer.c:356
HC_CMD
@ HC_CMD
External commands.
Definition: lib.h:54
ListNode::data
char * data
String.
Definition: list.h:36
C_SmimeIsDefault
bool C_SmimeIsDefault
Config: Use SMIME rather than PGP by default.
Definition: config.c:59
MUTT_CLEAR
#define MUTT_CLEAR
Clear input if printable character is pressed.
Definition: mutt.h:62
mutt_refresh
void mutt_refresh(void)
Force a refresh of the screen.
Definition: curs_lib.c:108
EnterState::curpos
size_t curpos
Definition: enter_state.h:37
mutt_rfc822_read_header
struct Envelope * mutt_rfc822_read_header(FILE *fp, struct Email *e, bool user_hdrs, bool weed)
parses an RFC822 header
Definition: parse.c:1112
mutt_select_file
void mutt_select_file(char *file, size_t filelen, SelectFileFlags flags, struct Mailbox *m, char ***files, int *numfiles)
Let the user select a file.
Definition: browser.c:2208
NeoMutt::sub
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
ENTER_REDRAW_NONE
@ ENTER_REDRAW_NONE
Nothing to redraw.
Definition: enter.c:60
MUTT_COMMAND
#define MUTT_COMMAND
Do command completion.
Definition: mutt.h:63
alias_complete
int alias_complete(char *buf, size_t buflen, struct ConfigSubset *sub)
alias completion routine
Definition: dlgalias.c:375
mutt_envlist_getlist
char ** mutt_envlist_getlist(void)
Get the private environment.
Definition: envlist.c:169
Body::use_disp
bool use_disp
Content-Disposition uses filename= ?
Definition: body.h:68
MuttThread::next
struct MuttThread * next
Next sibling Thread.
Definition: thread.h:47
plen
static size_t plen
Length of cached packet.
Definition: pgppacket.c:39
mutt_mb_wcstombs
void mutt_mb_wcstombs(char *dest, size_t dlen, const wchar_t *src, size_t slen)
Convert a string from wide to multibyte characters.
Definition: mbyte.c:237
mutt_buffer_addstr
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:225
Mailbox::msg_unread
int msg_unread
Number of unread messages.
Definition: mailbox.h:92
Mailbox::msg_tagged
int msg_tagged
How many messages are tagged?
Definition: mailbox.h:97
MUTT_MAILDIR
@ MUTT_MAILDIR
'Maildir' Mailbox type
Definition: mailbox.h:51
Body::email
struct Email * email
header information for message/rfc822
Definition: body.h:55
mutt_hist_prev
char * mutt_hist_prev(enum HistoryClass hclass)
Get the previous string in a History.
Definition: history.c:527
mutt_var_value_complete
int mutt_var_value_complete(char *buf, size_t buflen, int pos)
Complete a variable/value.
Definition: init.c:1487
km_dokey
int km_dokey(enum MenuType menu)
Determine what a keypress should do.
Definition: keymap.c:658
WindowState::cols
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:57
Body::unlink
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
Definition: body.h:69
mx_fastclose_mailbox
void mx_fastclose_mailbox(struct Mailbox *m)
free up memory associated with the Mailbox
Definition: mx.c:451
Body::parameter
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
XDG_CONFIG_HOME
@ XDG_CONFIG_HOME
XDG home dir: ~/.config.
Definition: protos.h:47
mutt_decode_attachment
void mutt_decode_attachment(struct Body *b, struct State *s)
Decode an email's attachment.
Definition: handler.c:1845
mx_msg_close
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1204
State::flags
StateFlags flags
Flags, e.g. MUTT_DISPLAY.
Definition: state.h:49
mutt_pretty_mailbox
void mutt_pretty_mailbox(char *buf, size_t buflen)
Shorten a mailbox path using '~' or '='.
Definition: muttlib.c:523
Email::replied
bool replied
Email has been replied to.
Definition: email.h:54
Buffer::data
char * data
Pointer to data.
Definition: buffer.h:35
dlg_select_pattern
bool dlg_select_pattern(char *buf, size_t buflen)
Show menu to select a Pattern.
Definition: dlgpattern.c:262
TYPE_MULTIPART
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition: mime.h:37
Email
The envelope/body of an email.
Definition: email.h:37
MUTT_ACL_SEEN
#define MUTT_ACL_SEEN
Change the 'seen' status of a message.
Definition: mailbox.h:73
mutt_str_startswith
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:160
mutt_message
#define mutt_message(...)
Definition: logging.h:83
mutt_set_flag
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:67
Mailbox::msg_new
int msg_new
Number of new messages.
Definition: mailbox.h:95
mutt_enter_state_free
void mutt_enter_state_free(struct EnterState **ptr)
Free an EnterState.
Definition: enter.c:842
OpGeneric
const struct Binding OpGeneric[]
Key bindings for the generic menu.
Definition: functions.c:53
HC_COMMAND
@ HC_COMMAND
NeoMutt commands.
Definition: lib.h:56
Envelope::mail_followup_to
struct AddressList mail_followup_to
Email's 'mail-followup-to'.
Definition: envelope.h:63
mutt_buffer_printf
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
mutt_hist_next
char * mutt_hist_next(enum HistoryClass hclass)
Get the next string in a History.
Definition: history.c:500
KeyEvent::ch
int ch
raw key pressed
Definition: keymap.h:65
mutt_buffer_make
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
mutt_list_free
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
mutt_map_get_name
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
Definition: mapping.c:42
crypt_valid_passphrase
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:135
mutt_sig_block_system
void mutt_sig_block_system(void)
Block signals before calling exec()
Definition: signal.c:183
Email::read
bool read
Email is read.
Definition: email.h:51
SEC_NO_FLAGS
#define SEC_NO_FLAGS
No flags are set.
Definition: lib.h:84
mutt_is_multipart_signed
SecurityFlags mutt_is_multipart_signed(struct Body *b)
Is a message signed?
Definition: crypt.c:409
mutt_mb_mbstowcs
size_t mutt_mb_mbstowcs(wchar_t **pwbuf, size_t *pwbuflen, size_t i, const char *buf)
Convert a string from multibyte to wide characters.
Definition: mbyte.c:295
mutt_buffer_concatn_path
size_t mutt_buffer_concatn_path(struct Buffer *buf, const char *dir, size_t dirlen, const char *fname, size_t fnamelen)
Join a directory name and a filename.
Definition: buffer.c:411
MUTT_NM_QUERY
#define MUTT_NM_QUERY
Notmuch query mode.
Definition: mutt.h:66
MENU_PAGER
@ MENU_PAGER
Pager pager (email viewer)
Definition: keymap.h:81
mutt_buffer_strcpy
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
Mailbox::id_hash
struct HashTable * id_hash
Hash Table by msg id.
Definition: mailbox.h:127
LL_DEBUG2
@ LL_DEBUG2
Log at debug level 2.
Definition: logging.h:41
mutt_is_application_smime
SecurityFlags mutt_is_application_smime(struct Body *m)
Does the message use S/MIME?
Definition: crypt.c:612
SEC_AUTOCRYPT
#define SEC_AUTOCRYPT
(Autocrypt) Message will be, or was Autocrypt encrypt+signed
Definition: lib.h:94
Email::changed
bool changed
Email has been edited.
Definition: email.h:48
Message
A local copy of an email.
Definition: mx.h:94
xdg_defaults
static const char * xdg_defaults[]
Definition: muttlib.c:77
Body::mime_headers
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:63
EnterState::wbuf
wchar_t * wbuf
Definition: enter_state.h:34
mutt_emails_set_flag
void mutt_emails_set_flag(struct Mailbox *m, struct EmailList *el, enum MessageType flag, bool bf)
Set flag on messages.
Definition: flags.c:354
Body::filename
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
Email::body
struct Body * body
List of MIME parts.
Definition: email.h:91
OptNews
WHERE bool OptNews
(pseudo) used to change reader mode
Definition: options.h:45
mx_msg_open
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1158
mutt_error
#define mutt_error(...)
Definition: logging.h:84
IsWPrint
#define IsWPrint(wc)
Definition: mbyte.h:40
mutt_str_copy
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:716