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.4 by root, Sun Mar 31 22:03:56 2002 UTC vs.
Revision 1.10 by root, Tue Dec 28 21:32:27 2004 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 local _$ = $_[0]; 39 local $_ = $_[0];
37 40
38 # the following rules are rather effective on some newsgroups, 41 # the following rules are rather effective on some newsgroups,
39 # like alt.binaries.games.anime, where non-mime, uuencoded data 42 # like alt.binaries.games.anime, where non-mime, uuencoded data
40 # is very common 43 # is very common
41 44
42 # if we find some *.rar, take it 45 # if we find some *.rar, take it as the filename
43 return $1 if /(\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;
44 50
45 # - filename.par (04/55) 51 # - filename.par (04/55)
46 return $1 if /- "?(\S+\.\S+?)"? (:yenc )?\(\d+\/\d+\)/i; 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
58 # try to detetc some common forms of filenames
59 return $1 if /([a-z0-9_\-+.]{3,}\.[a-z]{3,4}(?:.\d+))/i;
47 60
48 # otherwise just pass what we have 61 # otherwise just pass what we have
49 return (); 62 return ();
50}; 63};
51 64
52 65# now read all files in the directory uusrc/*
53for(<uusrc/*>) { 66for(<uusrc/*>) {
54 my($retval,$count)=LoadFile ($_,$_,1); 67 my($retval,$count)=LoadFile ($_, $_, 1);
55 print "file($_), status(",strerror($retval),") parts($count)\n"; 68 print "file($_), status(", strerror $retval, ") parts($count)\n";
56} 69}
57 70
58SetOption (OPT_SAVEPATH, "uudst/"); 71SetOption OPT_SAVEPATH, "uudst/";
59 72
73# now wade through all files and their source parts
60$i=0; 74$i = 0;
61while($uu=GetFileListItem($i)) { 75while ($uu = GetFileListItem $i) {
62 $i++; 76 $i++;
63 print "file nr. $i"; 77 print "file nr. $i";
64 print " state ",$uu->state; 78 print " state ", $uu->state;
65 print " mode ",$uu->mode; 79 print " mode ", $uu->mode;
66 print " uudet ",strencoding($uu->uudet); 80 print " uudet ", strencoding $uu->uudet;
67 print " size ",$uu->size; 81 print " size ", $uu->size;
68 print " filename ",$uu->filename; 82 print " filename ", $uu->filename;
69 print " subfname ",$uu->subfname; 83 print " subfname ", $uu->subfname;
70 print " mimeid ",$uu->mimeid; 84 print " mimeid ", $uu->mimeid;
71 print " mimetype ",$uu->mimetype; 85 print " mimetype ", $uu->mimetype;
72 print "\n"; 86 print "\n";
73 87
74 # print additional info about all parts 88 # print additional info about all parts
75 for($uu->parts) { 89 for ($uu->parts) {
76 while(my($k,$v)=each(%$_)) { 90 while (my ($k, $v) = each %$_) {
77 print "$k > $v, "; 91 print "$k > $v, ";
78 } 92 }
79 print "\n"; 93 print "\n";
80 } 94 }
81 95
82 print strerror($uu->decode_temp)."\n"; 96 $uu->decode_temp;
83 print " temporarily decoded to ",$uu->binfile,"\n"; 97 print " temporarily decoded to ", $uu->binfile, "\n";
84 $uu->remove_temp; 98 $uu->remove_temp;
85 99
86 print strerror($uu->decode)."\n"; 100 print strerror $uu->decode;
87 print " saved as uudst/",$uu->filename,"\n"; 101 print " saved as uudst/", $uu->filename, "\n";
88} 102}
89 103
90print "cleanup...\n"; 104print "cleanup...\n";
91 105
92CleanUp(); 106CleanUp();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines