RZ

01: // LocalScan.gateway.cc # the actual synthesize algorithm
02:
03: #include <sstream>
04: #include <vector>
05:
06: #include "ExtractIntermediate.hh"
07: #include "LocalScan.hh"
08:
09: using namespace RZ;
10:
11: int main(unsigned int argc, char **argv)
12: {
13:     // ######## gnu and library specific stuff ########
14:
15:     std::ios::sync_with_stdio(false);
16:     std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
17:
18:     // invocation
19:     // LocalScan.gateway RZWRAPPERFD LTABFD RTABFD [GIVENFD...]
20:
21:     if (argc < 4) throw
22:         RZ::Error("Insufficient number of commandline arguments");
23:     else if (argc == 4) return 0;
24:
25:     int rzwrapperfd = 0, ltabfd = 0, rtabfd = 0;
26:     std::vector< int > givenfd;
27:     (std::istringstream(argv[1])) >> rzwrapperfd;
28:     (std::istringstream(argv[2])) >> ltabfd;
29:     (std::istringstream(argv[3])) >> rtabfd;
30:     for (unsigned int i = 4; i < argc; ++i) {
31:         int t = 0;
32:         (std::istringstream(argv[i])) >> t;
33:         givenfd.push_back(t);
34:     }
35:
36:     // read rgz file header and set up local and remote reservation tables
37:     RZ::Scanner scanner(1, IntermediateWrapper(rzwrapperfd), ltabfd, rtabfd);
38:     //close(rzwrapperfd);
39:     close(ltabfd);
40:     close(rtabfd);
41:
42:     // scan each given fd
43:     for (
44:         std::vector< int >::iterator
45:             giveni = givenfd.begin(), giveniend = givenfd.end();
46:         giveni < giveniend;
47:         ++giveni)
48:     {
49:         try {
50:             scanner.scan_mmap(*giveni);
51:         }
52:         catch (RZ::MMapError x) {
53:             scanner.scan_circular(*giveni);
54:         }
55:         close(*giveni);
56:     }
57:
58:     return 0;
59: }
60:     
61: // LocalScan.gateway.cc # the actual synthesize algorithm