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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines