00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "config.h"
00023 #include "RTIG.hh"
00024 #include "RTIG_cmdline.h"
00025 #include "certi.hh"
00026
00027 #ifdef _WIN32
00028 #include <signal.h>
00029 #endif
00030
00031 #include <new>
00032 #include <csignal>
00033
00034 using namespace certi ;
00035 using namespace certi::rtig ;
00036 using std::cerr ;
00037 using std::cout ;
00038 using std::endl ;
00039 using std::string ;
00040
00041
00043 extern "C" void SignalHandler(int sig)
00044 {
00045 RTIG::signalHandler(sig);
00046
00047 std::signal(sig, SignalHandler);
00048 }
00049
00050
00052 void
00053 NewHandler()
00054 throw (MemoryExhausted)
00055 {
00056 throw MemoryExhausted("main RTIG");
00057 }
00058
00059
00094 int main(int argc, char *argv[])
00095 {
00096 RTIG myRTIG;
00097 gengetopt_args_info args ;
00098 if (cmdline_parser(argc, argv, &args)) exit(EXIT_FAILURE);
00099
00100 int verboseLevel = 2;
00101 if (args.verbose_given)
00102 verboseLevel = args.verbose_arg;
00103
00104 #if _WIN32
00105 string dn = string(argv[0]);
00106 dn = dn.substr(0,dn.find_last_of("\\"));
00107 dn = dn.substr(0,dn.find_last_of("\\"));
00108 if (NULL==getenv("CERTI_HOME")) {
00109 dn = "CERTI_HOME="+dn+"\\";
00110 cout << "Updating : " << dn << endl;
00111 putenv(dn.c_str());
00112 }
00113 #endif
00114
00115 if (verboseLevel>0) {
00116 cout << "CERTI RTIG " VERSION " - Copyright 2002-2008 ONERA" << endl ;
00117 cout << "This is free software ; see the source for copying "
00118 << "conditions. There is NO\nwarranty ; not even for "
00119 << "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
00120 << endl << endl ;
00121 }
00122
00123 std::signal(SIGINT, SignalHandler);
00124 #ifndef _WIN32
00125 std::signal(SIGPIPE, SignalHandler);
00126 #endif
00127
00128 std::set_new_handler(NewHandler);
00129
00130 myRTIG.setVerboseLevel(verboseLevel);
00131 myRTIG.execute();
00132
00133 if (verboseLevel>0) {
00134 cout << "CERTI RTIG exiting." << endl ;
00135 }
00136 exit(EXIT_SUCCESS);
00137 }