void ParseAnyString(const char * c, string * msg, const char * enc)
{
iconv_t cd;
-char * ob = new char[strlen(c) + 1];
-char * ib = new char[strlen(c) + 1];
-
-strcpy(ib, c);
-
-char * outbuf = ob;
-char * inbuf = ib;
setlocale(LC_ALL, "");
size_t nconv = 1;
-size_t insize = strlen(ib);
-size_t outsize = strlen(ib);
-
-insize = strlen(c);
-
cd = iconv_open(charsetT, charsetF);
if (cd == (iconv_t) -1)
{
exit(ICONV_ERR_CODE);
}
-#if defined(FREE_BSD) || defined(FREE_BSD5)
+char * ob = new char[strlen(c) + 1];
+char * ib = new char[strlen(c) + 1];
+
+strcpy(ib, c);
+
+char * outbuf = ob;
+char * inbuf = ib;
+
+size_t insize = strlen(c);
+size_t outsize = strlen(ib);
+
+#if defined(CONST_ICONV)
nconv = iconv (cd, (const char**)&inbuf, &insize, &outbuf, &outsize);
#else
nconv = iconv (cd, &inbuf, &insize, &outbuf, &outsize);
if (!req->usrMsg.empty())
{
string msg;
- Encode12str(msg, req->usrMsg.data());
+ Encode12str(msg, req->usrMsg.const_data());
sprintf(str, "<Message login=\"%s\" msgver=\"1\" msgtype=\"1\" repeat=\"0\" repeatperiod=\"0\" showtime=\"0\" text=\"%s\"/>", req->login.const_data().c_str(), msg.c_str());
//sprintf(str, "<message login=\"%s\" priority=\"0\" text=\"%s\"/>\n", req->login, msg);
strcat(r, str);
if (!req->cash.empty())
{
string msg;
- Encode12str(msg, req->message.data());
+ Encode12str(msg, req->message.c_str());
sprintf(str, "<cash add=\"%f\" msg=\"%s\"/>\n", req->cash.const_data(), msg.c_str());
strcat(r, str);
}
if (!req->setCash.empty())
{
string msg;
- Encode12str(msg, req->message.data());
+ Encode12str(msg, req->message.c_str());
sprintf(str, "<cash set=\"%f\" msg=\"%s\"/>\n", req->setCash.const_data(), msg.c_str());
strcat(r, str);
}
if (!req->note.empty())
{
string note;
- Encode12str(note, req->note.data());
+ Encode12str(note, req->note.const_data());
sprintf(str, "<note value=\"%s\"/>", note.c_str());
strcat(r, str);
}
if (!req->name.empty())
{
string name;
- Encode12str(name, req->name.data());
+ Encode12str(name, req->name.const_data());
sprintf(str, "<name value=\"%s\"/>", name.c_str());
strcat(r, str);
}
if (!req->address.empty())
{
string address;
- Encode12str(address, req->address.data());
+ Encode12str(address, req->address.const_data());
sprintf(str, "<address value=\"%s\"/>", address.c_str());
strcat(r, str);
}
if (!req->email.empty())
{
string email;
- Encode12str(email, req->email.data());
+ Encode12str(email, req->email.const_data());
sprintf(str, "<email value=\"%s\"/>", email.c_str());
strcat(r, str);
}
if (!req->phone.empty())
{
string phone;
- Encode12str(phone, req->phone.data());
+ Encode12str(phone, req->phone.const_data());
sprintf(str, "<phone value=\"%s\"/>", phone.c_str());
strcat(r, str);
}
if (!req->group.empty())
{
string group;
- Encode12str(group, req->group.data());
+ Encode12str(group, req->group.const_data());
sprintf(str, "<group value=\"%s\"/>", group.c_str());
strcat(r, str);
}
if (!req->ud[i].empty())
{
string ud;
- Encode12str(ud, req->ud[i].data());
+ Encode12str(ud, req->ud[i].const_data());
sprintf(str, "<userdata%d value=\"%s\"/>", i, ud.c_str());
strcat(r, str);
}
}
if (req.authBy)
- return ProcessAuthBy(req.server.data(), req.port.data(), req.admLogin.data(), req.admPasswd.data(), req.login.data(), &req);
+ return ProcessAuthBy(req.server.const_data(), req.port.const_data(), req.admLogin.const_data(), req.admPasswd.const_data(), req.login.const_data(), &req);
else
- return ProcessGetUser(req.server.data(), req.port.data(), req.admLogin.data(), req.admPasswd.data(), req.login.data(), &req);
+ return ProcessGetUser(req.server.const_data(), req.port.const_data(), req.admLogin.const_data(), req.admPasswd.const_data(), req.login.const_data(), &req);
}
//-----------------------------------------------------------------------------
int mainSet(int argc, char **argv)
break;
case 'P': //phone
- ParseAnyString(optarg, &str);
+ ParseAnyString(optarg, &str, "koi8-ru");
req.phone = str;
break;
case 707:
case 708:
case 709:
- ParseAnyString(optarg, &str);
+ ParseAnyString(optarg, &str, "koi8-ru");
//printf("UD%d\n", c - 700);
req.ud[c - 700] = str;
break;
memset(rstr, 0, rLen);
CreateRequestSet(&req, rstr);
-return ProcessSetUser(req.server.data(), req.port.data(), req.admLogin.data(), req.admPasswd.data(), rstr, NULL, isMessage);
+return ProcessSetUser(req.server.const_data(), req.port.const_data(), req.admLogin.const_data(), req.admPasswd.const_data(), rstr, NULL, isMessage);
}
//-----------------------------------------------------------------------------
int main(int argc, char **argv)