… | |
… | |
2 | |
2 | |
3 | use Carp; |
3 | use Carp; |
4 | |
4 | |
5 | require Exporter; |
5 | require Exporter; |
6 | require DynaLoader; |
6 | require DynaLoader; |
7 | use AutoLoader; |
|
|
8 | |
7 | |
9 | $VERSION = 0.3; |
8 | $VERSION = "1.05"; |
10 | |
9 | |
11 | @ISA = qw(Exporter DynaLoader); |
10 | @ISA = qw(Exporter DynaLoader); |
12 | |
11 | |
13 | @_consts = qw( |
12 | @_consts = qw( |
14 | ACT_COPYING ACT_DECODING ACT_ENCODING ACT_IDLE ACT_SCANNING |
13 | ACT_COPYING ACT_DECODING ACT_ENCODING ACT_IDLE ACT_SCANNING |
… | |
… | |
99 | =head1 SYNOPSIS |
98 | =head1 SYNOPSIS |
100 | |
99 | |
101 | use Convert::UUlib ':all'; |
100 | use Convert::UUlib ':all'; |
102 | |
101 | |
103 | # read all the files named on the commandline and decode them |
102 | # read all the files named on the commandline and decode them |
|
|
103 | # into the CURRENT directory. See below for a longer example. |
104 | LoadFile($_) for @ARGV; |
104 | LoadFile $_ for @ARGV; |
105 | for($i=0; $uu=GetFileListItem($i); $i++) { |
105 | for (my $i = 0; my $uu = GetFileListItem $i; $i++) { |
106 | $uu->decode if $uu->state & FILE_OK; |
106 | if ($uu->state & FILE_OK) { |
|
|
107 | $uu->decode; |
|
|
108 | print $uu->filename, "\n"; |
|
|
109 | } |
107 | } |
110 | } |
108 | |
111 | |
109 | =head1 DESCRIPTION |
112 | =head1 DESCRIPTION |
110 | |
113 | |
111 | Read the file doc/library.pdf from the distribution for in-depth |
114 | Read the file doc/library.pdf from the distribution for in-depth |
… | |
… | |
148 | OPT_PROGRESS retrieve progress information |
151 | OPT_PROGRESS retrieve progress information |
149 | OPT_USETEXT handle text messages |
152 | OPT_USETEXT handle text messages |
150 | OPT_PREAMB handle Mime preambles/epilogues |
153 | OPT_PREAMB handle Mime preambles/epilogues |
151 | OPT_TINYB64 detect short B64 outside of Mime |
154 | OPT_TINYB64 detect short B64 outside of Mime |
152 | OPT_ENCEXT extension for single-part encoded files |
155 | OPT_ENCEXT extension for single-part encoded files |
153 | OPT_REMOVE remove input files after decoding |
156 | OPT_REMOVE remove input files after decoding (dangerous) |
154 | OPT_MOREMIME strict MIME adherence |
157 | OPT_MOREMIME strict MIME adherence |
155 | OPT_DOTDOT .. unescaping has not yet been done on input files |
158 | OPT_DOTDOT ".."-unescaping has not yet been done on input files |
156 | |
159 | |
157 | =head2 Result/Error codes |
160 | =head2 Result/Error codes |
158 | |
161 | |
159 | RET_OK everything went fine |
162 | RET_OK everything went fine |
160 | RET_IOERR I/O Error - examine errno |
163 | RET_IOERR I/O Error - examine errno |
… | |
… | |
171 | |
174 | |
172 | This code is zero, i.e. "false": |
175 | This code is zero, i.e. "false": |
173 | |
176 | |
174 | UUFILE_READ Read in, but not further processed |
177 | UUFILE_READ Read in, but not further processed |
175 | |
178 | |
176 | The following state codes are ored together: |
179 | The following state codes are or'ed together: |
177 | |
180 | |
178 | FILE_MISPART Missing Part(s) detected |
181 | FILE_MISPART Missing Part(s) detected |
179 | FILE_NOBEGIN No 'begin' found |
182 | FILE_NOBEGIN No 'begin' found |
180 | FILE_NOEND No 'end' found |
183 | FILE_NOEND No 'end' found |
181 | FILE_NODATA File does not contain valid uudata |
184 | FILE_NODATA File does not contain valid uudata |
… | |
… | |
197 | =head1 EXPORTED FUNCTIONS |
200 | =head1 EXPORTED FUNCTIONS |
198 | |
201 | |
199 | =head2 Initializing and cleanup |
202 | =head2 Initializing and cleanup |
200 | |
203 | |
201 | Initialize is automatically called when the module is loaded and allocates |
204 | Initialize is automatically called when the module is loaded and allocates |
202 | quite a bit of memory. CleanUp releases that again. |
205 | quite a small amount of memory for todays machines ;) CleanUp releases that |
|
|
206 | again. |
203 | |
207 | |
204 | Initialize; # not normally necessary |
208 | On my machine, a fairly complete decode with DBI backend needs about 10MB |
|
|
209 | RSS to decode 20000 files. |
|
|
210 | |
|
|
211 | =over 4 |
|
|
212 | |
|
|
213 | =item Initialize |
|
|
214 | |
|
|
215 | Not normally necessary, (re-)initializes the library. |
|
|
216 | |
|
|
217 | =item CleanUp |
|
|
218 | |
205 | CleanUp; # could be called at the end to release memory |
219 | Not normally necessary, could be called at the end to release memory |
|
|
220 | before starting a new decoding round. |
|
|
221 | |
|
|
222 | =back |
206 | |
223 | |
207 | =head2 Setting and querying options |
224 | =head2 Setting and querying options |
208 | |
225 | |
|
|
226 | =over 4 |
|
|
227 | |
209 | $option = GetOption OPT_xxx; |
228 | =item $option = GetOption OPT_xxx |
|
|
229 | |
210 | SetOption OPT_xxx, opt-value; |
230 | =item SetOption OPT_xxx, opt-value |
|
|
231 | |
|
|
232 | =back |
|
|
233 | |
|
|
234 | See the C<OPT_xxx> constants above to see which options exist. |
211 | |
235 | |
212 | =head2 Setting various callbacks |
236 | =head2 Setting various callbacks |
213 | |
237 | |
|
|
238 | =over 4 |
|
|
239 | |
214 | SetMsgCallback [callback-function]; |
240 | =item SetMsgCallback [callback-function] |
|
|
241 | |
215 | SetBusyCallback [callback-function]; |
242 | =item SetBusyCallback [callback-function] |
|
|
243 | |
216 | SetFileCallback [callback-function]; |
244 | =item SetFileCallback [callback-function] |
|
|
245 | |
217 | SetFNameFilter [callback-function]; |
246 | =item SetFNameFilter [callback-function] |
|
|
247 | |
|
|
248 | =back |
218 | |
249 | |
219 | =head2 Call the currently selected FNameFilter |
250 | =head2 Call the currently selected FNameFilter |
220 | |
251 | |
|
|
252 | =over 4 |
|
|
253 | |
221 | $file = FNameFilter $file; |
254 | =item $file = FNameFilter $file |
|
|
255 | |
|
|
256 | =back |
222 | |
257 | |
223 | =head2 Loading sourcefiles, optionally fuzzy merge and start decoding |
258 | =head2 Loading sourcefiles, optionally fuzzy merge and start decoding |
224 | |
259 | |
|
|
260 | =over 4 |
|
|
261 | |
225 | ($retval, $count) = LoadFile $fname, [$id, [$delflag]]; |
262 | =item ($retval, $count) = LoadFile $fname, [$id, [$delflag, [$partno]]] |
|
|
263 | |
|
|
264 | Load the given file and scan it for encoded contents. Optionally tag it |
|
|
265 | with the given id, and if C<$delflag> is true, delete the file after it |
|
|
266 | is no longer necessary. If you are certain of the part number, you can |
|
|
267 | specify it as the last argument. |
|
|
268 | |
|
|
269 | A better (usually faster) way of doing this is using the C<SetFNameFilter> |
|
|
270 | functionality. |
|
|
271 | |
226 | $retval = Smerge $pass; |
272 | =item $retval = Smerge $pass |
|
|
273 | |
|
|
274 | If you are desperate, try to call C<Smerge> with increasing C<$pass> |
|
|
275 | values, beginning at C<0>, to try to merge parts that usually would not |
|
|
276 | have been merged. |
|
|
277 | |
|
|
278 | Most probably this will result in garbled files, so never do this by |
|
|
279 | default. |
|
|
280 | |
227 | $item = GetFileListItem $item_number; |
281 | =item $item = GetFileListItem $item_number |
228 | |
282 | |
229 | =head2 The procedural interface is undocumented, use the following methods instead |
283 | Return the C<$item> structure for the C<$item_number>'th found file, or |
|
|
284 | C<undef> of no file with that number exists. |
230 | |
285 | |
|
|
286 | The first file has number C<0>, and the series has no holes, so you can |
|
|
287 | iterate over all files by starting with zero and incrementing until you |
|
|
288 | hit C<undef>. |
|
|
289 | |
|
|
290 | =back |
|
|
291 | |
|
|
292 | =head2 Decoding files |
|
|
293 | |
|
|
294 | =over 4 |
|
|
295 | |
231 | $retval = $item->rename($newname); |
296 | =item $retval = $item->rename($newname) |
|
|
297 | |
|
|
298 | Change the ondisk filename where the decoded file will be saved. |
|
|
299 | |
232 | $retval = $item->decode_temp; |
300 | =item $retval = $item->decode_temp |
|
|
301 | |
|
|
302 | Decode the file into a temporary location, use C<< $item->infile >> to |
|
|
303 | retrieve the temporary filename. |
|
|
304 | |
233 | $retval = $item->remove_temp; |
305 | =item $retval = $item->remove_temp |
|
|
306 | |
|
|
307 | Remove the temporarily decoded file again. |
|
|
308 | |
234 | $retval = $item->decode([$target_path]); |
309 | =item $retval = $item->decode([$target_path]) |
|
|
310 | |
|
|
311 | Decode the file to it's destination, or the given target path. |
|
|
312 | |
235 | $retval = $item->info(callback-function); |
313 | =item $retval = $item->info(callback-function) |
|
|
314 | |
|
|
315 | =back |
236 | |
316 | |
237 | =head2 Querying (and setting) item attributes |
317 | =head2 Querying (and setting) item attributes |
238 | |
318 | |
|
|
319 | =over 4 |
|
|
320 | |
239 | $state = $item->state; |
321 | =item $state = $item->state |
|
|
322 | |
240 | $mode = $item->mode([newmode]); |
323 | =item $mode = $item->mode([newmode]) |
|
|
324 | |
241 | $uudet = $item->uudet; |
325 | =item $uudet = $item->uudet |
|
|
326 | |
242 | $size = $item->size; |
327 | =item $size = $item->size |
|
|
328 | |
243 | $filename = $item->filename([newfilename}); |
329 | =item $filename = $item->filename([newfilename}) |
|
|
330 | |
244 | $subfname = $item->subfname; |
331 | =item $subfname = $item->subfname |
|
|
332 | |
245 | $mimeid = $item->mimeid; |
333 | =item $mimeid = $item->mimeid |
|
|
334 | |
246 | $mimetype = $item->mimetype; |
335 | =item $mimetype = $item->mimetype |
|
|
336 | |
247 | $binfile = $item->binfile; |
337 | =item $binfile = $item->binfile |
248 | |
338 | |
249 | =head2 Totally undocumented but well tested ;) |
339 | =back |
250 | |
340 | |
|
|
341 | =head2 Information about source parts |
|
|
342 | |
|
|
343 | =over 4 |
|
|
344 | |
251 | $parts = $item->parts; |
345 | =item $parts = $item->parts |
|
|
346 | |
|
|
347 | Return information about all parts (source files) used to decode the file |
|
|
348 | as a list of hashrefs with the following structure: |
|
|
349 | |
|
|
350 | { |
|
|
351 | partno => <integer describing the part number, starting with 1>, |
|
|
352 | # the following member sonly exist when they contain useful information |
|
|
353 | sfname => <local pathname of the file where this part is from>, |
|
|
354 | filename => <the ondisk filename of the decoded file>, |
|
|
355 | subfname => <used to cluster postings, possibly the posting filename>, |
|
|
356 | subject => <the subject of the posting/mail>, |
|
|
357 | origin => <the possible source (From) address>, |
|
|
358 | mimetype => <the possible mimetype of the decoded file>, |
|
|
359 | mimeid => <the id part of the Content-Type>, |
|
|
360 | } |
|
|
361 | |
|
|
362 | Usually you are interested mostly the C<sfname> and possibly the C<partno> |
|
|
363 | and C<filename> members. |
|
|
364 | |
|
|
365 | =back |
252 | |
366 | |
253 | =head2 Functions below not documented and not very well tested |
367 | =head2 Functions below not documented and not very well tested |
254 | |
368 | |
255 | QuickDecode |
369 | QuickDecode |
256 | EncodeMulti |
370 | EncodeMulti |