| 1 |
root |
1.1 |
#!/usr/bin/perl |
| 2 |
|
|
|
| 3 |
|
|
# decode all the files in the directory uusrc/ and copy |
| 4 |
|
|
# the resulting files to uudst/ |
| 5 |
|
|
|
| 6 |
|
|
use Convert::UUlib ':all'; |
| 7 |
|
|
|
| 8 |
|
|
sub namefilter { |
| 9 |
|
|
my($path)=@_; |
| 10 |
|
|
$path=~s/^.*[\/\\]//; |
| 11 |
|
|
$path; |
| 12 |
|
|
} |
| 13 |
|
|
|
| 14 |
|
|
sub busycb { |
| 15 |
|
|
my($action,$curfile,$partno,$numparts,$percent,$fsize)=@_; |
| 16 |
|
|
$_[0]=straction($action); |
| 17 |
|
|
print "busy_callback(",join(",",@_),")\n"; |
| 18 |
|
|
0; |
| 19 |
|
|
} |
| 20 |
|
|
|
| 21 |
|
|
SetOption (OPT_IGNMODE, 1); |
| 22 |
|
|
SetOption (OPT_VERBOSE, 1); |
| 23 |
|
|
|
| 24 |
|
|
# show the three ways you can set callback functions |
| 25 |
|
|
SetFNameFilter (\&namefilter); |
| 26 |
|
|
|
| 27 |
|
|
SetBusyCallback ("busycb",333); |
| 28 |
|
|
|
| 29 |
|
|
SetMsgCallback (sub { |
| 30 |
|
|
my($msg,$level)=@_; |
| 31 |
|
|
print uc(strmsglevel($_[1])),": $msg\n"; |
| 32 |
|
|
}); |
| 33 |
|
|
|
| 34 |
root |
1.3 |
SetFileNameCallback sub { |
| 35 |
|
|
return unless $_[1]; # skip "Re:"-plies et al. |
| 36 |
root |
1.5 |
local $_ = $_[0]; |
| 37 |
root |
1.4 |
|
| 38 |
|
|
# the following rules are rather effective on some newsgroups, |
| 39 |
|
|
# like alt.binaries.games.anime, where non-mime, uuencoded data |
| 40 |
|
|
# is very common |
| 41 |
|
|
|
| 42 |
|
|
# if we find some *.rar, take it |
| 43 |
|
|
return $1 if /(\S+\.(?:[rstuvwxyz]\d\d|rar))\s/i; |
| 44 |
|
|
|
| 45 |
|
|
# - filename.par (04/55) |
| 46 |
|
|
return $1 if /- "?(\S+\.\S+?)"? (:yenc )?\(\d+\/\d+\)/i; |
| 47 |
|
|
|
| 48 |
root |
1.3 |
# otherwise just pass what we have |
| 49 |
|
|
return (); |
| 50 |
|
|
}; |
| 51 |
|
|
|
| 52 |
|
|
|
| 53 |
root |
1.1 |
for(<uusrc/*>) { |
| 54 |
|
|
my($retval,$count)=LoadFile ($_,$_,1); |
| 55 |
|
|
print "file($_), status(",strerror($retval),") parts($count)\n"; |
| 56 |
|
|
} |
| 57 |
|
|
|
| 58 |
|
|
SetOption (OPT_SAVEPATH, "uudst/"); |
| 59 |
|
|
|
| 60 |
|
|
$i=0; |
| 61 |
|
|
while($uu=GetFileListItem($i)) { |
| 62 |
|
|
$i++; |
| 63 |
|
|
print "file nr. $i"; |
| 64 |
|
|
print " state ",$uu->state; |
| 65 |
|
|
print " mode ",$uu->mode; |
| 66 |
|
|
print " uudet ",strencoding($uu->uudet); |
| 67 |
|
|
print " size ",$uu->size; |
| 68 |
|
|
print " filename ",$uu->filename; |
| 69 |
|
|
print " subfname ",$uu->subfname; |
| 70 |
|
|
print " mimeid ",$uu->mimeid; |
| 71 |
|
|
print " mimetype ",$uu->mimetype; |
| 72 |
|
|
print "\n"; |
| 73 |
|
|
|
| 74 |
|
|
# print additional info about all parts |
| 75 |
|
|
for($uu->parts) { |
| 76 |
|
|
while(my($k,$v)=each(%$_)) { |
| 77 |
|
|
print "$k > $v, "; |
| 78 |
|
|
} |
| 79 |
|
|
print "\n"; |
| 80 |
|
|
} |
| 81 |
|
|
|
| 82 |
root |
1.2 |
print strerror($uu->decode_temp)."\n"; |
| 83 |
root |
1.1 |
print " temporarily decoded to ",$uu->binfile,"\n"; |
| 84 |
|
|
$uu->remove_temp; |
| 85 |
|
|
|
| 86 |
root |
1.2 |
print strerror($uu->decode)."\n"; |
| 87 |
root |
1.1 |
print " saved as uudst/",$uu->filename,"\n"; |
| 88 |
|
|
} |
| 89 |
|
|
|
| 90 |
|
|
print "cleanup...\n"; |
| 91 |
|
|
|
| 92 |
|
|
CleanUp(); |