Difference between revisions of "Linelen"
m |
|||
Line 6: | Line 6: | ||
The following code creates an instance of read-only <tt>linelen</tt> stream which breaks the input stream (<tt>mu_stream_t input</tt>, which is supposed to have been initialized previously) to lines of no more than 76 characters. | The following code creates an instance of read-only <tt>linelen</tt> stream which breaks the input stream (<tt>mu_stream_t input</tt>, which is supposed to have been initialized previously) to lines of no more than 76 characters. | ||
− | < | + | <syntaxhighlight lang="C"> |
int rc; /* Return code */ | int rc; /* Return code */ | ||
mu_stream_t flt; /* Filter stream */ | mu_stream_t flt; /* Filter stream */ | ||
Line 12: | Line 12: | ||
rc = mu_filter_chain_create (&flt, input, MU_FILTER_ENCODE, MU_STREAM_READ, 2, argv); | rc = mu_filter_chain_create (&flt, input, MU_FILTER_ENCODE, MU_STREAM_READ, 2, argv); | ||
− | </ | + | </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: | ||
− | < | + | <syntaxhighlight lang="C"> |
extern mu_filter_record_t mu_linelen_filter; | extern mu_filter_record_t mu_linelen_filter; | ||
− | </ | + | </syntaxhighlight> |
== See also == | == See also == |
Latest revision as of 13:25, 16 October 2023
The linelen filter limits the length of the output lines to a certain number of octets. It operates in encode mode only and requires a single parameter: the desired output length in octets. This filter makes no attempt to analyze the lexical structure of the input: the newline caracters are inserted when the length of the output line reaches a predefined maximum. Any "\n" characters present in the input are taken into account when computing the input line length.
The following code creates an instance of read-only linelen stream which breaks the input stream (mu_stream_t input, which is supposed to have been initialized previously) to lines of no more than 76 characters.
int rc; /* Return code */
mu_stream_t flt; /* Filter stream */
char *argv[] = { "linelen", "76", NULL };
rc = mu_filter_chain_create (&flt, input, MU_FILTER_ENCODE, MU_STREAM_READ, 2, argv);
The object describing this filter is declared in mailutils/filter.h as follows:
extern mu_filter_record_t mu_linelen_filter;