ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/example-decoder
(Generate patch)

Comparing Convert-UUlib/example-decoder (file contents):
Revision 1.18 by root, Sat Jul 18 05:58:26 2009 UTC vs.
Revision 1.24 by root, Fri Feb 28 16:57:25 2020 UTC

1#!/usr/bin/perl 1#!/usr/bin/perl
2 2
3# decode all the files in the directory uusrc/ and copy 3# decode all the files in the directory uusrc/ and copy
4# the resulting files to uudst/ 4# the resulting files to uudst/
5
6#use Coro::Multicore;
7
8use strict;
5 9
6use Convert::UUlib ':all'; 10use Convert::UUlib ':all';
7 11
8sub namefilter { 12sub namefilter {
9 my ($path) = @_; 13 my ($path) = @_;
21} 25}
22 26
23SetOption OPT_RBUF, 128*1024; 27SetOption OPT_RBUF, 128*1024;
24SetOption OPT_WBUF, 1024*1024; 28SetOption OPT_WBUF, 1024*1024;
25SetOption OPT_IGNMODE, 1; 29SetOption OPT_IGNMODE, 1;
26SetOption OPT_IGNMODE, 1;
27SetOption OPT_VERBOSE, 1; 30SetOption OPT_VERBOSE, 1;
31SetOption OPT_DOTDOT, 1;
32SetOption OPT_AUTOCHECK, 0;
28 33
29# show the three ways you can set callback functions. I normally 34# show the three ways you can set callback functions. I normally
30# prefer the one with the sub inplace. 35# prefer the one with the sub inplace.
31SetFNameFilter \&namefilter; 36SetFNameFilter \&namefilter;
32 37
40# the following non-trivial FileNameCallback takes care 45# the following non-trivial FileNameCallback takes care
41# of some subject lines not detected properly by uulib: 46# of some subject lines not detected properly by uulib:
42SetFileNameCallback sub { 47SetFileNameCallback sub {
43 return unless $_[1]; # skip "Re:"-plies et al. 48 return unless $_[1]; # skip "Re:"-plies et al.
44 local $_ = $_[0]; 49 local $_ = $_[0];
50
51 if ($_[1] =~ /^(img_?\d+|\d+\w?)\./) {
52 return "$1 $_[1]"
53 if /^\s*\(([^)]+)\) \[\d+/;
54 }
45 55
46 # the following rules are rather effective on some newsgroups, 56 # the following rules are rather effective on some newsgroups,
47 # like alt.binaries.games.anime, where non-mime, uuencoded data 57 # like alt.binaries.games.anime, where non-mime, uuencoded data
48 # is very common 58 # is very common
49 59
74for(<uusrc/*>) { 84for(<uusrc/*>) {
75 my ($retval, $count) = LoadFile ($_, $_, 1); 85 my ($retval, $count) = LoadFile ($_, $_, 1);
76 print "file($_), status(", strerror $retval, ") parts($count)\n"; 86 print "file($_), status(", strerror $retval, ") parts($count)\n";
77} 87}
78 88
89Smerge -1;
90
79SetOption OPT_SAVEPATH, "uudst/"; 91SetOption OPT_SAVEPATH, "uudst/";
80 92
81# now wade through all files and their source parts 93# now wade through all files and their source parts
82$i = 0; 94for my $uu (GetFileList) {
83while ($uu = GetFileListItem $i) { 95 print "file ", $uu->filename, "\n";
84 $i++;
85 print "file nr. $i";
86 print " state ", $uu->state; 96 print " state ", $uu->state, "\n";
87 print " mode ", $uu->mode; 97 print " mode ", $uu->mode, "\n";
88 print " uudet ", strencoding $uu->uudet; 98 print " uudet ", strencoding $uu->uudet, "\n";
89 print " size ", $uu->size; 99 print " size ", $uu->size, "\n";
90 print " filename ", $uu->filename;
91 print " subfname ", $uu->subfname; 100 print " subfname ", $uu->subfname, "\n";
92 print " mimeid ", $uu->mimeid; 101 print " mimeid ", $uu->mimeid, "\n";
93 print " mimetype ", $uu->mimetype; 102 print " mimetype ", $uu->mimetype, "\n";
94 print "\n";
95 103
96 # print additional info about all parts 104 # print additional info about all parts
105 print " parts";
97 for ($uu->parts) { 106 for ($uu->parts) {
98 while (my ($k, $v) = each %$_) { 107 for my $k (sort keys %$_) {
99 print "$k > $v, "; 108 print " $k=$_->{$k}";
100 } 109 }
101 print "\n"; 110 print "\n";
102 } 111 }
103 112
104 print $uu->filename;
105
106 $uu->remove_temp; 113 $uu->remove_temp;
107 114
108 if (my $err = $uu->decode) { 115 if (my $err = $uu->decode) {
109 print ", ", strerror $err, "\n"; 116 print " ERROR ", strerror $err, "\n";
110 } else { 117 } else {
111 print ", saved as uudst/", $uu->filename, "\n"; 118 print " successfully saved as uudst/", $uu->filename, "\n";
112 } 119 }
113} 120}
114 121
115print "cleanup...\n"; 122print "cleanup...\n";
116 123

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines