increased ipc message length.

This commit is contained in:
Nick Bolton
2012-07-03 17:33:19 +00:00
parent 7d5fbde71d
commit 0537bbdfad
6 changed files with 42 additions and 36 deletions

View File

@@ -21,6 +21,7 @@
#include "Ipc.h"
#include "CLog.h"
#include "CIpcMessage.h"
#include "CProtocolUtil.h"
CEvent::Type CIpcClientProxy::s_messageReceivedEvent = CEvent::kUnknown;
@@ -88,11 +89,9 @@ CIpcClientProxy::send(const CIpcMessage& message)
case kIpcLogLine: {
CString* s = (CString*)message.m_data;
const char* data = s->c_str();
int len = strlen(data);
UInt8 lenBuf[1];
lenBuf[0] = len;
m_stream.write(lenBuf, 1);
CProtocolUtil::writef(&m_stream, "%2i", len);
m_stream.write(data, len);
}
@@ -109,13 +108,13 @@ CIpcClientProxy::send(const CIpcMessage& message)
void*
CIpcClientProxy::parseCommand()
{
UInt8 len[1];
m_stream.read(len, 1);
int len = 0;
CProtocolUtil::readf(&m_stream, "%2i", &len);
UInt8* buffer = new UInt8[len[0]];
m_stream.read(buffer, len[0]);
UInt8* buffer = new UInt8[len];
m_stream.read(buffer, len);
return new CString((const char*)buffer, len[0]);
return new CString((const char*)buffer, len);
}
void

View File

@@ -21,6 +21,7 @@
#include "CLog.h"
#include "CIpcMessage.h"
#include "Ipc.h"
#include "CProtocolUtil.h"
CEvent::Type CIpcServerProxy::s_messageReceivedEvent = CEvent::kUnknown;
@@ -80,12 +81,12 @@ CIpcServerProxy::send(const CIpcMessage& message)
switch (message.m_type) {
case kIpcCommand: {
CString* s = (CString*)message.m_data;
const char* data = s->c_str();
int len = strlen(data);
CProtocolUtil::writef(&m_stream, "%2i", len);
UInt8 len[1];
len[0] = s->size();
m_stream.write(len, 1);
m_stream.write(s->c_str(), s->size());
m_stream.write(data, len);
}
break;
@@ -98,13 +99,13 @@ CIpcServerProxy::send(const CIpcMessage& message)
void*
CIpcServerProxy::parseLogLine()
{
UInt8 len[1];
m_stream.read(len, 1);
int len = 0;
CProtocolUtil::readf(&m_stream, "%2i", &len);
UInt8* buffer = new UInt8[len[0]];
m_stream.read(buffer, len[0]);
UInt8* buffer = new UInt8[len];
m_stream.read(buffer, len);
return new CString((const char*)buffer, len[0]);
return new CString((const char*)buffer, len);
}
void

View File

@@ -43,6 +43,7 @@ set(inc
../io
../mt
../net
../synergy
)
if (UNIX)
@@ -55,5 +56,5 @@ include_directories(${inc})
add_library(ipc STATIC ${src})
if (UNIX)
target_link_libraries(arch base common mt io net)
target_link_libraries(arch base common mt io net synergy)
endif()