Difference between revisions of "C-escape"
From Mailutils
Jump to navigationJump to searchm |
m |
||
Line 23: | Line 23: | ||
initialize_input_stream (&stream); | initialize_input_stream (&stream); | ||
− | rc = | + | rc = mu_filter_create (&flt, input, "C-escape", MU_FILTER_DECODE, MU_STREAM_READ); |
</source> | </source> | ||
[[Category:Filters]] | [[Category:Filters]] | ||
[[Category:C API]] | [[Category:C API]] |
Revision as of 19:10, 5 September 2015
The C-escape filter replaces C escape sequences with the corresponding control character and vice versa.
In encode mode, recognized control characters are replaced with their C escapes. For example, newline (ASCII 10) becomes \n, horizontal tab (ASCII 9) becomes \t, etc.
In decode mode, the reverse operation is performed, i.e. each C escape is replaced with the corresponding character. Unrecognized escape sequences are copied verbatim.
Only named escapes are supported, i.e.: \\, \a, \b, \f, \n, \r, \t, \v.
This filter does not take arguments.
The following object, declared in mailutils/filter.h describes the C-escape filter:
extern mu_filter_record_t mu_c_escape_filter;
The example below shows how to create an instance of this filter in decode mode for reading:
int rc; /* Return code */
mu_stream_t flt; /* Filter stream */
mu_stream_t input; /* Input stream */
initialize_input_stream (&stream);
rc = mu_filter_create (&flt, input, "C-escape", MU_FILTER_DECODE, MU_STREAM_READ);