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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines