NeoMutt  2020-03-20-65-g141838
Teaching an old dog new tricks
DOXYGEN
commands.c File Reference

Manage where the email is piped to external commands. More...

#include "config.h"
#include <errno.h>
#include <limits.h>
#include <regex.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "mutt.h"
#include "commands.h"
#include "alias.h"
#include "context.h"
#include "copy.h"
#include "format_flags.h"
#include "globals.h"
#include "hdrline.h"
#include "hook.h"
#include "icommands.h"
#include "init.h"
#include "keymap.h"
#include "mutt_commands.h"
#include "mutt_logging.h"
#include "mutt_mailbox.h"
#include "mutt_menu.h"
#include "mutt_parse.h"
#include "muttlib.h"
#include "mx.h"
#include "options.h"
#include "pager.h"
#include "protos.h"
#include "sendlib.h"
#include "sort.h"
#include "ncrypt/lib.h"
#include "imap/lib.h"
#include "notmuch/lib.h"
#include <libintl.h>
#include "autocrypt/lib.h"
+ Include dependency graph for commands.c:

Go to the source code of this file.

Macros

#define EXTRA_SPACE   (15 + 7 + 2)
 

Functions

static void process_protected_headers (struct Email *e)
 Get the protected header and update the index. More...
 
int mutt_display_message (struct MuttWindow *win_index, struct MuttWindow *win_ibar, struct MuttWindow *win_pager, struct MuttWindow *win_pbar, struct Mailbox *m, struct Email *e)
 Display a message in the pager. More...
 
void ci_bounce_message (struct Mailbox *m, struct EmailList *el)
 Bounce an email. More...
 
static void pipe_set_flags (bool decode, bool print, CopyMessageFlags *cmflags, CopyHeaderFlags *chflags)
 Generate flags for copy header/message. More...
 
static void pipe_msg (struct Mailbox *m, struct Email *e, FILE *fp, bool decode, bool print)
 Pipe a message. More...
 
static int pipe_message (struct Mailbox *m, struct EmailList *el, char *cmd, bool decode, bool print, bool split, const char *sep)
 Pipe message to a command. More...
 
void mutt_pipe_message (struct Mailbox *m, struct EmailList *el)
 Pipe a message. More...
 
void mutt_print_message (struct Mailbox *m, struct EmailList *el)
 Print a message. More...
 
int mutt_select_sort (bool reverse)
 Ask the user for a sort method. More...
 
void mutt_shell_escape (void)
 invoke a command in a subshell More...
 
void mutt_enter_command (void)
 enter a neomutt command More...
 
void mutt_display_address (struct Envelope *env)
 Display the address of a message. More...
 
static void set_copy_flags (struct Email *e, bool decode, bool decrypt, CopyMessageFlags *cmflags, CopyHeaderFlags *chflags)
 Set the flags for a message copy. More...
 
int mutt_save_message_ctx (struct Email *e, bool delete_original, bool decode, bool decrypt, struct Mailbox *m)
 Save a message to a given mailbox. More...
 
int mutt_save_message (struct Mailbox *m, struct EmailList *el, bool delete_original, bool decode, bool decrypt)
 Save an email. More...
 
bool mutt_edit_content_type (struct Email *e, struct Body *b, FILE *fp)
 Edit the content type of an attachment. More...
 
static bool check_traditional_pgp (struct Email *e, MuttRedrawFlags *redraw)
 Check for an inline PGP content. More...
 
bool mutt_check_traditional_pgp (struct EmailList *el, MuttRedrawFlags *redraw)
 Check if a message has inline PGP content. More...
 
void mutt_check_stats (void)
 Forcibly update mailbox stats. More...
 

Variables

unsigned char C_CryptVerifySig
 Config: Verify PGP or SMIME signatures. More...
 
char * C_DisplayFilter
 Config: External command to pre-process an email before display. More...
 
bool C_PipeDecode
 Config: Decode the message when piping it. More...
 
char * C_PipeSep
 Config: Separator to add between multiple piped messages. More...
 
bool C_PipeSplit
 Config: Run the pipe command on each message separately. More...
 
bool C_PrintDecode
 Config: Decode message before printing it. More...
 
bool C_PrintSplit
 Config: Print multiple messages separately. More...
 
bool C_PromptAfter
 Config: Pause after running an external pager. More...
 
static const char * ExtPagerProgress = "all"
 
static char LastSaveFolder [PATH_MAX] = ""
 The folder the user last saved to. More...
 

Detailed Description

Manage where the email is piped to external commands.

Authors
  • Michael R. Elkins
  • Thomas Roessler
  • Pietro Cerutti

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 commands.c.

Macro Definition Documentation

◆ EXTRA_SPACE

#define EXTRA_SPACE   (15 + 7 + 2)

Function Documentation

◆ process_protected_headers()

static void process_protected_headers ( struct Email e)
static

Get the protected header and update the index.

Parameters
eEmail to update

Definition at line 103 of file commands.c.

