NeoMutt  2021-02-05-329-g9e03b7
Teaching an old dog new tricks
DOXYGEN
rfc3676.c File Reference

RFC3676 Format Flowed routines. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "rfc3676.h"
#include "muttlib.h"
+ Include dependency graph for rfc3676.c:

Go to the source code of this file.

Data Structures

struct  FlowedState
 State of a Format-Flowed line of text. More...
 

Macros

#define FLOWED_MAX   72
 

Functions

static int get_quote_level (const char *line)
 Get the quote level of a line. More...
 
static int space_quotes (struct State *s)
 Should we add spaces between quote levels. More...
 
static bool add_quote_suffix (struct State *s, int ql)
 Should we add a trailing space to quotes. More...
 
static size_t print_indent (int ql, struct State *s, int add_suffix)
 Print indented text. More...
 
static void flush_par (struct State *s, struct FlowedState *fst)
 Write out the paragraph. More...
 
static int quote_width (struct State *s, int ql)
 Calculate the paragraph width based upon the quote level. More...
 
static void print_flowed_line (char *line, struct State *s, int ql, struct FlowedState *fst, bool term)
 Print a format-flowed line. More...
 
static void print_fixed_line (const char *line, struct State *s, int ql, struct FlowedState *fst)
 Print a fixed format line. More...
 
int rfc3676_handler (struct Body *a, struct State *s)
 Body handler implementing RFC3676 for format=flowed - Implements handler_t. More...
 
bool mutt_rfc3676_is_format_flowed (struct Body *b)
 Is the Email "format-flowed"? More...
 
static void rfc3676_space_stuff (const char *filename, bool unstuff)
 Perform required RFC3676 space stuffing. More...
 
void mutt_rfc3676_space_stuff (struct Email *e)
 Perform RFC3676 space stuffing on an Email. More...
 
void mutt_rfc3676_space_unstuff (struct Email *e)
 Remove RFC3676 space stuffing. More...
 
void mutt_rfc3676_space_unstuff_attachment (struct Body *b, const char *filename)
 Unstuff attachments. More...
 
void mutt_rfc3676_space_stuff_attachment (struct Body *b, const char *filename)
 Stuff attachments. More...
 

Detailed Description

RFC3676 Format Flowed routines.

Authors
  • Andreas Krennmair
  • Peter J. Holzer
  • Rocco Rutte
  • Michael R. Elkins

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

Macro Definition Documentation

◆ FLOWED_MAX

#define FLOWED_MAX   72

Definition at line 45 of file rfc3676.c.

Function Documentation

◆ get_quote_level()

static int get_quote_level ( const char *  line)
static

Get the quote level of a line.

Parameters
lineText to examine
Return values
numQuote level

Definition at line 62 of file rfc3676.c.

63 {
64  int quoted = 0;
65  const char *p = line;
66 
67  while (p && (*p == '>'))
68  {
69  quoted++;
70  p++;
71  }
72 
73  return quoted;
74 }
+ Here is the caller graph for this function:

◆ space_quotes()

static int space_quotes ( struct State s)
static

Should we add spaces between quote levels.

Parameters
sState to use
Return values
trueSpaces should be added

Determines whether to add spacing between/after each quote level: >>>foo becomes > > > foo

Definition at line 86 of file rfc3676.c.

87 {
88  /* Allow quote spacing in the pager even for `$text_flowed`,
89  * but obviously not when replying. */
90  const bool c_text_flowed = cs_subset_bool(NeoMutt->sub, "text_flowed");
91  if (c_text_flowed && (s->flags & MUTT_REPLYING))
92  return 0;
93 
94  const bool c_reflow_space_quotes =
95  cs_subset_bool(NeoMutt->sub, "reflow_space_quotes");
96  return c_reflow_space_quotes;
97 }
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:71
Container for Accounts, Notifications.
Definition: neomutt.h:36
StateFlags flags
Flags, e.g. MUTT_DISPLAY.
Definition: state.h:49
#define MUTT_REPLYING
Are we replying?
Definition: state.h:38
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_quote_suffix()

static bool add_quote_suffix ( struct State s,
int  ql 
)
static

Should we add a trailing space to quotes.

Parameters
sState to use
qlQuote level
Return values
trueSpaces should be added

Determines whether to add a trailing space to quotes: >>> foo as opposed to >>>foo

Definition at line 110 of file rfc3676.c.

111 {
112  if (s->flags & MUTT_REPLYING)
113  return false;
114 
115  if (space_quotes(s))
116  return false;
117 
118  if (!ql && !s->prefix)
119  return false;
120 
121  /* The prefix will add its own space */
122  const bool c_text_flowed = cs_subset_bool(NeoMutt->sub, "text_flowed");
123  if (!c_text_flowed && !ql && s->prefix)
124  return false;
125 
126  return true;
127 }
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:71
static int space_quotes(struct State *s)
Should we add spaces between quote levels.
Definition: rfc3676.c:86
char * prefix
String to add to the beginning of each output line.
Definition: state.h:48
Container for Accounts, Notifications.
Definition: neomutt.h:36
StateFlags flags
Flags, e.g. MUTT_DISPLAY.
Definition: state.h:49
#define MUTT_REPLYING
Are we replying?
Definition: state.h:38
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_indent()

static size_t print_indent ( int  ql,
struct State s,
int  add_suffix 
)
static

Print indented text.

Parameters
qlQuote level
sState to work with
add_suffixIf true, write a trailing space character
Return values
numNumber of characters written

Definition at line 136 of file rfc3676.c.

137 {
138  size_t wid = 0;
139 
140  if (s->prefix)
141  {
142  /* use given prefix only for format=fixed replies to format=flowed,
143  * for format=flowed replies to format=flowed, use '>' indentation */
144  const bool c_text_flowed = cs_subset_bool(NeoMutt->sub, "text_flowed");
145  if (c_text_flowed)
146  ql++;
147  else
148  {
149  state_puts(s, s->prefix);
150  wid = mutt_strwidth(s->prefix);
151  }
152  }
153  for (int i = 0; i < ql; i++)
154  {
155  state_putc(s, '>');
156  if (space_quotes(s))
157  state_putc(s, ' ');
158  }
159  if (add_suffix)
160  state_putc(s, ' ');
161 
162  if (space_quotes(s))
163  ql *= 2;
164 
165  return ql + add_suffix + wid;
166 }
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:71
#define state_puts(STATE, STR)
Definition: state.h:55
static int space_quotes(struct State *s)
Should we add spaces between quote levels.
Definition: rfc3676.c:86
char * prefix
String to add to the beginning of each output line.
Definition: state.h:48
Container for Accounts, Notifications.
Definition: neomutt.h:36
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:1249
#define state_putc(STATE, STR)
Definition: state.h:56
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flush_par()

static void flush_par ( struct State s,
struct FlowedState fst 
)
static

Write out the paragraph.

Parameters
sState to work with
fstThe state of the flowed text

Definition at line 173 of file rfc3676.c.

174 {
175  if (fst->width > 0)
176  {
177  state_putc(s, '\n');
178  fst->width = 0;
179  }
180  fst->spaces = 0;
181 }
size_t spaces
Definition: rfc3676.c:53
size_t width
Definition: rfc3676.c:52
#define state_putc(STATE, STR)
Definition: state.h:56
+ Here is the caller graph for this function:

◆ quote_width()

static int quote_width ( struct State s,
int  ql 
)
static

Calculate the paragraph width based upon the quote level.

Parameters
sState to use
qlQuote level
Return values
numParagraph width

The start of a quoted line will be ">>> ", so we need to subtract the space required for the prefix from the terminal width.

Definition at line 192 of file rfc3676.c.

