]> git.stg.codes - stg.git/blobdiff - projects/sgconf/main.cpp
Fix compilation errors after splitting classes into interface and
[stg.git] / projects / sgconf / main.cpp
index ce8af73f7cbae348e8b9411598b1069b1e7324b1..ec7dadc77b1a7479e143d2b7959702389ec2626f 100644 (file)
@@ -312,6 +312,22 @@ delete[] s;
 return ss;
 }
 //-----------------------------------------------------------------------------
 return ss;
 }
 //-----------------------------------------------------------------------------
+time_t ParseCreditExpire(const char * str)
+{
+struct tm brokenTime;
+
+brokenTime.tm_wday = 0;
+brokenTime.tm_yday = 0;
+brokenTime.tm_isdst = 0;
+brokenTime.tm_hour = 0;
+brokenTime.tm_min = 0;
+brokenTime.tm_sec = 0;
+
+stg_strptime(str, "%Y-%m-%d", &brokenTime);
+
+return stg_timegm(&brokenTime);
+}
+//-----------------------------------------------------------------------------
 void ParseAnyString(const char * c, string * msg, const char * enc)
 {
 iconv_t cd;
 void ParseAnyString(const char * c, string * msg, const char * enc)
 {
 iconv_t cd;
@@ -419,6 +435,12 @@ if (!req->credit.res_empty())
     strcat(r, str);
     }
 
     strcat(r, str);
     }
 
+if (!req->creditExpire.res_empty())
+    {
+    sprintf(str, "<creditExpire value=\"%ld\"/>\n", req->creditExpire.const_data());
+    strcat(r, str);
+    }
+
 if (!req->prepaidTraff.res_empty())
     {
     sprintf(str, "<FreeMb value=\"%f\"/>\n", req->prepaidTraff.const_data());
 if (!req->prepaidTraff.res_empty())
     {
     sprintf(str, "<FreeMb value=\"%f\"/>\n", req->prepaidTraff.const_data());
@@ -681,7 +703,7 @@ REQUEST req;
 RESETABLE<string>   t1;
 int missedOptionArg = false;
 
 RESETABLE<string>   t1;
 int missedOptionArg = false;
 
-const char * short_options_get = "s:p:a:w:u:crtmodieNADLPGISO";
+const char * short_options_get = "s:p:a:w:u:crtmodieNADLPGISOE";
 int option_index = -1;
 
 while (1)
 int option_index = -1;
 
 while (1)
@@ -726,6 +748,10 @@ while (1)
             req.credit = 1;
             break;
 
             req.credit = 1;
             break;
 
+        case 'E': //credit expire
+            req.creditExpire = 1;
+            break;
+
         case 'd': //down
             req.down = 1;
             break;
         case 'd': //down
             req.down = 1;
             break;
@@ -860,7 +886,7 @@ REQUEST req;
 
 RESETABLE<string>   t1;
 
 
 RESETABLE<string>   t1;
 
-const char * short_options_set = "s:p:a:w:u:c:r:t:m:o:d:i:e:v:nlN:A:D:L:P:G:I:S:O:";
+const char * short_options_set = "s:p:a:w:u:c:r:t:m:o:d:i:e:v:nlN:A:D:L:P:G:I:S:O:E:";
 
 int missedOptionArg = false;
 
 
 int missedOptionArg = false;
 
@@ -912,6 +938,10 @@ while (1)
             req.credit = ParseCredit(optarg);
             break;
 
             req.credit = ParseCredit(optarg);
             break;
 
+        case 'E': //credit expire
+            req.creditExpire = ParseCreditExpire(optarg);
+            break;
+
         case 'd': //down
             req.down = ParseDownPassive(optarg);
             break;
         case 'd': //down
             req.down = ParseDownPassive(optarg);
             break;