|
|
@@ -16,15 +16,34 @@ using namespace std; |
|
|
|
const string SNF4CGP_VERSION_INFO = "CGPSNF Version 0.1.0 Build: " __DATE__ " " __TIME__;
|
|
|
|
|
|
|
|
const int ConfigPathArgNumber = 1;
|
|
|
|
const int CorrectArgcNumber = 2;
|
|
|
|
const int MaxArgcNumber = 2;
|
|
|
|
|
|
|
|
#if defined(WIN32) || defined(WIN64)
|
|
|
|
const string DefaultConfigPath = "C:\\CommuniGatePro\\CGPSNF\\snf_engine.xml";
|
|
|
|
#else
|
|
|
|
const string DefaultConfigPath = "/var/CommuniGate/CGPSNF/snf_engine.xml";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bool CommandLineIsValid(int argc, char*argv[]) { // Validate the command line.
|
|
|
|
if(CorrectArgcNumber != argc) {
|
|
|
|
cout << "* CGPSNF - Bad command line, use CGPSNF <path_to_config_file>" << endl;
|
|
|
|
if(argc > MaxArgcNumber) {
|
|
|
|
cout << "* CGPSNF - Bad command line. Use:" << endl
|
|
|
|
<< "\tCGPSNF <path_to_config_file>" << endl
|
|
|
|
<< "to use the specified config file, or" << endl
|
|
|
|
<< "\tCGSNF" << endl
|
|
|
|
<< "to use the default config file '" << DefaultConfigPath << "'"
|
|
|
|
<< endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
string GetConfigPath(int argc, char *argv[]) { // Returns the config file name.
|
|
|
|
if (ConfigPathArgNumber < argc) {
|
|
|
|
return string(argv[ConfigPathArgNumber]);
|
|
|
|
}
|
|
|
|
return DefaultConfigPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
void go(string ConfigurationPath) { // Application's main thread.
|
|
|
|
try {
|
|
|
|
ExecutiveProcess SNF4CGP(SNF4CGP_VERSION_INFO, ConfigurationPath);
|
|
|
@@ -41,6 +60,6 @@ void go(string ConfigurationPath) { |
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) { // Main entry point.
|
|
|
|
if(CommandLineIsValid(argc, argv)) go(argv[ConfigPathArgNumber]); // With a good command line we go.
|
|
|
|
if(CommandLineIsValid(argc, argv)) go(GetConfigPath(argc, argv)); // With a good command line we go.
|
|
|
|
return 0; // Then we're done.
|
|
|
|
}
|