forked from project-jedi/jcl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMime.dtx
220 lines (220 loc) · 7.71 KB
/
Mime.dtx
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
@@EJclMimeError
<GROUP MIME>
Summary:
Base class for exceptions raised in response to MIME encoding/decoding errors.
Description:
The EJclMimeError class is the exception class that is raised when an error occurs
within one of MIME-routines.
Donator:
Ralf Junker
--------------------------------------------------------------------------------
@@MimeEncodeString
<GROUP MIME>
Summary:
MIME-Encodes a string.
Description:
MimeEncodeString encodes the supplied string with a MIME64 encoding algorithm.
Parameters:
s - String to be encoded.
Result:
MIME encoded string.
See also:
MimeDecodeString
MimeEncodeStream
MimeEncode
MimeEncodedSize
Donator:
Ralf Junker
--------------------------------------------------------------------------------
@@MimeDecodeString
<GROUP MIME>
Summary:
MIME-Decodes a string.
Description:
MimeDecodeString decodes the supplied MIME64-encoded string.
Parameters:
s - MIME64-encoded string to be decoded.
Result:
Decoded string.
See also:
MimeEncodeString
MimeDecodeStream
MimeDecode
MimeDecodedSize
Donator:
Ralf Junker
--------------------------------------------------------------------------------
@@MimeEncodeStream
<GROUP MIME>
Summary:
MIME-Encodes a stream.
Description:
MimeEncodeStream encodes InputStream starting at the current position up to the
end and writes the result to OutputStream, again starting at the current
position. When done, it will not reset either stream's positions, but leave
InputStream at the last read position (i.e. the end) and OutputStream at the
last write position (which can, but is not always the end).
To encode the entire InputStream from beginning to end, make sure that its
offset is positioned at the beginning of the stream. You can force this by
issuing Seek (0, soFromBeginning) before calling this function.
Parameters:
InputStream - Input stream to be encoded.
OutputStream - Output stream.
See also:
MimeDecodeStream
MimeEncodeString
MimeEncode
MimeEncodedSize
Donator:
Ralf Junker
--------------------------------------------------------------------------------
@@MimeDecodeStream
<GROUP MIME>
Summary:
Decodes a MIME-encoded stream.
Description:
MimeDecodeStream decodes InputStream starting at the current position up to the
end and writes the result to OutputStream, again starting at the current
position. When done, it will not reset either stream's positions, but leave
InputStream at the last read position (i.e. the end) and OutputStream at the
last write position (which can, but is not always the end).
To decode the entire InputStream from beginning to end, make sure that its
offset is positioned at the beginning of the stream. You can force this by
issuing Seek (0, soFromBeginning) before calling this function.
Parameters:
InputStream - Input stream to be decoded.
OutputStream - Output stream.
See also:
MimeEncodeStream
MimeDecodeString
MimeDecode
MimeDecodedSize
Donator:
Ralf Junker
--------------------------------------------------------------------------------
@@MimeEncodedSize
<GROUP MIME>
Summary:
Calculates the output size for encoding.
Description:
MimeEncodedSize calculates the output size of I MimeEncoded bytes. Use for MimeEncode only.
Parameters:
I - Number of bytes to encode.
Result:
Number of bytes needed for encoding.
See also:
MimeEncode
MimeDecodedSize
Donator:
Ralf Junker
--------------------------------------------------------------------------------
@@MimeDecodedSize
<GROUP MIME>
Summary:
Calculates the output size for decoding.
Description:
MimeDecodedSize calculates the maximum output size of I MimeDecoded bytes. You
may use it for MimeDecode to calculate the maximum amount of memory required for
decoding in one single pass.
Parameters:
I - Number of bytes to decode.
Result:
Maximum number of bytes needed for decoding.
See also:
MimeDecode
MimeEncodedSize
Donator:
Ralf Junker
--------------------------------------------------------------------------------
@@MimeEncode
<GROUP MIME>
Summary:
The primary Mime encoding routine.
Description:
MimeEncode is the primary MIME-encoding routine and is used by MimeEncodeString
and MimeEncodeStream but can also be used directly.
CAUTION: OutputBuffer must have enough memory allocated to take all encoded
output. MimeEncodedSize(InputBytesCount) calculates this amount in bytes.
MimeEncode will then fill the entire OutputBuffer, so there is no
OutputBytesCount result for this procedure. Preallocating all memory at once (as
required by MimeEncode) avoids the time-consuming process of reallocation.
Parameters:
InputBuffer - Points to the memory block to encode.
InputByteCount - Number of bytes to encode.
OutputBuffer - Points to the output buffer.
Notes:
If not all data fits into memory at once, you can use MimeEncode multiple times, but you must be very careful about the size of the InputBuffer. It should be set to a number that is a multiple of 3.
See also:
MimeEncodedSize
MimeDecode
Donator:
Ralf Junker
--------------------------------------------------------------------------------
@@MimeDecode
<GROUP MIME>
Summary:
The primary Mime decoding routine.
Description:
MimeDecode is the primary MIME-decoding routine and can also be used directly.
CAUTION: OutputBuffer must have enough memory allocated to take all
output. MimeDecodedSize(InputBytesCount) calculates this amount in bytes. There is no
guarantee that all output will be filled after decoding. MimeDecode therefore
returns the actual number of bytes written to OutputBuffer. Preallocating all
memory at once (as is required by MimeDecode) avoids the time-consuming process
of reallocation. After calling MimeDecode, simply cut the allocated memory down
to OutputBytesCount, i.e. SetLength(OutString, OutputBytesCount).
Parameters:
InputBuffer - Points to the memory block to encode.
InputBytesCount - Number of bytes to encode.
OutputBuffer - Points to the output buffer.
Result:
Number of bytes actually written to the OutputBuffer.
See also:
MimeDecodedSize
MimeEncode
Donator:
Ralf Junker
--------------------------------------------------------------------------------
@@MimeDecodePartial
<GROUP MIME>
Summary:
MIME decode a chunk of data in a multi-phase decoding routine.
Description:
MIME decodes a chunk of data in a mutli-phase decoding routine. It is used
within MimeDecodeString, MimeDecodeStream, and MimeDecode, but can also be used
directly.
Parameters:
InputBuffer - Buffer to decode.
InputBytesCount - Number of bytes to decode.
OutputBuffer - Points to the output buffer.
ByteBuffer - Bytes of buffer from previous call.
ByteBufferSpace - Number of bytes to read before ByteBuffer is full.
Result:
Number of bytes actually written to the OutputBuffer.
Notes:
On first call ByteBuffer should be 0 (zero) and ByteBufferSpace should be 4. The values returned in these parameters should be used in the next call to MimeDecodePartial or MimeDecodePartialEnd.
See also:
MimeDecodePartialEnd
Donator:
Ralf Junker
--------------------------------------------------------------------------------
@@MimeDecodePartialEnd
<GROUP MIME>
Summary:
MIME decode the last chunk of data in a multi-phase decoding routine.
Description:
MIME decodes the last chunk of data in a mutli-phase decoding routine. It is
used within MimeDecodeString, MimeDecodeStream, and MimeDecode, but can also be
used directly.
Parameters:
OutputBuffer - Points to the output buffer.
ByteBuffer - Bytes of buffer from previous call.
ByteBufferSpace - Number of bytes to read before ByteBuffer is full
Result:
Number of bytes actually written to the OutputBuffer.
Notes:
ByteBuffer and ByteBufferSpace are the values returned in the last call to MimeDecodePartial.
See also:
MimeDecodePartial
Donator:
Ralf Junker