ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/example-decoder
Revision: 1.3
Committed: Sun Mar 31 21:42:36 2002 UTC (22 years, 1 month ago) by root
Branch: MAIN
Changes since 1.2: +10 -0 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/usr/bin/perl
2
3 # decode all the files in the directory uusrc/ and copy
4 # the resulting files to uudst/
5
6 use Convert::UUlib ':all';
7
8 sub namefilter {
9 my($path)=@_;
10 $path=~s/^.*[\/\\]//;
11 $path;
12 }
13
14 sub busycb {
15 my($action,$curfile,$partno,$numparts,$percent,$fsize)=@_;
16 $_[0]=straction($action);
17 print "busy_callback(",join(",",@_),")\n";
18 0;
19 }
20
21 SetOption (OPT_IGNMODE, 1);
22 SetOption (OPT_VERBOSE, 1);
23
24 # show the three ways you can set callback functions
25 SetFNameFilter (\&namefilter);
26
27 SetBusyCallback ("busycb",333);
28
29 SetMsgCallback (sub {
30 my($msg,$level)=@_;
31 print uc(strmsglevel($_[1])),": $msg\n";
32 });
33
34 SetFileNameCallback sub {
35 return unless $_[1]; # skip "Re:"-plies et al.
36 my ($subject, $filename) = @_;
37 ## if we find some *.rar, take it
38 return $1 if $subject =~ /(\S+\.(?:[rstuvwxyz]\d\d|rar))\s/i;
39 # otherwise just pass what we have
40 return ();
41 };
42
43
44 for(<uusrc/*>) {
45 my($retval,$count)=LoadFile ($_,$_,1);
46 print "file($_), status(",strerror($retval),") parts($count)\n";
47 }
48
49 SetOption (OPT_SAVEPATH, "uudst/");
50
51 $i=0;
52 while($uu=GetFileListItem($i)) {
53 $i++;
54 print "file nr. $i";
55 print " state ",$uu->state;
56 print " mode ",$uu->mode;
57 print " uudet ",strencoding($uu->uudet);
58 print " size ",$uu->size;
59 print " filename ",$uu->filename;
60 print " subfname ",$uu->subfname;
61 print " mimeid ",$uu->mimeid;
62 print " mimetype ",$uu->mimetype;
63 print "\n";
64
65 # print additional info about all parts
66 for($uu->parts) {
67 while(my($k,$v)=each(%$_)) {
68 print "$k > $v, ";
69 }
70 print "\n";
71 }
72
73 print strerror($uu->decode_temp)."\n";
74 print " temporarily decoded to ",$uu->binfile,"\n";
75 $uu->remove_temp;
76
77 print strerror($uu->decode)."\n";
78 print " saved as uudst/",$uu->filename,"\n";
79 }
80
81 print "cleanup...\n";
82
83 CleanUp();