… | |
… | |
6 | use Carp; |
6 | use Carp; |
7 | |
7 | |
8 | require Exporter; |
8 | require Exporter; |
9 | require DynaLoader; |
9 | require DynaLoader; |
10 | |
10 | |
11 | our $VERSION = '1.12'; |
11 | our $VERSION = 1.62; |
12 | |
12 | |
13 | our @ISA = qw(Exporter DynaLoader); |
13 | our @ISA = qw(Exporter DynaLoader); |
14 | |
14 | |
15 | our @_consts = qw( |
15 | our @_consts = qw( |
16 | ACT_COPYING ACT_DECODING ACT_ENCODING ACT_IDLE ACT_SCANNING |
16 | ACT_COPYING ACT_DECODING ACT_ENCODING ACT_IDLE ACT_SCANNING |
… | |
… | |
34 | ); |
34 | ); |
35 | |
35 | |
36 | our @_funcs = qw( |
36 | our @_funcs = qw( |
37 | Initialize CleanUp GetOption SetOption strerror SetMsgCallback |
37 | Initialize CleanUp GetOption SetOption strerror SetMsgCallback |
38 | SetBusyCallback SetFileCallback SetFNameFilter SetFileNameCallback |
38 | SetBusyCallback SetFileCallback SetFNameFilter SetFileNameCallback |
39 | FNameFilter LoadFile GetFileListItem RenameFile DecodeToTemp |
39 | FNameFilter LoadFile GetFileListItem GetFileList RenameFile DecodeToTemp |
40 | RemoveTemp DecodeFile InfoFile Smerge QuickDecode EncodeMulti |
40 | RemoveTemp DecodeFile InfoFile Smerge QuickDecode EncodeMulti |
41 | EncodePartial EncodeToStream EncodeToFile E_PrepSingle |
41 | EncodePartial EncodeToStream EncodeToFile E_PrepSingle |
42 | E_PrepPartial |
42 | E_PrepPartial |
43 | |
43 | |
44 | straction strencoding strmsglevel |
44 | straction strencoding strmsglevel |
… | |
… | |
105 | use Convert::UUlib ':all'; |
105 | use Convert::UUlib ':all'; |
106 | |
106 | |
107 | # read all the files named on the commandline and decode them |
107 | # read all the files named on the commandline and decode them |
108 | # into the CURRENT directory. See below for a longer example. |
108 | # into the CURRENT directory. See below for a longer example. |
109 | LoadFile $_ for @ARGV; |
109 | LoadFile $_ for @ARGV; |
110 | for (my $i = 0; my $uu = GetFileListItem $i; $i++) { |
110 | for my $uu (GetFileList) { |
111 | if ($uu->state & FILE_OK) { |
111 | if ($uu->state & FILE_OK) { |
112 | $uu->decode; |
112 | $uu->decode; |
113 | print $uu->filename, "\n"; |
113 | print $uu->filename, "\n"; |
114 | } |
114 | } |
115 | } |
115 | } |
… | |
… | |
214 | again. |
214 | again. |
215 | |
215 | |
216 | On my machine, a fairly complete decode with DBI backend needs about 10MB |
216 | On my machine, a fairly complete decode with DBI backend needs about 10MB |
217 | RSS to decode 20000 files. |
217 | RSS to decode 20000 files. |
218 | |
218 | |
219 | =over 4 |
219 | =over |
220 | |
220 | |
221 | =item Initialize |
221 | =item Initialize |
222 | |
222 | |
223 | Not normally necessary, (re-)initializes the library. |
223 | Not normally necessary, (re-)initializes the library. |
224 | |
224 | |
… | |
… | |
229 | |
229 | |
230 | =back |
230 | =back |
231 | |
231 | |
232 | =head2 Setting and querying options |
232 | =head2 Setting and querying options |
233 | |
233 | |
234 | =over 4 |
234 | =over |
235 | |
235 | |
236 | =item $option = GetOption OPT_xxx |
236 | =item $option = GetOption OPT_xxx |
237 | |
237 | |
238 | =item SetOption OPT_xxx, opt-value |
238 | =item SetOption OPT_xxx, opt-value |
239 | |
239 | |
… | |
… | |
241 | |
241 | |
242 | See the C<OPT_xxx> constants above to see which options exist. |
242 | See the C<OPT_xxx> constants above to see which options exist. |
243 | |
243 | |
244 | =head2 Setting various callbacks |
244 | =head2 Setting various callbacks |
245 | |
245 | |
246 | =over 4 |
246 | =over |
247 | |
247 | |
248 | =item SetMsgCallback [callback-function] |
248 | =item SetMsgCallback [callback-function] |
249 | |
249 | |
250 | =item SetBusyCallback [callback-function] |
250 | =item SetBusyCallback [callback-function] |
251 | |
251 | |
… | |
… | |
255 | |
255 | |
256 | =back |
256 | =back |
257 | |
257 | |
258 | =head2 Call the currently selected FNameFilter |
258 | =head2 Call the currently selected FNameFilter |
259 | |
259 | |
260 | =over 4 |
260 | =over |
261 | |
261 | |
262 | =item $file = FNameFilter $file |
262 | =item $file = FNameFilter $file |
263 | |
263 | |
264 | =back |
264 | =back |
265 | |
265 | |
266 | =head2 Loading sourcefiles, optionally fuzzy merge and start decoding |
266 | =head2 Loading sourcefiles, optionally fuzzy merge and start decoding |
267 | |
267 | |
268 | =over 4 |
268 | =over |
269 | |
269 | |
270 | =item ($retval, $count) = LoadFile $fname, [$id, [$delflag, [$partno]]] |
270 | =item ($retval, $count) = LoadFile $fname, [$id, [$delflag, [$partno]]] |
271 | |
271 | |
272 | Load the given file and scan it for encoded contents. Optionally tag it |
272 | Load the given file and scan it for encoded contents. Optionally tag it |
273 | with the given id, and if C<$delflag> is true, delete the file after it |
273 | with the given id, and if C<$delflag> is true, delete the file after it |
… | |
… | |
298 | |
298 | |
299 | The first file has number C<0>, and the series has no holes, so you can |
299 | The first file has number C<0>, and the series has no holes, so you can |
300 | iterate over all files by starting with zero and incrementing until you |
300 | iterate over all files by starting with zero and incrementing until you |
301 | hit C<undef>. |
301 | hit C<undef>. |
302 | |
302 | |
|
|
303 | This function has to walk the linear list of fils on each access, so |
|
|
304 | if you want to iterate over all items, it is usually faster to use |
|
|
305 | C<GetFileList>. |
|
|
306 | |
|
|
307 | =item @items = GetFileList |
|
|
308 | |
|
|
309 | Similar to C<GetFileListItem>, but returns all files in one go. |
|
|
310 | |
303 | =back |
311 | =back |
304 | |
312 | |
305 | =head2 Decoding files |
313 | =head2 Decoding files |
306 | |
314 | |
307 | =over 4 |
315 | =over |
308 | |
316 | |
309 | =item $retval = $item->rename($newname) |
317 | =item $retval = $item->rename ($newname) |
310 | |
318 | |
311 | Change the ondisk filename where the decoded file will be saved. |
319 | Change the ondisk filename where the decoded file will be saved. |
312 | |
320 | |
313 | =item $retval = $item->decode_temp |
321 | =item $retval = $item->decode_temp |
314 | |
322 | |
… | |
… | |
317 | |
325 | |
318 | =item $retval = $item->remove_temp |
326 | =item $retval = $item->remove_temp |
319 | |
327 | |
320 | Remove the temporarily decoded file again. |
328 | Remove the temporarily decoded file again. |
321 | |
329 | |
322 | =item $retval = $item->decode([$target_path]) |
330 | =item $retval = $item->decode ([$target_path]) |
323 | |
331 | |
324 | Decode the file to it's destination, or the given target path. |
332 | Decode the file to its destination, or the given target path. |
325 | |
333 | |
326 | =item $retval = $item->info(callback-function) |
334 | =item $retval = $item->info (callback-function) |
327 | |
335 | |
328 | =back |
336 | =back |
329 | |
337 | |
330 | =head2 Querying (and setting) item attributes |
338 | =head2 Querying (and setting) item attributes |
331 | |
339 | |
332 | =over 4 |
340 | =over |
333 | |
341 | |
334 | =item $state = $item->state |
342 | =item $state = $item->state |
335 | |
343 | |
336 | =item $mode = $item->mode([newmode]) |
344 | =item $mode = $item->mode ([newmode]) |
337 | |
345 | |
338 | =item $uudet = $item->uudet |
346 | =item $uudet = $item->uudet |
339 | |
347 | |
340 | =item $size = $item->size |
348 | =item $size = $item->size |
341 | |
349 | |
342 | =item $filename = $item->filename([newfilename}) |
350 | =item $filename = $item->filename ([newfilename}) |
343 | |
351 | |
344 | =item $subfname = $item->subfname |
352 | =item $subfname = $item->subfname |
345 | |
353 | |
346 | =item $mimeid = $item->mimeid |
354 | =item $mimeid = $item->mimeid |
347 | |
355 | |
… | |
… | |
351 | |
359 | |
352 | =back |
360 | =back |
353 | |
361 | |
354 | =head2 Information about source parts |
362 | =head2 Information about source parts |
355 | |
363 | |
356 | =over 4 |
364 | =over |
357 | |
365 | |
358 | =item $parts = $item->parts |
366 | =item $parts = $item->parts |
359 | |
367 | |
360 | Return information about all parts (source files) used to decode the file |
368 | Return information about all parts (source files) used to decode the file |
361 | as a list of hashrefs with the following structure: |
369 | as a list of hashrefs with the following structure: |
… | |
… | |
375 | Usually you are interested mostly the C<sfname> and possibly the C<partno> |
383 | Usually you are interested mostly the C<sfname> and possibly the C<partno> |
376 | and C<filename> members. |
384 | and C<filename> members. |
377 | |
385 | |
378 | =back |
386 | =back |
379 | |
387 | |
380 | =head2 Functions below not documented and not very well tested |
388 | =head2 Functions below are not documented and not very well tested - feedback welcome |
381 | |
389 | |
382 | QuickDecode |
390 | QuickDecode |
383 | EncodeMulti |
391 | EncodeMulti |
384 | EncodePartial |
392 | EncodePartial |
385 | EncodeToStream |
393 | EncodeToStream |
… | |
… | |
389 | |
397 | |
390 | =head2 EXTENSION FUNCTIONS |
398 | =head2 EXTENSION FUNCTIONS |
391 | |
399 | |
392 | Functions found in this module but not documented in the uulib documentation: |
400 | Functions found in this module but not documented in the uulib documentation: |
393 | |
401 | |
394 | =over 4 |
402 | =over |
395 | |
403 | |
396 | =item $msg = straction ACT_xxx |
404 | =item $msg = straction ACT_xxx |
397 | |
405 | |
398 | Return a human readable string representing the given action code. |
406 | Return a human readable string representing the given action code. |
399 | |
407 | |
… | |
… | |
513 | # otherwise just pass what we have |
521 | # otherwise just pass what we have |
514 | () |
522 | () |
515 | }; |
523 | }; |
516 | |
524 | |
517 | # now read all files in the directory uusrc/* |
525 | # now read all files in the directory uusrc/* |
518 | for(<uusrc/*>) { |
526 | for (<uusrc/*>) { |
519 | my ($retval, $count) = LoadFile ($_, $_, 1); |
527 | my ($retval, $count) = LoadFile ($_, $_, 1); |
520 | print "file($_), status(", strerror $retval, ") parts($count)\n"; |
528 | print "file($_), status(", strerror $retval, ") parts($count)\n"; |
521 | } |
529 | } |
522 | |
530 | |
523 | SetOption OPT_SAVEPATH, "uudst/"; |
531 | SetOption OPT_SAVEPATH, "uudst/"; |
524 | |
532 | |
525 | # now wade through all files and their source parts |
533 | # now wade through all files and their source parts |
526 | $i = 0; |
534 | for my $uu (GetFileList) { |
527 | while ($uu = GetFileListItem $i) { |
535 | print "file ", $uu->filename, "\n"; |
528 | $i++; |
|
|
529 | print "file nr. $i"; |
|
|
530 | print " state ", $uu->state; |
536 | print " state ", $uu->state, "\n"; |
531 | print " mode ", $uu->mode; |
537 | print " mode ", $uu->mode, "\n"; |
532 | print " uudet ", strencoding $uu->uudet; |
538 | print " uudet ", strencoding $uu->uudet, "\n"; |
533 | print " size ", $uu->size; |
539 | print " size ", $uu->size, "\n"; |
534 | print " filename ", $uu->filename; |
|
|
535 | print " subfname ", $uu->subfname; |
540 | print " subfname ", $uu->subfname, "\n"; |
536 | print " mimeid ", $uu->mimeid; |
541 | print " mimeid ", $uu->mimeid, "\n"; |
537 | print " mimetype ", $uu->mimetype; |
542 | print " mimetype ", $uu->mimetype, "\n"; |
538 | print "\n"; |
|
|
539 | |
543 | |
540 | # print additional info about all parts |
544 | # print additional info about all parts |
|
|
545 | print " parts"; |
541 | for ($uu->parts) { |
546 | for ($uu->parts) { |
542 | while (my ($k, $v) = each %$_) { |
547 | for my $k (sort keys %$_) { |
543 | print "$k > $v, "; |
548 | print " $k=$_->{$k}"; |
544 | } |
549 | } |
545 | print "\n"; |
550 | print "\n"; |
546 | } |
551 | } |
547 | |
552 | |
548 | print $uu->filename; |
|
|
549 | |
|
|
550 | $uu->remove_temp; |
553 | $uu->remove_temp; |
551 | |
554 | |
552 | if (my $err = $uu->decode ()) { |
555 | if (my $err = $uu->decode) { |
553 | print ", ", strerror $err, "\n"; |
556 | print " ERROR ", strerror $err, "\n"; |
554 | } else { |
557 | } else { |
555 | print ", saved as uudst/", $uu->filename, "\n"; |
558 | print " successfully saved as uudst/", $uu->filename, "\n"; |
556 | } |
559 | } |
557 | } |
560 | } |
558 | |
561 | |
559 | print "cleanup...\n"; |
562 | print "cleanup...\n"; |
560 | |
563 | |
561 | CleanUp; |
564 | CleanUp; |
|
|
565 | |
|
|
566 | =head1 PERLMULTICORE SUPPORT |
|
|
567 | |
|
|
568 | This module supports the perlmulticore standard (see |
|
|
569 | L<http://perlmulticore.schmorp.de/> for more info) for the following |
|
|
570 | functions - generally these are functions accessing the disk and/or using |
|
|
571 | considerable CPU time: |
|
|
572 | |
|
|
573 | LoadFile |
|
|
574 | $item->decode |
|
|
575 | $item->decode_temp |
|
|
576 | $item->remove_temp |
|
|
577 | $item->info |
|
|
578 | |
|
|
579 | The perl interpreter will be reacquired/released on every callback |
|
|
580 | invocation, so for performance reasons, callbacks should be avoided if |
|
|
581 | that is costly. |
|
|
582 | |
|
|
583 | Future versions might enable multicore support for more functions. |
|
|
584 | |
|
|
585 | =head1 BUGS AND LIMITATIONS |
|
|
586 | |
|
|
587 | The original uulib library this module uses was written at a time where |
|
|
588 | main memory of measured in megabytes and buffer overflows as a security |
|
|
589 | thign didn't exist. While a lot of security fixes have been applied over |
|
|
590 | the years (includign some defense in depth mechanism that can shield |
|
|
591 | against a lot of as-of-yet undetected bugs), using this library for |
|
|
592 | security purposes requires care. |
|
|
593 | |
|
|
594 | Likewise, file sizes when the uulib library was written were tiny compared |
|
|
595 | to today, so do not expect this library to handle files larger than 2GB. |
562 | |
596 | |
563 | =head1 AUTHOR |
597 | =head1 AUTHOR |
564 | |
598 | |
565 | Marc Lehmann <schmorp@schmorp.de>, the original uulib library was written |
599 | Marc Lehmann <schmorp@schmorp.de>, the original uulib library was written |
566 | by Frank Pilhofer <fp@informatik.uni-frankfurt.de>, and later heavily |
600 | by Frank Pilhofer <fp@informatik.uni-frankfurt.de>, and later heavily |
567 | bugfixed by Marc Lehmann. |
601 | bugfixed by Marc Lehmann. |
568 | |
602 | |
569 | =head1 SEE ALSO |
603 | =head1 SEE ALSO |
570 | |
604 | |
571 | perl(1), uudeview homepage at http://www.uni-frankfurt.de/~fp/uudeview/. |
605 | perl(1), uudeview homepage at L<http://www.fpx.de/fp/Software/UUDeview/>. |
572 | |
606 | |
573 | =cut |
607 | =cut |
|
|
608 | |