File: filter_pipe.texi

package info (click to toggle)
mailfromd 9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,512 kB
  • sloc: ansic: 56,882; sh: 22,979; yacc: 4,130; lex: 1,428; makefile: 928; lisp: 488; awk: 393; perl: 319; sed: 25
file content (278 lines) | stat: -rw-r--r-- 10,047 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
@c Copyright (C) 2005--2025 Sergey Poznyakoff
@c Permission is granted to copy, distribute and/or modify this document
@c under the terms of the GNU Free Documentation License, Version 1.3 or
@c any later version published by the Free Software Foundation; with no
@c Invariant Sections, with the Front and Back-Cover texts at your option. 
@cindex pipe
@cindex filter pipe
A @dfn{filter pipe} is a string consisting of filter invocations
delimited by pipe characters (@samp{|}).  Each invocation 
is a filter name optionally followed by a comma-separated list of
parameters.  Most filters can operate in two modes: @dfn{encode} and
@dfn{decode}.  Unless specified otherwise, filters are invoked in
encode mode.  To change the mode, the @code{encode} and @code{decode}
meta-filters are provided.  Argments to these filters are filter pipes
that will be executed in the corresponding mode.

The following Mailutils filters are available:

@deffn {Filter} 7bit
In encode mode, converts its input into 7-bit ASCII, by clearing the
8th bit on each processed byte. 

In decode mode, it operates exactly as the 8bit filter, i.e. copies
its input to the output verbatim.

The filter takes no arguments.
@end deffn

@deffn {Filter} 8bit
@deffnx {Filter} binary
Copies its input to output verbatim.
@end deffn

@deffn {Filter} base64
@deffnx {Filter} B
Encodes or decodes the input using the @code{base64} encoding.

The only difference between @code{BASE64} and @code{B} is that, in
encode mode, the former limits each ouput line length to 76 octets,
whereas the latter produces a contiguous stream of base64 data.

In decode mode, both filters operate exactly the same way.
@end deffn

@deffn {Filter} charset (@var{cset})
@deffnx {Filter} charset (@var{cset}, @var{fallback})
A convenience interface to the @code{iconv} filter, available for use
only in the @code{message_body_to_stream} function.  It decodes the
part of a MIME message from its original character set, which is
determined from the value of the @code{Content-Type} header, to the
destination character set @var{cset}.  Optional @var{fallback}
parameter specifies the representation fallback to be used for octets
that cannot be converted between the charater sets.  Its use is
described in @xref{iconv}.

This filter is normally takes its input from the @code{mimedecode}
filter, as in:

@example
message_body_to_stream(fd, msg, 'mimedecode|charset(utf-8)')
@end example

@xref{mimedecode}, for a detailed discussion.
@end deffn

@deffn {Filter} crlf
@deffnx {Filter} rfc822
Converts line separators from LF (ASCII 10) to CRLF (ASCII 13 10) and
vice-versa.

In decode mode, translates each CRLF to LF.  Takes no arguments.

In encode mode, translates each LF to CRLF.  If an optional argument
@samp{-n} is given, produces a @dfn{normalized} output, by preserving
each input CRLF sequence untouched (otherwise such sequences will be
are translated to CR CR LF).
@end deffn

@deffn {Filter} crlfdot
In encode mode, replaces each LF (@samp{\n} or ASCII 10) character with
CRLF (@samp{\r\n}, ASCII 13 10), and @dfn{byte-stuffs} the output by
producing an additional @samp{.} in front of any @samp{.} appearing at 
the beginning of a line in input.  Upon end of input, it outputs
additional @samp{.\r\n}, if the last output character was @samp{\n}, or
@samp{\r\n.\r\n} otherwise.

If supplied the @samp{-n} argument, it preserves each CRLF input
sequence untranslated (see the @code{CRLF} above).

In decode mode, the reverse is performed: each CRLF is replaced with a
single LF byte, and additional dots are removed from beginning of
lines.  A single dot on a line by itself marks the end of the stream and
causes the filter to return EOF.
@end deffn

@deffn {Filter} dot
In encode mode, @dfn{byte-stuffs} the input by outputting an
additional dot (@samp{.}) in front of any dot appearing at the
beginning of a line.  Upon encountering end of input, it outputs
additional @samp{.\n}.

In decode mode, the reverse is performed: additional dots are
removed from beginning of lines.  A single dot on a line by itself
(i.e. the sequence @samp{\n.\n}) marks the end of the stream and
causes the filter to return EOF.

This filter doesn't take arguments.
@end deffn

@deffn {Filter} from
Performs a traditional UNIX processing of lines starting with a
@samp{From} followed by a space character.

In encode mode, each @samp{From } at the beginning of a line is
replaced by @samp{>From }.

