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.3 by root, Sun Mar 31 21:42:36 2002 UTC vs.
Revision 1.8 by root, Tue Oct 15 23:20:30 2002 UTC

10 $path=~s/^.*[\/\\]//; 10 $path=~s/^.*[\/\\]//;
11 $path; 11 $path;
12} 12}
13 13
14sub busycb { 14sub busycb {
15 my($action,$curfile,$partno,$numparts,$percent,$fsize)=@_; 15 my ($action, $curfile, $partno, $numparts, $percent, $fsize) = @_;
16 $_[0]=straction($action); 16 $_[0]=straction($action);
17 print "busy_callback(",join(",",@_),")\n"; 17 print "busy_callback(", (join ",",@_), ")\n";
18 0; 18 0;
19} 19}
20 20
21SetOption (OPT_IGNMODE, 1); 21SetOption OPT_IGNMODE, 1;
22SetOption (OPT_VERBOSE, 1); 22SetOption OPT_VERBOSE, 1;
23 23
24# show the three ways you can set callback functions 24# show the three ways you can set callback functions. I normally
25# prefer the one with the sub inplace.
25SetFNameFilter (\&namefilter); 26SetFNameFilter \&namefilter;
26 27
27SetBusyCallback ("busycb",333); 28SetBusyCallback "busycb", 333;
28 29
29SetMsgCallback (sub { 30SetMsgCallback sub {
30 my($msg,$level)=@_; 31 my ($msg, $level) = @_;
31 print uc(strmsglevel($_[1])),": $msg\n"; 32 print uc strmsglevel $_[1], ": $msg\n";
32}); 33};
33 34
35# the following non-trivial FileNameCallback takes care
36# of some subject lines not detected properly by uulib:
34SetFileNameCallback sub { 37SetFileNameCallback sub {
35 return unless $_[1]; # skip "Re:"-plies et al. 38 return unless $_[1]; # skip "Re:"-plies et al.
36 my ($subject, $filename) = @_; 39 local $_ = $_[0];
40
41 # the following rules are rather effective on some newsgroups,
42 # like alt.binaries.games.anime, where non-mime, uuencoded data
43 # is very common
44
37 ## if we find some *.rar, take it 45 # if we find some *.rar, take it as the filename
38 return $1 if $subject =~ /(\S+\.(?:[rstuvwxyz]\d\d|rar))\s/i; 46 return $1 if /(\S{3,}\.(?:[rstuvwxyz]\d\d|rar))\s/i;
47
48 # one common subject format
49 return $1 if /- "(.{2,}?\..+?)" (?:yenc )?\(\d+\/\d+\)/i;
50
51 # - filename.par (04/55)
52 return $1 if /- "?(\S{3,}\.\S+?)"? (?:yenc )?\(\d+\/\d+\)/i;
53
54 # - (xxx) No. 1 sayuri81.jpg 756565 bytes
55 # - (20 files) No.17 Roseanne.jpg [2/2]
56 return $1 if /No\.[ 0-9]+ (\S+\....) (?:\d+ bytes )?\[/;
57
39 # otherwise just pass what we have 58 # otherwise just pass what we have
40 return (); 59 return ();
41}; 60};
42 61
43 62# now read all files in the directory uusrc/*
44for(<uusrc/*>) { 63for(<uusrc/*>) {
45 my($retval,$count)=LoadFile ($_,$_,1); 64 my($retval,$count)=LoadFile ($_, $_, 1);
46 print "file($_), status(",strerror($retval),") parts($count)\n"; 65 print "file($_), status(", strerror $retval, ") parts($count)\n";
47} 66}
48 67
49SetOption (OPT_SAVEPATH, "uudst/"); 68SetOption OPT_SAVEPATH, "uudst/";
50 69
70# now wade through all files and their source parts
51$i=0; 71$i = 0;
52while($uu=GetFileListItem($i)) { 72while ($uu = GetFileListItem $i) {
53 $i++; 73 $i++;
54 print "file nr. $i"; 74 print "file nr. $i";
55 print " state ",$uu->state; 75 print " state ", $uu->state;
56 print " mode ",$uu->mode; 76 print " mode ", $uu->mode;
57 print " uudet ",strencoding($uu->uudet); 77 print " uudet ", strencoding $uu->uudet;
58 print " size ",$uu->size; 78 print " size ", $uu->size;
59 print " filename ",$uu->filename; 79 print " filename ", $uu->filename;
60 print " subfname ",$uu->subfname; 80 print " subfname ", $uu->subfname;
61 print " mimeid ",$uu->mimeid; 81 print " mimeid ", $uu->mimeid;
62 print " mimetype ",$uu->mimetype; 82 print " mimetype ", $uu->mimetype;
63 print "\n"; 83 print "\n";
64 84
65 # print additional info about all parts 85 # print additional info about all parts
66 for($uu->parts) { 86 for ($uu->parts) {
67 while(my($k,$v)=each(%$_)) { 87 while (my ($k, $v) = each %$_) {
68 print "$k > $v, "; 88 print "$k > $v, ";
69 } 89 }
70 print "\n"; 90 print "\n";
71 } 91 }
72 92
73 print strerror($uu->decode_temp)."\n"; 93 $uu->decode_temp;
74 print " temporarily decoded to ",$uu->binfile,"\n"; 94 print " temporarily decoded to ", $uu->binfile, "\n";
75 $uu->remove_temp; 95 $uu->remove_temp;
76 96
77 print strerror($uu->decode)."\n"; 97 print strerror $uu->decode;
78 print " saved as uudst/",$uu->filename,"\n"; 98 print " saved as uudst/", $uu->filename, "\n";
79} 99}
80 100
81print "cleanup...\n"; 101print "cleanup...\n";
82 102
83CleanUp(); 103CleanUp();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines