X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/38ae57da63d8faa84bc639b15774567c49fedf40..471a8ddb278cb5621e36a6c45e450d40580e50fd:/projects/sgconf/common_sg.cpp diff --git a/projects/sgconf/common_sg.cpp b/projects/sgconf/common_sg.cpp index 27f0b9f9..d197e982 100644 --- a/projects/sgconf/common_sg.cpp +++ b/projects/sgconf/common_sg.cpp @@ -24,6 +24,10 @@ $Date: 2009/06/08 10:02:28 $ */ +#include "stg/common.h" +#include "sg_error_codes.h" +#include "common_sg.h" +#include "version_sg.h" #include #include @@ -34,11 +38,6 @@ #include #include -#include "stg/common.h" -#include "sg_error_codes.h" -#include "common_sg.h" -#include "version_sg.h" - using namespace std; const int usageConf = 0; @@ -90,7 +89,7 @@ HelpParams hp[] = {"set credit expire", "get credit expire", "-E", ""}, {"set password", "get password", "-o", ""}, {"set prepaid traffic", "get prepaid traffic", "-e", ""}, - {"set IP-addresses", "get IP-addresses", "-I", "<*|ip_addr[,ip_addr...]>"}, + {"set IP-addresses", "get IP-addresses", "-I", "<*|ip_addr[,ip_addr...]>"}, {"set name", "get name", "-A", ""}, {"set note", "get note", "-N", ""}, {"set street address", "get street address", "-D", "
"}, @@ -213,13 +212,6 @@ return usr; void ConvertKOI8(const string & src, string * dst, int encType) { iconv_t cd; -char * ob = new char[src.size() * 2 + 1]; -char * ib = new char[src.size() + 1]; - -strcpy(ib, src.c_str()); - -char * outbuf = ob; -char * inbuf = ib; setlocale(LC_ALL, ""); @@ -239,11 +231,6 @@ else size_t nconv = 1; -size_t insize = strlen(ib); -size_t outsize = insize * 2 + 1; - -insize = src.size(); - cd = iconv_open(charsetT, charsetF); if (cd == (iconv_t) -1) { @@ -259,7 +246,20 @@ if (cd == (iconv_t) -1) exit(ICONV_ERR_CODE); } -#if defined(FREE_BSD) || defined(FREE_BSD5) +char * ob = new char[src.size() * 2 + 1]; +char * ib = new char[src.size() + 1]; + +strcpy(ib, src.c_str()); + +char * outbuf = ob; +char * inbuf = ib; + +size_t insize = strlen(ib); +size_t outsize = insize * 2 + 1; + +insize = src.size(); + +#if defined(CONST_ICONV) nconv = iconv(cd, (const char **)&inbuf, &insize, &outbuf, &outsize); #else nconv = iconv(cd, &inbuf, &insize, &outbuf, &outsize); @@ -290,21 +290,12 @@ void ConvertFromKOI8(const string & src, string * dst) ConvertKOI8(src, dst, FROM_KOI8); } //----------------------------------------------------------------------------- -void ConvertToKOI8(const string & src, string * dst) -{ -ConvertKOI8(src, dst, TO_KOI8); -} -//----------------------------------------------------------------------------- int RecvSetUserAnswer(const char * ans, void * d) { -GetUserCbData * gucbd; -gucbd = (GetUserCbData *)d; +GetUserCbData * gucbd = static_cast(d); bool * result = gucbd->result; -//REQUEST * req = (REQUEST *)gucbd->data; - -//printf("ans=%s\n", ans); if (strcasecmp("Ok", ans) == 0) *result = true; else @@ -322,8 +313,7 @@ struct StringReqParams //----------------------------------------------------------------------------- void RecvUserData(USERDATA * ud, void * d) { -GetUserCbData * gucbd; -gucbd = (GetUserCbData *)d; +GetUserCbData * gucbd = static_cast(d); bool * result = gucbd->result; @@ -404,7 +394,7 @@ StringReqParams strReqParams[] = {"group", req->group, &ud->group}, {"tariff", req->tariff, &ud->tariff}, {"password", req->usrPasswd, &ud->password}, - {"ip", req->ips, &ud->ips} // IP-address of user + {"ip", req->ips, &ud->ips} // IP-address of user }; for (unsigned i = 0; i < sizeof(strReqParams) / sizeof(StringReqParams); i++) { @@ -420,8 +410,7 @@ for (unsigned i = 0; i < sizeof(strReqParams) / sizeof(StringReqParams); i++) //----------------------------------------------------------------------------- void RecvAuthByData(const std::vector & list, void * d) { -AuthByCbData * abcbd; -abcbd = (AuthByCbData *)d; +AuthByCbData * abcbd = static_cast(d); bool * result = abcbd->result;