diff options
author | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2007-07-01 17:33:01 +0000 |
---|---|---|
committer | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2007-07-01 17:33:01 +0000 |
commit | 287cb92158ee9eeba5eac6edea7d830777810beb (patch) | |
tree | 5e7f04cf1f1c80469f6ac496ccb8fc1776beab81 | |
parent | 7d2d0d17e720b43162433410b88ff1de7f019f38 (diff) |
finally fixed packet reading code
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@236 4f64403b-2f21-0410-a795-97e2b3489a10
-rw-r--r-- | MySpace/NetMessage.cpp | 13 | ||||
-rw-r--r-- | MySpace/server_con.cpp | 17 | ||||
-rw-r--r-- | MySpace/version.h | 2 |
3 files changed, 21 insertions, 11 deletions
diff --git a/MySpace/NetMessage.cpp b/MySpace/NetMessage.cpp index 45b9159..a43ce85 100644 --- a/MySpace/NetMessage.cpp +++ b/MySpace/NetMessage.cpp @@ -175,11 +175,14 @@ int NetMessage::parse(char *data, int size) { key = &data[start];
start = end + 1;
- end = start;
- while(end < size && data[end] != '\\') end++;
- if(end < size) {
- data[end] = 0;
- value = &data[start];
+ if(strcmp(key, "final") != 0) {
+ end = start;
+ while(end < size && data[end] != '\\') end++;
+ if(end < size) {
+ data[end] = 0;
+ value = &data[start];
+ } else
+ value = 0;
} else
value = 0;
} else {
diff --git a/MySpace/server_con.cpp b/MySpace/server_con.cpp index e7eea8d..87cb69e 100644 --- a/MySpace/server_con.cpp +++ b/MySpace/server_con.cpp @@ -251,14 +251,18 @@ void __cdecl ServerThreadFunc(void*) { myspace_server_running = true;
- char *recv_buffer = new char[SERVER_READ_BUFFER_SIZE];
+ char *recv_buffer = new char[SERVER_READ_BUFFER_SIZE + 1];
int bytes = 0;
char mt[256];
int tries = 0;
bool login = true;
+ int bytes_read;
HANDLE connection = 0;
+ char *pbuff = recv_buffer, *end;
+ int buffer_bytes = 0;
+ recv_buffer[SERVER_READ_BUFFER_SIZE] = 0;
while(!Miranda_Terminated() && !server_stop) {
if(login) {
if(connection) Netlib_CloseHandle(connection);
@@ -273,7 +277,9 @@ void __cdecl ServerThreadFunc(void*) { }
}
}
- bytes = Netlib_Recv(connection, (char *)recv_buffer, SERVER_READ_BUFFER_SIZE, MSG_DUMPASTEXT);
+ bytes = Netlib_Recv(connection, (char *)pbuff, SERVER_READ_BUFFER_SIZE - (pbuff - recv_buffer), MSG_DUMPASTEXT);
+ buffer_bytes += bytes;
+ pbuff[bytes] = 0;
if(bytes == 0) {
//PUShowMessage("Connection closed", SM_NOTIFY);
@@ -299,8 +305,7 @@ void __cdecl ServerThreadFunc(void*) { DBWriteContactSettingDword(0, MODULE, "LastPort", conn_data.wPort);
}
- char *pbuff = recv_buffer, *end;
- while((end = strstr(pbuff, "\\final\\")) != 0 && (end - recv_buffer <= bytes)) {
+ while((end = strstr(pbuff, "\\final\\")) != 0) {
//mir_snprintf(mt, 256, "recvd %d bytes", bytes);
//PUShowMessage(mt, SM_NOTIFY);
end += 7;
@@ -540,7 +545,9 @@ void __cdecl ServerThreadFunc(void*) { }
}
}
- pbuff = end;
+ buffer_bytes -= (end - pbuff);
+ memmove(recv_buffer, end, buffer_bytes);
+ pbuff = recv_buffer;
}
}
}
diff --git a/MySpace/version.h b/MySpace/version.h index adeec54..fca11da 100644 --- a/MySpace/version.h +++ b/MySpace/version.h @@ -5,7 +5,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 0
#define __RELEASE_NUM 1
-#define __BUILD_NUM 6
+#define __BUILD_NUM 7
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
|