193 {
194  const int screen_width = (s->flags & MUTT_DISPLAY) ? s->wraplen : 80;
195  const short c_reflow_wrap = cs_subset_number(NeoMutt->sub, "reflow_wrap");
196  int width = mutt_window_wrap_cols(screen_width, c_reflow_wrap);
197  const bool c_text_flowed = cs_subset_bool(NeoMutt->sub, "text_flowed");
198  if (c_text_flowed && (s->flags & MUTT_REPLYING))
199  {
200  /* When replying, force a wrap at FLOWED_MAX to comply with RFC3676
201  * guidelines */
202  if (width > FLOWED_MAX)
203  width = FLOWED_MAX;
204  ql++; /* When replying, we will add an additional quote level */
205  }
206  /* adjust the paragraph width subtracting the number of prefix chars */
207  width -= space_quotes(s) ? ql * 2 : ql;
208  /* When displaying (not replying), there may be a space between the prefix
209  * string and the paragraph */
210  if (add_quote_suffix(s, ql))
211  width--;
212  /* failsafe for really long quotes */
213  if (width <= 0)
214  width = FLOWED_MAX; /* arbitrary, since the line will wrap */
215  return width;
216 }
#define MUTT_DISPLAY
Output is displayed to the user.
Definition: state.h:32
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:71
static bool add_quote_suffix(struct State *s, int ql)
Should we add a trailing space to quotes.
Definition: rfc3676.c:110
static int space_quotes(struct State *s)
Should we add spaces between quote levels.
Definition: rfc3676.c:86
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:159
Container for Accounts, Notifications.
Definition: neomutt.h:36
StateFlags flags
Flags, e.g. MUTT_DISPLAY.
Definition: state.h:49
int wraplen
Width to wrap lines to (when flags & MUTT_DISPLAY)
Definition: state.h:50
int mutt_window_wrap_cols(int width, short wrap)
Calculate the wrap column for a given screen width.
Definition: mutt_window.c:474
#define FLOWED_MAX
Definition: rfc3676.c:45
#define MUTT_REPLYING
Are we replying?
Definition: state.h:38
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_flowed_line()

static void print_flowed_line ( char *  line,
struct State s,
int  ql,
struct FlowedState fst,
bool  term 
)
static

Print a format-flowed line.

Parameters
lineText to print
sState to work with
qlQuote level
fstThe state of the flowed text
termIf true, terminate with a new line

Definition at line 226 of file rfc3676.c.

228 {
229  size_t width, w, words = 0;
230  char *p = NULL;
231  char last;
232 
233  if (!line || (*line == '\0'))
234  {
235  /* flush current paragraph (if any) first */
236  flush_par(s, fst);
237  print_indent(ql, s, 0);
238  state_putc(s, '\n');
239  return;
240  }
241 
242  width = quote_width(s, ql);
243  last = line[mutt_str_len(line) - 1];
244 
245  mutt_debug(LL_DEBUG5, "f=f: line [%s], width = %ld, spaces = %lu\n", line,
246  (long) width, fst->spaces);
247 
248  for (words = 0; (p = strsep(&line, " "));)
249  {
250  mutt_debug(LL_DEBUG5, "f=f: word [%s], width: %lu, remaining = [%s]\n", p,
251  fst->width, line);
252 
253  /* remember number of spaces */
254  if (*p == '\0')
255  {
256  mutt_debug(LL_DEBUG3, "f=f: additional space\n");
257  fst->spaces++;
258  continue;
259  }
260  /* there's exactly one space prior to every but the first word */
261  if (words)
262  fst->spaces++;
263 
264  w = mutt_strwidth(p);
265  /* see if we need to break the line but make sure the first word is put on
266  * the line regardless; if for DelSp=yes only one trailing space is used,
267  * we probably have a long word that we should break within (we leave that
268  * up to the pager or user) */
269  if (!(!fst->spaces && fst->delsp && (last != ' ')) && (w < width) &&
270  (w + fst->width + fst->spaces > width))
271  {
272  mutt_debug(LL_DEBUG3, "f=f: break line at %lu, %lu spaces left\n",
273  fst->width, fst->spaces);
274  /* only honor trailing spaces for format=flowed replies */
275  const bool c_text_flowed = cs_subset_bool(NeoMutt->sub, "text_flowed");
276  if (c_text_flowed)
277  for (; fst->spaces; fst->spaces--)
278  state_putc(s, ' ');
279  state_putc(s, '\n');
280  fst->width = 0;
281  fst->spaces = 0;
282  words = 0;
283  }
284 
285  if (!words && !fst->width)
286  fst->width = print_indent(ql, s, add_quote_suffix(s, ql));
287  fst->width += w + fst->spaces;
288  for (; fst->spaces; fst->spaces--)
289  state_putc(s, ' ');
290  state_puts(s, p);
291  words++;
292  }
293 
294  if (term)
295  flush_par(s, fst);
296 }
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:71
#define state_puts(STATE, STR)
Definition: state.h:55
static bool add_quote_suffix(struct State *s, int ql)
Should we add a trailing space to quotes.
Definition: rfc3676.c:110
static int quote_width(struct State *s, int ql)
Calculate the paragraph width based upon the quote level.
Definition: rfc3676.c:192
size_t spaces
Definition: rfc3676.c:53
Container for Accounts, Notifications.
Definition: neomutt.h:36
static size_t print_indent(int ql, struct State *s, int add_suffix)
Print indented text.
Definition: rfc3676.c:136
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:1249
size_t width
Definition: rfc3676.c:52
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:631
static void flush_par(struct State *s, struct FlowedState *fst)
Write out the paragraph.
Definition: rfc3676.c:173
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
#define state_putc(STATE, STR)
Definition: state.h:56
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
Log at debug level 5.
Definition: logging.h:44
bool delsp
Definition: rfc3676.c:54
Log at debug level 3.
Definition: logging.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_fixed_line()

static void print_fixed_line ( const char *  line,
struct State s,
int  ql,
struct FlowedState fst 
)
static

Print a fixed format line.

Parameters
lineText to print
sState to work with
qlQuote level
fstThe state of the flowed text

Definition at line 305 of file rfc3676.c.

306 {
307  print_indent(ql, s, add_quote_suffix(s, ql));
308  if (line && *line)
309  state_puts(s, line);
310  state_putc(s, '\n');
311 
312  fst->width = 0;
313  fst->spaces = 0;
314 }
#define state_puts(STATE, STR)
Definition: state.h:55
static bool add_quote_suffix(struct State *s, int ql)
Should we add a trailing space to quotes.
Definition: rfc3676.c:110
size_t spaces
Definition: rfc3676.c:53
static size_t print_indent(int ql, struct State *s, int add_suffix)
Print indented text.
Definition: rfc3676.c:136
size_t width
Definition: rfc3676.c:52
#define state_putc(STATE, STR)
Definition: state.h:56
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rfc3676_handler()

int rfc3676_handler ( struct Body a,
struct State s 
)

Body handler implementing RFC3676 for format=flowed - Implements handler_t.

Return values
0Always

Definition at line 320 of file rfc3676.c.

321 {
322  char *buf = NULL;
323  unsigned int quotelevel = 0;
324  bool delsp = false;
325  size_t sz = 0;
326  struct FlowedState fst = { 0 };
327 
328  /* respect DelSp of RFC3676 only with f=f parts */
329  char *t = mutt_param_get(&a->parameter, "delsp");
330  if (t)
331  {
332  delsp = mutt_istr_equal(t, "yes");
333  t = NULL;
334  fst.delsp = true;
335  }
336 
337  mutt_debug(LL_DEBUG3, "f=f: DelSp: %s\n", delsp ? "yes" : "no");
338 
339  while ((buf = mutt_file_read_line(buf, &sz, s->fp_in, NULL, MUTT_RL_NO_FLAGS)))
340  {
341  const size_t buf_len = mutt_str_len(buf);
342  const unsigned int newql = get_quote_level(buf);
343 
344  /* end flowed paragraph (if we're within one) if quoting level
345  * changes (should not but can happen, see RFC3676, sec. 4.5.) */
346  if (newql != quotelevel)
347  flush_par(s, &fst);
348 
349  quotelevel = newql;
350  int buf_off = newql;
351 
352  /* respect sender's space-stuffing by removing one leading space */
353  if (buf[buf_off] == ' ')
354  buf_off++;
355 
356  /* test for signature separator */
357  const unsigned int sigsep = mutt_str_equal(buf + buf_off, "-- ");
358 
359  /* a fixed line either has no trailing space or is the
360  * signature separator */
361  const bool fixed = (buf_len == buf_off) || (buf[buf_len - 1] != ' ') || sigsep;
362 
363  /* print fixed-and-standalone, fixed-and-empty and sigsep lines as
364  * fixed lines */
365  if ((fixed && ((fst.width == 0) || (buf_len == 0))) || sigsep)
366  {
367  /* if we're within a flowed paragraph, terminate it */
368  flush_par(s, &fst);
369  print_fixed_line(buf + buf_off, s, quotelevel, &fst);
370  continue;
371  }
372 
373  /* for DelSp=yes, we need to strip one SP prior to CRLF on flowed lines */
374  if (delsp && !fixed)
375  buf[buf_len - 1] = '\0';
376 
377  print_flowed_line(buf + buf_off, s, quotelevel, &fst, fixed);
378  }
379 
380  flush_par(s, &fst);
381 
382  FREE(&buf);
383  return 0;
384 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, ReadLineFlags flags)
Read a line from a file.
Definition: file.c:667
FILE * fp_in
File to read from.
Definition: state.h:46
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
static int get_quote_level(const char *line)
Get the quote level of a line.
Definition: rfc3676.c:62
static void print_fixed_line(const char *line, struct State *s, int ql, struct FlowedState *fst)
Print a fixed format line.
Definition: rfc3676.c:305
size_t width
Definition: rfc3676.c:52
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:631
State of a Format-Flowed line of text.
Definition: rfc3676.c:50
#define MUTT_RL_NO_FLAGS
No flags are set.
Definition: file.h:38
#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
static void flush_par(struct State *s, struct FlowedState *fst)
Write out the paragraph.
Definition: rfc3676.c:173
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
static void print_flowed_line(char *line, struct State *s, int ql, struct FlowedState *fst, bool term)
Print a format-flowed line.
Definition: rfc3676.c:226
bool delsp
Definition: rfc3676.c:54
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
Log at debug level 3.
Definition: logging.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_rfc3676_is_format_flowed()