104 {
105  struct Envelope *prot_headers = NULL;
106  regmatch_t pmatch[1];
107 
108 #ifdef USE_AUTOCRYPT
110  return;
111 #else
113  return;
114 #endif
115 
116  /* Grab protected headers to update in the index */
117  if (e->security & SEC_SIGN)
118  {
119  /* Don't update on a bad signature.
120  *
121  * This is a simplification. It's possible the headers are in the
122  * encrypted part of a nested encrypt/signed. But properly handling that
123  * case would require more complexity in the decryption handlers, which
124  * I'm not sure is worth it. */
125  if (!(e->security & SEC_GOODSIGN))
126  return;
127 
129  {
130  prot_headers = e->content->parts->mime_headers;
131  }
133  {
134  prot_headers = e->content->mime_headers;
135  }
136  }
137  if (!prot_headers && (e->security & SEC_ENCRYPT))
138  {
139  if (((WithCrypto & APPLICATION_PGP) != 0) &&
142  {
143  prot_headers = e->content->mime_headers;
144  }
145  else if (((WithCrypto & APPLICATION_SMIME) != 0) && mutt_is_application_smime(e->content))
146  {
147  prot_headers = e->content->mime_headers;
148  }
149  }
150 
151  /* Update protected headers in the index and header cache. */
152  if (C_CryptProtectedHeadersRead && prot_headers && prot_headers->subject &&
153  mutt_str_strcmp(e->env->subject, prot_headers->subject))
154  {
155  if (Context->mailbox->subj_hash && e->env->real_subj)
157 
158  mutt_str_replace(&e->env->subject, prot_headers->subject);
159  FREE(&e->env->disp_subj);
160  if (mutt_regex_capture(C_ReplyRegex, e->env->subject, 1, pmatch))
161  e->env->real_subj = e->env->subject + pmatch[0].rm_eo;
162  else
163  e->env->real_subj = e->env->subject;
164 
165  if (Context->mailbox->subj_hash)
167 
169 
170  /* Also persist back to the message headers if this is set */
172  {
174  e->changed = true;
175  Context->mailbox->changed = true;
176  }
177  }
178 
179 #ifdef USE_AUTOCRYPT
180  if (C_Autocrypt && (e->security & SEC_ENCRYPT) && prot_headers && prot_headers->autocrypt_gossip)
181  {
182  mutt_autocrypt_process_gossip_header(e, prot_headers);
183  }
184 #endif
185 }
The "current" mailbox.
Definition: context.h:37
void mutt_hash_delete(struct Hash *table, const char *strkey, const void *data)
Remove an element from a Hash table.
Definition: hash.c:443
WHERE bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: globals.h:200
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:63
#define WithCrypto
Definition: lib.h:163
struct AutocryptHeader * autocrypt_gossip
Definition: envelope.h:86
char * disp_subj
Display subject (modified copy of subject)
Definition: envelope.h:68
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:125
struct Body * content
List of MIME parts.
Definition: email.h:90
int mutt_autocrypt_process_gossip_header(struct Email *e, struct Envelope *prot_headers)
Parse an Autocrypt email gossip header.
Definition: autocrypt.c:397
int mutt_is_valid_multipart_pgp_encrypted(struct Body *b)
Is this a valid multi-part encrypted message?
Definition: crypt.c:483
char * real_subj
Offset of the real subject.
Definition: envelope.h:67
bool changed
Email has been edited.
Definition: email.h:48
int mx_save_hcache(struct Mailbox *m, struct Email *e)
Save message to the header cache - Wrapper for MxOps::msg_save_hcache()
Definition: mx.c:1726
#define MUTT_ENV_CHANGED_SUBJECT
Protected header update.
Definition: envelope.h:35
unsigned char changed
Changed fields, e.g. MUTT_ENV_CHANGED_SUBJECT.
Definition: envelope.h:88
struct Mailbox * mailbox
Definition: context.h:51
struct Envelope * env
Envelope information.
Definition: email.h:89
SecurityFlags mutt_is_multipart_signed(struct Body *b)
Is a message signed?
Definition: crypt.c:418
struct Regex * C_ReplyRegex
Config: Regex to match message reply subjects like "re: ".
Definition: email_globals.c:37
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: lib.h:138
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:137
WHERE bool C_CryptProtectedHeadersSave
Config: Save the cleartext Subject with the headers.
Definition: globals.h:271
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
Definition: crypt.c:520
SecurityFlags mutt_is_application_smime(struct Body *m)
Does the message use S/MIME?
Definition: crypt.c:624
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
Definition: email.h:39
WHERE bool C_CryptProtectedHeadersRead
Config: Display protected headers (Memory Hole) in the pager.
Definition: globals.h:270
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:453
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:594
#define SEC_SIGN
Email is signed.
Definition: lib.h:126
char * subject
Email&#39;s subject.
Definition: envelope.h:66
struct Hash * subj_hash
Hash table by subject.
Definition: mailbox.h:128
#define FREE(x)
Definition: memory.h:40
bool changed
Mailbox has been modified.
Definition: mailbox.h:114
struct HashElem * mutt_hash_insert(struct Hash *table, const char *strkey, void *data)
Add a new element to the Hash table (with string keys)
Definition: hash.c:351
#define SEC_GOODSIGN
Email has a valid signature.
Definition: lib.h:127
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
The header of an Email.
Definition: envelope.h:54
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_display_message()

int mutt_display_message ( struct MuttWindow win_index,
struct MuttWindow win_ibar,
struct MuttWindow win_pager,
struct MuttWindow win_pbar,
struct Mailbox m,
struct Email e 
)

Display a message in the pager.

Parameters
win_indexIndex Window
win_ibarIndex Bar Window
win_pagerPager Window
win_pbarPager Bar Window
mMailbox
eEmail to display
Return values
0Success
-1Error

Definition at line 198 of file commands.c.

201 {
202  int rc = 0;
203  bool builtin = false;
205  CopyHeaderFlags chflags;
206  pid_t filterpid = -1;
207  struct Buffer *tempfile = NULL;
208  int res;
209 
212 
213  char columns[16];
214  // win_pager might not be visible and have a size yet, so use win_index
215  snprintf(columns, sizeof(columns), "%d", win_index->state.cols);
216  mutt_envlist_set("COLUMNS", columns, true);
217 
218  /* see if crypto is needed for this message. if so, we should exit curses */
219  if ((WithCrypto != 0) && e->security)
220  {
221  if (e->security & SEC_ENCRYPT)
222  {
223  if (e->security & APPLICATION_SMIME)
226  goto cleanup;
227 
228  cmflags |= MUTT_CM_VERIFY;
229  }
230  else if (e->security & SEC_SIGN)
231  {
232  /* find out whether or not the verify signature */
233  /* L10N: Used for the $crypt_verify_sig prompt */
234  if (query_quadoption(C_CryptVerifySig, _("Verify signature?")) == MUTT_YES)
235  {
236  cmflags |= MUTT_CM_VERIFY;
237  }
238  }
239  }
240 
241  if (cmflags & MUTT_CM_VERIFY || e->security & SEC_ENCRYPT)
242  {
243  if (e->security & APPLICATION_PGP)
244  {
245  if (!TAILQ_EMPTY(&e->env->from))
247 
249  }
250 
251  if (e->security & APPLICATION_SMIME)
253  }
254 
255  FILE *fp_filter_out = NULL;
256  tempfile = mutt_buffer_pool_get();
257  mutt_buffer_mktemp(tempfile);
258  FILE *fp_out = mutt_file_fopen(mutt_b2s(tempfile), "w");
259  if (!fp_out)
260  {
261  mutt_error(_("Could not create temporary file"));
262  goto cleanup;
263  }
264 
265  if (C_DisplayFilter)
266  {
267  fp_filter_out = fp_out;
268  fp_out = NULL;
269  filterpid = filter_create_fd(C_DisplayFilter, &fp_out, NULL, NULL, -1,
270  fileno(fp_filter_out), -1);
271  if (filterpid < 0)
272  {
273  mutt_error(_("Can't create display filter"));
274  mutt_file_fclose(&fp_filter_out);
275  unlink(mutt_b2s(tempfile));
276  goto cleanup;
277  }
278  }
279 
280  if (!C_Pager || (mutt_str_strcmp(C_Pager, "builtin") == 0))
281  builtin = true;
282  else
283  {
284  char buf[1024];
285  struct HdrFormatInfo hfi;
286 
287  hfi.ctx = Context;
288  hfi.mailbox = m;
289  hfi.pager_progress = ExtPagerProgress;
290  hfi.email = e;
291  mutt_make_string_info(buf, sizeof(buf), win_pager->state.cols,
293  fputs(buf, fp_out);
294  fputs("\n\n", fp_out);
295  }
296 
297  chflags = (C_Weed ? (CH_WEED | CH_REORDER) : CH_NO_FLAGS) | CH_DECODE | CH_FROM | CH_DISPLAY;
298 #ifdef USE_NOTMUCH
299  if (m->type == MUTT_NOTMUCH)
300  chflags |= CH_VIRTUAL;
301 #endif
302  res = mutt_copy_message(fp_out, m, e, cmflags, chflags, win_pager->state.cols);
303 
304  if (((mutt_file_fclose(&fp_out) != 0) && (errno != EPIPE)) || (res < 0))
305  {
306  mutt_error(_("Could not copy message"));
307  if (fp_filter_out)
308  {
309  filter_wait(filterpid);
310  mutt_file_fclose(&fp_filter_out);
311  }
312  mutt_file_unlink(mutt_b2s(tempfile));
313  goto cleanup;
314  }
315 
316  if (fp_filter_out && (filter_wait(filterpid) != 0))
318 
319  mutt_file_fclose(&fp_filter_out); /* XXX - check result? */
320 
321  if (WithCrypto)
322  {
323  /* update crypto information for this message */
324  e->security &= ~(SEC_GOODSIGN | SEC_BADSIGN);
325  e->security |= crypt_query(e->content);
326 
327  /* Remove color cache for this message, in case there
328  * are color patterns for both ~g and ~V */
329  e->pair = 0;
330 
331  /* Process protected headers and autocrypt gossip headers */
333  }
334 
335  if (builtin)
336  {
337  if ((WithCrypto != 0) && (e->security & APPLICATION_SMIME) && (cmflags & MUTT_CM_VERIFY))
338  {
339  if (e->security & SEC_GOODSIGN)
340  {
341  if (crypt_smime_verify_sender(m, e) == 0)
342  mutt_message(_("S/MIME signature successfully verified"));
343  else
344  mutt_error(_("S/MIME certificate owner does not match sender"));
345  }
346  else if (e->security & SEC_PARTSIGN)
347  mutt_message(_("Warning: Part of this message has not been signed"));
348  else if (e->security & SEC_SIGN || e->security & SEC_BADSIGN)
349  mutt_error(_("S/MIME signature could NOT be verified"));
350  }
351 
352  if ((WithCrypto != 0) && (e->security & APPLICATION_PGP) && (cmflags & MUTT_CM_VERIFY))
353  {
354  if (e->security & SEC_GOODSIGN)
355  mutt_message(_("PGP signature successfully verified"));
356  else if (e->security & SEC_PARTSIGN)
357  mutt_message(_("Warning: Part of this message has not been signed"));
358  else if (e->security & SEC_SIGN)
359  mutt_message(_("PGP signature could NOT be verified"));
360  }
361 
362  struct Pager info = { 0 };
363  /* Invoke the builtin pager */
364  info.email = e;
365  info.ctx = Context;
366  info.win_ibar = win_ibar;
367  info.win_index = win_index;
368  info.win_pbar = win_pbar;
369  info.win_pager = win_pager;
370  rc = mutt_pager(NULL, mutt_b2s(tempfile), MUTT_PAGER_MESSAGE, &info);
371  }
372  else
373  {
374  mutt_endwin();
375 
376  struct Buffer *cmd = mutt_buffer_pool_get();
377  mutt_buffer_printf(cmd, "%s %s", NONULL(C_Pager), mutt_b2s(tempfile));
378  int r = mutt_system(mutt_b2s(cmd));
379  if (r == -1)
380  mutt_error(_("Error running \"%s\""), mutt_b2s(cmd));
381  unlink(mutt_b2s(tempfile));
383 
384  if (!OptNoCurses)
385  keypad(stdscr, true);
386  if (r != -1)
387  mutt_set_flag(m, e, MUTT_READ, true);
388  if ((r != -1) && C_PromptAfter)
389  {
390  mutt_unget_event(mutt_any_key_to_continue(_("Command: ")), 0);
391  rc = km_dokey(MENU_PAGER);
392  }
393  else
394  rc = 0;
395  }
396 
397 cleanup:
398  mutt_envlist_unset("COLUMNS");
399  mutt_buffer_pool_release(&tempfile);
400  return rc;
401 }
int km_dokey(enum MenuType menu)
Determine what a keypress should do.
Definition: keymap.c:619
struct Context * ctx
Definition: hdrline.h:47
#define mutt_buffer_mktemp(buf)
Definition: muttlib.h:81
struct MuttWindow * win_index
Definition: pager.h:74
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
#define NONULL(x)
Definition: string2.h:37
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:70
#define WithCrypto
Definition: lib.h:163
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
#define TAILQ_FIRST(head)
Definition: queue.h:716
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:1099
#define mutt_message(...)
Definition: logging.h:83
#define MUTT_PAGER_MESSAGE
Definition: pager.h:58
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:40
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:125
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
struct Body * content
List of MIME parts.
Definition: email.h:90
void mutt_file_unlink(const char *s)
Delete a file, carefully.
Definition: file.c:195
String manipulation buffer.
Definition: buffer.h:33
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:49
int mutt_copy_message(FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen)
Copy a message from a Mailbox.
Definition: copy.c:812
void mutt_unget_event(int ch, int op)
Return a keystroke to the input buffer.
Definition: curs_lib.c:812
#define CH_FROM
Retain the "From " message separator?
Definition: copy.h:55
#define _(a)
Definition: message.h:28
static const char * ExtPagerProgress
Definition: commands.c:94
WHERE bool OptNoCurses
(pseudo) when sending in batch mode
Definition: options.h:49
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:52
uint16_t CopyMessageFlags
Flags for mutt_copy_message(), e.g. MUTT_CM_NOHEADER.
Definition: copy.h:31
int crypt_smime_verify_sender(struct Mailbox *m, struct Email *e)
Wrapper for CryptModuleSpecs::smime_verify_sender()
Definition: cryptglue.c:457
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
An email being displayed.
Definition: pager.h:65
unsigned char C_CryptVerifySig
Config: Verify PGP or SMIME signatures.
Definition: commands.c:85
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: format_flags.h:30
Pager pager (email viewer)
Definition: keymap.h:78
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:146
struct Mailbox * mailbox
Definition: context.h:51
#define MUTT_CM_DISPLAY
Output is displayed to the user.
Definition: copy.h:38
Data passed to index_format_str()
Definition: hdrline.h:45
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
#define CH_WEED
Weed the headers?
Definition: copy.h:52
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:153
struct Envelope * env
Envelope information.
Definition: email.h:89
#define CH_VIRTUAL
Write virtual header lines too.
Definition: copy.h:72
struct MuttWindow * win_pager
Definition: pager.h:76
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:58
void mutt_make_string_info(char *buf, size_t buflen, int cols, const char *s, struct HdrFormatInfo *hfi, MuttFormatFlags flags)
Create pager status bar string.
Definition: hdrline.c:1528
void crypt_invoke_message(SecurityFlags type)
Display an informative message.
Definition: cryptglue.c:146
#define mutt_b2s(buf)
Definition: buffer.h:41
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: lib.h:138
struct Context * ctx
Current mailbox.
Definition: pager.h:67
WHERE struct Context * Context
Definition: globals.h:42
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:93
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:137
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:547
bool mutt_envlist_unset(const char *name)
Unset an environment variable.
Definition: envlist.c:132
#define CH_NO_FLAGS
No flags are set.
Definition: copy.h:50
#define MUTT_CM_DECODE
Decode the message body into text/plain.
Definition: copy.h:37
#define CH_REORDER
Re-order output of headers (specified by &#39;hdr_order&#39;)
Definition: copy.h:58
#define MUTT_CM_CHARCONV
Perform character set conversions.
Definition: copy.h:41
void crypt_smime_getkeys(struct Envelope *env)
Wrapper for CryptModuleSpecs::smime_getkeys()
Definition: cryptglue.c:448
#define CH_DECODE
Do RFC2047 header decoding.
Definition: copy.h:53
void crypt_pgp_invoke_getkeys(struct Address *addr)
Wrapper for CryptModuleSpecs::pgp_invoke_getkeys()
Definition: cryptglue.c:265
#define CH_DISPLAY
Display result to user.
Definition: copy.h:69
Messages that have been read.
Definition: mutt.h:94
#define MUTT_CM_VERIFY
Do signature verification.
Definition: copy.h:46
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
Definition: email.h:39
#define SEC_BADSIGN
Email has a bad signature.
Definition: lib.h:128
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:54
#define SEC_SIGN
Email is signed.
Definition: lib.h:126
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:580
bool C_PromptAfter
Config: Pause after running an external pager.
Definition: commands.c:92
struct Email * email
Current message.
Definition: pager.h:68
char * C_DisplayFilter
Config: External command to pre-process an email before display.
Definition: commands.c:86
pid_t filter_create_fd(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err, int fdin, int fdout, int fderr)
Run a command on a pipe (optionally connect stdin/stdout)
Definition: filter.c:61
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
Definition: copy.h:49
#define mutt_error(...)
Definition: logging.h:84
static void process_protected_headers(struct Email *e)
Get the protected header and update the index.
Definition: commands.c:103
bool mutt_envlist_set(const char *name, const char *value, bool overwrite)
Set an environment variable.
Definition: envlist.c:85
struct MuttWindow * win_ibar
Definition: pager.h:73
WHERE char * C_Pager
Config: External command for viewing messages, or &#39;builtin&#39; to use NeoMutt&#39;s.
Definition: globals.h:133
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:579
#define TAILQ_EMPTY(head)
Definition: queue.h:714
int mutt_pager(const char *banner, const char *fname, PagerFlags flags, struct Pager *extra)
Display a file, or help, in a window.
Definition: pager.c:2206
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:588
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:217
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:700
#define SEC_GOODSIGN
Email has a valid signature.
Definition: lib.h:127
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
int pair
Color-pair to use when displaying in the index.
Definition: email.h:79
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:51
#define SEC_PARTSIGN
Not all parts of the email is signed.
Definition: lib.h:129
WHERE char * C_PagerFormat
Config: printf-like format string for the pager&#39;s status bar.
Definition: globals.h:134
bool C_Weed
Config: Filter headers when displaying/forwarding/printing/replying.
Definition: email_globals.c:40
struct MuttWindow * win_pbar
Definition: pager.h:75
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ci_bounce_message()

void ci_bounce_message ( struct Mailbox m,
struct EmailList *  el 
)

Bounce an email.

Parameters
mMailbox
elList of Emails to bounce

Definition at line 408 of file commands.c.

409 {
410  if (!m || !el || STAILQ_EMPTY(el))
411  return;
412 
413  char prompt[8193];
414  char scratch[8192];
415  char buf[8192] = { 0 };
416  struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
417  char *err = NULL;
418  int rc;
419  int msg_count = 0;
420 
421  struct EmailNode *en = NULL;
422  STAILQ_FOREACH(en, el, entries)
423  {
424  /* RFC5322 mandates a From: header,
425  * so warn before bouncing messages without one */
426  if (!TAILQ_EMPTY(&en->email->env->from))
427  mutt_error(_("Warning: message contains no From: header"));
428 
429  msg_count++;
430  }
431 
432  if (msg_count == 1)
433  mutt_str_strfcpy(prompt, _("Bounce message to: "), sizeof(prompt));
434  else
435  mutt_str_strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt));
436 
437  rc = mutt_get_field(prompt, buf, sizeof(buf), MUTT_ALIAS);
438  if (rc || !buf[0])
439  return;
440 
441  mutt_addrlist_parse2(&al, buf);
442  if (TAILQ_EMPTY(&al))
443  {
444  mutt_error(_("Error parsing address"));
445  return;
446  }
447 
448  mutt_expand_aliases(&al);
449 
450  if (mutt_addrlist_to_intl(&al, &err) < 0)
451  {
452  mutt_error(_("Bad IDN: '%s'"), err);
453  FREE(&err);
454  mutt_addrlist_clear(&al);
455  return;
456  }
457 
458  buf[0] = '\0';
459  mutt_addrlist_write(&al, buf, sizeof(buf), true);
460 
461 #define EXTRA_SPACE (15 + 7 + 2)
462  snprintf(scratch, sizeof(scratch),
463  ngettext("Bounce message to %s?", "Bounce messages to %s?", msg_count), buf);
464 
466  {
467  mutt_simple_format(prompt, sizeof(prompt), 0, MuttMessageWindow->state.cols - EXTRA_SPACE,
468  JUSTIFY_LEFT, 0, scratch, sizeof(scratch), false);
469  mutt_str_strcat(prompt, sizeof(prompt), "...?");
470  }
471  else
472  snprintf(prompt, sizeof(prompt), "%s", scratch);
473 
474  if (query_quadoption(C_Bounce, prompt) != MUTT_YES)
475  {
476  mutt_addrlist_clear(&al);
478  mutt_message(ngettext("Message not bounced", "Messages not bounced", msg_count));
479  return;
480  }
481 
483 
484  struct Message *msg = NULL;
485  STAILQ_FOREACH(en, el, entries)
486  {
487  msg = mx_msg_open(m, en->email->msgno);
488  if (!msg)
489  {
490  rc = -1;
491  break;
492  }
493 
494  rc = mutt_bounce_message(msg->fp, en->email, &al);
495  mx_msg_close(m, &msg);
496 
497  if (rc < 0)
498  break;
499  }
500 
501  mutt_addrlist_clear(&al);
502  /* If no error, or background, display message. */
503  if ((rc == 0) || (rc == S_BKG))
504  mutt_message(ngettext("Message bounced", "Messages bounced", msg_count));
505 }
WHERE unsigned char C_Bounce
Config: Confirm before bouncing a message.
Definition: globals.h:179
void mutt_expand_aliases(struct AddressList *al)
Expand aliases in a List of Addresses.
Definition: alias.c:303
Left justify the text.
Definition: curs_lib.h:47
#define MUTT_ALIAS
Do alias "completion" by calling up the alias-menu.
Definition: mutt.h:57
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:1099
#define mutt_message(...)
Definition: logging.h:83
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:40
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1382
#define _(a)
Definition: message.h:28
#define S_BKG
Definition: string2.h:43
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:607
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:90
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1171
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:112
struct Envelope * env
Envelope information.
Definition: email.h:89
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:58
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:93
int mutt_bounce_message(FILE *fp, struct Email *e, struct AddressList *to)
Bounce an email message.
Definition: sendlib.c:3123
A local copy of an email.
Definition: mx.h:83
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:1337
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:773
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
char * mutt_str_strcat(char *buf, size_t buflen, const char *s)
Concatenate two strings.
Definition: string.c:395
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1217
struct Email * email
Email in the list.
Definition: email.h:116
#define mutt_error(...)
Definition: logging.h:84
FILE * fp
pointer to the message data
Definition: mx.h:85
#define FREE(x)
Definition: memory.h:40
#define STAILQ_EMPTY(head)
Definition: queue.h:345
List of Emails.
Definition: email.h:114
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:46
#define TAILQ_EMPTY(head)
Definition: queue.h:714
#define EXTRA_SPACE
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:630
size_t mutt_addrlist_write(const struct AddressList *al, char *buf, size_t buflen, bool display)
Write an Address to a buffer.
Definition: address.c:1138
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1123
int msgno
Number displayed to the user.
Definition: email.h:86
void mutt_simple_format(char *buf, size_t buflen, int min_width, int max_width, enum FormatJustify justify, char pad_char, const char *s, size_t n, bool arboreal)
Format a string, like snprintf()
Definition: curs_lib.c:1071
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pipe_set_flags()

static void pipe_set_flags ( bool  decode,
bool  print,
CopyMessageFlags cmflags,
CopyHeaderFlags chflags 
)
static

Generate flags for copy header/message.

Parameters
[in]decodeIf true decode the message
[in]printIf true, mark the message for printing
[out]cmflagsFlags, see CopyMessageFlags
[out]chflagsFlags, see CopyHeaderFlags

Definition at line 514 of file commands.c.

516 {
517  if (decode)
518  {
519  *chflags |= CH_DECODE | CH_REORDER;
520  *cmflags |= MUTT_CM_DECODE | MUTT_CM_CHARCONV;
521 
522  if (C_Weed)
523  {
524  *chflags |= CH_WEED;
525  *cmflags |= MUTT_CM_WEED;
526  }
527 
528  /* Just as with copy-decode, we need to update the mime fields to avoid
529  * confusing programs that may process the email. However, we don't want
530  * to force those fields to appear in printouts. */
531  if (!print)
532  *chflags |= CH_MIME | CH_TXTPLAIN;
533  }
534 
535  if (print)
536  *cmflags |= MUTT_CM_PRINTING;
537 }
#define CH_MIME
Ignore MIME fields.
Definition: copy.h:60
#define MUTT_CM_WEED
Weed message/rfc822 attachment headers.
Definition: copy.h:40
#define MUTT_CM_PRINTING
Printing the message - display light.
Definition: copy.h:42
#define CH_WEED
Weed the headers?
Definition: copy.h:52
#define CH_TXTPLAIN
Generate text/plain MIME headers.
Definition: copy.h:62
#define MUTT_CM_DECODE
Decode the message body into text/plain.
Definition: copy.h:37
#define CH_REORDER
Re-order output of headers (specified by &#39;hdr_order&#39;)
Definition: copy.h:58
#define MUTT_CM_CHARCONV
Perform character set conversions.
Definition: copy.h:41
#define CH_DECODE
Do RFC2047 header decoding.
Definition: copy.h:53
bool C_Weed
Config: Filter headers when displaying/forwarding/printing/replying.
Definition: email_globals.c:40
+ Here is the caller graph for this function:

◆ pipe_msg()

static void pipe_msg ( struct Mailbox m,
struct Email e,
FILE *  fp,
bool  decode,
bool  print 
)
static

Pipe a message.

Parameters
mMailbox
eEmail to pipe
fpFile to write to
decodeIf true, decode the message
printIf true, message is for printing

Definition at line 547 of file commands.c.

548 {
550  CopyHeaderFlags chflags = CH_FROM;
551 
552  pipe_set_flags(decode, print, &cmflags, &chflags);
553 
554  if ((WithCrypto != 0) && decode && e->security & SEC_ENCRYPT)
555  {
557  return;
558  endwin();
559  }
560 
561  if (decode)
563 
564  mutt_copy_message(fp, m, e, cmflags, chflags, 0);
565 }
#define WithCrypto
Definition: lib.h:163
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:125
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:49
int mutt_copy_message(FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen)
Copy a message from a Mailbox.
Definition: copy.c:812
#define CH_FROM
Retain the "From " message separator?
Definition: copy.h:55
uint16_t CopyMessageFlags
Flags for mutt_copy_message(), e.g. MUTT_CM_NOHEADER.
Definition: copy.h:31
#define MUTT_CM_NO_FLAGS
No flags are set.
Definition: copy.h:34
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:146
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
Definition: email.h:39
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
Definition: copy.h:49
FILE * fp
pointer to the message data
Definition: mx.h:85
static void pipe_set_flags(bool decode, bool print, CopyMessageFlags *cmflags, CopyHeaderFlags *chflags)
Generate flags for copy header/message.
Definition: commands.c:514
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pipe_message()

static int pipe_message ( struct Mailbox m,
struct EmailList *  el,
char *  cmd,
bool  decode,
bool  print,
bool  split,
const char *  sep 
)
static

Pipe message to a command.

Parameters
mMailbox
elList of Emails to pipe
cmdCommand to pipe to
decodeShould the message be decrypted
printTrue if this is a print job
splitShould a separator be sent between messages?
sepSeparator string
Return values
0Success
1Error

The following code is shared between printing and piping.

Definition at line 581 of file commands.c.

583 {
584  if (!m || !el)
585  return 1;
586 
587  struct EmailNode *en = STAILQ_FIRST(el);
588  if (!en)
589  return 1;
590 
591  int rc = 0;
592  pid_t pid;
593  FILE *fp_out = NULL;
594 
595  if (!STAILQ_NEXT(en, entries))
596  {
597  /* handle a single message */
599 
600  if ((WithCrypto != 0) && decode)
601  {
603  if ((en->email->security & SEC_ENCRYPT) &&
605  {
606  return 1;
607  }
608  }
609  mutt_endwin();
610 
611  pid = filter_create(cmd, &fp_out, NULL, NULL);
612  if (pid < 0)
613  {
614  mutt_perror(_("Can't create filter process"));
615  return 1;
616  }
617 
618  OptKeepQuiet = true;
619  pipe_msg(m, en->email, fp_out, decode, print);
620  mutt_file_fclose(&fp_out);
621  rc = filter_wait(pid);
622  OptKeepQuiet = false;
623  }
624  else
625  {
626  /* handle tagged messages */
627  if ((WithCrypto != 0) && decode)
628  {
629  STAILQ_FOREACH(en, el, entries)
630  {
633  if ((en->email->security & SEC_ENCRYPT) &&
635  {
636  return 1;
637  }
638  }
639  }
640 
641  if (split)
642  {
643  STAILQ_FOREACH(en, el, entries)
644  {
646  mutt_endwin();
647  pid = filter_create(cmd, &fp_out, NULL, NULL);
648  if (pid < 0)
649  {
650  mutt_perror(_("Can't create filter process"));
651  return 1;
652  }
653  OptKeepQuiet = true;
654  pipe_msg(m, en->email, fp_out, decode, print);
655  /* add the message separator */
656  if (sep)
657  fputs(sep, fp_out);
658  mutt_file_fclose(&fp_out);
659  if (filter_wait(pid) != 0)
660  rc = 1;
661  OptKeepQuiet = false;
662  }
663  }
664  else
665  {
666  mutt_endwin();
667  pid = filter_create(cmd, &fp_out, NULL, NULL);
668  if (pid < 0)
669  {
670  mutt_perror(_("Can't create filter process"));
671  return 1;
672  }
673  OptKeepQuiet = true;
674  STAILQ_FOREACH(en, el, entries)
675  {
677  pipe_msg(m, en->email, fp_out, decode, print);
678  /* add the message separator */
679  if (sep)
680  fputs(sep, fp_out);
681  }
682  mutt_file_fclose(&fp_out);
683  if (filter_wait(pid) != 0)
684  rc = 1;
685  OptKeepQuiet = false;
686  }
687  }
688 
689  if ((rc != 0) || C_WaitKey)
691  return rc;
692 }
pid_t filter_create(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err)
Set up filter program.
Definition: filter.c:206
#define WithCrypto
Definition: lib.h:163
#define mutt_perror(...)
Definition: logging.h:85
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:125
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:49
#define _(a)
Definition: message.h:28
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:52
static void pipe_msg(struct Mailbox *m, struct Email *e, FILE *fp, bool decode, bool print)
Pipe a message.
Definition: commands.c:547
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:146
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:153
WHERE bool C_WaitKey
Config: Prompt to press a key after running external commands.
Definition: globals.h:257
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:547
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
#define STAILQ_NEXT(elm, field)
Definition: queue.h:397
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
Definition: email.h:39
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:580
struct Email * email
Email in the list.
Definition: email.h:116
List of Emails.
Definition: email.h:114
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:579
WHERE bool OptKeepQuiet
(pseudo) shut up the message and refresh functions while we are executing an external program ...
Definition: options.h:39
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:217
#define STAILQ_FIRST(head)
Definition: queue.h:347
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_pipe_message()

void mutt_pipe_message ( struct Mailbox m,
struct EmailList *  el 
)

Pipe a message.

Parameters
mMailbox
elList of Emails to pipe

Definition at line 699 of file commands.c.

700 {
701  if (!m || !el)
702  return;
703 
704  char buf[1024] = { 0 };
705 
706  if ((mutt_get_field(_("Pipe to command: "), buf, sizeof(buf), MUTT_CMD) != 0) ||
707  (buf[0] == '\0'))
708  {
709  return;
710  }
711 
712  mutt_expand_path(buf, sizeof(buf));
713  pipe_message(m, el, buf, C_PipeDecode, false, C_PipeSplit, C_PipeSep);
714 }
#define _(a)
Definition: message.h:28
char * C_PipeSep
Config: Separator to add between multiple piped messages.
Definition: commands.c:88
bool C_PipeDecode
Config: Decode the message when piping it.
Definition: commands.c:87
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:90
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:133
bool C_PipeSplit
Config: Run the pipe command on each message separately.
Definition: commands.c:89
#define MUTT_CMD
Do completion on previous word.
Definition: mutt.h:60
static int pipe_message(struct Mailbox *m, struct EmailList *el, char *cmd, bool decode, bool print, bool split, const char *sep)
Pipe message to a command.
Definition: commands.c:581
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_print_message()

void mutt_print_message ( struct Mailbox m,
struct EmailList *  el 
)

Print a message.

Parameters
mMailbox
elList of Emails to print

Definition at line 721 of file commands.c.

722 {
723  if (!m || !el)
724  return;
725 
726  if (C_Print && !C_PrintCommand)
727  {
728  mutt_message(_("No printing command has been defined"));
729  return;
730  }
731 
732  int msg_count = 0;
733  struct EmailNode *en = NULL;
734  STAILQ_FOREACH(en, el, entries)
735  {
736  msg_count++;
737  }
738 
739  if (query_quadoption(C_Print, (msg_count == 1) ?
740  _("Print message?") :
741  _("Print tagged messages?")) != MUTT_YES)
742  {
743  return;
744  }
745 
746  if (pipe_message(m, el, C_PrintCommand, C_PrintDecode, true, C_PrintSplit, "\f") == 0)
747  mutt_message(ngettext("Message printed", "Messages printed", msg_count));
748  else
749  {
750  mutt_message(ngettext("Message could not be printed",
751  "Messages could not be printed", msg_count));
752  }
753 }
WHERE unsigned char C_Print
Config: Confirm before printing a message.
Definition: globals.h:184
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:1099
#define mutt_message(...)
Definition: logging.h:83
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:40
bool C_PrintSplit
Config: Print multiple messages separately.
Definition: commands.c:91
#define _(a)
Definition: message.h:28
bool C_PrintDecode
Config: Decode message before printing it.
Definition: commands.c:90
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
WHERE char * C_PrintCommand
Config: External command to print a message.
Definition: globals.h:137
List of Emails.
Definition: email.h:114
static int pipe_message(struct Mailbox *m, struct EmailList *el, char *cmd, bool decode, bool print, bool split, const char *sep)
Pipe message to a command.
Definition: commands.c:581
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_select_sort()

int mutt_select_sort ( bool  reverse)

Ask the user for a sort method.

Parameters
reverseIf true make it a reverse sort
Return values
numSort type, see SortType

Definition at line 760 of file commands.c.

761 {
762  enum SortType method = C_Sort; /* save the current method in case of abort */
763  enum SortType new_sort = C_Sort;
764 
765  switch (mutt_multi_choice(reverse ?
766  /* L10N: The highlighted letters must match the "Sort" options */
767  _("Rev-Sort "
768  "(d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/"
769  "(u)nsort/si(z)e/s(c)ore/s(p)am/(l)abel?") :
770  /* L10N: The highlighted letters must match the "Rev-Sort" options */
771  _("Sort "
772  "(d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/"
773  "(u)nsort/si(z)e/s(c)ore/s(p)am/(l)abel?"),
774  /* L10N: These must match the highlighted letters from "Sort" and "Rev-Sort" */
775  _("dfrsotuzcpl")))
776  {
777  case -1: /* abort - don't resort */
778  return -1;
779 
780  case 1: /* (d)ate */
781  new_sort = SORT_DATE;
782  break;
783 
784  case 2: /* (f)rm */
785  new_sort = SORT_FROM;
786  break;
787 
788  case 3: /* (r)ecv */
789  new_sort = SORT_RECEIVED;
790  break;
791 
792  case 4: /* (s)ubj */
793  new_sort = SORT_SUBJECT;
794  break;
795 
796  case 5: /* t(o) */
797  new_sort = SORT_TO;
798  break;
799 
800  case 6: /* (t)hread */
801  new_sort = SORT_THREADS;
802  break;
803 
804  case 7: /* (u)nsort */
805  new_sort = SORT_ORDER;
806  break;
807 
808  case 8: /* si(z)e */
809  new_sort = SORT_SIZE;
810  break;
811 
812  case 9: /* s(c)ore */
813  new_sort = SORT_SCORE;
814  break;
815 
816  case 10: /* s(p)am */
817  new_sort = SORT_SPAM;
818  break;
819 
820  case 11: /* (l)abel */
821  new_sort = SORT_LABEL;
822  break;
823  }
824  if (reverse)
825  new_sort |= SORT_REVERSE;
826 
827  cs_subset_str_native_set(NeoMutt->sub, "sort", new_sort, NULL);
828  return (C_Sort != method) ? 0 : -1; /* no need to resort if it's the same */
829 }
SortType
Methods for sorting.
Definition: sort2.h:48
Sort by the email&#39;s From field.
Definition: sort2.h:54
#define _(a)
Definition: message.h:28
Sort by the email&#39;s score.
Definition: sort2.h:59
Sort by the emails label.
Definition: sort2.h:69
Container for Accounts, Notifications.
Definition: neomutt.h:35
int cs_subset_str_native_set(const struct ConfigSubset *sub, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
Definition: subset.c:292
Sort by the size of the email.
Definition: sort2.h:51
Sort by the order the messages appear in the mailbox.
Definition: sort2.h:55
WHERE short C_Sort
Config: Sort method for the index.
Definition: sort.h:58
int mutt_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question.
Definition: curs_lib.c:911
Sort by email threads.
Definition: sort2.h:56
Sort by the email&#39;s spam score.
Definition: sort2.h:64
Sort by the email&#39;s To field.
Definition: sort2.h:58
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:38
Sort by when the message were delivered locally.
Definition: sort2.h:57
Sort by the date the email was sent.
Definition: sort2.h:50
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort2.h:86
Sort by the email&#39;s subject.
Definition: sort2.h:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_shell_escape()

void mutt_shell_escape ( void  )

invoke a command in a subshell

Definition at line 834 of file commands.c.

835 {
836  char buf[1024];
837 
838  buf[0] = '\0';
839  if (mutt_get_field(_("Shell command: "), buf, sizeof(buf), MUTT_CMD) != 0)
840  return;
841 
842  if ((buf[0] == '\0') && C_Shell)
843  mutt_str_strfcpy(buf, C_Shell, sizeof(buf));
844  if (buf[0] == '\0')
845  return;
846 
848  mutt_endwin();
849  fflush(stdout);
850  int rc = mutt_system(buf);
851  if (rc == -1)
852  mutt_debug(LL_DEBUG1, "Error running \"%s\"", buf);
853 
854  if ((rc != 0) || C_WaitKey)
857 }
The "current" mailbox.
Definition: context.h:37
#define _(a)
Definition: message.h:28
WHERE char * C_Shell
Config: External command to run subshells in.
Definition: globals.h:140
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:90
struct Mailbox * mailbox
Definition: context.h:51
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:112
#define MUTT_CMD
Do completion on previous word.
Definition: mutt.h:60
WHERE bool C_WaitKey
Config: Prompt to press a key after running external commands.
Definition: globals.h:257
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:547
int mutt_mailbox_check(struct Mailbox *m_cur, int force)
Check all all Mailboxes for new mail.
Definition: mutt_mailbox.c:152
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:773
#define MUTT_MAILBOX_CHECK_FORCE
Definition: mutt_mailbox.h:17
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:580
Log at debug level 1.
Definition: logging.h:40
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:46
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_enter_command()

void mutt_enter_command ( void  )

enter a neomutt command

Definition at line 862 of file commands.c.

863 {
864  char buf[1024] = { 0 };
865 
866  /* if enter is pressed after : with no command, just return */
867  if ((mutt_get_field(":", buf, sizeof(buf), MUTT_COMMAND) != 0) || !buf[0])
868  return;
869 
870  struct Buffer err = mutt_buffer_make(256);
871  struct Buffer token = mutt_buffer_make(256);
872 
873  /* check if buf is a valid icommand, else fall back quietly to parse_rc_lines */
874  enum CommandResult rc = mutt_parse_icommand(buf, &err);
875  if (!mutt_buffer_is_empty(&err))
876  {
877  /* since errbuf could potentially contain printf() sequences in it,
878  * we must call mutt_error() in this fashion so that vsprintf()
879  * doesn't expect more arguments that we passed */
880  if (rc == MUTT_CMD_ERROR)
881  mutt_error("%s", err.data);
882  else
883  mutt_warning("%s", err.data);
884  }
885  else if (rc != MUTT_CMD_SUCCESS)
886  {
887  rc = mutt_parse_rc_line(buf, &token, &err);
888  if (!mutt_buffer_is_empty(&err))
889  {
890  if (rc == MUTT_CMD_SUCCESS) /* command succeeded with message */
891  mutt_message("%s", err.data);
892  else if (rc == MUTT_CMD_ERROR)
893  mutt_error("%s", err.data);
894  else if (rc == MUTT_CMD_WARNING)
895  mutt_warning("%s", err.data);
896  }
897  }
898  /* else successful command */
899 
900  mutt_buffer_dealloc(&token);
901  mutt_buffer_dealloc(&err);
902 }
#define mutt_warning(...)
Definition: logging.h:82
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:33
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define mutt_message(...)
Definition: logging.h:83
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
String manipulation buffer.
Definition: buffer.h:33
enum CommandResult mutt_parse_icommand(char *line, struct Buffer *err)
Parse an informational command.
Definition: icommands.c:77
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:90
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
#define MUTT_COMMAND
Do command completion.
Definition: mutt.h:63
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
Warning: Help given to the user.
Definition: mutt_commands.h:36
#define mutt_error(...)
Definition: logging.h:84
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:991
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_display_address()

void mutt_display_address ( struct Envelope env)

Display the address of a message.

Parameters
envEnvelope containing address

Definition at line 908 of file commands.c.

909 {
910  const char *pfx = NULL;
911  char buf[128];
912 
913  struct AddressList *al = mutt_get_address(env, &pfx);
914  if (!al)
915  return;
916 
917  /* Note: We don't convert IDNA to local representation this time.
918  * That is intentional, so the user has an opportunity to copy &
919  * paste the on-the-wire form of the address to other, IDN-unable
920  * software. */
921  buf[0] = '\0';
922  mutt_addrlist_write(al, buf, sizeof(buf), false);
923  mutt_message("%s: %s", pfx, buf);
924 }
#define mutt_message(...)
Definition: logging.h:83
struct AddressList * mutt_get_address(struct Envelope *env, const char **pfxp)
Get an Address from an Envelope.
Definition: alias.c:335
size_t mutt_addrlist_write(const struct AddressList *al, char *buf, size_t buflen, bool display)
Write an Address to a buffer.
Definition: address.c:1138
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_copy_flags()

static void set_copy_flags ( struct Email e,
bool  decode,
bool  decrypt,
CopyMessageFlags cmflags,
CopyHeaderFlags chflags 
)
static

Set the flags for a message copy.

Parameters
[in]eEmail
[in]decodeIf true, decode the message
[in]decryptIf true, decrypt the message
[out]cmflagsFlags, see CopyMessageFlags
[out]chflagsFlags, see CopyHeaderFlags

Definition at line 934 of file commands.c.

936 {
937  *cmflags = MUTT_CM_NO_FLAGS;
938  *chflags = CH_UPDATE_LEN;
939 
940  if ((WithCrypto != 0) && !decode && decrypt && (e->security & SEC_ENCRYPT))
941  {
943  {
944  *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
945  *cmflags = MUTT_CM_DECODE_PGP;
946  }
947  else if (((WithCrypto & APPLICATION_PGP) != 0) &&
949  {
950  decode = 1;
951  }
952  else if (((WithCrypto & APPLICATION_SMIME) != 0) &&
954  {
955  *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
956  *cmflags = MUTT_CM_DECODE_SMIME;
957  }
958  }
959 
960  if (decode)
961  {
962  *chflags = CH_XMIT | CH_MIME | CH_TXTPLAIN;
963  *cmflags = MUTT_CM_DECODE | MUTT_CM_CHARCONV;
964 
965  if (!decrypt) /* If decode doesn't kick in for decrypt, */
966  {
967  *chflags |= CH_DECODE; /* then decode RFC2047 headers, */
968 
969  if (C_Weed)
970  {
971  *chflags |= CH_WEED; /* and respect $weed. */
972  *cmflags |= MUTT_CM_WEED;
973  }
974  }
975  }
976 }
#define CH_MIME
Ignore MIME fields.
Definition: copy.h:60
#define WithCrypto
Definition: lib.h:163
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:125
struct Body * content
List of MIME parts.
Definition: email.h:90
#define MUTT_CM_WEED
Weed message/rfc822 attachment headers.
Definition: copy.h:40
#define MUTT_CM_NO_FLAGS
No flags are set.
Definition: copy.h:34
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
Definition: crypt.c:459
#define CH_WEED
Weed the headers?
Definition: copy.h:52
#define CH_TXTPLAIN
Generate text/plain MIME headers.
Definition: copy.h:62
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: lib.h:138
SecurityFlags mutt_is_application_pgp(struct Body *m)
Does the message use PGP?
Definition: crypt.c:565
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:137
#define MUTT_CM_DECODE
Decode the message body into text/plain.
Definition: copy.h:37
#define MUTT_CM_CHARCONV
Perform character set conversions.
Definition: copy.h:41
#define CH_DECODE
Do RFC2047 header decoding.
Definition: copy.h:53
#define CH_XMIT
Transmitting this message? (Ignore Lines: and Content-Length:)
Definition: copy.h:54
#define CH_UPDATE_LEN
Update Lines: and Content-Length:
Definition: copy.h:61
SecurityFlags mutt_is_application_smime(struct Body *m)
Does the message use S/MIME?
Definition: crypt.c:624
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
Definition: email.h:39
#define MUTT_CM_DECODE_SMIME
Used for decoding S/MIME messages.
Definition: copy.h:45
#define MUTT_CM_DECODE_PGP
Used for decoding PGP messages.
Definition: copy.h:44
#define CH_NONEWLINE
Don&#39;t output terminating newline after the header.
Definition: copy.h:59
bool C_Weed
Config: Filter headers when displaying/forwarding/printing/replying.
Definition: email_globals.c:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_save_message_ctx()

int mutt_save_message_ctx ( struct Email e,
bool  delete_original,
bool  decode,
bool  decrypt,
struct Mailbox m 
)

Save a message to a given mailbox.

Parameters
eEmail
delete_originalIf true, delete the original
decodeIf true, decode the message
decryptIf true, decrypt the message
mMailbox to save to
Return values
0Success
-1Error

Definition at line 988 of file commands.c.

990 {
992  CopyHeaderFlags chflags = CH_NO_FLAGS;
993  int rc;
994 
995  set_copy_flags(e, decode, decrypt, &cmflags, &chflags);
996 
997  if (decode || decrypt)
999 
1000  rc = mutt_append_message(m, Context->mailbox, e, cmflags, chflags);
1001  if (rc != 0)
1002  return rc;
1003 
1004  if (delete_original)
1005  {
1008  if (C_DeleteUntag)
1009  mutt_set_flag(Context->mailbox, e, MUTT_TAG, false);
1010  }
1011 
1012  return 0;
1013 }
The "current" mailbox.
Definition: context.h:37
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:70
static void set_copy_flags(struct Email *e, bool decode, bool decrypt, CopyMessageFlags *cmflags, CopyHeaderFlags *chflags)
Set the flags for a message copy.
Definition: commands.c:934
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:49
Messages to be purged (bypass trash)
Definition: mutt.h:98
uint16_t CopyMessageFlags
Flags for mutt_copy_message(), e.g. MUTT_CM_NOHEADER.
Definition: copy.h:31
#define MUTT_CM_NO_FLAGS
No flags are set.
Definition: copy.h:34
struct Mailbox * mailbox
Definition: context.h:51
Messages to be deleted.
Definition: mutt.h:96
#define CH_NO_FLAGS
No flags are set.
Definition: copy.h:50
Tagged messages.
Definition: mutt.h:101
WHERE bool C_DeleteUntag
Config: Untag messages when they are marked for deletion.
Definition: globals.h:211
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
Definition: copy.h:49
int mutt_append_message(struct Mailbox *dest, struct Mailbox *src, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags)
Append a message.
Definition: copy.c:882
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_save_message()

int mutt_save_message ( struct Mailbox m,
struct EmailList *  el,
bool  delete_original,
bool  decode,
bool  decrypt 
)

Save an email.

Parameters
mMailbox
elList of Emails to save
delete_originalIf true, delete the original (save)
decodeIf true, decode the message
decryptIf true, decrypt the message
Return values
0Copy/save was successful
-1Error/abort

Definition at line 1025 of file commands.c.

1027 {
1028  if (!el || STAILQ_EMPTY(el))
1029  return -1;
1030 
1031  bool need_passphrase = false;
1032  int app = 0;
1033  int rc = -1;
1034  const char *prompt = NULL;
1035  struct stat st;
1036  struct EmailNode *en = STAILQ_FIRST(el);
1037  bool single = !STAILQ_NEXT(en, entries);
1038 
1039  struct Buffer *buf = mutt_buffer_pool_get();
1040 
1041  if (delete_original)
1042  {
1043  if (decode)
1044  prompt = single ? _("Decode-save to mailbox") : _("Decode-save tagged to mailbox");
1045  else if (decrypt)
1046  prompt = single ? _("Decrypt-save to mailbox") : _("Decrypt-save tagged to mailbox");
1047  else
1048  prompt = single ? _("Save to mailbox") : _("Save tagged to mailbox");
1049  }
1050  else
1051  {
1052  if (decode)
1053  prompt = single ? _("Decode-copy to mailbox") : _("Decode-copy tagged to mailbox");
1054  else if (decrypt)
1055  prompt = single ? _("Decrypt-copy to mailbox") : _("Decrypt-copy tagged to mailbox");
1056  else
1057  prompt = single ? _("Copy to mailbox") : _("Copy tagged to mailbox");
1058  }
1059 
1060  if (WithCrypto)
1061  {
1062  need_passphrase = (en->email->security & SEC_ENCRYPT);
1063  app = en->email->security;
1064  }
1066  mutt_default_save(buf->data, buf->dsize, en->email);
1067  mutt_buffer_fix_dptr(buf);
1068 
1070  if (mutt_buffer_enter_fname(prompt, buf, false) == -1)
1071  goto cleanup;
1072 
1073  size_t pathlen = mutt_buffer_len(buf);
1074  if (pathlen == 0)
1075  goto cleanup;
1076 
1077  /* Trim any trailing '/' */
1078  if (buf->data[pathlen - 1] == '/')
1079  buf->data[pathlen - 1] = '\0';
1080 
1081  /* This is an undocumented feature of ELM pointed out to me by Felix von
1082  * Leitner <leitner@prz.fu-berlin.de> */
1083  if (mutt_str_strcmp(mutt_b2s(buf), ".") == 0)
1085  else
1087 
1089 
1090  /* check to make sure that this file is really the one the user wants */
1091  if (mutt_save_confirm(mutt_b2s(buf), &st) != 0)
1092  goto cleanup;
1093 
1094  if ((WithCrypto != 0) && need_passphrase && (decode || decrypt) &&
1095  !crypt_valid_passphrase(app))
1096  {
1097  goto cleanup;
1098  }
1099 
1100  mutt_message(_("Copying to %s..."), mutt_b2s(buf));
1101 
1102 #ifdef USE_IMAP
1103  if ((m->type == MUTT_IMAP) && !(decode || decrypt) &&
1104  (imap_path_probe(mutt_b2s(buf), NULL) == MUTT_IMAP))
1105  {
1106  switch (imap_copy_messages(m, el, mutt_b2s(buf), delete_original))
1107  {
1108  /* success */
1109  case 0:
1110  mutt_clear_error();
1111  rc = 0;
1112  goto cleanup;
1113  /* non-fatal error: continue to fetch/append */
1114  case 1:
1115  break;
1116  /* fatal error, abort */
1117  case -1:
1118  goto cleanup;
1119  }
1120  }
1121 #endif
1122 
1124  struct Mailbox *m_save = mx_path_resolve(mutt_b2s(buf));
1125  bool old_append = m_save->append;
1126  struct Context *ctx_save = mx_mbox_open(m_save, MUTT_NEWFOLDER);
1127  if (!ctx_save)
1128  {
1129  mailbox_free(&m_save);
1130  goto cleanup;
1131  }
1132  m_save->append = true;
1133 
1134 #ifdef USE_COMP_MBOX
1135  /* If we're saving to a compressed mailbox, the stats won't be updated
1136  * until the next open. Until then, improvise. */
1137  struct Mailbox *m_comp = NULL;
1138  if (ctx_save->mailbox->compress_info)
1139  {
1140  m_comp = mailbox_find(ctx_save->mailbox->realpath);
1141  }
1142  /* We probably haven't been opened yet */
1143  if (m_comp && (m_comp->msg_count == 0))
1144  m_comp = NULL;
1145 #endif
1146  if (single)
1147  {
1148  if (mutt_save_message_ctx(en->email, delete_original, decode, decrypt,
1149  ctx_save->mailbox) != 0)
1150  {
1151  mx_mbox_close(&ctx_save);
1152  m_save->append = old_append;
1153  goto cleanup;
1154  }
1155 #ifdef USE_COMP_MBOX
1156  if (m_comp)
1157  {
1158  m_comp->msg_count++;
1159  if (!en->email->read)
1160  {
1161  m_comp->msg_unread++;
1162  if (!en->email->old)
1163  m_comp->msg_new++;
1164  }
1165  if (en->email->flagged)
1166  m_comp->msg_flagged++;
1167  }
1168 #endif
1169  }
1170  else
1171  {
1172  rc = 0;
1173 
1174 #ifdef USE_NOTMUCH
1175  if (m->type == MUTT_NOTMUCH)
1176  nm_db_longrun_init(m, true);
1177 #endif
1178  STAILQ_FOREACH(en, el, entries)
1179  {
1181  rc = mutt_save_message_ctx(en->email, delete_original, decode, decrypt,
1182  ctx_save->mailbox);
1183  if (rc != 0)
1184  break;
1185 #ifdef USE_COMP_MBOX
1186  if (m_comp)
1187  {
1188  struct Email *e2 = en->email;
1189  m_comp->msg_count++;
1190  if (!e2->read)
1191  {
1192  m_comp->msg_unread++;
1193  if (!e2->old)
1194  m_comp->msg_new++;
1195  }
1196  if (e2->flagged)
1197  m_comp->msg_flagged++;
1198  }
1199 #endif
1200  }
1201 #ifdef USE_NOTMUCH
1202  if (m->type == MUTT_NOTMUCH)
1203  nm_db_longrun_done(m);
1204 #endif
1205  if (rc != 0)
1206  {
1207  mx_mbox_close(&ctx_save);
1208  m_save->append = old_append;
1209  goto cleanup;
1210  }
1211  }
1212 
1213  const bool need_mailbox_cleanup = ((ctx_save->mailbox->type == MUTT_MBOX) ||
1214  (ctx_save->mailbox->type == MUTT_MMDF));
1215 
1216  mx_mbox_close(&ctx_save);
1217  m_save->append = old_append;
1218 
1219  if (need_mailbox_cleanup)
1220  mutt_mailbox_cleanup(mutt_b2s(buf), &st);
1221 
1222  mutt_clear_error();
1223  rc = 0;
1224 
1225 cleanup:
1227  return rc;
1228 }
int mutt_save_message_ctx(struct Email *e, bool delete_original, bool decode, bool decrypt, struct Mailbox *m)
Save a message to a given mailbox.
Definition: commands.c:988
The "current" mailbox.
Definition: context.h:37
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
int msg_count
Total number of messages.
Definition: mailbox.h:91
#define WithCrypto
Definition: lib.h:163
The envelope/body of an email.
Definition: email.h:37
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox? - Implements MxOps::path_probe()
Definition: imap.c:2516
int msg_unread
Number of unread messages.
Definition: mailbox.h:92
int mx_mbox_close(struct Context **ptr)
Save changes and close mailbox.
Definition: mx.c:593
void mutt_mailbox_cleanup(const char *path, struct stat *st)
Restore the timestamp of a mailbox.
Definition: mutt_mailbox.c:381
#define mutt_message(...)
Definition: logging.h:83
int msg_flagged
Number of flagged messages.
Definition: mailbox.h:93
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:125
struct Mailbox * mailbox_find(const char *path)
Find the mailbox with a given path.
Definition: mailbox.c:88
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:84
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
struct Context * mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
Definition: mx.c:255
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:52
void mutt_default_save(char *path, size_t pathlen, struct Email *e)
Find the default save path for an email.
Definition: hook.c:662
void mutt_buffer_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using &#39;~&#39; or &#39;=&#39;.
Definition: muttlib.c:689
int mutt_save_confirm(const char *s, struct stat *st)
Ask the user to save.
Definition: muttlib.c:1438
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:146
size_t dsize
Length of data.
Definition: buffer.h:37
bool read
Email is read.
Definition: email.h:51
struct Mailbox * mailbox
Definition: context.h:51
bool old
Email is seen, but unread.
Definition: email.h:50
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:60
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
void mutt_buffer_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
Definition: buffer.c:181
#define mutt_b2s(buf)
Definition: buffer.h:41
int imap_copy_messages(struct Mailbox *m, struct EmailList *el, const char *dest, bool delete_original)
Server COPY messages to another folder.
Definition: message.c:1587
size_t mutt_buffer_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition: buffer.c:356
A mailbox.
Definition: mailbox.h:81
char * data
Pointer to data.
Definition: buffer.h:35
&#39;mmdf&#39; Mailbox type
Definition: mailbox.h:49
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:773
void mutt_file_resolve_symlink(struct Buffer *buf)
Resolve a symlink in place.
Definition: file.c:1611
bool append
Mailbox is opened in append mode.
Definition: mailbox.h:113
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
#define STAILQ_NEXT(elm, field)
Definition: queue.h:397
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
Definition: email.h:39
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:54
&#39;mbox&#39; Mailbox type
Definition: mailbox.h:48
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:328
bool flagged
Marked important?
Definition: email.h:43
int msg_new
Number of new messages.
Definition: mailbox.h:95
struct Email * email
Email in the list.
Definition: email.h:116
void * compress_info
Compressed mbox module private data.
Definition: mailbox.h:124
void nm_db_longrun_done(struct Mailbox *m)
Finish a long transaction.
Definition: nm_db.c:304
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
Definition: mx.c:1655
#define STAILQ_EMPTY(head)
Definition: queue.h:345
List of Emails.
Definition: email.h:114
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:579
#define MUTT_NEWFOLDER
Create a new folder - same as MUTT_APPEND,.
Definition: mx.h:57
&#39;IMAP&#39; Mailbox type
Definition: mailbox.h:53
#define STAILQ_FIRST(head)
Definition: queue.h:347
void nm_db_longrun_init(struct Mailbox *m, bool writable)
Start a long transaction.
Definition: nm_db.c:289
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:638
#define mutt_buffer_enter_fname(prompt, fname, mailbox)
Definition: curs_lib.h:87
static char LastSaveFolder[PATH_MAX]
The folder the user last saved to.
Definition: commands.c:97
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_edit_content_type()

bool mutt_edit_content_type ( struct Email e,
struct Body b,
FILE *  fp 
)

Edit the content type of an attachment.

Parameters
eEmail
bAttachment
fpFile handle to the attachment
Return values
booltrue if a structural change is made

recvattach requires the return code to know when to regenerate the actx.

Definition at line 1239 of file commands.c.

1240 {
1241  char buf[1024];
1242  char obuf[1024];
1243  char tmp[256];
1244  char charset[256];
1245 
1246  bool charset_changed = false;
1247  bool type_changed = false;
1248  bool structure_changed = false;
1249 
1250  char *cp = mutt_param_get(&b->parameter, "charset");
1251  mutt_str_strfcpy(charset, cp, sizeof(charset));
1252 
1253  snprintf(buf, sizeof(buf), "%s/%s", TYPE(b), b->subtype);
1254  mutt_str_strfcpy(obuf, buf, sizeof(obuf));
1255  if (!TAILQ_EMPTY(&b->parameter))
1256  {
1257  size_t l = strlen(buf);
1258  struct Parameter *np = NULL;
1259  TAILQ_FOREACH(np, &b->parameter, entries)
1260  {
1261  mutt_addr_cat(tmp, sizeof(tmp), np->value, MimeSpecials);
1262  l += snprintf(buf + l, sizeof(buf) - l, "; %s=%s", np->attribute, tmp);
1263  if (l >= sizeof(buf))
1264  {
1265  // L10N: e.g. "text/plain; charset=UTF-8; ..."
1266  mutt_error(_("Content type is too long"));
1267  return false;
1268  }
1269  }
1270  }
1271 
1272  if ((mutt_get_field("Content-Type: ", buf, sizeof(buf), MUTT_COMP_NO_FLAGS) != 0) ||
1273  (buf[0] == '\0'))
1274  {
1275  return false;
1276  }
1277 
1278  /* clean up previous junk */
1280  FREE(&b->subtype);
1281 
1282  mutt_parse_content_type(buf, b);
1283 
1284  snprintf(tmp, sizeof(tmp), "%s/%s", TYPE(b), NONULL(b->subtype));
1285  type_changed = (mutt_str_strcasecmp(tmp, obuf) != 0);
1286  charset_changed =
1287  (mutt_str_strcasecmp(charset, mutt_param_get(&b->parameter, "charset")) != 0);
1288 
1289  /* if in send mode, check for conversion - current setting is default. */
1290 
1291  if (!e && (b->type == TYPE_TEXT) && charset_changed)
1292  {
1293  snprintf(tmp, sizeof(tmp), _("Convert to %s upon sending?"),
1294  mutt_param_get(&b->parameter, "charset"));
1295  int ans = mutt_yesorno(tmp, b->noconv ? MUTT_NO : MUTT_YES);
1296  if (ans != MUTT_ABORT)
1297  b->noconv = (ans == MUTT_NO);
1298  }
1299 
1300  /* inform the user */
1301 
1302  snprintf(tmp, sizeof(tmp), "%s/%s", TYPE(b), NONULL(b->subtype));
1303  if (type_changed)
1304  mutt_message(_("Content-Type changed to %s"), tmp);
1305  if ((b->type == TYPE_TEXT) && charset_changed)
1306  {
1307  if (type_changed)
1308  mutt_sleep(1);
1309  mutt_message(b->noconv ? _("Character set changed to %s; not converting") :
1310  _("Character set changed to %s; converting"),
1311  mutt_param_get(&b->parameter, "charset"));
1312  }
1313 
1314  b->force_charset |= charset_changed;
1315 
1316  if (!is_multipart(b) && b->parts)
1317  {
1318  structure_changed = true;
1319  mutt_body_free(&b->parts);
1320  }
1321  if (!mutt_is_message_type(b->type, b->subtype) && b->email)
1322  {
1323  structure_changed = true;
1324  b->email->content = NULL;
1325  email_free(&b->email);
1326  }
1327 
1328  if (fp && !b->parts && (is_multipart(b) || mutt_is_message_type(b->type, b->subtype)))
1329  {
1330  structure_changed = true;
1331  mutt_parse_part(fp, b);
1332  }
1333 
1334  if ((WithCrypto != 0) && e)
1335  {
1336  if (e->content == b)
1337  e->security = SEC_NO_FLAGS;
1338 
1339  e->security |= crypt_query(b);
1340  }
1341 
1342  return structure_changed;
1343 }
char * attribute
Parameter name.
Definition: parameter.h:34
#define NONULL(x)
Definition: string2.h:37
#define WithCrypto
Definition: lib.h:163
bool mutt_is_message_type(int type, const char *subtype)
Determine if a mime type matches a message or not.
Definition: parse.c:1391
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
#define is_multipart(body)
Definition: mime.h:77
#define SEC_NO_FLAGS
No flags are set.
Definition: lib.h:124
User aborted the question (with Ctrl-G)
Definition: quad.h:38
#define mutt_message(...)
Definition: logging.h:83
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:40
struct Body * content
List of MIME parts.
Definition: email.h:90
bool noconv
Don&#39;t do character set conversion.
Definition: body.h:73
#define _(a)
Definition: message.h:28
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:90
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1535
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
Definition: curs_lib.c:378
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition: mutt.h:56
bool force_charset
Send mode: don&#39;t adjust the character set when in send-mode.
Definition: body.h:74
void mutt_param_free(struct ParameterList *pl)
Free a ParameterList.
Definition: parameter.c:61
char * subtype
content-type subtype
Definition: body.h:37
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:39
Type: &#39;text/*&#39;.
Definition: mime.h:38
const char MimeSpecials[]
Characters that need special treatment in MIME.
Definition: mime.c:67
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:773
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
Definition: email.h:39
unsigned int type
content-type primary type
Definition: body.h:65
#define TYPE(body)
Definition: mime.h:83
void mutt_parse_content_type(const char *s, struct Body *ct)
Parse a content type.
Definition: parse.c:456
void mutt_parse_part(FILE *fp, struct Body *b)
Parse a MIME part.
Definition: parse.c:1406
char * value
Parameter value.
Definition: parameter.h:35
#define mutt_error(...)
Definition: logging.h:84
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:651
Attribute associated with a MIME part.
Definition: parameter.h:32
#define FREE(x)
Definition: memory.h:40
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
#define TAILQ_EMPTY(head)
Definition: queue.h:714
void email_free(struct Email **ptr)
Free an Email.
Definition: email.c:41
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
struct Email * email
header information for message/rfc822
Definition: body.h:55
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:700
void mutt_addr_cat(char *buf, size_t buflen, const char *value, const char *specials)
Copy a string and wrap it in quotes if it contains special characters.
Definition: address.c:672
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_traditional_pgp()

static bool check_traditional_pgp ( struct Email e,
MuttRedrawFlags redraw 
)
static

Check for an inline PGP content.

Parameters
[in]eEmail to check
[out]redrawFlags if the screen needs redrawing, see MuttRedrawFlags
Return values
trueIf message contains inline PGP content

Definition at line 1351 of file commands.c.

1352 {
1353  bool rc = false;
1354 
1356 
1358  struct Message *msg = mx_msg_open(Context->mailbox, e->msgno);
1359  if (!msg)
1360  return 0;
1361  if (crypt_pgp_check_traditional(msg->fp, e->content, false))
1362  {
1363  e->security = crypt_query(e->content);
1364  *redraw |= REDRAW_FULL;
1365  rc = true;
1366  }
1367 
1369  mx_msg_close(Context->mailbox, &msg);
1370  return rc;
1371 }
The "current" mailbox.
Definition: context.h:37
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:47
struct Body * content
List of MIME parts.
Definition: email.h:90
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:49
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1171
struct Mailbox * mailbox
Definition: context.h:51
A local copy of an email.
Definition: mx.h:83
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
Definition: email.h:39
int crypt_pgp_check_traditional(FILE *fp, struct Body *b, bool just_one)
Wrapper for CryptModuleSpecs::pgp_check_traditional()
Definition: cryptglue.c:274
FILE * fp
pointer to the message data
Definition: mx.h:85
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
Definition: lib.h:139
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:700
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1123
int msgno
Number displayed to the user.
Definition: email.h:86
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_check_traditional_pgp()

bool mutt_check_traditional_pgp ( struct EmailList *  el,
MuttRedrawFlags redraw 
)

Check if a message has inline PGP content.

Parameters
[in]elList of Emails to check
[out]redrawFlags if the screen needs redrawing, see MuttRedrawFlags
Return values
trueIf message contains inline PGP content

Definition at line 1379 of file commands.c.

1380 {
1381  bool rc = false;
1382  struct EmailNode *en = NULL;
1383  STAILQ_FOREACH(en, el, entries)
1384  {
1385  if (!(en->email->security & PGP_TRADITIONAL_CHECKED))
1386  rc = check_traditional_pgp(en->email, redraw) || rc;
1387  }
1388 
1389  return rc;
1390 }
static bool check_traditional_pgp(struct Email *e, MuttRedrawFlags *redraw)
Check for an inline PGP content.
Definition: commands.c:1351
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
Definition: email.h:39
struct Email * email
Email in the list.
Definition: email.h:116
List of Emails.
Definition: email.h:114
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
Definition: lib.h:139
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_check_stats()

void mutt_check_stats ( void  )

Forcibly update mailbox stats.

Definition at line 1395 of file commands.c.

1396 {
1398 }
The "current" mailbox.
Definition: context.h:37
struct Mailbox * mailbox
Definition: context.h:51
int mutt_mailbox_check(struct Mailbox *m_cur, int force)
Check all all Mailboxes for new mail.
Definition: mutt_mailbox.c:152
#define MUTT_MAILBOX_CHECK_FORCE
Definition: mutt_mailbox.h:17
#define MUTT_MAILBOX_CHECK_FORCE_STATS
Definition: mutt_mailbox.h:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ C_CryptVerifySig

unsigned char C_CryptVerifySig

Config: Verify PGP or SMIME signatures.

Definition at line 85 of file commands.c.

◆ C_DisplayFilter

char* C_DisplayFilter

Config: External command to pre-process an email before display.

Definition at line 86 of file commands.c.

◆ C_PipeDecode

bool C_PipeDecode

Config: Decode the message when piping it.

Definition at line 87 of file commands.c.

◆ C_PipeSep

char* C_PipeSep

Config: Separator to add between multiple piped messages.

Definition at line 88 of file commands.c.

◆ C_PipeSplit

bool C_PipeSplit

Config: Run the pipe command on each message separately.

Definition at line 89 of file commands.c.

◆ C_PrintDecode

bool C_PrintDecode

Config: Decode message before printing it.

Definition at line 90 of file commands.c.

◆ C_PrintSplit

bool C_PrintSplit

Config: Print multiple messages separately.

Definition at line 91 of file commands.c.

◆ C_PromptAfter

bool C_PromptAfter

Config: Pause after running an external pager.

Definition at line 92 of file commands.c.

◆ ExtPagerProgress

const char* ExtPagerProgress = "all"
static

Definition at line 94 of file commands.c.

◆ LastSaveFolder

char LastSaveFolder[PATH_MAX] = ""
static

The folder the user last saved to.

Used by ci_save_message()

Definition at line 97 of file commands.c.