1 | package Convert::UUlib; |
1 | package Convert::UUlib; |
2 | |
2 | |
3 | no warnings; |
3 | use common::sense; |
4 | use strict; |
|
|
5 | |
4 | |
6 | use Carp; |
5 | use Carp; |
7 | |
6 | |
8 | require Exporter; |
7 | require Exporter; |
9 | require DynaLoader; |
8 | require DynaLoader; |
10 | |
9 | |
11 | our $VERSION = 1.62; |
10 | our $VERSION = 1.71; |
12 | |
11 | |
13 | our @ISA = qw(Exporter DynaLoader); |
12 | our @ISA = qw(Exporter DynaLoader); |
14 | |
13 | |
15 | our @_consts = qw( |
14 | our @_consts = qw( |
16 | ACT_COPYING ACT_DECODING ACT_ENCODING ACT_IDLE ACT_SCANNING |
15 | ACT_COPYING ACT_DECODING ACT_ENCODING ACT_IDLE ACT_SCANNING |
… | |
… | |
50 | |
49 | |
51 | bootstrap Convert::UUlib $VERSION; |
50 | bootstrap Convert::UUlib $VERSION; |
52 | |
51 | |
53 | # dummy function for compatiiblity with pre-1.7 versions |
52 | # dummy function for compatiiblity with pre-1.7 versions |
54 | sub Initialize { } |
53 | sub Initialize { } |
55 | |
|
|
56 | for (@_consts) { |
|
|
57 | my $constant = constant ($_); |
|
|
58 | no strict 'refs'; |
|
|
59 | *$_ = sub () { $constant }; |
|
|
60 | } |
|
|
61 | |
54 | |
62 | # action code -> string mapping |
55 | # action code -> string mapping |
63 | sub straction($) { |
56 | sub straction($) { |
64 | return 'copying' if $_[0] == &ACT_COPYING; |
57 | return 'copying' if $_[0] == &ACT_COPYING; |
65 | return 'decoding' if $_[0] == &ACT_DECODING; |
58 | return 'decoding' if $_[0] == &ACT_DECODING; |
… | |
… | |
94 | 1; |
87 | 1; |
95 | __END__ |
88 | __END__ |
96 | |
89 | |
97 | =head1 NAME |
90 | =head1 NAME |
98 | |
91 | |
99 | Convert::UUlib - Perl interface to the uulib library (a.k.a. uudeview/uuenview). |
92 | Convert::UUlib - decode uu/xx/b64/mime/yenc/etc-encoded data from a massive number of files |
100 | |
93 | |
101 | =head1 SYNOPSIS |
94 | =head1 SYNOPSIS |
102 | |
95 | |
103 | use Convert::UUlib ':all'; |
96 | use Convert::UUlib ':all'; |
104 | |
97 | |
… | |
… | |
112 | print $uu->filename, "\n"; |
105 | print $uu->filename, "\n"; |
113 | } |
106 | } |
114 | } |
107 | } |
115 | |
108 | |
116 | =head1 DESCRIPTION |
109 | =head1 DESCRIPTION |
|
|
110 | |
|
|
111 | This module started as an interface to the uulib/uudeview library by Frank |
|
|
112 | Pilhofer that can be used to decode all kinds of usenet (and other) |
|
|
113 | binary messages. |
|
|
114 | |
|
|
115 | After upstream abondoned the project, th library was continuously bugfixed |
|
|
116 | and improved in this module, with major focuses on security fixes, |
|
|
117 | correctness and speed (that does not mean that this library is considered |
|
|
118 | safe with untrusted data, but it surely is safer than the poriginal |
|
|
119 | uudeview). |
117 | |
120 | |
118 | Read the file doc/library.pdf from the distribution for in-depth |
121 | Read the file doc/library.pdf from the distribution for in-depth |
119 | information about the C-library used in this interface, and the rest of |
122 | information about the C-library used in this interface, and the rest of |
120 | this document and especially the non-trivial decoder program at the end. |
123 | this document and especially the non-trivial decoder program at the end. |
121 | |
124 | |
… | |
… | |
299 | if you want to iterate over all items, it is usually faster to use |
302 | if you want to iterate over all items, it is usually faster to use |
300 | C<GetFileList>. |
303 | C<GetFileList>. |
301 | |
304 | |
302 | =item @items = GetFileList |
305 | =item @items = GetFileList |
303 | |
306 | |
304 | Similar to C<GetFileListItem>, but returns all files in one go. |
307 | Similar to C<GetFileListItem>, but returns all files in one go, which is |
|
|
308 | very much faster for large number of items, and has no drawbacks when used |
|
|
309 | for a small number of items. |
305 | |
310 | |
306 | =back |
311 | =back |
307 | |
312 | |
308 | =head2 Decoding files |
313 | =head2 Decoding files |
309 | |
314 | |
… | |
… | |
489 | SetOption OPT_RBUF, 128*1024; |
494 | SetOption OPT_RBUF, 128*1024; |
490 | SetOption OPT_WBUF, 1024*1024; |
495 | SetOption OPT_WBUF, 1024*1024; |
491 | SetOption OPT_IGNMODE, 1; |
496 | SetOption OPT_IGNMODE, 1; |
492 | SetOption OPT_IGNMODE, 1; |
497 | SetOption OPT_IGNMODE, 1; |
493 | SetOption OPT_VERBOSE, 1; |
498 | SetOption OPT_VERBOSE, 1; |
|
|
499 | SetOption OPT_AUTOCHK, 0; |
494 | |
500 | |
495 | # show the three ways you can set callback functions. I normally |
501 | # show the three ways you can set callback functions. I normally |
496 | # prefer the one with the sub inplace. |
502 | # prefer the one with the sub inplace. |
497 | SetFNameFilter \&namefilter; |
503 | SetFNameFilter \&namefilter; |
498 | |
504 | |
… | |
… | |
536 | # now read all files in the directory uusrc/* |
542 | # now read all files in the directory uusrc/* |
537 | for (<uusrc/*>) { |
543 | for (<uusrc/*>) { |
538 | my ($retval, $count) = LoadFile ($_, $_, 1); |
544 | my ($retval, $count) = LoadFile ($_, $_, 1); |
539 | print "file($_), status(", strerror $retval, ") parts($count)\n"; |
545 | print "file($_), status(", strerror $retval, ") parts($count)\n"; |
540 | } |
546 | } |
|
|
547 | |
|
|
548 | Smerge -1; |
541 | |
549 | |
542 | SetOption OPT_SAVEPATH, "uudst/"; |
550 | SetOption OPT_SAVEPATH, "uudst/"; |
543 | |
551 | |
544 | # now wade through all files and their source parts |
552 | # now wade through all files and their source parts |
545 | for my $uu (GetFileList) { |
553 | for my $uu (GetFileList) { |
… | |
… | |
603 | security purposes requires care. |
611 | security purposes requires care. |
604 | |
612 | |
605 | Likewise, file sizes when the uulib library was written were tiny compared |
613 | Likewise, file sizes when the uulib library was written were tiny compared |
606 | to today, so do not expect this library to handle files larger than 2GB. |
614 | to today, so do not expect this library to handle files larger than 2GB. |
607 | |
615 | |
|
|
616 | Lastly, this module uses a very "C-like" interface, which means it doesn't |
|
|
617 | protect you from invalid points as you might expect from "more perlish" |
|
|
618 | modules - for example, accessing a file item object after callinbg |
|
|
619 | C<CleanUp> will likely result in crashes, memory corruption, or worse. |
|
|
620 | |
608 | =head1 AUTHOR |
621 | =head1 AUTHOR |
609 | |
622 | |
610 | Marc Lehmann <schmorp@schmorp.de>, the original uulib library was written |
623 | Marc Lehmann <schmorp@schmorp.de>, the original uulib library was written |
611 | by Frank Pilhofer <fp@informatik.uni-frankfurt.de>, and later heavily |
624 | by Frank Pilhofer <fp@informatik.uni-frankfurt.de>, and later heavily |
612 | bugfixed by Marc Lehmann. |
625 | bugfixed by Marc Lehmann. |