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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines