File: example-decoder

package info (click to toggle)
libconvert-uulib-perl 0.201-2woody1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 756 kB
  • ctags: 440
  • sloc: ansic: 7,268; perl: 118; makefile: 95; awk: 13
file content (73 lines) | stat: -rwxr-xr-x 1,566 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/perl

# decode all the files in the directory uusrc/ and copy
# the resulting files to uudst/

use Convert::UUlib ':all';

sub namefilter {
   my($path)=@_;
   $path=~s/^.*[\/\\]//;
   $path;
}

sub busycb {
   my($action,$curfile,$partno,$numparts,$percent,$fsize)=@_;
   $_[0]=straction($action);
   print "busy_callback(",join(",",@_),")\n";
   0;
}

SetOption (OPT_IGNMODE, 1);
SetOption (OPT_VERBOSE, 1);

# show the three ways you can set callback functions
SetFNameFilter (\&namefilter);

SetBusyCallback ("busycb",333);

SetMsgCallback (sub {
   my($msg,$level)=@_;
   print uc(strmsglevel($_[1])),": $msg\n";
});

for(<uusrc/*>) {
   my($retval,$count)=LoadFile ($_,$_,1);
   print "file($_), status(",strerror($retval),") parts($count)\n";
}

SetOption (OPT_SAVEPATH, "uudst/");

$i=0;
while($uu=GetFileListItem($i)) {
   $i++;
   print "file nr. $i";
   print " state ",$uu->state;
   print " mode ",$uu->mode;
   print " uudet ",strencoding($uu->uudet);
   print " size ",$uu->size;
   print " filename ",$uu->filename;
   print " subfname ",$uu->subfname;
   print " mimeid ",$uu->mimeid;
   print " mimetype ",$uu->mimetype;
   print "\n";

   # print additional info about all parts
   for($uu->parts) {
      while(my($k,$v)=each(%$_)) {
         print "$k > $v, ";
      }
      print "\n";
   }

   print strerror($uu->decode_temp)."\n";
   print " temporarily decoded to ",$uu->binfile,"\n";
   $uu->remove_temp;

   print strerror($uu->decode)."\n";
   print " saved as uudst/",$uu->filename,"\n";
}

print "cleanup...\n";

CleanUp();