Difference between revisions of "Header (filter)"

From Mailutils
Jump to navigationJump to search
m
m
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
 
An example of its usage:
 
An example of its usage:
  
<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 */
 
   mu_stream_t input; /* Input stream */
 
   mu_stream_t input; /* Input stream */
  
   initialize_input_stream (&stream);
+
   initialize_input_stream (&input);
   rc = mu_filter_stream_create (&flt, input, "header", MU_FILTER_DECODE, MU_STREAM_READ);
+
   rc = mu_filter_create (&flt, input, "header", MU_FILTER_DECODE, MU_STREAM_READ);
</source>
+
</syntaxhighlight>
  
 
Input lines must be separated by single "\n" (LF) characters.  If you want this filter to operate on CRLF-separated lines, [[filter chain|chain]] it with a [[CRLF]] filter, as shown in the example below:
 
Input lines must be separated by single "\n" (LF) characters.  If you want this filter to operate on CRLF-separated lines, [[filter chain|chain]] it with a [[CRLF]] filter, as shown in the example below:
  
<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 */
Line 20: Line 20:
  
 
   rc = mu_filter_chain_create (&flt, input, MU_FILTER_DECODE, MU_STREAM_READ, 3, argv);
 
   rc = mu_filter_chain_create (&flt, input, MU_FILTER_DECODE, MU_STREAM_READ, 3, argv);
</source>
+
</syntaxhighlight>
  
 
== See also ==
 
== See also ==

Latest revision as of 13:16, 16 October 2023

The header filter regards its input as a RFC-822 email message. It extracts its header part (i.e. everything up to the first empty line) and copies it to the output. The body of the message is ignored. The filter operates only in decode mode.

An example of its usage:

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

  initialize_input_stream (&input);
  rc = mu_filter_create (&flt, input, "header", MU_FILTER_DECODE, MU_STREAM_READ);

Input lines must be separated by single "\n" (LF) characters. If you want this filter to operate on CRLF-separated lines, chain it with a CRLF filter, as shown in the example below:

  int rc;          /* Return code */
  mu_stream_t flt; /* Filter stream */
  char *argv[] = { "CRLF", "+", "header", NULL };

  rc = mu_filter_chain_create (&flt, input, MU_FILTER_DECODE, MU_STREAM_READ, 3, argv);

See also