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 |
for(<uusrc/*>) { |
35 |
my($retval,$count)=LoadFile ($_,$_,1); |
36 |
print "file($_), status(",strerror($retval),") parts($count)\n"; |
37 |
} |
38 |
|
39 |
SetOption (OPT_SAVEPATH, "uudst/"); |
40 |
|
41 |
$i=0; |
42 |
while($uu=GetFileListItem($i)) { |
43 |
$i++; |
44 |
print "file nr. $i"; |
45 |
print " state ",$uu->state; |
46 |
print " mode ",$uu->mode; |
47 |
print " uudet ",strencoding($uu->uudet); |
48 |
print " size ",$uu->size; |
49 |
print " filename ",$uu->filename; |
50 |
print " subfname ",$uu->subfname; |
51 |
print " mimeid ",$uu->mimeid; |
52 |
print " mimetype ",$uu->mimetype; |
53 |
print "\n"; |
54 |
|
55 |
# print additional info about all parts |
56 |
for($uu->parts) { |
57 |
while(my($k,$v)=each(%$_)) { |
58 |
print "$k > $v, "; |
59 |
} |
60 |
print "\n"; |
61 |
} |
62 |
|
63 |
print strerror($uu->decode_temp)."\n"; |
64 |
print " temporarily decoded to ",$uu->binfile,"\n"; |
65 |
$uu->remove_temp; |
66 |
|
67 |
print strerror($uu->decode)."\n"; |
68 |
print " saved as uudst/",$uu->filename,"\n"; |
69 |
} |
70 |
|
71 |
print "cleanup...\n"; |
72 |
|
73 |
CleanUp(); |