… | |
… | |
48 | our @EXPORT_OK = @_funcs; |
48 | our @EXPORT_OK = @_funcs; |
49 | our %EXPORT_TAGS = (all => [@_consts,@_funcs], constants => \@_consts); |
49 | our %EXPORT_TAGS = (all => [@_consts,@_funcs], constants => \@_consts); |
50 | |
50 | |
51 | bootstrap Convert::UUlib $VERSION; |
51 | bootstrap Convert::UUlib $VERSION; |
52 | |
52 | |
53 | Initialize(); |
53 | # dummy function for compatiiblity with pre-1.7 versions |
54 | |
54 | sub Initialize { } |
55 | # not when < 5.005_6x |
|
|
56 | # END { CleanUp() } |
|
|
57 | |
55 | |
58 | for (@_consts) { |
56 | for (@_consts) { |
59 | my $constant = constant($_); |
57 | my $constant = constant ($_); |
60 | no strict 'refs'; |
58 | no strict 'refs'; |
61 | *$_ = sub () { $constant }; |
59 | *$_ = sub () { $constant }; |
62 | } |
60 | } |
63 | |
61 | |
64 | # action code -> string mapping |
62 | # action code -> string mapping |
… | |
… | |
105 | use Convert::UUlib ':all'; |
103 | use Convert::UUlib ':all'; |
106 | |
104 | |
107 | # read all the files named on the commandline and decode them |
105 | # read all the files named on the commandline and decode them |
108 | # into the CURRENT directory. See below for a longer example. |
106 | # into the CURRENT directory. See below for a longer example. |
109 | LoadFile $_ for @ARGV; |
107 | LoadFile $_ for @ARGV; |
|
|
108 | |
110 | for my $uu (GetFileList) { |
109 | for my $uu (GetFileList) { |
111 | if ($uu->state & FILE_OK) { |
110 | if ($uu->state & FILE_OK) { |
112 | $uu->decode; |
111 | $uu->decode; |
113 | print $uu->filename, "\n"; |
112 | print $uu->filename, "\n"; |
114 | } |
113 | } |
… | |
… | |
216 | On my machine, a fairly complete decode with DBI backend needs about 10MB |
215 | On my machine, a fairly complete decode with DBI backend needs about 10MB |
217 | RSS to decode 20000 files. |
216 | RSS to decode 20000 files. |
218 | |
217 | |
219 | =over |
218 | =over |
220 | |
219 | |
221 | =item Initialize |
|
|
222 | |
|
|
223 | Not normally necessary, (re-)initializes the library. |
|
|
224 | |
|
|
225 | =item CleanUp |
220 | =item CleanUp |
226 | |
221 | |
227 | Not normally necessary, could be called at the end to release memory |
222 | Release memory, file items and clean up files. Should be called after a |
228 | before starting a new decoding round. |
223 | decoidng run, if you want to start a new one. |
229 | |
224 | |
230 | =back |
225 | =back |
231 | |
226 | |
232 | =head2 Setting and querying options |
227 | =head2 Setting and querying options |
233 | |
228 | |
… | |
… | |
448 | |
443 | |
449 | =back |
444 | =back |
450 | |
445 | |
451 | =head1 LARGE EXAMPLE DECODER |
446 | =head1 LARGE EXAMPLE DECODER |
452 | |
447 | |
|
|
448 | The general workflow for decoding is like this: |
|
|
449 | |
|
|
450 | =over |
|
|
451 | |
|
|
452 | =item 1. Configure options with C<SetOption> or C<SetXXXCallback>. |
|
|
453 | |
|
|
454 | =item 2. Load all source files with C<LoadFile>. |
|
|
455 | |
|
|
456 | =item 3. Optionally C<Smerge>. |
|
|
457 | |
|
|
458 | =item 4. Iterate over all C<GetFileList> items (i.e. result files). |
|
|
459 | |
|
|
460 | =item 5. C<CleanUp> to delete files and free items. |
|
|
461 | |
|
|
462 | =back |
|
|
463 | |
453 | This is the file C<example-decoder> from the distribution, put here |
464 | What follows is the file C<example-decoder> from the distribution that |
454 | instead of more thorough documentation. |
465 | illustrates the above worklfow in a non-trivial example. |
455 | |
466 | |
456 | #!/usr/bin/perl |
467 | #!/usr/bin/perl |
457 | |
468 | |
458 | # decode all the files in the directory uusrc/ and copy |
469 | # decode all the files in the directory uusrc/ and copy |
459 | # the resulting files to uudst/ |
470 | # the resulting files to uudst/ |