1 | #!/usr/bin/perl |
1 | #!/usr/bin/perl |
2 | |
2 | |
3 | # decode all the files in the directory uusrc/ and copy |
3 | # decode all the files in the directory uusrc/ and copy |
4 | # the resulting files to uudst/ |
4 | # the resulting files to uudst/ |
|
|
5 | |
|
|
6 | #use Coro::Multicore; |
|
|
7 | |
|
|
8 | use strict; |
5 | |
9 | |
6 | use Convert::UUlib ':all'; |
10 | use Convert::UUlib ':all'; |
7 | |
11 | |
8 | sub namefilter { |
12 | sub namefilter { |
9 | my ($path) = @_; |
13 | my ($path) = @_; |
… | |
… | |
21 | } |
25 | } |
22 | |
26 | |
23 | SetOption OPT_RBUF, 128*1024; |
27 | SetOption OPT_RBUF, 128*1024; |
24 | SetOption OPT_WBUF, 1024*1024; |
28 | SetOption OPT_WBUF, 1024*1024; |
25 | SetOption OPT_IGNMODE, 1; |
29 | SetOption OPT_IGNMODE, 1; |
26 | SetOption OPT_IGNMODE, 1; |
|
|
27 | SetOption OPT_VERBOSE, 1; |
30 | SetOption OPT_VERBOSE, 1; |
|
|
31 | SetOption OPT_DOTDOT, 1; |
|
|
32 | SetOption OPT_AUTOCHECK, 0; |
28 | |
33 | |
29 | # show the three ways you can set callback functions. I normally |
34 | # show the three ways you can set callback functions. I normally |
30 | # prefer the one with the sub inplace. |
35 | # prefer the one with the sub inplace. |
31 | SetFNameFilter \&namefilter; |
36 | SetFNameFilter \&namefilter; |
32 | |
37 | |
… | |
… | |
41 | # of some subject lines not detected properly by uulib: |
46 | # of some subject lines not detected properly by uulib: |
42 | SetFileNameCallback sub { |
47 | SetFileNameCallback sub { |
43 | return unless $_[1]; # skip "Re:"-plies et al. |
48 | return unless $_[1]; # skip "Re:"-plies et al. |
44 | local $_ = $_[0]; |
49 | local $_ = $_[0]; |
45 | |
50 | |
|
|
51 | if ($_[1] =~ /^(img_?\d+|\d+\w?)\./) { |
|
|
52 | return "$1 $_[1]" |
|
|
53 | if /^\s*\(([^)]+)\) \[\d+/; |
|
|
54 | } |
|
|
55 | |
46 | # the following rules are rather effective on some newsgroups, |
56 | # the following rules are rather effective on some newsgroups, |
47 | # like alt.binaries.games.anime, where non-mime, uuencoded data |
57 | # like alt.binaries.games.anime, where non-mime, uuencoded data |
48 | # is very common |
58 | # is very common |
|
|
59 | |
|
|
60 | # File 06 of 33 - Kendo - Final - 0001.jpg (2/3) |
|
|
61 | return $1 if /File \d+ of \d+ - (.*) \(\d+\/\d+\)/i; |
49 | |
62 | |
50 | # if we find some *.rar, take it as the filename |
63 | # if we find some *.rar, take it as the filename |
51 | return $1 if /(\S{3,}\.(?:[rstuvwxyz]\d\d|rar))\s/i; |
64 | return $1 if /(\S{3,}\.(?:[rstuvwxyz]\d\d|rar))\s/i; |
52 | |
65 | |
53 | # one common subject format |
66 | # one common subject format |
… | |
… | |
71 | for(<uusrc/*>) { |
84 | for(<uusrc/*>) { |
72 | my ($retval, $count) = LoadFile ($_, $_, 1); |
85 | my ($retval, $count) = LoadFile ($_, $_, 1); |
73 | print "file($_), status(", strerror $retval, ") parts($count)\n"; |
86 | print "file($_), status(", strerror $retval, ") parts($count)\n"; |
74 | } |
87 | } |
75 | |
88 | |
|
|
89 | Smerge -1; |
|
|
90 | |
76 | SetOption OPT_SAVEPATH, "uudst/"; |
91 | SetOption OPT_SAVEPATH, "uudst/"; |
77 | |
92 | |
78 | # now wade through all files and their source parts |
93 | # now wade through all files and their source parts |
79 | $i = 0; |
94 | for my $uu (GetFileList) { |
80 | while ($uu = GetFileListItem $i) { |
95 | print "file ", $uu->filename, "\n"; |
81 | $i++; |
|
|
82 | print "file nr. $i"; |
|
|
83 | print " state ", $uu->state; |
96 | print " state ", $uu->state, "\n"; |
84 | print " mode ", $uu->mode; |
97 | print " mode ", $uu->mode, "\n"; |
85 | print " uudet ", strencoding $uu->uudet; |
98 | print " uudet ", strencoding $uu->uudet, "\n"; |
86 | print " size ", $uu->size; |
99 | print " size ", $uu->size, "\n"; |
87 | print " filename ", $uu->filename; |
|
|
88 | print " subfname ", $uu->subfname; |
100 | print " subfname ", $uu->subfname, "\n"; |
89 | print " mimeid ", $uu->mimeid; |
101 | print " mimeid ", $uu->mimeid, "\n"; |
90 | print " mimetype ", $uu->mimetype; |
102 | print " mimetype ", $uu->mimetype, "\n"; |
91 | print "\n"; |
|
|
92 | |
103 | |
93 | # print additional info about all parts |
104 | # print additional info about all parts |
|
|
105 | print " parts"; |
94 | for ($uu->parts) { |
106 | for ($uu->parts) { |
95 | while (my ($k, $v) = each %$_) { |
107 | for my $k (sort keys %$_) { |
96 | print "$k > $v, "; |
108 | print " $k=$_->{$k}"; |
97 | } |
109 | } |
98 | print "\n"; |
110 | print "\n"; |
99 | } |
111 | } |
100 | |
112 | |
101 | print $uu->filename; |
|
|
102 | |
|
|
103 | $uu->remove_temp; |
113 | $uu->remove_temp; |
104 | |
114 | |
105 | if (my $err = $uu->decode ()) { |
115 | if (my $err = $uu->decode) { |
106 | print ", ", strerror $err, "\n"; |
116 | print " ERROR ", strerror $err, "\n"; |
107 | } else { |
117 | } else { |
108 | print ", saved as uudst/", $uu->filename, "\n"; |
118 | print " successfully saved as uudst/", $uu->filename, "\n"; |
109 | } |
119 | } |
110 | } |
120 | } |
111 | |
121 | |
112 | print "cleanup...\n"; |
122 | print "cleanup...\n"; |
113 | |
123 | |