X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/641204dfbdb9fc870cdd2e7f9e3169a44693e7bf..f204a070a53f7a2f05686d5ecad30da3fe2f0d27:/projects/sgconf/main.cpp diff --git a/projects/sgconf/main.cpp b/projects/sgconf/main.cpp index d2671be4..ec7dadc7 100644 --- a/projects/sgconf/main.cpp +++ b/projects/sgconf/main.cpp @@ -181,9 +181,11 @@ double ParseCash(const char * c, string * message) double cash; char * msg; char * str; -str = new char[strlen(c)]; +str = new char[strlen(c) + 1]; + +strncpy(str, c, strlen(c)); +str[strlen(c)] = 0; -strcpy(str, c); msg = strchr(str, ':'); if (msg) @@ -310,6 +312,22 @@ delete[] s; 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; @@ -417,6 +435,12 @@ if (!req->credit.res_empty()) strcat(r, str); } +if (!req->creditExpire.res_empty()) + { + sprintf(str, "\n", req->creditExpire.const_data()); + strcat(r, str); + } + if (!req->prepaidTraff.res_empty()) { sprintf(str, "\n", req->prepaidTraff.const_data()); @@ -679,7 +703,7 @@ REQUEST req; RESETABLE 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) @@ -724,6 +748,10 @@ while (1) req.credit = 1; break; + case 'E': //credit expire + req.creditExpire = 1; + break; + case 'd': //down req.down = 1; break; @@ -858,7 +886,7 @@ REQUEST req; RESETABLE 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; @@ -910,6 +938,10 @@ while (1) req.credit = ParseCredit(optarg); break; + case 'E': //credit expire + req.creditExpire = ParseCreditExpire(optarg); + break; + case 'd': //down req.down = ParseDownPassive(optarg); break; @@ -946,7 +978,7 @@ while (1) break; case 'A': //nAme - ParseAnyString(optarg, &str, "koi8-r"); + ParseAnyString(optarg, &str, "koi8-ru"); req.name = str; break;