In decode mode, the reverse operation is performed: initial
greater-then sign (@samp{>}) is removed from any line starting with 
@samp{>From }.

The filter takes no arguments.
@end deffn

@deffn {Filter} fromrd
MBOXRD-compatible processing of envelope lines.

In encode mode, each @samp{From } optionally preceded by any number of
contiguous @samp{>} characters and appearing at the beginning of a
line is prefixed by another @samp{>} character on output.

In decode mode, the reverse operation is performed: initial
greater-then sign (@samp{>}) is removed from any line starting with
one or more @samp{>} characters followed by @samp{From }.
@end deffn

@deffn {Filter} header
This filter treats its input as a RFC-2822 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 and takes no arguments.
@end deffn

@anchor{iconv}
@deffn {Filter} iconv (@var{src}, @var{dst} [, @var{fallback}])
Converts input from character set @var{src} to @var{dst}.  The filter
works the same way in both decode and encode modes.

@anchor{iconv fallback}
It takes two mandatory arguments: the names of the input (@var{src})
and output (@var{dst}) charset.  Optional third argument specifies
what to do when an illegal character sequence is encountered in the
input stream.  Its possible values are:

@table @option
@kwindex none
@item none
Raise a @code{e_ilseq} exception.

@kwindex copy-pass
@item copy-pass
Copy the offending octet to the output verbatim and continue
conversion from the next octet.

@kwindex copy-octal
@item copy-octal
Print the offending octet to the output using the C octal conversion
and continue conversion from the next octet.
@end table

The default is @code{copy-octal}.

The following example creates a @code{iconv} filter for converting from
@code{iso-8859-2} to @code{utf-8}, raising the @code{e_ilseq}
exception on the first conversion error:

@example
iconv(iso-8859-2, utf-8, none)
@end example
@end deffn

@deffn {Filter} inline-comment
@deffnx {Filter} inline-comment (@var{str}, [options])
In decode mode, the filter removes from the input all lines beginning
with a given @dfn{inline comment sequence} @var{str}.  The default comment
sequence is @samp{;} (a semicolon).

The following options modify the default behavior:

@table @option
@item -i, @var{str}
Emit line number information after each contiguous sequence of removed
lines.  The argument @var{str} supplies an @dfn{information starter}
-- a sequence of characters which is output before the actual line number.

@item -r
Remove empty lines, i.e. the lines that contain only whitespace characters.

@item -s
Squeeze whitespace.  Each sequence of two or more whitespace
characters encountered on input is replaced by a single space
character on output.

@item -S
A @dfn{whitespace-must-follow} mode.  A comment sequence is recognized
only if followed by a whitespace character.  The character itself is
retained on output.
@end table

In encode mode the @code{inline-comment} filter adds a comment-starter
sequence at the beginning of each line.  The default comment-starter
is @samp{;} and can be changed by specifying the desired comment
starter as the first argument.

The only option supported in this mode is @option{-S}, which enables the
whitespace-must-follow mode, in which a single space character (ASCII
20) is output after each comment sequence.
@end deffn
      
@deffn {Filter} linecon
@deffnx {Filter} linecon (-i, @var{str})
Implements a familiar UNIX line-continuation facility.  The filter
removes from itsinput stream any newline character immediately
preceded by a backslash.  This filter operates only in decode mode.

If given the arguments (@samp{-i}, @var{str}), enables the @dfn{line
number information facility}.  This facility emits current input line
number (prefixed with @var{str}) after each contiguous sequence of one
or more removed newline characters.  It is useful for implementing
parsers which are normally supposed to identify eventual erroneous
lines with their input line numbers.
@end deffn

@deffn {Filter} linelen (@var{n})
Limits the length of each output line 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 newline characters present in the input are taken into
account when computing the input line length.
@end deffn

@deffn {Filter} mimedecode
This is a domain-specific filter available for use only with the
@code{message_body_to_stream} function.  It decodes the part of
a MIME message from whatever encoding that was used to store it
in the message to a stream of bytes.  @xref{mimedecode}.
@end deffn

@deffn {Filter} quoted-printable
@deffnx {Filter} Q
Encodes or decodes the input using the @dfn{quoted-printable}
encoding.
@end deffn

@deffn {Filter} XML
In encode mode, the @code{xml} filter converts input stream (which must
contain valid UTF-8 characters) into a form suitable for inclusion into
a XML or HTML document, i.e. it replaces @samp{<}, @samp{>}, and
@samp{&} with @samp{&lt;}, @samp{&gt;}, and @samp{&amp;},
correspondingly, and replaces invalid characters with their numeric
character reference representation.

In decode mode, a reverse operation is performed.

The filter does not take arguments.
@end deffn