NeoMutt  2018-07-16 +2225-8687db
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 <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "mutt/mutt.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "conn/conn.h"
#include "mutt.h"
#include "alias.h"
#include "context.h"
#include "copy.h"
#include "core/lib.h"
#include "curs_lib.h"
#include "filter.h"
#include "format_flags.h"
#include "globals.h"
#include "hdrline.h"
#include "hook.h"
#include "icommands.h"
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_logging.h"
#include "mutt_mailbox.h"
#include "mutt_menu.h"
#include "mutt_parse.h"
#include "mutt_window.h"
#include "muttlib.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
#include "options.h"
#include "pager.h"
#include "protos.h"
#include "sendlib.h"
#include "sort.h"
#include "imap/imap.h"
#include "notmuch/mutt_notmuch.h"
#include <libintl.h>

Go to the source code of this file.

Macros

#define EXTRA_SPACE   (15 + 7 + 2)
 

Functions

static void update_protected_headers (struct Email *e)
 Get the protected header and update the index. More...
 
int mutt_display_message (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

#define EXTRA_SPACE   (15 + 7 + 2)

Function Documentation

static void update_protected_headers ( struct Email e)
static

Get the protected header and update the index.

Parameters
eEmail to update

Definition at line 100 of file commands.c.

101 {
102  struct Envelope *prot_headers = NULL;
103  regmatch_t pmatch[1];
104 
106  return;
107 
108  /* Grab protected headers to update in the index */
109  if (e->security & SEC_SIGN)
110  {
111  /* Don't update on a bad signature.
112  *
113  * This is a simplification. It's possible the headers are in the
114  * encrypted part of a nested encrypt/signed. But properly handling that
115  * case would require more complexity in the decryption handlers, which
116  * I'm not sure is worth it. */
117  if (!(e->security & SEC_GOODSIGN))
118  return;
119 
121  {
122  prot_headers = e->content->parts->mime_headers;
123  }
125  {
126  prot_headers = e->content->mime_headers;
127  }
128  }
129  if (!prot_headers && (e->security & SEC_ENCRYPT))
130  {
131  if (((WithCrypto & APPLICATION_PGP) != 0) &&
134  {
135  prot_headers = e->content->mime_headers;
136  }
137  else if (((WithCrypto & APPLICATION_SMIME) != 0) && mutt_is_application_smime(e->content))
138  {
139  prot_headers = e->content->mime_headers;
140  }
141  }
142 
143  /* Update protected headers in the index and header cache. */
144  if (prot_headers && prot_headers->subject &&
145  mutt_str_strcmp(e->env->subject, prot_headers->subject))
146  {
147  if (Context->mailbox->subj_hash && e->env->real_subj)
149 
150  mutt_str_replace(&e->env->subject, prot_headers->subject);
151  FREE(&e->env->disp_subj);
152  if (regexec(C_ReplyRegex->regex, e->env->subject, 1, pmatch, 0) == 0)
153  e->env->real_subj = e->env->subject + pmatch[0].rm_eo;
154  else
155  e->env->real_subj = e->env->subject;
156 
157  if (Context->mailbox->subj_hash)
159 
161 
162  /* Also persist back to the message headers if this is set */
164  {
166  e->changed = 1;
167  Context->mailbox->changed = 1;
168  }
169  }
170 }
The "current" mailbox.
Definition: context.h:39
void mutt_hash_delete(struct Hash *table, const char *strkey, const void *data)
Remove an element from a Hash table.
Definition: hash.c:444
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:63
char * disp_subj
Display subject (modified copy of subject)
Definition: envelope.h:54
regex_t * regex
compiled expression
Definition: regex3.h:60
struct Body * content
List of MIME parts.
Definition: email.h:90
int mutt_is_valid_multipart_pgp_encrypted(struct Body *b)
Is this a valid multi-part encrypted message?
Definition: crypt.c:444
char * real_subj
Offset of the real subject.
Definition: envelope.h:53
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:1613
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:121
#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:71
struct Mailbox * mailbox
Definition: context.h:53
#define SEC_GOODSIGN
Email has a valid signature.
Definition: ncrypt.h:123
struct Envelope * env
Envelope information.
Definition: email.h:89
SecurityFlags mutt_is_multipart_signed(struct Body *b)
Is a message signed?
Definition: crypt.c:379
struct Regex * C_ReplyRegex
Config: Regex to match message reply subjects like "re: ".
Definition: email_globals.c:37
#define SEC_SIGN
Email is signed.
Definition: ncrypt.h:122
WHERE bool C_CryptProtectedHeadersSave
Config: Save the cleartext Subject with the headers.
Definition: globals.h:269
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:482
SecurityFlags mutt_is_application_smime(struct Body *m)
Does the message use S/MIME?
Definition: crypt.c:586
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
WHERE bool C_CryptProtectedHeadersRead
Config: Display protected headers (Memory Hole) in the pager.
Definition: globals.h:268
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:453
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:130
char * subject
Email&#39;s subject.
Definition: envelope.h:52
struct Hash * subj_hash
Hash table by subject.
Definition: mailbox.h:140
#define FREE(x)
Definition: memory.h:40
bool changed
Mailbox has been modified.
Definition: mailbox.h:126
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:352
#define WithCrypto
Definition: ncrypt.h:156
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:615
The header of an Email.
Definition: envelope.h:40
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:131
int mutt_display_message ( struct Email e)

Display a message in the pager.

Parameters
eEmail to display
Return values
0Success
-1Error

Definition at line 178 of file commands.c.

179 {
180  char tempfile[PATH_MAX], buf[1024];
181  int rc = 0;
182  bool builtin = false;
184  CopyHeaderFlags chflags;
185  pid_t filterpid = -1;
186  int res;
187 
188  snprintf(buf, sizeof(buf), "%s/%s", TYPE(e->content), e->content->subtype);
189 
192 
193  /* see if crypto is needed for this message. if so, we should exit curses */
194  if ((WithCrypto != 0) && e->security)
195  {
196  if (e->security & SEC_ENCRYPT)
197  {
198  if (e->security & APPLICATION_SMIME)
201  return 0;
202 
203  cmflags |= MUTT_CM_VERIFY;
204  }
205  else if (e->security & SEC_SIGN)
206  {
207  /* find out whether or not the verify signature */
208  /* L10N: Used for the $crypt_verify_sig prompt */
209  if (query_quadoption(C_CryptVerifySig, _("Verify signature?")) == MUTT_YES)
210  {
211  cmflags |= MUTT_CM_VERIFY;
212  }
213  }
214  }
215 
216  if (cmflags & MUTT_CM_VERIFY || e->security & SEC_ENCRYPT)
217  {
218  if (e->security & APPLICATION_PGP)
219  {
220  if (!TAILQ_EMPTY(&e->env->from))
222 
224  }
225 
226  if (e->security & APPLICATION_SMIME)
228  }
229 
230  mutt_mktemp(tempfile, sizeof(tempfile));
231  FILE *fp_filter_out = NULL;
232  FILE *fp_out = mutt_file_fopen(tempfile, "w");
233  if (!fp_out)
234  {
235  mutt_error(_("Could not create temporary file"));
236  return 0;
237  }
238 
239  if (C_DisplayFilter)
240  {
241  fp_filter_out = fp_out;
242  fp_out = NULL;
243  filterpid = mutt_create_filter_fd(C_DisplayFilter, &fp_out, NULL, NULL, -1,
244  fileno(fp_filter_out), -1);
245  if (filterpid < 0)
246  {
247  mutt_error(_("Can't create display filter"));
248  mutt_file_fclose(&fp_filter_out);
249  unlink(tempfile);
250  return 0;
251  }
252  }
253 
254  if (!C_Pager || (mutt_str_strcmp(C_Pager, "builtin") == 0))
255  builtin = true;
256  else
257  {
258  struct HdrFormatInfo hfi;
259  hfi.ctx = Context;
260  hfi.mailbox = Context->mailbox;
261  hfi.pager_progress = ExtPagerProgress;
262  hfi.email = e;
263  mutt_make_string_info(buf, sizeof(buf), MuttIndexWindow->cols,
265  fputs(buf, fp_out);
266  fputs("\n\n", fp_out);
267  }
268 
269  chflags = (C_Weed ? (CH_WEED | CH_REORDER) : CH_NO_FLAGS) | CH_DECODE | CH_FROM | CH_DISPLAY;
270 #ifdef USE_NOTMUCH
272  chflags |= CH_VIRTUAL;
273 #endif
274  res = mutt_copy_message(fp_out, Context->mailbox, e, cmflags, chflags);
275 
276  if (((mutt_file_fclose(&fp_out) != 0) && (errno != EPIPE)) || (res < 0))
277  {
278  mutt_error(_("Could not copy message"));
279  if (fp_filter_out)
280  {
281  mutt_wait_filter(filterpid);
282  mutt_file_fclose(&fp_filter_out);
283  }
284  mutt_file_unlink(tempfile);
285  return 0;
286  }
287 
288  if (fp_filter_out && (mutt_wait_filter(filterpid) != 0))
290 
291  mutt_file_fclose(&fp_filter_out); /* XXX - check result? */
292 
293  if (WithCrypto)
294  {
295  /* update crypto information for this message */
296  e->security &= ~(SEC_GOODSIGN | SEC_BADSIGN);
297  e->security |= crypt_query(e->content);
298 
299  /* Remove color cache for this message, in case there
300  * are color patterns for both ~g and ~V */
301  e->pair = 0;
302 
303  /* Grab protected headers and update the header and index */
305  }
306 
307  if (builtin)
308  {
309  if ((WithCrypto != 0) && (e->security & APPLICATION_SMIME) && (cmflags & MUTT_CM_VERIFY))
310  {
311  if (e->security & SEC_GOODSIGN)
312  {
313  if (crypt_smime_verify_sender(e) == 0)
314  mutt_message(_("S/MIME signature successfully verified"));
315  else
316  mutt_error(_("S/MIME certificate owner does not match sender"));
317  }
318  else if (e->security & SEC_PARTSIGN)
319  mutt_message(_("Warning: Part of this message has not been signed"));
320  else if (e->security & SEC_SIGN || e->security & SEC_BADSIGN)
321  mutt_error(_("S/MIME signature could NOT be verified"));
322  }
323 
324  if ((WithCrypto != 0) && (e->security & APPLICATION_PGP) && (cmflags & MUTT_CM_VERIFY))
325  {
326  if (e->security & SEC_GOODSIGN)
327  mutt_message(_("PGP signature successfully verified"));
328  else if (e->security & SEC_PARTSIGN)
329  mutt_message(_("Warning: Part of this message has not been signed"));
330  else if (e->security & SEC_SIGN)
331  mutt_message(_("PGP signature could NOT be verified"));
332  }
333 
334  struct Pager info = { 0 };
335  /* Invoke the builtin pager */
336  info.email = e;
337  info.ctx = Context;
338  rc = mutt_pager(NULL, tempfile, MUTT_PAGER_MESSAGE, &info);
339  }
340  else
341  {
342  int r;
343 
344  char cmd[STR_COMMAND];
345  mutt_endwin();
346  snprintf(cmd, sizeof(cmd), "%s %s", NONULL(C_Pager), tempfile);
347  r = mutt_system(cmd);
348  if (r == -1)
349  mutt_error(_("Error running \"%s\""), cmd);
350  unlink(tempfile);
351  if (!OptNoCurses)
352  keypad(stdscr, true);
353  if (r != -1)
355  if ((r != -1) && C_PromptAfter)
356  {
357  mutt_unget_event(mutt_any_key_to_continue(_("Command: ")), 0);
358  rc = km_dokey(MENU_PAGER);
359  }
360  else
361  rc = 0;
362  }
363 
364  return rc;
365 }
struct Context * ctx
Definition: hdrline.h:46
The "current" mailbox.
Definition: context.h:39
#define NONULL(x)
Definition: string2.h:37
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:68
#define TAILQ_FIRST(head)
Definition: queue.h:717
int km_dokey(int menu)
Determine what a keypress should do.
Definition: keymap.c:570
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3321
#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:39
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:191
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:50
void mutt_unget_event(int ch, int op)
Return a keystroke to the input buffer.
Definition: curs_lib.c:715
#define CH_FROM
Retain the "From " message separator?
Definition: copy.h:55
int mutt_copy_message(FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags)
Copy a message from a Mailbox.
Definition: copy.c:802
#define _(a)
Definition: message.h:28
static const char * ExtPagerProgress
Definition: commands.c:91
WHERE bool OptNoCurses
(pseudo) when sending in batch mode
Definition: options.h:45
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:51
uint16_t CopyMessageFlags
Flags for mutt_copy_message(), e.g. MUTT_CM_NOHEADER.
Definition: copy.h:31
An email being displayed.
Definition: pager.h:65
unsigned char C_CryptVerifySig
Config: Verify PGP or SMIME signatures.
Definition: commands.c:82
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:121
#define SEC_PARTSIGN
Not all parts of the email is signed.
Definition: ncrypt.h:125
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: format_flags.h:30
#define SEC_BADSIGN
Email has a bad signature.
Definition: ncrypt.h:124
Pager pager (email viewer)
Definition: keymap.h:77
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:143
struct Mailbox * mailbox
Definition: context.h:53
#define MUTT_CM_DISPLAY
Output is displayed to the user.
Definition: copy.h:38
Data passed to index_format_str()
Definition: hdrline.h:44
#define SEC_GOODSIGN
Email has a valid signature.
Definition: ncrypt.h:123
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:43
enum MailboxType magic
Mailbox type.
Definition: mailbox.h:117
#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:149
struct Envelope * env
Envelope information.
Definition: email.h:89
#define CH_VIRTUAL
Write virtual header lines too.
Definition: copy.h:72
char * subtype
content-type subtype
Definition: body.h:37
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:1524
void crypt_invoke_message(SecurityFlags type)
Display an informative message.
Definition: cryptglue.c:139
struct Context * ctx
current mailbox
Definition: pager.h:67
#define mutt_mktemp(buf, buflen)
Definition: muttlib.h:76
#define SEC_SIGN
Email is signed.
Definition: ncrypt.h:122
WHERE struct Context * Context
Definition: globals.h:41
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:499
#define PATH_MAX
Definition: mutt.h:50
struct MuttWindow * MuttIndexWindow
Index Window.
Definition: mutt_window.c:39
#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:407
#define CH_DECODE
Do RFC2047 header decoding.
Definition: copy.h:53
pid_t mutt_create_filter_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:64
void crypt_pgp_invoke_getkeys(struct Address *addr)
Wrapper for CryptModuleSpecs::pgp_invoke_getkeys()
Definition: cryptglue.c:230
#define CH_DISPLAY
Display result to user.
Definition: copy.h:69
Messages that have been read.
Definition: mutt.h:100
int crypt_smime_verify_sender(struct Email *e)
Wrapper for CryptModuleSpecs::smime_verify_sender()
Definition: cryptglue.c:416
#define MUTT_CM_VERIFY
Do signature verification.
Definition: copy.h:46
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:54
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:130
#define STR_COMMAND
Enough space for a long command line.
Definition: string2.h:35
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:544
bool C_PromptAfter
Config: Pause after running an external pager.
Definition: commands.c:89
#define TYPE(body)
Definition: mime.h:83
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:83
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
Definition: copy.h:49
#define mutt_error(...)
Definition: logging.h:84
WHERE char * C_Pager
Config: External command for viewing messages, or &#39;builtin&#39; to use NeoMutt&#39;s.
Definition: globals.h:130
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:715
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:2239
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:584
int mutt_wait_filter(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:227
#define WithCrypto
Definition: ncrypt.h:156
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:663
static void update_protected_headers(struct Email *e)
Get the protected header and update the index.
Definition: commands.c:100
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:615
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:50
WHERE char * C_PagerFormat
Config: printf-like format string for the pager&#39;s status bar.
Definition: globals.h:131
bool C_Weed
Config: Filter headers when displaying/forwarding/printing/replying.
Definition: email_globals.c:40
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:131
void ci_bounce_message ( struct Mailbox m,
struct EmailList *  el 
)

Bounce an email.

Parameters
mMailbox
elList of Emails to bounce

Definition at line 372 of file commands.c.

373 {
374  if (!m || !el || STAILQ_EMPTY(el))
375  return;
376 
377  char prompt[129];
378  char scratch[128];
379  char buf[8192] = { 0 };
380  struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
381  char *err = NULL;
382  int rc;
383  int msg_count = 0;
384 
385  struct EmailNode *en = NULL;
386  STAILQ_FOREACH(en, el, entries)
387  {
388  /* RFC5322 mandates a From: header,
389  * so warn before bouncing messages without one */
390  if (!TAILQ_EMPTY(&en->email->env->from))
391  mutt_error(_("Warning: message contains no From: header"));
392 
393  msg_count++;
394  }
395 
396  if (msg_count == 1)
397  mutt_str_strfcpy(prompt, _("Bounce message to: "), sizeof(prompt));
398  else
399  mutt_str_strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt));
400 
401  rc = mutt_get_field(prompt, buf, sizeof(buf), MUTT_ALIAS);
402  if (rc || !buf[0])
403  return;
404 
405  mutt_addrlist_parse2(&al, buf);
406  if (TAILQ_EMPTY(&al))
407  {
408  mutt_error(_("Error parsing address"));
409  return;
410  }
411 
412  mutt_expand_aliases(&al);
413 
414  if (mutt_addrlist_to_intl(&al, &err) < 0)
415  {
416  mutt_error(_("Bad IDN: '%s'"), err);
417  FREE(&err);
418  mutt_addrlist_clear(&al);
419  return;
420  }
421 
422  buf[0] = '\0';
423  mutt_addrlist_write(buf, sizeof(buf), &al, true);
424 
425 #define EXTRA_SPACE (15 + 7 + 2)
426  snprintf(scratch, sizeof(scratch),
427  ngettext("Bounce message to %s?", "Bounce messages to %s?", msg_count), buf);
428 
430  {
431  mutt_simple_format(prompt, sizeof(prompt), 0, MuttMessageWindow->cols - EXTRA_SPACE,
432  JUSTIFY_LEFT, 0, scratch, sizeof(scratch), false);
433  mutt_str_strcat(prompt, sizeof(prompt), "...?");
434  }
435  else
436  snprintf(prompt, sizeof(prompt), "%s?", scratch);
437 
438  if (query_quadoption(C_Bounce, prompt) != MUTT_YES)
439  {
440  mutt_addrlist_clear(&al);
442  mutt_message(ngettext("Message not bounced", "Messages not bounced", msg_count));
443  return;
444  }
445 
447 
448  struct Message *msg = NULL;
449  STAILQ_FOREACH(en, el, entries)
450  {
451  msg = mx_msg_open(m, en->email->msgno);
452  if (!msg)
453  {
454  rc = -1;
455  break;
456  }
457 
458  rc = mutt_bounce_message(msg->fp, en->email, &al);
459  mx_msg_close(m, &msg);
460 
461  if (rc < 0)
462  break;
463  }
464 
465  mutt_addrlist_clear(&al);
466  /* If no error, or background, display message. */
467  if ((rc == 0) || (rc == S_BKG))
468  mutt_message(ngettext("Message bounced", "Messages bounced", msg_count));
469 }
WHERE unsigned char C_Bounce
Config: Confirm before bouncing a message.
Definition: globals.h:180
void mutt_expand_aliases(struct AddressList *al)
Expand aliases in a List of Addresses.
Definition: alias.c:290
Left justify the text.
Definition: curs_lib.h:46
#define MUTT_ALIAS
Do alias "completion" by calling up the alias-menu.
Definition: mutt.h:63
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3321
#define mutt_message(...)
Definition: logging.h:83
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1351
#define _(a)
Definition: message.h:28
#define S_BKG
Definition: string2.h:43
size_t mutt_addrlist_write(char *buf, size_t buflen, const struct AddressList *al, bool display)
Write an Address to a buffer.
Definition: address.c:1134
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:603
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:86
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1092
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:43
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:69
struct Envelope * env
Envelope information.
Definition: email.h:89
int mutt_bounce_message(FILE *fp, struct Email *e, struct AddressList *to)
Bounce an email message.
Definition: sendlib.c:3038
A local copy of an email.
Definition: mx.h:82
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:1254
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:750
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
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:1186
struct Email * email
Email in the list.
Definition: email.h:119
#define mutt_error(...)
Definition: logging.h:84
FILE * fp
pointer to the message data
Definition: mx.h:84
#define FREE(x)
Definition: memory.h:40
#define STAILQ_EMPTY(head)
Definition: queue.h:346
List of Emails.
Definition: email.h:117
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:41
#define TAILQ_EMPTY(head)
Definition: queue.h:715
#define EXTRA_SPACE
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:631
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1044
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:988
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 478 of file commands.c.

480 {
481  if (decode)
482  {
483  *cmflags |= MUTT_CM_DECODE | MUTT_CM_CHARCONV;
484  *chflags |= CH_DECODE | CH_REORDER;
485 
486  if (C_Weed)
487  {
488  *chflags |= CH_WEED;
489  *cmflags |= MUTT_CM_WEED;
490  }
491  }
492 
493  if (print)
494  *cmflags |= MUTT_CM_PRINTING;
495 }
#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 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
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 505 of file commands.c.

506 {
508  CopyHeaderFlags chflags = CH_FROM;
509 
510  pipe_set_flags(decode, print, &cmflags, &chflags);
511 
512  if ((WithCrypto != 0) && decode && e->security & SEC_ENCRYPT)
513  {
515  return;
516  endwin();
517  }
518 
519  if (decode)
521 
522  mutt_copy_message(fp, m, e, cmflags, chflags);
523 }
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:50
#define CH_FROM
Retain the "From " message separator?
Definition: copy.h:55
int mutt_copy_message(FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags)
Copy a message from a Mailbox.
Definition: copy.c:802
uint16_t CopyMessageFlags
Flags for mutt_copy_message(), e.g. MUTT_CM_NOHEADER.
Definition: copy.h:31
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:121
#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:143
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
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:84
#define WithCrypto
Definition: ncrypt.h:156
static void pipe_set_flags(bool decode, bool print, CopyMessageFlags *cmflags, CopyHeaderFlags *chflags)
Generate flags for copy header/message.
Definition: commands.c:478
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 539 of file commands.c.

541 {
542  if (!m || !el)
543  return 1;
544 
545  struct EmailNode *en = STAILQ_FIRST(el);
546  if (!en)
547  return 1;
548 
549  int rc = 0;
550  pid_t pid;
551  FILE *fp_out = NULL;
552 
553  if (!STAILQ_NEXT(en, entries))
554  {
555  /* handle a single message */
557 
558  if ((WithCrypto != 0) && decode)
559  {
561  if ((en->email->security & SEC_ENCRYPT) &&
563  {
564  return 1;
565  }
566  }
567  mutt_endwin();
568 
569  pid = mutt_create_filter(cmd, &fp_out, NULL, NULL);
570  if (pid < 0)
571  {
572  mutt_perror(_("Can't create filter process"));
573  return 1;
574  }
575 
576  OptKeepQuiet = true;
577  pipe_msg(m, en->email, fp_out, decode, print);
578  mutt_file_fclose(&fp_out);
579  rc = mutt_wait_filter(pid);
580  OptKeepQuiet = false;
581  }
582  else
583  {
584  /* handle tagged messages */
585  if ((WithCrypto != 0) && decode)
586  {
587  STAILQ_FOREACH(en, el, entries)
588  {
591  if ((en->email->security & SEC_ENCRYPT) &&
593  {
594  return 1;
595  }
596  }
597  }
598 
599  if (split)
600  {
601  STAILQ_FOREACH(en, el, entries)
602  {
604  mutt_endwin();
605  pid = mutt_create_filter(cmd, &fp_out, NULL, NULL);
606  if (pid < 0)
607  {
608  mutt_perror(_("Can't create filter process"));
609  return 1;
610  }
611  OptKeepQuiet = true;
612  pipe_msg(m, en->email, fp_out, decode, print);
613  /* add the message separator */
614  if (sep)
615  fputs(sep, fp_out);
616  mutt_file_fclose(&fp_out);
617  if (mutt_wait_filter(pid) != 0)
618  rc = 1;
619  OptKeepQuiet = false;
620  }
621  }
622  else
623  {
624  mutt_endwin();
625  pid = mutt_create_filter(cmd, &fp_out, NULL, NULL);
626  if (pid < 0)
627  {
628  mutt_perror(_("Can't create filter process"));
629  return 1;
630  }
631  OptKeepQuiet = true;
632  STAILQ_FOREACH(en, el, entries)
633  {
635  pipe_msg(m, en->email, fp_out, decode, print);
636  /* add the message separator */
637  if (sep)
638  fputs(sep, fp_out);
639  }
640  mutt_file_fclose(&fp_out);
641  if (mutt_wait_filter(pid) != 0)
642  rc = 1;
643  OptKeepQuiet = false;
644  }
645  }
646 
647  if ((rc != 0) || C_WaitKey)
649  return rc;
650 }
pid_t mutt_create_filter(const char *s, FILE **fp_in, FILE **fp_out, FILE **fp_err)
Set up filter program.
Definition: filter.c:216
#define mutt_perror(...)
Definition: logging.h:85
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:50
#define _(a)
Definition: message.h:28
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:51
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:121
static void pipe_msg(struct Mailbox *m, struct Email *e, FILE *fp, bool decode, bool print)
Pipe a message.
Definition: commands.c:505
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:143
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
WHERE bool C_WaitKey
Config: Prompt to press a key after running external commands.
Definition: globals.h:258
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:499
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
#define STAILQ_NEXT(elm, field)
Definition: queue.h:398
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
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:544
struct Email * email
Email in the list.
Definition: email.h:119
List of Emails.
Definition: email.h:117
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:579
int mutt_wait_filter(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:227
WHERE bool OptKeepQuiet
(pseudo) shut up the message and refresh functions while we are executing an external program...
Definition: options.h:36
#define STAILQ_FIRST(head)
Definition: queue.h:348
#define WithCrypto
Definition: ncrypt.h:156
void mutt_pipe_message ( struct Mailbox m,
struct EmailList *  el 
)

Pipe a message.

Parameters
mMailbox
elList of Emails to pipe

Definition at line 657 of file commands.c.

658 {
659  if (!m || !el)
660  return;
661 
662  char buf[1024] = { 0 };
663 
664  if ((mutt_get_field(_("Pipe to command: "), buf, sizeof(buf), MUTT_CMD) != 0) ||
665  (buf[0] == '\0'))
666  {
667  return;
668  }
669 
670  mutt_expand_path(buf, sizeof(buf));
671  pipe_message(m, el, buf, C_PipeDecode, false, C_PipeSplit, C_PipeSep);
672 }
#define _(a)
Definition: message.h:28
char * C_PipeSep
Config: Separator to add between multiple piped messages.
Definition: commands.c:85
bool C_PipeDecode
Config: Decode the message when piping it.
Definition: commands.c:84
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:86
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:128
bool C_PipeSplit
Config: Run the pipe command on each message separately.
Definition: commands.c:86
#define MUTT_CMD
Do completion on previous word.
Definition: mutt.h:66
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:539
void mutt_print_message ( struct Mailbox m,
struct EmailList *  el 
)

Print a message.

Parameters
mMailbox
elList of Emails to print

Definition at line 679 of file commands.c.

680 {
681  if (!m || !el)
682  return;
683 
684  if (C_Print && !C_PrintCommand)
685  {
686  mutt_message(_("No printing command has been defined"));
687  return;
688  }
689 
690  int msg_count = 0;
691  struct EmailNode *en = NULL;
692  STAILQ_FOREACH(en, el, entries)
693  {
694  msg_count++;
695  }
696 
697  if (query_quadoption(C_Print, (msg_count == 1) ?
698  _("Print message?") :
699  _("Print tagged messages?")) != MUTT_YES)
700  {
701  return;
702  }
703 
704  if (pipe_message(m, el, C_PrintCommand, C_PrintDecode, true, C_PrintSplit, "\f") == 0)
705  mutt_message(ngettext("Message printed", "Messages printed", msg_count));
706  else
707  {
708  mutt_message(ngettext("Message could not be printed",
709  "Messages could not be printed", msg_count));
710  }
711 }
WHERE unsigned char C_Print
Config: Confirm before printing a message.
Definition: globals.h:185
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3321
#define mutt_message(...)
Definition: logging.h:83
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
bool C_PrintSplit
Config: Print multiple messages separately.
Definition: commands.c:88
#define _(a)
Definition: message.h:28
bool C_PrintDecode
Config: Decode message before printing it.
Definition: commands.c:87
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
WHERE char * C_PrintCommand
Config: External command to print a message.
Definition: globals.h:134
List of Emails.
Definition: email.h:117
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:539
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 718 of file commands.c.

719 {
720  enum SortType method = C_Sort; /* save the current method in case of abort */
721  enum SortType new_sort = C_Sort;
722 
723  switch (mutt_multi_choice(reverse ?
724  /* L10N: The highlighted letters must match the "Sort" options */
725  _("Rev-Sort "
726  "(d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/"
727  "(u)nsort/si(z)e/s(c)ore/s(p)am/(l)abel?") :
728  /* L10N: The highlighted letters must match the "Rev-Sort" options */
729  _("Sort "
730  "(d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/"
731  "(u)nsort/si(z)e/s(c)ore/s(p)am/(l)abel?"),
732  /* L10N: These must match the highlighted letters from "Sort" and "Rev-Sort" */
733  _("dfrsotuzcpl")))
734  {
735  case -1: /* abort - don't resort */
736  return -1;
737 
738  case 1: /* (d)ate */
739  new_sort = SORT_DATE;
740  break;
741 
742  case 2: /* (f)rm */
743  new_sort = SORT_FROM;
744  break;
745 
746  case 3: /* (r)ecv */
747  new_sort = SORT_RECEIVED;
748  break;
749 
750  case 4: /* (s)ubj */
751  new_sort = SORT_SUBJECT;
752  break;
753 
754  case 5: /* t(o) */
755  new_sort = SORT_TO;
756  break;
757 
758  case 6: /* (t)hread */
759  new_sort = SORT_THREADS;
760  break;
761 
762  case 7: /* (u)nsort */
763  new_sort = SORT_ORDER;
764  break;
765 
766  case 8: /* si(z)e */
767  new_sort = SORT_SIZE;
768  break;
769 
770  case 9: /* s(c)ore */
771  new_sort = SORT_SCORE;
772  break;
773 
774  case 10: /* s(p)am */
775  new_sort = SORT_SPAM;
776  break;
777 
778  case 11: /* (l)abel */
779  new_sort = SORT_LABEL;
780  break;
781  }
782  if (reverse)
783  new_sort |= SORT_REVERSE;
784 
785  cs_str_native_set(Config, "sort", new_sort, NULL);
786  return (C_Sort != method) ? 0 : -1; /* no need to resort if it's the same */
787 }
Sort by the date the email was sent.
Definition: sort.h:50
#define _(a)
Definition: message.h:28
WHERE struct ConfigSet * Config
Wrapper around the user&#39;s config settings.
Definition: globals.h:39
Sort by the email&#39;s subject.
Definition: sort.h:53
Sort by the email&#39;s spam score.
Definition: sort.h:64
WHERE short C_Sort
Config: Sort method for the index.
Definition: sort.h:59
int mutt_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question.
Definition: curs_lib.c:839
Sort by the email&#39;s To field.
Definition: sort.h:58
Sort by the emails label.
Definition: sort.h:69
Sort by the email&#39;s From field.
Definition: sort.h:54
Sort by the size of the email.
Definition: sort.h:51
SortType
Methods for sorting.
Definition: sort.h:48
Sort by when the message were delivered locally.
Definition: sort.h:57
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort.h:86
Sort by email threads.
Definition: sort.h:56
Sort by the order the messages appear in the mailbox.
Definition: sort.h:55
Sort by the email&#39;s score.
Definition: sort.h:59
int cs_str_native_set(const struct ConfigSet *cs, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
Definition: set.c:771
void mutt_shell_escape ( void  )

invoke a command in a subshell

Definition at line 792 of file commands.c.

793 {
794  char buf[1024];
795 
796  buf[0] = '\0';
797  if (mutt_get_field(_("Shell command: "), buf, sizeof(buf), MUTT_CMD) != 0)
798  return;
799 
800  if ((buf[0] == '\0') && C_Shell)
801  mutt_str_strfcpy(buf, C_Shell, sizeof(buf));
802  if (buf[0] == '\0')
803  return;
804 
806  mutt_endwin();
807  fflush(stdout);
808  int rc = mutt_system(buf);
809  if (rc == -1)
810  mutt_debug(LL_DEBUG1, "Error running \"%s\"", buf);
811 
812  if ((rc != 0) || C_WaitKey)
815 }
The "current" mailbox.
Definition: context.h:39
#define _(a)
Definition: message.h:28
WHERE char * C_Shell
Config: External command to run subshells in.
Definition: globals.h:137
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:86
struct Mailbox * mailbox
Definition: context.h:53
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:69
#define MUTT_CMD
Do completion on previous word.
Definition: mutt.h:66
WHERE bool C_WaitKey
Config: Prompt to press a key after running external commands.
Definition: globals.h:258
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:499
int mutt_mailbox_check(struct Mailbox *m_cur, int force)
Check all all Mailboxes for new mail.
Definition: mutt_mailbox.c:126
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:750
#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:544
Log at debug level 1.
Definition: logging.h:56
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:41
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:50
void mutt_enter_command ( void  )

enter a neomutt command

Definition at line 820 of file commands.c.

821 {
822  char buf[1024] = { 0 };
823 
824  /* if enter is pressed after : with no command, just return */
825  if ((mutt_get_field(":", buf, sizeof(buf), MUTT_COMMAND) != 0) || !buf[0])
826  return;
827 
828  struct Buffer *err = mutt_buffer_alloc(256);
829  struct Buffer *token = mutt_buffer_alloc(256);
830 
831  /* check if buf is a valid icommand, else fall back quietly to parse_rc_lines */
832  enum CommandResult rc = mutt_parse_icommand(buf, err);
833  if (!mutt_buffer_is_empty(err))
834  {
835  /* since errbuf could potentially contain printf() sequences in it,
836  * we must call mutt_error() in this fashion so that vsprintf()
837  * doesn't expect more arguments that we passed */
838  if (rc == MUTT_CMD_ERROR)
839  mutt_error("%s", err->data);
840  else
841  mutt_warning("%s", err->data);
842  }
843  else if (rc != MUTT_CMD_SUCCESS)
844  {
845  rc = mutt_parse_rc_line(buf, token, err);
846  if (!mutt_buffer_is_empty(err))
847  {
848  if (rc == MUTT_CMD_SUCCESS) /* command succeeded with message */
849  mutt_message("%s", err->data);
850  else /* error executing command */
851  mutt_error("%s", err->data);
852  }
853  }
854  /* else successful command */
855 
856  mutt_buffer_free(&token);
857  mutt_buffer_free(&err);
858 }
#define mutt_warning(...)
Definition: logging.h:82
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:31
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define mutt_message(...)
Definition: logging.h:83
String manipulation buffer.
Definition: buffer.h:33
enum CommandResult mutt_parse_icommand(char *line, struct Buffer *err)
Parse an informational command.
Definition: icommands.c:73
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:86
struct Buffer * mutt_buffer_alloc(size_t size)
Create a new Buffer.
Definition: buffer.c:296
#define MUTT_COMMAND
Do command completion.
Definition: mutt.h:69
void mutt_buffer_free(struct Buffer **p)
Release a Buffer and its contents.
Definition: buffer.c:134
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
#define mutt_error(...)
Definition: logging.h:84
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:283
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:3211
void mutt_display_address ( struct Envelope env)

Display the address of a message.

Parameters
envEnvelope containing address

Definition at line 864 of file commands.c.

865 {
866  const char *pfx = NULL;
867  char buf[128];
868 
869  struct AddressList *al = mutt_get_address(env, &pfx);
870  if (!al)
871  return;
872 
873  /* Note: We don't convert IDNA to local representation this time.
874  * That is intentional, so the user has an opportunity to copy &
875  * paste the on-the-wire form of the address to other, IDN-unable
876  * software. */
877  buf[0] = '\0';
878  mutt_addrlist_write(buf, sizeof(buf), al, false);
879  mutt_message("%s: %s", pfx, buf);
880 }
#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:322
size_t mutt_addrlist_write(char *buf, size_t buflen, const struct AddressList *al, bool display)
Write an Address to a buffer.
Definition: address.c:1134
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 890 of file commands.c.

892 {
893  *cmflags = MUTT_CM_NO_FLAGS;
894  *chflags = CH_UPDATE_LEN;
895 
896  if ((WithCrypto != 0) && !decode && decrypt && (e->security & SEC_ENCRYPT))
897  {
899  {
900  *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
901  *cmflags = MUTT_CM_DECODE_PGP;
902  }
903  else if (((WithCrypto & APPLICATION_PGP) != 0) &&
905  {
906  decode = 1;
907  }
908  else if (((WithCrypto & APPLICATION_SMIME) != 0) &&
910  {
911  *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
912  *cmflags = MUTT_CM_DECODE_SMIME;
913  }
914  }
915 
916  if (decode)
917  {
918  *chflags = CH_XMIT | CH_MIME | CH_TXTPLAIN;
919  *cmflags = MUTT_CM_DECODE | MUTT_CM_CHARCONV;
920 
921  if (!decrypt) /* If decode doesn't kick in for decrypt, */
922  {
923  *chflags |= CH_DECODE; /* then decode RFC2047 headers, */
924 
925  if (C_Weed)
926  {
927  *chflags |= CH_WEED; /* and respect $weed. */
928  *cmflags |= MUTT_CM_WEED;
929  }
930  }
931  }
932 }
#define CH_MIME
Ignore MIME fields.
Definition: copy.h:60
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 SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:121
#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:420
#define CH_WEED
Weed the headers?
Definition: copy.h:52
#define CH_TXTPLAIN
Generate text/plain MIME headers.
Definition: copy.h:62
SecurityFlags mutt_is_application_pgp(struct Body *m)
Does the message use PGP?
Definition: crypt.c:527
#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:586
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:130
#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 WithCrypto
Definition: ncrypt.h:156
#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
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:131
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 944 of file commands.c.

946 {
948  CopyHeaderFlags chflags = CH_NO_FLAGS;
949  int rc;
950 
951  set_copy_flags(e, decode, decrypt, &cmflags, &chflags);
952 
953  if (decode || decrypt)
955 
956  rc = mutt_append_message(m, Context->mailbox, e, cmflags, chflags);
957  if (rc != 0)
958  return rc;
959 
960  if (delete_original)
961  {
964  if (C_DeleteUntag)
965  mutt_set_flag(Context->mailbox, e, MUTT_TAG, false);
966  }
967 
968  return 0;
969 }
The "current" mailbox.
Definition: context.h:39
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:68
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:890
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:50
Messages to be purged (bypass trash)
Definition: mutt.h:104
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:53
Messages to be deleted.
Definition: mutt.h:102
#define CH_NO_FLAGS
No flags are set.
Definition: copy.h:50
Tagged messages.
Definition: mutt.h:107
WHERE bool C_DeleteUntag
Config: Untag messages when they are marked for deletion.
Definition: globals.h:207
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:872
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 981 of file commands.c.

983 {
984  if (!el || STAILQ_EMPTY(el))
985  return -1;
986 
987  bool need_passphrase = false;
988  int app = 0;
989  char buf[PATH_MAX];
990  const char *prompt = NULL;
991  struct stat st;
992  struct EmailNode *en = STAILQ_FIRST(el);
993  bool single = !STAILQ_NEXT(en, entries);
994 
995  if (delete_original)
996  {
997  if (decode)
998  prompt = single ? _("Decode-save to mailbox") : _("Decode-save tagged to mailbox");
999  else if (decrypt)
1000  prompt = single ? _("Decrypt-save to mailbox") : _("Decrypt-save tagged to mailbox");
1001  else
1002  prompt = single ? _("Save to mailbox") : _("Save tagged to mailbox");
1003  }
1004  else
1005  {
1006  if (decode)
1007  prompt = single ? _("Decode-copy to mailbox") : _("Decode-copy tagged to mailbox");
1008  else if (decrypt)
1009  prompt = single ? _("Decrypt-copy to mailbox") : _("Decrypt-copy tagged to mailbox");
1010  else
1011  prompt = single ? _("Copy to mailbox") : _("Copy tagged to mailbox");
1012  }
1013 
1014  if (WithCrypto)
1015  {
1016  need_passphrase = (en->email->security & SEC_ENCRYPT);
1017  app = en->email->security;
1018  }
1020  mutt_default_save(buf, sizeof(buf), en->email);
1021 
1022  mutt_pretty_mailbox(buf, sizeof(buf));
1023  if (mutt_enter_fname(prompt, buf, sizeof(buf), false) == -1)
1024  return -1;
1025 
1026  size_t pathlen = strlen(buf);
1027  if (pathlen == 0)
1028  return -1;
1029 
1030  /* Trim any trailing '/' */
1031  if (buf[pathlen - 1] == '/')
1032  buf[pathlen - 1] = '\0';
1033 
1034  /* This is an undocumented feature of ELM pointed out to me by Felix von
1035  * Leitner <leitner@prz.fu-berlin.de> */
1036  if (mutt_str_strcmp(buf, ".") == 0)
1037  mutt_str_strfcpy(buf, LastSaveFolder, sizeof(buf));
1038  else
1040 
1041  mutt_expand_path(buf, sizeof(buf));
1042 
1043  /* check to make sure that this file is really the one the user wants */
1044  if (mutt_save_confirm(buf, &st) != 0)
1045  return -1;
1046 
1047  if ((WithCrypto != 0) && need_passphrase && (decode || decrypt) &&
1048  !crypt_valid_passphrase(app))
1049  {
1050  return -1;
1051  }
1052 
1053  mutt_message(_("Copying to %s..."), buf);
1054 
1055 #ifdef USE_IMAP
1056  if ((m->magic == MUTT_IMAP) && !(decode || decrypt) &&
1057  (imap_path_probe(buf, NULL) == MUTT_IMAP))
1058  {
1059  switch (imap_copy_messages(m, el, buf, delete_original))
1060  {
1061  /* success */
1062  case 0:
1063  mutt_clear_error();
1064  return 0;
1065  /* non-fatal error: continue to fetch/append */
1066  case 1:
1067  break;
1068  /* fatal error, abort */
1069  case -1:
1070  return -1;
1071  }
1072  }
1073 #endif
1074 
1075  struct Mailbox *m_save = mx_path_resolve(buf);
1076  struct Context *ctx_save = mx_mbox_open(m_save, MUTT_NEWFOLDER);
1077  if (!ctx_save)
1078  {
1079  mailbox_free(&m_save);
1080  return -1;
1081  }
1082  bool old_append = m_save->append;
1083  m_save->append = true;
1084 
1085 #ifdef USE_COMPRESSED
1086  /* If we're saving to a compressed mailbox, the stats won't be updated
1087  * until the next open. Until then, improvise. */
1088  struct Mailbox *m_comp = NULL;
1089  if (ctx_save->mailbox->compress_info)
1090  {
1091  m_comp = mailbox_find(ctx_save->mailbox->realpath);
1092  }
1093  /* We probably haven't been opened yet */
1094  if (m_comp && (m_comp->msg_count == 0))
1095  m_comp = NULL;
1096 #endif
1097  if (single)
1098  {
1099  if (mutt_save_message_ctx(en->email, delete_original, decode, decrypt,
1100  ctx_save->mailbox) != 0)
1101  {
1102  m_save->append = old_append;
1103  mx_mbox_close(&ctx_save);
1104  return -1;
1105  }
1106 #ifdef USE_COMPRESSED
1107  if (m_comp)
1108  {
1109  m_comp->msg_count++;
1110  if (!en->email->read)
1111  {
1112  m_comp->msg_unread++;
1113  if (!en->email->old)
1114  m_comp->msg_new++;
1115  }
1116  if (en->email->flagged)
1117  m_comp->msg_flagged++;
1118  }
1119 #endif
1120  }
1121  else
1122  {
1123  int rc = 0;
1124 
1125 #ifdef USE_NOTMUCH
1126  if (m->magic == MUTT_NOTMUCH)
1127  nm_db_longrun_init(m, true);
1128 #endif
1129  STAILQ_FOREACH(en, el, entries)
1130  {
1132  rc = mutt_save_message_ctx(en->email, delete_original, decode, decrypt,
1133  ctx_save->mailbox);
1134  if (rc != 0)
1135  break;
1136 #ifdef USE_COMPRESSED
1137  if (m_comp)
1138  {
1139  struct Email *e2 = en->email;
1140  m_comp->msg_count++;
1141  if (!e2->read)
1142  {
1143  m_comp->msg_unread++;
1144  if (!e2->old)
1145  m_comp->msg_new++;
1146  }
1147  if (e2->flagged)
1148  m_comp->msg_flagged++;
1149  }
1150 #endif
1151  }
1152 #ifdef USE_NOTMUCH
1153  if (m->magic == MUTT_NOTMUCH)
1154  nm_db_longrun_done(m);
1155 #endif
1156  if (rc != 0)
1157  {
1158  m_save->append = old_append;
1159  mx_mbox_close(&ctx_save);
1160  return -1;
1161  }
1162  }
1163 
1164  const bool need_mailbox_cleanup = ((ctx_save->mailbox->magic == MUTT_MBOX) ||
1165  (ctx_save->mailbox->magic == MUTT_MMDF));
1166 
1167  m_save->append = old_append;
1168  mx_mbox_close(&ctx_save);
1169 
1170  if (need_mailbox_cleanup)
1171  mutt_mailbox_cleanup(buf, &st);
1172 
1173  mutt_clear_error();
1174  return 0;
1175 }
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:944
The "current" mailbox.
Definition: context.h:39
int msg_count
Total number of messages.
Definition: mailbox.h:103
The envelope/body of an email.
Definition: email.h:37
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox? - Implements MxOps::path_probe()
Definition: imap.c:2432
int msg_unread
Number of unread messages.
Definition: mailbox.h:104
int mx_mbox_close(struct Context **ptr)
Save changes and close mailbox.
Definition: mx.c:561
void mutt_mailbox_cleanup(const char *path, struct stat *st)
Restore the timestamp of a mailbox.
Definition: mutt_mailbox.c:353
#define mutt_message(...)
Definition: logging.h:83
int msg_flagged
Number of flagged messages.
Definition: mailbox.h:105
struct Mailbox * mailbox_find(const char *path)
Find the mailbox with a given path.
Definition: mailbox.c:78
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:96
#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:264
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:51
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:121
void mutt_default_save(char *path, size_t pathlen, struct Email *e)
Find the default save path for an email.
Definition: hook.c:662
int mutt_save_confirm(const char *s, struct stat *st)
Ask the user to save.
Definition: muttlib.c:1411
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:143
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:128
bool read
Email is read.
Definition: email.h:51
struct Mailbox * mailbox
Definition: context.h:53
bool old
Email is seen, but unread.
Definition: email.h:50
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:56
enum MailboxType magic
Mailbox type.
Definition: mailbox.h:117
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:141
int imap_copy_messages(struct Mailbox *m, struct EmailList *el, char *dest, bool delete_original)
Server COPY messages to another folder.
Definition: message.c:1563
void nm_db_longrun_done(struct Mailbox *m)
Finish a long transaction.
Definition: nm_db.c:307
A mailbox.
Definition: mailbox.h:93
#define PATH_MAX
Definition: mutt.h:50
&#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:750
bool append
Mailbox is opened in append mode.
Definition: mailbox.h:125
void mutt_pretty_mailbox(char *buf, size_t buflen)
Shorten a mailbox path using &#39;~&#39; or &#39;=&#39;.
Definition: muttlib.c:615
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
#define STAILQ_NEXT(elm, field)
Definition: queue.h:398
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:54
&#39;mbox&#39; Mailbox type
Definition: mailbox.h:48
bool flagged
Marked important?
Definition: email.h:43
int msg_new
Number of new messages.
Definition: mailbox.h:107
struct Email * email
Email in the list.
Definition: email.h:119
void * compress_info
Compressed mbox module private data.
Definition: mailbox.h:136
#define mutt_enter_fname(prompt, buf, buflen, mailbox)
Definition: curs_lib.h:85
struct Mailbox * mx_path_resolve(const char *path)
XXX.
Definition: mx.c:1544
#define STAILQ_EMPTY(head)
Definition: queue.h:346
List of Emails.
Definition: email.h:117
void nm_db_longrun_init(struct Mailbox *m, bool writable)
Start a long transaction.
Definition: nm_db.c:292
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:56
&#39;IMAP&#39; Mailbox type
Definition: mailbox.h:53
#define STAILQ_FIRST(head)
Definition: queue.h:348
#define WithCrypto
Definition: ncrypt.h:156
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:615
static char LastSaveFolder[PATH_MAX]
The folder the user last saved to.
Definition: commands.c:94
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 1186 of file commands.c.

1187 {
1188  char buf[1024];
1189  char obuf[1024];
1190  char tmp[256];
1191  char charset[256];
1192 
1193  bool charset_changed = false;
1194  bool type_changed = false;
1195  bool structure_changed = false;
1196 
1197  char *cp = mutt_param_get(&b->parameter, "charset");
1198  mutt_str_strfcpy(charset, cp, sizeof(charset));
1199 
1200  snprintf(buf, sizeof(buf), "%s/%s", TYPE(b), b->subtype);
1201  mutt_str_strfcpy(obuf, buf, sizeof(obuf));
1202  if (!TAILQ_EMPTY(&b->parameter))
1203  {
1204  size_t l = strlen(buf);
1205  struct Parameter *np = NULL;
1206  TAILQ_FOREACH(np, &b->parameter, entries)
1207  {
1208  mutt_addr_cat(tmp, sizeof(tmp), np->value, MimeSpecials);
1209  l += snprintf(buf + l, sizeof(buf) - l, "; %s=%s", np->attribute, tmp);
1210  if (l >= sizeof(buf))
1211  {
1212  // L10N: e.g. "text/plain; charset=UTF-8; ..."
1213  mutt_error(_("Content type is too long"));
1214  return false;
1215  }
1216  }
1217  }
1218 
1219  if ((mutt_get_field("Content-Type: ", buf, sizeof(buf), 0) != 0) || (buf[0] == '\0'))
1220  return false;
1221 
1222  /* clean up previous junk */
1224  FREE(&b->subtype);
1225 
1226  mutt_parse_content_type(buf, b);
1227 
1228  snprintf(tmp, sizeof(tmp), "%s/%s", TYPE(b), NONULL(b->subtype));
1229  type_changed = (mutt_str_strcasecmp(tmp, obuf) != 0);
1230  charset_changed =
1231  (mutt_str_strcasecmp(charset, mutt_param_get(&b->parameter, "charset")) != 0);
1232 
1233  /* if in send mode, check for conversion - current setting is default. */
1234 
1235  if (!e && (b->type == TYPE_TEXT) && charset_changed)
1236  {
1237  snprintf(tmp, sizeof(tmp), _("Convert to %s upon sending?"),
1238  mutt_param_get(&b->parameter, "charset"));
1239  int ans = mutt_yesorno(tmp, b->noconv ? MUTT_NO : MUTT_YES);
1240  if (ans != MUTT_ABORT)
1241  b->noconv = (ans == MUTT_NO);
1242  }
1243 
1244  /* inform the user */
1245 
1246  snprintf(tmp, sizeof(tmp), "%s/%s", TYPE(b), NONULL(b->subtype));
1247  if (type_changed)
1248  mutt_message(_("Content-Type changed to %s"), tmp);
1249  if ((b->type == TYPE_TEXT) && charset_changed)
1250  {
1251  if (type_changed)
1252  mutt_sleep(1);
1253  mutt_message(b->noconv ? _("Character set changed to %s; not converting") :
1254  _("Character set changed to %s; converting"),
1255  mutt_param_get(&b->parameter, "charset"));
1256  }
1257 
1258  b->force_charset |= charset_changed;
1259 
1260  if (!is_multipart(b) && b->parts)
1261  {
1262  structure_changed = true;
1263  mutt_body_free(&b->parts);
1264  }
1265  if (!mutt_is_message_type(b->type, b->subtype) && b->email)
1266  {
1267  structure_changed = true;
1268  b->email->content = NULL;
1269  mutt_email_free(&b->email);
1270  }
1271 
1272  if (fp && !b->parts && (is_multipart(b) || mutt_is_message_type(b->type, b->subtype)))
1273  {
1274  structure_changed = true;
1275  mutt_parse_part(fp, b);
1276  }
1277 
1278  if ((WithCrypto != 0) && e)
1279  {
1280  if (e->content == b)
1281  e->security = SEC_NO_FLAGS;
1282 
1283  e->security |= crypt_query(b);
1284  }
1285 
1286  return structure_changed;
1287 }
char * attribute
Parameter name.
Definition: parameter.h:34
#define NONULL(x)
Definition: string2.h:37
bool mutt_is_message_type(int type, const char *subtype)
Determine if a mime type matches a message or not.
Definition: parse.c:1270
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:719
#define is_multipart(body)
Definition: mime.h:77
User aborted the question (with Ctrl-G)
Definition: quad.h:37
#define mutt_message(...)
Definition: logging.h:83
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
#define SEC_NO_FLAGS
No flags are set.
Definition: ncrypt.h:120
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:86
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1505
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
Definition: curs_lib.c:332
bool force_charset
Send mode: don&#39;t adjust the character set when in send-mode.
Definition: body.h:74
char * subtype
content-type subtype
Definition: body.h:37
void mutt_param_free(struct ParameterList *p)
Free a ParameterList.
Definition: parameter.c:61
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:38
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:750
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
void mutt_email_free(struct Email **e)
Free an Email.
Definition: email.c:41
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:434
void mutt_parse_part(FILE *fp, struct Body *b)
Parse a MIME part.
Definition: parse.c:1285
char * mutt_param_get(const struct ParameterList *p, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
void mutt_body_free(struct Body **p)
Free a Body.
Definition: body.c:57
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:628
Attribute associated with a MIME part.
Definition: parameter.h:32
#define FREE(x)
Definition: memory.h:40
#define TAILQ_EMPTY(head)
Definition: queue.h:715
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
struct Email * email
header information for message/rfc822
Definition: body.h:55
#define WithCrypto
Definition: ncrypt.h:156
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:663
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:668
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 1295 of file commands.c.

1296 {
1297  bool rc = false;
1298 
1300 
1302  struct Message *msg = mx_msg_open(Context->mailbox, e->msgno);
1303  if (!msg)
1304  return 0;
1305  if (crypt_pgp_check_traditional(msg->fp, e->content, false))
1306  {
1307  e->security = crypt_query(e->content);
1308  *redraw |= REDRAW_FULL;
1309  rc = true;
1310  }
1311 
1313  mx_msg_close(Context->mailbox, &msg);
1314  return rc;
1315 }
The "current" mailbox.
Definition: context.h:39
#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:50
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
Definition: ncrypt.h:132
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1092
struct Mailbox * mailbox
Definition: context.h:53
A local copy of an email.
Definition: mx.h:82
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
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:239
FILE * fp
pointer to the message data
Definition: mx.h:84
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:663
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1044
int msgno
Number displayed to the user.
Definition: email.h:86
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 1323 of file commands.c.

1324 {
1325  bool rc = false;
1326  struct EmailNode *en = NULL;
1327  STAILQ_FOREACH(en, el, entries)
1328  {
1329  if (!(en->email->security & PGP_TRADITIONAL_CHECKED))
1330  rc = check_traditional_pgp(en->email, redraw) || rc;
1331  }
1332 
1333  return rc;
1334 }
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
Definition: ncrypt.h:132
static bool check_traditional_pgp(struct Email *e, MuttRedrawFlags *redraw)
Check for an inline PGP content.
Definition: commands.c:1295
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
struct Email * email
Email in the list.
Definition: email.h:119
List of Emails.
Definition: email.h:117
void mutt_check_stats ( void  )

Forcibly update mailbox stats.

Definition at line 1339 of file commands.c.

1340 {
1342 }
The "current" mailbox.
Definition: context.h:39
struct Mailbox * mailbox
Definition: context.h:53
int mutt_mailbox_check(struct Mailbox *m_cur, int force)
Check all all Mailboxes for new mail.
Definition: mutt_mailbox.c:126
#define MUTT_MAILBOX_CHECK_FORCE
Definition: mutt_mailbox.h:17
#define MUTT_MAILBOX_CHECK_FORCE_STATS
Definition: mutt_mailbox.h:18

Variable Documentation

unsigned char C_CryptVerifySig

Config: Verify PGP or SMIME signatures.

Definition at line 82 of file commands.c.

char* C_DisplayFilter

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

Definition at line 83 of file commands.c.

bool C_PipeDecode

Config: Decode the message when piping it.

Definition at line 84 of file commands.c.

char* C_PipeSep

Config: Separator to add between multiple piped messages.

Definition at line 85 of file commands.c.

bool C_PipeSplit

Config: Run the pipe command on each message separately.

Definition at line 86 of file commands.c.

bool C_PrintDecode

Config: Decode message before printing it.

Definition at line 87 of file commands.c.

bool C_PrintSplit

Config: Print multiple messages separately.

Definition at line 88 of file commands.c.

bool C_PromptAfter

Config: Pause after running an external pager.

Definition at line 89 of file commands.c.

const char* ExtPagerProgress = "all"
static

Definition at line 91 of file commands.c.

char LastSaveFolder[PATH_MAX] = ""
static

The folder the user last saved to.

Used by ci_save_message()

Definition at line 94 of file commands.c.