NeoMutt  2020-11-20
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 "email/lib.h"
#include "gui/lib.h"
#include "rfc3676.h"
#include "mutt_globals.h"
#include "muttlib.h"
#include "state.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...
 

Variables

bool C_ReflowSpaceQuotes
 Config: Insert spaces into reply quotes for 'format=flowed' messages. More...
 
short C_ReflowWrap
 Config: Maximum paragraph width for reformatting 'format=flowed' text. 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 49 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 66 of file rfc3676.c.

67 {
68  int quoted = 0;
69  const char *p = line;
70 
71  while (p && (*p == '>'))
72  {
73  quoted++;
74  p++;
75  }
76 
77  return quoted;
78 }
+ 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
trueIf spaces should be added

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

Definition at line 90 of file rfc3676.c.

91 {
92  /* Allow quote spacing in the pager even for `$text_flowed`,
93  * but obviously not when replying. */
94  if (C_TextFlowed && (s->flags & MUTT_REPLYING))
95  return 0;
96 
97  return C_ReflowSpaceQuotes;
98 }
StateFlags flags
Flags, e.g. MUTT_DISPLAY.
Definition: state.h:49
#define MUTT_REPLYING
Are we replying?
Definition: state.h:38
bool C_ReflowSpaceQuotes
Config: Insert spaces into reply quotes for &#39;format=flowed&#39; messages.
Definition: rfc3676.c:46
WHERE bool C_TextFlowed
Config: Generate &#39;format=flowed&#39; messages.
Definition: mutt_globals.h:166
+ 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
trueIf spaces should be added

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

Definition at line 111 of file rfc3676.c.

112 {
113  if (s->flags & MUTT_REPLYING)
114  return false;
115 
116  if (space_quotes(s))
117  return false;
118 
119  if (!ql && !s->prefix)
120  return false;
121 
122  /* The prefix will add its own space */
123  if (!C_TextFlowed && !ql && s->prefix)
124  return false;
125 
126  return true;
127 }
static int space_quotes(struct State *s)
Should we add spaces between quote levels.
Definition: rfc3676.c:90
char * prefix
String to add to the beginning of each output line.
Definition: state.h:48
StateFlags flags
Flags, e.g. MUTT_DISPLAY.
Definition: state.h:49
#define MUTT_REPLYING
Are we replying?
Definition: state.h:38
WHERE bool C_TextFlowed
Config: Generate &#39;format=flowed&#39; messages.
Definition: mutt_globals.h:166
+ 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  if (C_TextFlowed)
145  ql++;
146  else
147  {
148  state_puts(s, s->prefix);
149  wid = mutt_strwidth(s->prefix);
150  }
151  }
152  for (int i = 0; i < ql; i++)
153  {
154  state_putc(s, '>');
155  if (space_quotes(s))
156  state_putc(s, ' ');
157  }
158  if (add_suffix)
159  state_putc(s, ' ');
160 
161  if (space_quotes(s))
162  ql *= 2;
163 
164  return ql + add_suffix + wid;
165 }
#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:90
char * prefix
String to add to the beginning of each output line.
Definition: state.h:48
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:1359
#define state_putc(STATE, STR)
Definition: state.h:56
WHERE bool C_TextFlowed
Config: Generate &#39;format=flowed&#39; messages.
Definition: mutt_globals.h:166
+ 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 172 of file rfc3676.c.

173 {
174  if (fst->width > 0)
175  {
176  state_putc(s, '\n');
177  fst->width = 0;
178  }
179  fst->spaces = 0;
180 }
size_t spaces
Definition: rfc3676.c:57
size_t width
Definition: rfc3676.c:56
#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 191 of file rfc3676.c.

