RZ

01: # FileAnalyze.pl # wrapper for C++ code
02: # FileAnalysis.hh # the actual analyze algorithm
03:
04: use strict;
05:
06: require "GetoptAnalyze.pl";
07: local( $::debug ) = GetoptAnalyze::debug();
08:
09: package FileAnalyze;
10:
11: ######## ######## ######## ######## ######## ######## ######## ######## ########
12:
13: my ( $SOURCEFILE, $RZA, $RZB, $RZC );
14:
15: {
16:     local( $^F ) = 1<<31 - 1; # want our open files visible after exec
17:
18:     GetoptAnalyze::openh( departure => $SOURCEFILE );
19:     GetoptAnalyze::differh( destination => $SOURCEFILE );
20:
21:     print STDERR "  departure -> tempfiles\n" if $::debug;
22:
23:     # RZA - header and stream structure
24:     # RZB - signature table
25:     # RZC - compressed data stream
26:     open $RZA, "+>", undef or die "Can't open tempfile\n";
27:     open $RZB, "+>", undef or die "Can't open tempfile\n";
28:     open $RZC, "+>", undef or die "Can't open tempfile\n";
29: }
30:
31: {
32:     ######## ######## ######## wrap C++ code ######## ######## ########
33:
34:     my @DESCRIPTORS = map fileno( $_ ), ( $SOURCEFILE, $RZA, $RZB, $RZC );
35:
36:     print STDERR
37:         "  fork and exec to C++ with descriptors @DESCRIPTORS\n" if $::debug;
38:
39:     system { $INC[0]."/FileAnalyze.gateway" } ( $0, @DESCRIPTORS ) and die
40:         "Analyzer failure: $?\n";
41:
42:     ######## ######## ######## ######## ######## ######## ######## ########
43: }
44:
45: GetoptAnalyze::backh( departure => );
46: GetoptAnalyze::backh( destination => );
47:
48: {
49:     my $DESTINATION;
50:
51:     GetoptAnalyze::converth( $SOURCEFILE => $DESTINATION ) or (
52:         GetoptAnalyze::closeh( $SOURCEFILE ),
53:         GetoptAnalyze::openh( destination => $DESTINATION ),
54:     );
55:
56:     print STDERR "  tempfiles -> destination\n" if $::debug;
57:
58:     for my $RZ ( $RZA, $RZB, $RZC ) {
59:         seek( $RZ, 0 , 0 );
60:         while( read( $RZ, my $bk, 8192 ) ) { print $DESTINATION $bk; }
61:     }
62:
63:     GetoptAnalyze::closeh( $DESTINATION );
64: }
65:
66: ######## ######## ######## ######## ######## ######## ######## ######## ########
67:
68: # FileAnalyze.pl # wrapper for C++ code
69:
70: 1;