Значит пишу дллку для сетевого телефона...
Отсылаю вот такую строку - "CommandID=[0];LineDevID=[14];CallID=[];Param1=[%S];Param2=[%S];"
Мне приходит точно такая-же строка только с другими параметрами Param1=[вот этими] и Param2=[и этими]..
Как можно вытащить эти параметры? В инете искал, но ничего не нашёл...
Вот код программы:
Код:
bool __stdcall rtcLogin( wchar_t* serverIP, wchar_t* userAccount, wchar_t* userPassword, wchar_t* serverPort )
{
if(!serverIP)
{
logWrite(L"Invalid serverIP", LOG_ERROR_MESSAGE);
return false;
}
if(!userAccount)
{
logWrite(L"Invalid userAccount", LOG_ERROR_MESSAGE);
return false;
}
if(!userPassword)
{
logWrite(L"Invalid userPassword", LOG_ERROR_MESSAGE);
return false;
}
if(!serverPort)
{
logWrite(L"Invalid serverPort", LOG_ERROR_MESSAGE);
return false;
}
const int ERROR_GET_PROFILE_FAILED = 0;
bool l_functionSucceeded = false;
HRESULT l_hResult = S_OK;
IRTCClientProvisioning* l_pIRTCClientProvisioning = NULL;
// start OCSLogin
SOCKET sClient;
char szBuffer[1024];
int ret;
struct sockaddr_in server;
struct hostent *host = NULL;
char szServerName[1024], szMessage[1024];
int szServerPort;
szServerPort = _wtoi(serverPort);
sprintf(szServerName, "%S", serverIP);
sprintf(szMessage, "CommandID=[0];LineDevID=[14];CallID=[];Param1=[%S];Param2=[%S];", userAccount, userPassword);
sClient = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sClient == INVALID_SOCKET)
{
logWrite(L"Can't create socket", LOG_ERROR_MESSAGE);
return 1;
}
server.sin_family = AF_INET;
server.sin_port = htons(szServerPort);
server.sin_addr.s_addr = inet_addr(szServerName);
if (server.sin_addr.s_addr == INADDR_NONE)
{
host = gethostbyname(szServerName);
if (host == NULL)
{
logWrite(L"Unable to resolve server", LOG_ERROR_MESSAGE);
return 1;
}
CopyMemory(&server.sin_addr, host->h_addr_list[0],
host->h_length);
}
if (connect(sClient, (struct sockaddr *)&server,
sizeof(server)) == SOCKET_ERROR)
{
logWrite(L"connect failed", LOG_ERROR_MESSAGE);
return 1;
}
// Send and receive data
ret = send(sClient, szMessage, strlen(szMessage), 0);
if (ret == SOCKET_ERROR)
{
logWrite(L"send failed", LOG_ERROR_MESSAGE);
}
Sleep(2000);
char szRecvBuff[1024];
ret = recv(sClient, szRecvBuff, 1024, 0);
if (ret == SOCKET_ERROR)
{
logWrite(L"recv failed", LOG_ERROR_MESSAGE);
}
logWrite(L"Recived data", LOG_INFO_MESSAGE);
if (ret == true)
{ logWrite(L"Data received!", LOG_INFO_MESSAGE); }
closesocket(sClient);
//stop OSCLogin
logWrite( L"Logging in...", LOG_INFO_MESSAGE );
try
{
l_hResult = g_globals.pIRTCClient->QueryInterface( IID_IRTCClientProvisioning,
reinterpret_cast<void**> (&l_pIRTCClientProvisioning) );
long l_cookie;
std::wstringstream uri;
SOCKET s = socket(AF_INET, SOCK_STREAM, 0);
uri<<L"SIP:"<<userAccount<<'@'<<serverIP;
l_hResult = l_pIRTCClientProvisioning->GetProfile( userAccount,
userPassword,
(BSTR)uri.str().c_str(),
serverIP,
g_globals.options.transportProtocol,
(LONG_PTR)&l_cookie );
if ( FAILED(l_hResult) )
throw ERROR_GET_PROFILE_FAILED;
logWrite( L"REGISTER XML successfully generated and sent to the server.", LOG_OK_MESSAGE );
l_functionSucceeded = true;
}
catch( int l_error )
{
std::wstring l_errorString = L"";
switch ( l_error )
{
case ERROR_GET_PROFILE_FAILED:
if (l_errorString == L"") l_errorString = L"Failed to create a profile.";
switch ( l_hResult ){
case RTC_E_UDP_NOT_SUPPORTED:
l_errorString += L" UDP is not supported by the current authentication type.";
break;
}
break;
}
logWrite( l_errorString.c_str(), LOG_ERROR_MESSAGE, l_hResult );
l_functionSucceeded = false;
}
SAFE_RELEASE(l_pIRTCClientProvisioning);
g_globals.dllState.rtcLoginSucceeded = l_functionSucceeded;
return l_functionSucceeded;
}