Parcourir la source

Implemented default config file. Tested under Ubuntu; need to test

under Windows.


git-svn-id: https://svn.microneil.com/svn/SNF4CGP/trunk@45 59e8e3e7-56fa-483b-b4b4-fa6ab0af3dfc
master
adeniz il y a 15 ans
Parent
révision
3b2dc7305c
1 fichiers modifiés avec 23 ajouts et 4 suppressions
  1. 23
    4
      SNF4CGP/main.cpp

+ 23
- 4
SNF4CGP/main.cpp Voir le fichier

@@ -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.
}

Chargement…
Annuler
Enregistrer