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