bool mutt_rfc3676_is_format_flowed ( struct Body b)

Is the Email "format-flowed"?

Parameters
bEmail Body to examine
Return values
trueEmail is "format-flowed"

Definition at line 391 of file rfc3676.c.

392 {
393  if (b && (b->type == TYPE_TEXT) && mutt_istr_equal("plain", b->subtype))
394  {
395  const char *format = mutt_param_get(&b->parameter, "format");
396  if (mutt_istr_equal("flowed", format))
397  return true;
398  }
399 
400  return false;
401 }
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
char * subtype
content-type subtype
Definition: body.h:37
Type: &#39;text/*&#39;.
Definition: mime.h:38
unsigned int type
content-type primary type, ContentType
Definition: body.h:65
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rfc3676_space_stuff()

static void rfc3676_space_stuff ( const char *  filename,
bool  unstuff 
)
static

Perform required RFC3676 space stuffing.

Parameters
filenameAttachment file
unstuffIf true, remove space stuffing

Space stuffing means that we have to add leading spaces to certain lines:

  • lines starting with a space
  • lines starting with 'From '

Care is taken to preserve the e->body->filename, as mutt -i -E can directly edit a passed in filename.

Definition at line 416 of file rfc3676.c.

417 {
418  FILE *fp_out = NULL;
419  char *buf = NULL;
420  size_t blen = 0;
421 
422  struct Buffer *tmpfile = mutt_buffer_pool_get();
423 
424  FILE *fp_in = mutt_file_fopen(filename, "r");
425  if (!fp_in)
426  goto bail;
427 
428  mutt_buffer_mktemp(tmpfile);
429  fp_out = mutt_file_fopen(mutt_buffer_string(tmpfile), "w+");
430  if (!fp_out)
431  goto bail;
432 
433  while ((buf = mutt_file_read_line(buf, &blen, fp_in, NULL, MUTT_RL_NO_FLAGS)) != NULL)
434  {
435  if (unstuff)
436  {
437  if (buf[0] == ' ')
438  fputs(buf + 1, fp_out);
439  else
440  fputs(buf, fp_out);
441  }
442  else
443  {
444  if ((buf[0] == ' ') || mutt_str_startswith(buf, "From "))
445  fputc(' ', fp_out);
446  fputs(buf, fp_out);
447  }
448  fputc('\n', fp_out);
449  }
450  FREE(&buf);
451  mutt_file_fclose(&fp_in);
452  mutt_file_fclose(&fp_out);
453  mutt_file_set_mtime(filename, mutt_buffer_string(tmpfile));
454 
455  fp_in = mutt_file_fopen(mutt_buffer_string(tmpfile), "r");
456  if (!fp_in)
457  goto bail;
458 
459  if ((truncate(filename, 0) == -1) || ((fp_out = mutt_file_fopen(filename, "a")) == NULL))
460  {
461  mutt_perror(filename);
462  goto bail;
463  }
464 
465  mutt_file_copy_stream(fp_in, fp_out);
466  mutt_file_set_mtime(mutt_buffer_string(tmpfile), filename);
467  unlink(mutt_buffer_string(tmpfile));
468 
469 bail:
470  mutt_file_fclose(&fp_in);
471  mutt_file_fclose(&fp_out);
472  mutt_buffer_pool_release(&tmpfile);
473 }
#define mutt_buffer_mktemp(buf)
Definition: muttlib.h:74
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
#define mutt_perror(...)
Definition: logging.h:85
void mutt_file_set_mtime(const char *from, const char *to)
Set the modification time of one file from another.
Definition: file.c:1006
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
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, ReadLineFlags flags)
Read a line from a file.
Definition: file.c:667
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:153
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:160
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
Definition: file.c:271
#define MUTT_RL_NO_FLAGS
No flags are set.
Definition: file.h:38
#define FREE(x)
Definition: memory.h:40
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:589
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_rfc3676_space_stuff()

