Difference between revisions of "From (filter)"

From Mailutils
Jump to navigationJump to search
m
 
Line 8: Line 8:
 
The following code creates an instance of read-only <tt>from</tt> stream which adds the ''greater-than'' character to each  "<tt>>From </tt>" at the beginning of a line (the <tt>mu_stream_t input</tt> is supposed to have been initialized previously):
 
The following code creates an instance of read-only <tt>from</tt> stream which adds the ''greater-than'' character to each  "<tt>>From </tt>" at the beginning of a line (the <tt>mu_stream_t input</tt> is supposed to have been initialized previously):
  
<source lang="C">
+
<syntaxhighlight lang="C">
 
   int rc;          /* Return code */
 
   int rc;          /* Return code */
 
   mu_stream_t flt; /* Filter stream */
 
   mu_stream_t flt; /* Filter stream */
  
 
   rc = mu_filter_create (&flt, input, "from", MU_FILTER_ENCODE, MU_STREAM_READ);
 
   rc = mu_filter_create (&flt, input, "from", MU_FILTER_ENCODE, MU_STREAM_READ);
</source>  
+
</syntaxhighlight>  
  
 
The object describing this filter is declared in <tt>mailutils/filter.h</tt> as follows:
 
The object describing this filter is declared in <tt>mailutils/filter.h</tt> as follows:
  
<source lang="C">
+
<syntaxhighlight lang="C">
 
extern mu_filter_record_t mu_from_filter;
 
extern mu_filter_record_t mu_from_filter;
</source>
+
</syntaxhighlight>
  
 
[[Category:Filters]]
 
[[Category:Filters]]
 
[[Category:C API]]
 
[[Category:C API]]

Latest revision as of 13:22, 16 October 2023

The from filter performs a traditional UNIX processing of lines starting with a From followed by a space character.

Encode mode
In encode mode, each "From " at the beginning of a line is replaced by ">From "
Decode mode
In decode mode, the reverse operation is performed: initial greater-then sign (>) is removed from any line starting with ">From ".

The following code creates an instance of read-only from stream which adds the greater-than character to each ">From " at the beginning of a line (the mu_stream_t input is supposed to have been initialized previously):

  int rc;          /* Return code */
  mu_stream_t flt; /* Filter stream */

  rc = mu_filter_create (&flt, input, "from", MU_FILTER_ENCODE, MU_STREAM_READ);

The object describing this filter is declared in mailutils/filter.h as follows:

extern mu_filter_record_t mu_from_filter;