192 {
193  const int screen_width = (s->flags & MUTT_DISPLAY) ? s->wraplen : 80;
194  int width = mutt_window_wrap_cols(screen_width, C_ReflowWrap);
195  if (C_TextFlowed && (s->flags & MUTT_REPLYING))
196  {
197  /* When replying, force a wrap at FLOWED_MAX to comply with RFC3676
198  * guidelines */
199  if (width > FLOWED_MAX)
200  width = FLOWED_MAX;
201  ql++; /* When replying, we will add an additional quote level */
202  }
203  /* adjust the paragraph width subtracting the number of prefix chars */
204  width -= space_quotes(s) ? ql * 2 : ql;
205  /* When displaying (not replying), there may be a space between the prefix
206  * string and the paragraph */
207  if (add_quote_suffix(s, ql))
208  width--;
209  /* failsafe for really long quotes */
210  if (width <= 0)
211  width = FLOWED_MAX; /* arbitrary, since the line will wrap */
212  return width;
213 }
#define MUTT_DISPLAY
Output is displayed to the user.
Definition: state.h:32
static bool add_quote_suffix(struct State *s, int ql)
Should we add a trailing space to quotes.
Definition: rfc3676.c:111
static int space_quotes(struct State *s)
Should we add spaces between quote levels.
Definition: rfc3676.c:90
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:477
#define FLOWED_MAX
Definition: rfc3676.c:49
#define MUTT_REPLYING
Are we replying?
Definition: state.h:38
short C_ReflowWrap
Config: Maximum paragraph width for reformatting &#39;format=flowed&#39; text.
Definition: rfc3676.c:47
WHERE bool C_TextFlowed
Config: Generate &#39;format=flowed&#39; messages.
Definition: mutt_globals.h:166
+ 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 223 of file rfc3676.c.

225 {
226  size_t width, w, words = 0;
227  char *p = NULL;
228  char last;
229 
230  if (!line || (*line == '\0'))
231  {
232  /* flush current paragraph (if any) first */
233  flush_par(s, fst);
234  print_indent(ql, s, 0);
235  state_putc(s, '\n');
236  return;
237  }
238 
239  width = quote_width(s, ql);
240  last = line[mutt_str_len(line) - 1];
241 
242  mutt_debug(LL_DEBUG5, "f=f: line [%s], width = %ld, spaces = %lu\n", line,
243  (long) width, fst->spaces);
244 
245  for (words = 0; (p = strsep(&line, " "));)
246  {
247  mutt_debug(LL_DEBUG5, "f=f: word [%s], width: %lu, remaining = [%s]\n", p,
248  fst->width, line);
249 
250  /* remember number of spaces */
251  if (*p == '\0')
252  {
253  mutt_debug(LL_DEBUG3, "f=f: additional space\n");
254  fst->spaces++;
255  continue;
256  }
257  /* there's exactly one space prior to every but the first word */
258  if (words)
259  fst->spaces++;
260 
261  w = mutt_strwidth(p);
262  /* see if we need to break the line but make sure the first word is put on
263  * the line regardless; if for DelSp=yes only one trailing space is used,
264  * we probably have a long word that we should break within (we leave that
265  * up to the pager or user) */
266  if (!(!fst->spaces && fst->delsp && (last != ' ')) && (w < width) &&
267  (w + fst->width + fst->spaces > width))
268  {
269  mutt_debug(LL_DEBUG3, "f=f: break line at %lu, %lu spaces left\n",
270  fst->width, fst->spaces);
271  /* only honor trailing spaces for format=flowed replies */
272  if (C_TextFlowed)
273  for (; fst->spaces; fst->spaces--)
274  state_putc(s, ' ');
275  state_putc(s, '\n');
276  fst->width = 0;
277  fst->spaces = 0;
278  words = 0;
279  }
280 
281  if (!words && !fst->width)
282  fst->width = print_indent(ql, s, add_quote_suffix(s, ql));
283  fst->width += w + fst->spaces;
284  for (; fst->spaces; fst->spaces--)
285  state_putc(s, ' ');
286  state_puts(s, p);
287  words++;
288  }
289 
290  if (term)
291  flush_par(s, fst);
292 }
#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:111
static int quote_width(struct State *s, int ql)
Calculate the paragraph width based upon the quote level.
Definition: rfc3676.c:191
size_t spaces
Definition: rfc3676.c:57
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:1359
size_t width
Definition: rfc3676.c:56
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:172
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
#define state_putc(STATE, STR)
Definition: state.h:56
Log at debug level 5.
Definition: logging.h:44
bool delsp
Definition: rfc3676.c:58
Log at debug level 3.
Definition: logging.h:42
WHERE bool C_TextFlowed
Config: Generate &#39;format=flowed&#39; messages.
Definition: mutt_globals.h:166
+ 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 301 of file rfc3676.c.

302 {
303  print_indent(ql, s, add_quote_suffix(s, ql));
304  if (line && *line)
305  state_puts(s, line);
306  state_putc(s, '\n');
307 
308  fst->width = 0;
309  fst->spaces = 0;
310 }
#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:111
size_t spaces
Definition: rfc3676.c:57
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:56
#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 316 of file rfc3676.c.

317 {
318  char *buf = NULL;
319  unsigned int quotelevel = 0;
320  bool delsp = false;
321  size_t sz = 0;
322  struct FlowedState fst = { 0 };
323 
324  /* respect DelSp of RFC3676 only with f=f parts */
325  char *t = mutt_param_get(&a->parameter, "delsp");
326  if (t)
327  {
328  delsp = mutt_istr_equal(t, "yes");
329  t = NULL;
330  fst.delsp = true;
331  }
332 
333  mutt_debug(LL_DEBUG3, "f=f: DelSp: %s\n", delsp ? "yes" : "no");
334 
335  while ((buf = mutt_file_read_line(buf, &sz, s->fp_in, NULL, 0)))
336  {
337  const size_t buf_len = mutt_str_len(buf);
338  const unsigned int newql = get_quote_level(buf);
339 
340  /* end flowed paragraph (if we're within one) if quoting level
341  * changes (should not but can happen, see RFC3676, sec. 4.5.) */
342  if (newql != quotelevel)
343  flush_par(s, &fst);
344 
345  quotelevel = newql;
346  int buf_off = newql;
347 
348  /* respect sender's space-stuffing by removing one leading space */
349  if (buf[buf_off] == ' ')
350  buf_off++;
351 
352  /* test for signature separator */
353  const unsigned int sigsep = mutt_str_equal(buf + buf_off, "-- ");
354 
355  /* a fixed line either has no trailing space or is the
356  * signature separator */
357  const bool fixed = (buf_len == buf_off) || (buf[buf_len - 1] != ' ') || sigsep;
358 
359  /* print fixed-and-standalone, fixed-and-empty and sigsep lines as
360  * fixed lines */
361  if ((fixed && ((fst.width == 0) || (buf_len == 0))) || sigsep)
362  {
363  /* if we're within a flowed paragraph, terminate it */
364  flush_par(s, &fst);
365  print_fixed_line(buf + buf_off, s, quotelevel, &fst);
366  continue;
367  }
368 
369  /* for DelSp=yes, we need to strip one SP prior to CRLF on flowed lines */
370  if (delsp && !fixed)
371  buf[buf_len - 1] = '\0';
372 
373  print_flowed_line(buf + buf_off, s, quotelevel, &fst, fixed);
374  }
375 
376  flush_par(s, &fst);
377 
378  FREE(&buf);
379  return 0;
380 }
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, int 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:66
static void print_fixed_line(const char *line, struct State *s, int ql, struct FlowedState *fst)
Print a fixed format line.
Definition: rfc3676.c:301
size_t width
Definition: rfc3676.c:56
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:54
#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:172
#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:223
bool delsp
Definition: rfc3676.c:58
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
booltrue, if "format-flowed"

Definition at line 387 of file rfc3676.c.

388 {
389  if (b && (b->type == TYPE_TEXT) && mutt_istr_equal("plain", b->subtype))
390  {
391  const char *format = mutt_param_get(&b->parameter, "format");
392  if (mutt_istr_equal("flowed", format))
393  return true;
394  }
395 
396  return false;
397 }
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 412 of file rfc3676.c.

413 {
414  FILE *fp_out = NULL;
415  char *buf = NULL;
416  size_t blen = 0;
417 
418  struct Buffer *tmpfile = mutt_buffer_pool_get();
419 
420  FILE *fp_in = mutt_file_fopen(filename, "r");
421  if (!fp_in)
422  goto bail;
423 
424  mutt_buffer_mktemp(tmpfile);
425  fp_out = mutt_file_fopen(mutt_b2s(tmpfile), "w+");
426  if (!fp_out)
427  goto bail;
428 
429  while ((buf = mutt_file_read_line(buf, &blen, fp_in, NULL, 0)) != NULL)
430  {
431  if (unstuff)
432  {
433  if (buf[0] == ' ')
434  fputs(buf + 1, fp_out);
435  else
436  fputs(buf, fp_out);
437  }
438  else
439  {
440  if ((buf[0] == ' ') || mutt_str_startswith(buf, "From "))
441  fputc(' ', fp_out);
442  fputs(buf, fp_out);
443  }
444  fputc('\n', fp_out);
445  }
446  FREE(&buf);
447  mutt_file_fclose(&fp_in);
448  mutt_file_fclose(&fp_out);
449  mutt_file_set_mtime(filename, mutt_b2s(tmpfile));
450 
451  fp_in = mutt_file_fopen(mutt_b2s(tmpfile), "r");
452  if (!fp_in)
453  goto bail;
454 
455  if ((truncate(filename, 0) == -1) || ((fp_out = mutt_file_fopen(filename, "a")) == NULL))
456  {
457  mutt_perror(filename);
458  goto bail;
459  }
460 
461  mutt_file_copy_stream(fp_in, fp_out);
462  mutt_file_set_mtime(mutt_b2s(tmpfile), filename);
463  unlink(mutt_b2s(tmpfile));
464 
465 bail:
466  mutt_file_fclose(&fp_in);
467  mutt_file_fclose(&fp_out);
468  mutt_buffer_pool_release(&tmpfile);
469 }
#define mutt_buffer_mktemp(buf)
Definition: muttlib.h:77
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:1003
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, int flags)
Read a line from a file.
Definition: file.c:667
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:153
#define mutt_b2s(buf)
Definition: buffer.h:41
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 FREE(x)
Definition: memory.h:40
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:588
+ 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 479 of file rfc3676.c.

480 {
481  if (!e || !e->body || !e->body->filename)
482  return;
483 
485  rfc3676_space_stuff(e->body->filename, false);
486 }
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:387
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:412
+ 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 492 of file rfc3676.c.

493 {
494  if (!e || !e->body || !e->body->filename)
495  return;
496 
498  rfc3676_space_stuff(e->body->filename, true);
499 }
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:387
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:412
+ 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 511 of file rfc3676.c.

512 {
513  if (!filename)
514  return;
515 
516  if (b && !mutt_rfc3676_is_format_flowed(b))
517  return;
518 
519  rfc3676_space_stuff(filename, true);
520 }
bool mutt_rfc3676_is_format_flowed(struct Body *b)
Is the Email "format-flowed"?
Definition: rfc3676.c:387
static void rfc3676_space_stuff(const char *filename, bool unstuff)
Perform required RFC3676 space stuffing.
Definition: rfc3676.c:412
+ 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 532 of file rfc3676.c.

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

Variable Documentation

◆ C_ReflowSpaceQuotes

bool C_ReflowSpaceQuotes

Config: Insert spaces into reply quotes for 'format=flowed' messages.

Definition at line 46 of file rfc3676.c.

◆ C_ReflowWrap

short C_ReflowWrap

Config: Maximum paragraph width for reformatting 'format=flowed' text.

Definition at line 47 of file rfc3676.c.