void mutt_rfc3676_space_stuff ( struct Email e)

Perform RFC3676 space stuffing on an Email.

Parameters
eEmail
Note
We don't check the option $text_flowed because we want to stuff based the actual content type. The option only decides whether to set format=flowed on new messages.

Definition at line 483 of file rfc3676.c.

484 {
485  if (!e || !e->body || !e->body->filename)
486  return;
487 
489  rfc3676_space_stuff(e->body->filename, false);
490 }
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
bool mutt_rfc3676_is_format_flowed(struct Body *b)
Is the Email "format-flowed"?
Definition: rfc3676.c:391
struct Body * body
List of MIME parts.
Definition: email.h:91
static void rfc3676_space_stuff(const char *filename, bool unstuff)
Perform required RFC3676 space stuffing.
Definition: rfc3676.c:416
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_rfc3676_space_unstuff()

void mutt_rfc3676_space_unstuff ( struct Email e)

Remove RFC3676 space stuffing.

Parameters
eEmail

Definition at line 496 of file rfc3676.c.

497 {
498  if (!e || !e->body || !e->body->filename)
499  return;
500 
502  rfc3676_space_stuff(e->body->filename, true);
503 }
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
bool mutt_rfc3676_is_format_flowed(struct Body *b)
Is the Email "format-flowed"?
Definition: rfc3676.c:391
struct Body * body
List of MIME parts.
Definition: email.h:91
static void rfc3676_space_stuff(const char *filename, bool unstuff)
Perform required RFC3676 space stuffing.
Definition: rfc3676.c:416
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_rfc3676_space_unstuff_attachment()

void mutt_rfc3676_space_unstuff_attachment ( struct Body b,
const char *  filename 
)

Unstuff attachments.

Parameters
bEmail Body (OPTIONAL)
filenameAttachment file

This routine is used when saving/piping/viewing rfc3676 attachments.

If b is provided, the function will verify that the Email is format-flowed. The filename will be unstuffed, not b->filename or b->fp.

Definition at line 515 of file rfc3676.c.

516 {
517  if (!filename)
518  return;
519 
520  if (b && !mutt_rfc3676_is_format_flowed(b))
521  return;
522 
523  rfc3676_space_stuff(filename, true);
524 }
bool mutt_rfc3676_is_format_flowed(struct Body *b)
Is the Email "format-flowed"?
Definition: rfc3676.c:391
static void rfc3676_space_stuff(const char *filename, bool unstuff)
Perform required RFC3676 space stuffing.
Definition: rfc3676.c:416
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_rfc3676_space_stuff_attachment()

void mutt_rfc3676_space_stuff_attachment ( struct Body b,
const char *  filename 
)

Stuff attachments.

Parameters
bEmail Body (OPTIONAL)
filenameAttachment file

This routine is used when filtering rfc3676 attachments.

If b is provided, the function will verify that the Email is format-flowed. The filename will be unstuffed, not b->filename or b->fp.

Definition at line 536 of file rfc3676.c.

537 {
538  if (!filename)
539  return;
540 
541  if (b && !mutt_rfc3676_is_format_flowed(b))
542  return;
543 
544  rfc3676_space_stuff(filename, false);
545 }
bool mutt_rfc3676_is_format_flowed(struct Body *b)
Is the Email "format-flowed"?
Definition: rfc3676.c:391
static void rfc3676_space_stuff(const char *filename, bool unstuff)
Perform required RFC3676 space stuffing.
Definition: rfc3676.c:416
+ Here is the call graph for this function:
+ Here is the caller graph for this function: