]> git.stg.codes - stg.git/blobdiff - projects/sgauthstress/settings.cpp
Merge branch 'stg-2.409-radius'
[stg.git] / projects / sgauthstress / settings.cpp
index 9055ceed24df59e9b11190f92a79ca2782653ed1..62adc14359f0eb7ad493ec2c7e19f36c8df55f0c 100644 (file)
 SETTINGS::SETTINGS()
     : port(0),
       localPort(0),
-      confFile("/etc/sgauth.conf")
+      confFile("sgauthstress.conf")
 {
 }
 //-----------------------------------------------------------------------------
-int ParseYesNo(const string & value, bool * val)
-{
-if (0 == strcasecmp(value.c_str(), "yes"))
-    {
-    *val = true;
-    return 0;
-    }
-if (0 == strcasecmp(value.c_str(), "no"))
-    {
-    *val = false;
-    return 0;
-    }
-
-return -1;
-}
-//-----------------------------------------------------------------------------
-int ParseInt(const string & value, int * val)
-{
-if (str2x<int>(value, *val))
-    return -1;
-
-return 0;
-}
-//-----------------------------------------------------------------------------
-int ParseUnsigned(const string & value, unsigned * val)
-{
-if (str2x<unsigned>(value, *val))
-    return -1;
-
-return 0;
-}
-//-----------------------------------------------------------------------------
-int ParseIntInRange(const string & value, int min, int max, int * val)
-{
-if (ParseInt(value, val) != 0)
-    return -1;
-
-if (*val < min || *val > max)
-    return -1;
-
-return 0;
-}
-//-----------------------------------------------------------------------------
-int ParseUnsignedInRange(const string & value, unsigned min, unsigned max, unsigned * val)
-{
-if (ParseUnsigned(value, val) != 0)
-    return -1;
-
-if (*val < min || *val > max)
-    return -1;
-
-return 0;
-}
-//-----------------------------------------------------------------------------
 int ParseModuleSettings(const DOTCONFDocumentNode * node, std::vector<PARAM_VALUE> * params)
 {
 assert(node && "DOTCONFDocumentNode must not be NULL!");
@@ -99,6 +45,7 @@ while (childNode)
     PARAM_VALUE pv;
     pv.param = childNode->getName();
     int i = 0;
+    const char * value;
     while ((value = childNode->getValue(i++)) != NULL)
         pv.value.push_back(value);
     params->push_back(pv);
@@ -116,7 +63,7 @@ const char * requiredOptions[] = {
     "Login",
     "Password",
     "ServerName",
-    "ServerPort"
+    "ServerPort",
     NULL
     };
 
@@ -144,19 +91,23 @@ while (node)
     else if (strcasecmp(node->getName(), "ServerName") == 0)
         serverName = node->getValue(0);
     else if (strcasecmp(node->getName(), "ServerPort") == 0)
+        {
         if (ParseIntInRange(node->getValue(0), 1, 65535, &port))
             {
             strError = "Parameter 'ServerPort' is not valid.";
             printfd(__FILE__, "SETTINGS::ReadSettings() - %s\n", strError.c_str());
             return -1;
             }
+        }
     else if (strcasecmp(node->getName(), "LocalPort") == 0)
+        {
         if (ParseIntInRange(node->getValue(0), 0, 65535, &localPort))
             {
             strError = "Parameter 'LocalPort' is not valid.";
             printfd(__FILE__, "SETTINGS::ReadSettings() - %s\n", strError.c_str());
             return -1;
             }
+        }
     else if (strcasecmp(node->getName(), "StoreModule") == 0)
         {
         if (node->getValue(1))