Update of /cvsroot/sharedaemon/core/src
In directory sc8-pr-cvs1:/tmp/cvs-serv9377
Modified Files:
Addr.cpp Addr.h Array.h Client.cpp Client.h Ed2kConnection.cpp
Ed2kConnection.h Ed2kPacket.cpp Ed2kPacket.h Ed2kSocket.cpp
MultiLevelBitmap.cpp ParseClass.cpp ParseClass.h Socket.cpp
Socket.h debug.h osdep.cpp osdep.h parse-ed2k.c parse-ed2k.h
util.cpp util.h
Log Message:
Reformatted very big amout of code to fit 80 CPL limit
Index: Addr.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/Addr.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Addr.cpp 29 Sep 2003 22:06:21 -0000 1.3
+++ Addr.cpp 20 Nov 2003 16:21:24 -0000 1.4
@@ -44,7 +44,9 @@
if (dns==next_dns || c>255 || *next_dns!='.') goto bad_ip;
dns=++next_dns;
d=strtoul(dns,&next_dns,10);
- if (dns==next_dns || d>255 || (*next_dns && *next_dns!=':')) goto bad_ip;
+ if (dns==next_dns || d>255 || (*next_dns && *next_dns!=':')) {
+ goto bad_ip;
+ }
SocketAddress.sin_family=AF_INET;
SocketAddress.sin_port=htons(port);
SocketAddress.sin_addr.s_addr=htonl(a<<24 | b<<16 | c<<8 | d);
Index: Addr.h
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/Addr.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Addr.h 12 Aug 2003 10:35:16 -0000 1.4
+++ Addr.h 20 Nov 2003 16:21:24 -0000 1.5
@@ -61,7 +61,13 @@
resolver_id=-1;
}
void SetPort(u16 port) { SocketAddress.sin_port=htons(port); }
- void SetIP(u32 ip) { if (resolver_id!=-1) { close(resolver_id); resolver_id=-1; } SocketAddress.sin_addr.s_addr=htonl(ip); }
+ void SetIP(u32 ip) {
+ if (resolver_id!=-1) {
+ close(resolver_id);
+ resolver_id=-1;
+ }
+ SocketAddress.sin_addr.s_addr=htonl(ip);
+ }
u32 GetIP() const { return ntohl(SocketAddress.sin_addr.s_addr); }
u16 GetPort() const { return ntohs(SocketAddress.sin_port); }
Index: Array.h
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/Array.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Array.h 31 Oct 2003 21:00:11 -0000 1.4
+++ Array.h 20 Nov 2003 16:21:24 -0000 1.5
@@ -81,7 +81,9 @@
delete ptr_array[i];
}
- new_ptr_array=(T**)realloc((void*)ptr_array,sizeof(T)*new_size);
+ new_ptr_array=(T**)realloc(
+ (void*)ptr_array,sizeof(T)*new_size
+ );
if (new_ptr_array || !new_size) {
ptr_array=new_ptr_array;
}
@@ -93,7 +95,9 @@
T * * new_ptr_array;
size_t i;
- new_ptr_array=(T**)realloc((void*)ptr_array,sizeof(T*)*new_size);
+ new_ptr_array=(T**)realloc(
+ (void*)ptr_array,sizeof(T*)*new_size
+ );
if (!new_ptr_array) {
throw std::bad_alloc();
}
@@ -136,7 +140,9 @@
throw std::bad_alloc();
}
- new_ptr_array=(T**)realloc((void*)ptr_array,sizeof(T*)*new_size);
+ new_ptr_array=(T**)realloc(
+ (void*)ptr_array,sizeof(T*)*new_size
+ );
if (!new_ptr_array) {
throw std::bad_alloc();
}
Index: Client.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/Client.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Client.cpp 29 Sep 2003 22:06:21 -0000 1.8
+++ Client.cpp 20 Nov 2003 16:21:24 -0000 1.9
@@ -49,14 +49,16 @@
*
* Warning: The vector ClientShadow::Vector is NOT sorted in any means.
*
- * hash == "" is the special InvalidClient. It's returned by other functions on
- * Errors.
+ * hash == "" is the special InvalidClient. It's returned by other functions
+ * on Errors.
*/
Client Client::GetClientByHash(std::string hash) {
ENTER();
if (Hash2Client_map.count(hash)) {
- ClientShadow * fcs=&ClientShadow::Vector[Hash2Client_map[hash]];
+ ClientShadow * fcs;
+
+ fcs=&ClientShadow::Vector[Hash2Client_map[hash]];
if (fcs->GetHash()==hash) {
RETURN(Client(*fcs));
}
@@ -76,8 +78,9 @@
RETURN(Client(ClientShadow::Vector.end()[-1]));
/*
+ std::vector<ClientShadow>::iterator i;
for (
- std::vector<ClientShadow>::iterator i=ClientShadow::Vector.begin();
+ i=ClientShadow::Vector.begin();
i!=ClientShadow::Vector.end();
++i
) {
@@ -103,7 +106,9 @@
first_call=false;
// we=GetClientByHash("").we;
-// ClientShadow::Vector.push_back(ClientShadow("",we=Hash2Client_map[""]=ClientShadow::Vector.size()));
+// ClientShadow::Vector.push_back(ClientShadow(
+// "",we=Hash2Client_map[""]=ClientShadow::Vector.size()
+// ));
// raise(SIGSTOP);
Index: Client.h
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/Client.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Client.h 12 Aug 2003 10:35:16 -0000 1.5
+++ Client.h 20 Nov 2003 16:21:24 -0000 1.6
@@ -63,9 +63,9 @@
static std::string FileName;
public:
/*
- * This function must be called exactly once to load the file known.met.
- * The filename will be remembered by the class to being able to write
- * back the data if neccessary.
+ * This function must be called exactly once to load the file
+ * known.met. The filename will be remembered by the class to being
+ * able to write back the data if neccessary.
*/
static bool Init(std::string filename);
/*
@@ -78,8 +78,8 @@
public:
Client(const Client & client);
/*
- * Returns the client with the given hash. If that client didn't exist before,
- * it get's created.
+ * Returns the client with the given hash. If that client didn't exist
+ * before, it get's created.
*/
static Client GetClientByHash(std::string hash);
static Client GetClientByEd2kLink(std::string ed2klink);
Index: Ed2kConnection.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/Ed2kConnection.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Ed2kConnection.cpp 31 Oct 2003 21:00:12 -0000 1.1
+++ Ed2kConnection.cpp 20 Nov 2003 16:21:24 -0000 1.2
@@ -1,3 +1,23 @@
+/*
+ * Ed2kConnection.cpp. Part of the xMule project.
+ *
+ * Copyright (C) 2003 Bodo Thiesen <bo...@gm...>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
#include "Ed2kConnection.h"
Array<Connection> Connection::connection;
@@ -7,7 +27,9 @@
bool TcpAccept(u32 id,u32 new_id,state istatus) {
assert(Connection::connection[new_id].status==ILLEGAL);
bool rc;
- rc=Connection::connection[id].socket.TcpAccept(Connection::connection[new_id].socket);
+ rc=Connection::connection[id].socket.TcpAccept(
+ Connection::connection[new_id].socket
+ );
if (!rc) return false;
Connection::connection[new_id].status=istatus;
return true;
Index: Ed2kConnection.h
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/Ed2kConnection.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Ed2kConnection.h 31 Oct 2003 21:00:13 -0000 1.1
+++ Ed2kConnection.h 20 Nov 2003 16:21:24 -0000 1.2
@@ -1,3 +1,23 @@
+/*
+ * Ed2kConnection.h. Part of the xMule project.
+ *
+ * Copyright (C) 2003 Bodo Thiesen <bo...@gm...>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
#ifndef ED2KCONNECTION_H
#define ED2KCONNECTION_H
@@ -107,13 +127,36 @@
}
};
-inline bool ClientTcpListen (u32 id, u16 port /* 4662 */) { return TcpListen (id,port,CLIENT_TCP_LISTENING); }
-inline bool ClientUdpListen (u32 id, u16 port /* 4665 */) { return UdpListen (id,port,CLIENT_UDP_LISTENING); }
-inline bool ClientExtListen (u32 id, u16 port /* 4672 */) { return UdpListen (id,port,CLIENT_EXT_LISTENING); }
-inline bool ServerTcpListen (u32 id, u16 port /* 4661 */) { return TcpListen (id,port,SERVER_TCP_LISTENING); }
-inline bool ServerUdpListen (u32 id, u16 port /* 4666 */) { return UdpListen (id,port,SERVER_UDP_LISTENING); }
-inline bool ServerTcpConnect(u32 id,u32 ip,u16 port ) { return TcpConnect(id,ip,port,SERVER_TCP_SENDING_LOGIN_REQUEST); }
-inline bool ClientTcpConnect(u32 id,u32 ip,u16 port ) { return TcpConnect(id,ip,port,CLIENT_TCP_SENDING_HELLO_PACKET); }
-inline bool ClientTcpAccept (u32 id,u32 new_id ) { return TcpAccept (id,new_id,CLIENT_TCP_WAITING_FOR_HELLO_PACKET); }
+inline bool ClientTcpListen (u32 id, u16 port /* 4662 */) {
+ return TcpListen (id,port,CLIENT_TCP_LISTENING);
+}
+
+inline bool ClientUdpListen (u32 id, u16 port /* 4665 */) {
+ return UdpListen (id,port,CLIENT_UDP_LISTENING);
+}
+
+inline bool ClientExtListen (u32 id, u16 port /* 4672 */) {
+ return UdpListen (id,port,CLIENT_EXT_LISTENING);
+}
+
+inline bool ServerTcpListen (u32 id, u16 port /* 4661 */) {
+ return TcpListen (id,port,SERVER_TCP_LISTENING);
+}
+
+inline bool ServerUdpListen (u32 id, u16 port /* 4666 */) {
+ return UdpListen (id,port,SERVER_UDP_LISTENING);
+}
+
+inline bool ServerTcpConnect(u32 id,u32 ip,u16 port ) {
+ return TcpConnect(id,ip,port,SERVER_TCP_SENDING_LOGIN_REQUEST);
+}
+
+inline bool ClientTcpConnect(u32 id,u32 ip,u16 port ) {
+ return TcpConnect(id,ip,port,CLIENT_TCP_SENDING_HELLO_PACKET);
+}
+
+inline bool ClientTcpAccept (u32 id,u32 new_id ) {
+ return TcpAccept (id,new_id,CLIENT_TCP_WAITING_FOR_HELLO_PACKET);
+}
#endif // #ifndef ED2KCONNECTION_H
Index: Ed2kPacket.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/Ed2kPacket.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Ed2kPacket.cpp 12 Oct 2003 20:59:46 -0000 1.1
+++ Ed2kPacket.cpp 20 Nov 2003 16:21:24 -0000 1.2
@@ -20,7 +20,7 @@
#include "Ed2kPacket.h"
-#define LOGINREQUEST 0x01 // mlDonkey adds a DWORD with content: 'MLDK' // <DWORD>tagcount<TAG>tag[tagcount] // <BYTE>magic=0x10
+#define LOGINREQUEST 0x01 // mlDonkey adds DWORD with content: 'MLDK'
#define REJECT 0x05
#define GETSERVERLIST 0x14
#define OFFERFILES 0x15
@@ -40,14 +40,14 @@
#define SERVERIDENT 0x41
#define FOUNDSOURCES 0x42
#define USERS_LIST 0x43
-#define QUERY_CHATS 0x1D // (deprecated not supported by server any longer)
-#define CHAT_MESSAGE 0x1E // (deprecated not supported by server any longer)
-#define JOIN_ROOM 0x1F // (deprecated not supported by server any longer)
-#define CHAT_ROOM_REQUEST 0x39 // (deprecated not supported by server any longer)
-#define CHAT_BROADCAST 0x3A // (deprecated not supported by server any longer)
-#define CHAT_USER_JOIN 0x3B // (deprecated not supported by server any longer)
-#define CHAT_USER_LEAVE 0x3C // (deprecated not supported by server any longer)
-#define CHAT_USER 0x3D // (deprecated not supported by server any longer)
+#define QUERY_CHATS 0x1D // (this
+#define CHAT_MESSAGE 0x1E // opcodes
+#define JOIN_ROOM 0x1F // are
+#define CHAT_ROOM_REQUEST 0x39 // deprecated
+#define CHAT_BROADCAST 0x3A // and not
+#define CHAT_USER_JOIN 0x3B // supported
+#define CHAT_USER_LEAVE 0x3C // by servers
+#define CHAT_USER 0x3D // any longer)
#define GLOBSERVSTATREQ 0x96
#define GLOBSERVSTATRES 0x97
#define GLOBSEARCHREQUEST 0x98
@@ -62,11 +62,11 @@
#define UNKNOWN2 0xA4
#define HELLO 0x01
#define SENDINGPART 0x46
-#define REQUESTPARTS 0x47 // "<HASH>file_hash<DWORD>start[3]<DWORD>end[3]"
+#define REQUESTPARTS 0x47
#define FILEREQANSNOFIL 0x48
#define END_OF_DOWNLOAD 0x49
#define ASKSHAREDFILES 0x4A
-#define ASKSHAREDFILESANSWER 0x4B // ? "<DWORD>file_count{<HASH>file<TAG>name}file[file_count]" },
+#define ASKSHAREDFILESANSWER 0x4B // ? "<DWORD>file_count{<HASH>file<TAG>name}file[file_count]" },
#define HELLOANSWER 0x4c
#define CHANGE_CLIENT_ID 0x4D
#define MESSAGE 0x4E
@@ -98,15 +98,17 @@
#define REASKACK 0x91
#define FILENOTFOUND 0x92
#define QUEUEFULL 0x93
-#define VERIFYUPSREQ 0x71 // (never used) */
-#define VERIFYUPSANSWER 0x72 // (never used) */
-#define UDPVERIFYUPREQ 0x73 // (never used) */
+#define VERIFYUPSREQ 0x71 // (never used)
+#define VERIFYUPSANSWER 0x72 // (never used)
+#define UDPVERIFYUPREQ 0x73 // (never used)
#define UDPVERIFYUPA 0x74 // (never used)
static u8 buf[1024];
static int ofs;
-// LOGINREQUEST "<HASH>user_hash<IPPORT>client_address=0,0<DWORD>tagcount<TAG>tag[tagcount]<IPPORT>server_address<DWORD>*software_id=1262767181"
+// LOGINREQUEST "<HASH>user_hash<IPPORT>client_address=0,0
+// <DWORD>tagcount<TAG>tag[tagcount]<IPPORT>server_address
+// <DWORD>*software_id=1262767181"
void Ed2kPacket::BuildLoginRequest3Packet(
hash user,ipport client,/* dword 3, */
u8 id1,const char * string,
@@ -143,7 +145,8 @@
SetData(0xe3,GETSERVERLIST,ofs,buf);
}
-//OFFERFILES "<DWORD>file_count{<HASH>hash<IPPORT>source<TAG>name}file[file_count]"
+// OFFERFILES "<DWORD>file_count
+// {<HASH>hash<IPPORT>source<TAG>name}file[file_count]"
/*
void BuildOfferFilesPacket(u32 file_count,) {
ofs=0;
@@ -173,7 +176,9 @@
// SERVERLIST "<BYTE>server_count<IPPORT>server[server_count]"
-// SEARCHRESULT "<DWORD>num_results{<HASH>hash<IPPORT>ipport<DWORD>tag_count<TAG>tag[tag_count]}user[num_results]<DWORD>unknown1<DWORD>unknown2"
+// SEARCHRESULT "<DWORD>num_results{<HASH>hash<IPPORT>ipport
+// <DWORD>tag_count<TAG>tag[tag_count]}user[num_results]
+// <DWORD>unknown1<DWORD>unknown2"
// SERVERSTATUS "<DWORD>user_count<DWORD>file_count"
@@ -185,11 +190,14 @@
// IDCHANGE "<DWORD>new_id"
-// SERVERIDENT "<HASH>server_hash<IPPORT>server_address<DWORD>tag_count<TAG>tag[tag_count]"
+// SERVERIDENT "<HASH>server_hash<IPPORT>server_address
+// <DWORD>tag_count<TAG>tag[tag_count]"
-// FOUNDSOURCES "<HASH>file_hash<BYTE>source_count<IPPORT>source_address[source_count]"
+// FOUNDSOURCES "<HASH>file_hash
+// <BYTE>source_count<IPPORT>source_address[source_count]"
-// USERS_LIST "<DWORD>user_count{<HASH>hash<IPPORT>address<TAG>name}user[user_count]"
+// USERS_LIST "<DWORD>user_count
+// {<HASH>hash<IPPORT>address<TAG>name}user[user_count]"
// QUERY_CHATS "DEPRECATED"
@@ -211,11 +219,13 @@
// GLOBSERVSTATRES "<DWORD>user_count<DWORD>file_count<DWORD>*max_users"
-// GLOBSERVSTATRES "<WORD>unknown1<WORD>unknown2<DWORD>user_count<DWORD>file_count<DWORD>*max_users"
+// GLOBSERVSTATRES "<WORD>unknown1<WORD>unknown2<DWORD>user_count
+// <DWORD>file_count<DWORD>*max_users"
// // GLOBSEARCHREQUEST "<Search query>"
-// GLOBSEARCHRESULT "<HASH>hash<IPPORT>dummy<DWORD>tag_count<TAG>tag[tag_count]"
+// GLOBSEARCHRESULT "<HASH>hash<IPPORT>dummy
+// <DWORD>tag_count<TAG>tag[tag_count]"
// GLOBGETSOURCES "<HASH>file_hash"
@@ -233,7 +243,8 @@
// // UNKNOWN2 ""
-// HELLO "<BYTE>magic=0x10<HASH>user_hash<IPPORT>address<DWORD>tagcount<TAG>tag[tagcount]<IPPORT>server_address"
+// HELLO "<BYTE>magic=0x10<HASH>user_hash<IPPORT>address
+// <DWORD>tagcount<TAG>tag[tagcount]<IPPORT>server_address"
void Ed2kPacket::BuildHello3Packet(
u8 magic,hash user,ipport client,/* dword 3, */
u8 id1,const char * string,
@@ -260,7 +271,9 @@
// SENDINGPART "<HASH>file_hash<RANGE>range<BYTE>data[range]"
-// REQUESTPARTS "<HASH>file_hash<DWORD>part_1_start<DWORD>part_2_start<DWORD>part_3_start<DWORD>part_1_end<DWORD>part_2_end<DWORD>part_3_end"
+// REQUESTPARTS "<HASH>file_hash
+// <DWORD>part_1_start<DWORD>part_2_start<DWORD>part_3_start
+// <DWORD>part_1_end<DWORD>part_2_end<DWORD>part_3_end"
// FILEREQANSNOFIL "<HASH>file_hash"
@@ -268,9 +281,11 @@
// ASKSHAREDFILES ""
-// ASKSHAREDFILESANSWER "<DWORD>file_count{<IPPORT>address<TAG>name}file[file_count]"
+// ASKSHAREDFILESANSWER "<DWORD>file_count
+// {<IPPORT>address<TAG>name}file[file_count]"
-// HELLOANSWER "<HASH>user_hash<IPPORT>user<DWORD>tagcount<TAG>tag[tagcount]<IPPORT>server"
+// HELLOANSWER "<HASH>user_hash<IPPORT>user
+// <DWORD>tagcount<TAG>tag[tagcount]<IPPORT>server"
// CHANGE_CLIENT_ID "<DWORD>old_id<DWORD>new_id"
@@ -290,7 +305,8 @@
SetData(0xe3,0x51,ofs,buf);
}
-// HASHSETANSWER "<HASH>file_hash<WORD>chunk_count<HASH>chunk_hash[chunk_count]"
+// HASHSETANSWER "<HASH>file_hash<WORD>chunk_count
+// <HASH>chunk_hash[chunk_count]"
// STARTUPLOADREQ "<HASH>*file_hash"
@@ -302,7 +318,8 @@
// FILEREQUEST "<HASH>file_hash<BITMAP>*chunks<WORD>*unknown"
-// FILEREQANSWER "<HASH>file_hash<WORD>filename_len<CHAR>filename[filename_len]"
+// FILEREQANSWER "<HASH>file_hash
+// <WORD>filename_len<CHAR>filename[filename_len]"
// CHANGE_SLOT "<HASH>file_hash"
@@ -318,9 +335,11 @@
// ANSWERSHAREDDENIED ""
-// EMULEINFO "<BYTE>client_version<BYTE>protocol_version<DWORD>tagcount<TAG>tag[tagcount]"
+// EMULEINFO "<BYTE>client_version<BYTE>protocol_version
+// <DWORD>tagcount<TAG>tag[tagcount]"
-// EMULEINFOANSWER "<BYTE>client_version<BYTE>protocol_version<DWORD>tagcount<TAG>tag[tagcount]"
+// EMULEINFOANSWER "<BYTE>client_version<BYTE>protocol_version
+// <DWORD>tagcount<TAG>tag[tagcount]"
// COMPRESSEDPART "<HASH>file_hash<RANGE>range<BYTE>cdata[range]"
@@ -330,7 +349,8 @@
// REQUESTSOURCES "<HASH>file_hash"
-// ANSWERSOURCES "<HASH>file_hash<WORD>num_sources{<IPPORT>server<IPPORT>client}source[num_sources]"
+// ANSWERSOURCES "<HASH>file_hash<WORD>num_sources
+// {<IPPORT>server<IPPORT>client}source[num_sources]"
// REASKFILEPING "<HASH>file_hash"
Index: Ed2kPacket.h
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/Ed2kPacket.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Ed2kPacket.h 29 Sep 2003 22:06:21 -0000 1.3
+++ Ed2kPacket.h 20 Nov 2003 16:21:24 -0000 1.4
@@ -37,22 +37,26 @@
private:
Addr Address;
u8 Protocol; // 0xc5, 0xd4 or 0xe3
- u8 Opcode; // Ie. 0x01 for Hello Packet
+ u8 Opcode; // E.g. 0x01 for Hello Packet
u32 Size; // Size of the eDonkey Packet (excluding the Opcode)
- u8 * Buffer; // Pointer to the data for the eDonkey Packet (excluding the Opcode)
+ u8 * Buffer; // Pointer to data for Packet (excluding the Opcode)
enum {} empty;
public:
// We will do all sanity checks in this class :-)
/*
- Ed2kPacket(u32 ip,u16 port,u8 protocol,u8 opcode,u32 size,u8 * data,bool tcp)
+ Ed2kPacket(
+ u32 ip,u16 port,u8 protocol,u8 opcode,
+ u32 size,u8 * data,bool tcp
+ )
: Packet(ip,port) {
Address.SetIP(ip); Address.SetPort(port);
Valid=false;
SetData(protocol,opcode,size,data,tcp);
}
- Ed2kPacket(u8 protocol,u8 opcode,u32 size,u8 * data,bool tcp) : Packet() {
+ Ed2kPacket(u8 protocol,u8 opcode,u32 size,u8 * data,bool tcp)
+ : Packet() {
SetIP(INADDR_ANY); Address.SetPort(0);
Valid=false;
SetData(protocol,opcode,size,data,tcp);
Index: Ed2kSocket.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/Ed2kSocket.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Ed2kSocket.cpp 29 Sep 2003 22:06:21 -0000 1.3
+++ Ed2kSocket.cpp 20 Nov 2003 16:21:24 -0000 1.4
@@ -94,7 +94,7 @@
Packet p;
while ((sock.ReceivePacket(p))) {
- if ((p.GetSize())) { // Can we ever receive a packet with size=0?
+ if (p.GetSize()) { // Can we ever receive a packet with size=0?
in_list.push_back(p);
in_SumPacketSizes+=p.GetSize();
}
@@ -112,7 +112,11 @@
for (i=0,pi=in_list.begin();i<5;++pi) {
ptr =pi->GetPtr()+tpo;
- size=pi->GetSize()-tpo; // Packes of size 0 are already discarded in Ed2kSocket::LowLevelReceive().
+ size=pi->GetSize()-tpo;
+ /*
+ * Packes of size 0 are already discarded in
+ * Ed2kSocket::LowLevelReceive().
+ */
do {
packet_header[i]=*ptr++;
@@ -128,9 +132,13 @@
|((u32)packet_header[4])<<24
;
- if (in_Ed2kPacketSize>0x7fffffff)
- return; // FIXME: throw an exception, close the socket etc. ...
-
+ if (in_Ed2kPacketSize>0x7fffffff) {
+ return;
+ /*
+ * FIXME: throw an exception, close the socket, let
+ * the computer explode etc. ...
+ */
+ }
}
}
@@ -143,11 +151,17 @@
}
CheckPacketHeader(sps);
- if (in_SumPacketSizes<5 || in_Ed2kPacketSize+5>in_SumPacketSizes)
+ if (in_SumPacketSizes<5 || in_Ed2kPacketSize+5>in_SumPacketSizes) {
return false;
+ }
- if (in_Ed2kPacketSize>0x7fffffff)
- return false; // FIXME: Remove this as soon as this case is handled in Ed2kSocket::CheckPacketHeader()
+ if (in_Ed2kPacketSize>0x7fffffff) {
+ return false;
+ /*
+ * FIXME: Remove this as soon as this case is handled in
+ * Ed2kSocket::CheckPacketHeader().
+ */
+ }
u8 * data=new u8[in_Ed2kPacketSize+5];
u32 pos=0;
Index: MultiLevelBitmap.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/MultiLevelBitmap.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- MultiLevelBitmap.cpp 3 Sep 2003 15:58:15 -0000 1.4
+++ MultiLevelBitmap.cpp 20 Nov 2003 16:21:24 -0000 1.5
@@ -19,7 +19,12 @@
*/
#define MULTILEVELBITMAP_SIZES_POW_2_ON_AUTOERLARGE
-#define MULTILEVELBITMAP_ERLARGEFACTOR 3.41 // Only used #ifndef MULTILEVELBITMAP_SIZES_POW_2_ON_AUTOERLARGE
+#define MULTILEVELBITMAP_ERLARGEFACTOR 3.41
+
+/*
+ * MULTILEVELBITMAP_ERLARGEFACTOR is only used, if
+ * MULTILEVELBITMAP_SIZES_POW_2_ON_AUTOERLARGE is not defined
+ */
#include "MultiLevelBitmap.h"
@@ -133,7 +138,9 @@
#ifdef MULTILEVELBITMAP_SIZES_POW_2_ON_AUTOERLARGE
if (!Erlarge(num_entries?num_entries*2:1)) return ULONG_MAX;
#else // #ifdef MULTILEVELBITMAP_SIZES_POW_2_ON_AUTOERLARGE
- if (!Erlarge(num_entries?(unsigned long)(MULTILEVELBITMAP_ERLARGEFACTOR*num_entries):1)) return ULONG_MAX;
+ if (!Erlarge(num_entries?(unsigned long)(
+ MULTILEVELBITMAP_ERLARGEFACTOR*num_entries
+ ):1)) return ULONG_MAX;
#endif // #ifdef MULTILEVELBITMAP_SIZES_POW_2_ON_AUTOERLARGE, #else
}
@@ -250,7 +257,8 @@
);
for (unsigned long j=0;j<one;++j) {
if (!bitmap[num_levels-i+1][j]) {
- bitmap[num_levels-i][j/CB]^=(1<<(j%CB));
+ bitmap[num_levels-i][j/CB]^=
+ (1<<(j%CB));
}
}
}
Index: ParseClass.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/ParseClass.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ParseClass.cpp 20 Nov 2003 14:41:11 -0000 1.6
+++ ParseClass.cpp 20 Nov 2003 16:21:24 -0000 1.7
@@ -88,7 +88,9 @@
// printf("parseError(\"%s\",...)\n",expr);
- delimiter=parse_string(&expr,"[.",LettersUnderscore,LettersNumbersUnderscore,&var);
+ delimiter=parse_string(
+ &expr,"[.",LettersUnderscore,LettersNumbersUnderscore,&var
+ );
for (*ps=type;*ps;*ps=(*ps)->next) {
if (!strcmp((*ps)->varname,var))
@@ -115,7 +117,10 @@
if ((!((*ps)->flags&PF_ARRAY0)) == (*array=delimiter=='[')) {
if (delimiter=='[') {
- fprintf(stderr,"Array subscript given on something not an array\n");
+ fprintf(stderr,
+ "Array subscript given on something "
+ "not an array\n"
+ );
} else {
fprintf(stderr,"Array subscript expected\n");
}
@@ -133,11 +138,15 @@
if (debug_now) printf("*index=%i\n",*index);
expr=var;
if (*(expr-1)=='[') {
- fprintf(stderr,"Array subscript is empty or invalid\n");
+ fprintf(stderr,
+ "Array subscript is empty or invalid\n"
+ );
return true;
}
if (*expr++!=']') {
- fprintf(stderr,"Array subscript is not followed by a ']'\n");
+ fprintf(stderr,
+ "Array subscript is not followed by a ']'\n"
+ );
return true;
}
delimiter=*expr++;
@@ -149,7 +158,10 @@
// if (debug_now) printf("*expr='%c'\n",*expr);
if (delimiter=='.') {
- fprintf(stderr,"Struct subscript given on something not an struct\n");
+ fprintf(stderr,
+ "Struct subscript given on something "
+ "not an struct\n"
+ );
} else {
fprintf(stderr,"Struct subscript expected\n");
}
@@ -210,8 +222,9 @@
offset=size-sizeof(ParseClass*);
for (i=n;i<nume;++i) {
- for (p=0;p<numPCs;++p) {
- (*(ParseClass**)(data+size*i+offset))[p].~ParseClass();
+ ParseClass * PC=(*(ParseClass**)(data+size*i+offset));
+ for (p=0;p<numPCs;++p,++PC) {
+ PC->~ParseClass();
}
free(*(ParseClass**)(data+size*i+offset));
}
@@ -242,7 +255,8 @@
*(ParseClass**)(data+size*i+offset)=PCp;
for (ps=type;ps;ps=ps->next) {
- if (ps->flags&PF_ARRAY0 || ps->type_id==STRUCT) {
+ if (ps->flags&PF_ARRAY0
+ || ps->type_id==STRUCT) {
assert(ps->referer_id<numPCs);
if (ps->type_id==STRUCT) {
new (PCp+ps->referer_id)
@@ -269,265 +283,339 @@
int PClevel;
-size_t ParseClass::IncrementalRead(const u8 * buffer,size_t buffsize,size_t n) {
- const struct parsestruct * ps;
- size_t i,done;
- u8 * dataptr;
+size_t ParseClass::IncrementalReadArray(
+ const u8 * buffer,size_t buffsize
+) {
+ size_t n=nume;
+ size_t done;
struct tag * tag;
-/*
- printf(
- "%*s>> IncrementalRead(buffer=%p,buffsize=%u,n=%u)\n"
- ,8*PClevel++,"",buffer,(int)buffsize,(int)n
- );
-*/
-
- if (nume!=n) {
- Resize(n);
- }
-
done=0;
- if (!IsArray()) {
- dataptr=data;
-
-/*
- printf("size=%i, offset of %s=%i\n",size,type->next->varname,type->next->offset);
-*/
- for (i=0;i<n;++i) {
-/*
- printf("i=%i\n",i);
-*/
- for (ps=type;ps;ps=ps->next) {
- if (ps->flags&PF_ARRAY0 || ps->type_id==STRUCT) {
- u32 num;
-
+ if (type->type_id==BITMAP) {
+ fprintf(
+ stderr,
+ "%s:%s:%i: Fatal: ParseClass::IncrementalRead is "
+ "not implemented for type->type_id==BITMAP.\n"
+ ,__FILE__,__FUNCTION__,__LINE__
+ );
+ exit(1);
+ }
+ if (type->type_id==TAG) {
/*
- if (!strcmp(ps->counter_var->varname,"num_tags")) {
- Get(num,0,ps->counter_var->varname);
- printf("num[0]=%i, ",num);
- Get(num,1,ps->counter_var->varname);
- printf("num[1]=%i, ",num);
- Get(num,2,ps->counter_var->varname);
- printf("num[2]=%i, ",num);
- printf("i=%i\n",i);
- }
+ printf("size=%i, type[TAG].len=%i\n",size,::type[TAG].len);
+ printf("TAG\n");
*/
-
- /*
- * XXX: Struct without array is not defined, so
- * I don't take care about that special case
- * here at all.
- */
- /*
- if (parent) {
- parent->Get(num,i,ps->counter_var->varname);
- } else {
- */
- Get(num,i,ps->counter_var->varname);
- //}
-
+
+ for (
+ tag=reinterpret_cast<struct tag *>(data);
+ n;
+ ++tag,--n
+ ) {
/*
- printf("num=%i\n",num);
+ printf("tag"); fflush(stdout);
*/
-
- if (num) {
- size_t call_done;
-
- ParseClass * PC=*(ParseClass**)
- (data+size*(i+1)-sizeof(ParseClass*)*numPCs);
- PC+=ps->referer_id;
+ if (buffsize<1) return (size_t)-1;
+ tag->type=*buffer;
+ buffer +=1;
+ buffsize-=1;
+ done +=1;
/*
- printf(">>PC->IncrementalRead(buffer,buffsize,num);\n");
+ printf(" (0x%02x)",(unsigned)tag->type);
+ fflush(stdout);
*/
- call_done=PC->IncrementalRead(buffer,buffsize,num);
+
+ if (buffsize<2) return (size_t)-1;
+ tag->id_len=ltoh16(*(u16*)buffer);
+ buffer +=2;
+ buffsize-=2;
+ done +=2;
+
+ if (buffsize<tag->id_len) return (size_t)-1;
+ if (!tag->id_len) {
+ fprintf(
+ stderr,
+ "%s:%s:%i: Fatal: ParseClass::"
+ "IncrementalRead: Type id len = 0.\n"
+ ,__FILE__,__FUNCTION__,__LINE__
+ );
+ exit(1);
+ } else if (tag->id_len==1) {
+ tag->id.number=*buffer;
+ buffer +=1;
+ buffsize-=1;
+ done +=1;
/*
- printf("<<PC->IncrementalRead(buffer,buffsize,num);\n");
+ printf(" id=0x%02x: ",tag->id.number);
+ fflush(stdout);
*/
- if (call_done==(size_t)-1) return call_done;
- buffer +=call_done;
- buffsize-=call_done;
- done +=call_done;
+ } else {
+ tag->id.string=new u8[tag->id_len+1];
+ memcpy(tag->id.string,buffer,tag->id_len);
+ tag->id.string[tag->id_len]=0;
+ buffer +=tag->id_len;
+ buffsize-=tag->id_len;
+ done +=tag->id_len;
/*
- printf("*buffer=0x%02x, ps->next=%p\n",(unsigned)*buffer,(void*)ps->next);
+ printf(" id=%s: ",tag->id.string);
+ fflush(stdout);
*/
+ }
+
+ switch (tag->type) {
+ case 2: // STRING
+ if (buffsize<2) return (size_t)-1;
+ tag->value.string.length=
+ ltoh16(*(u16*)buffer);
+ buffer +=2;
+ buffsize-=2;
+ done +=2;
+
+ if (buffsize<tag->value.string.length) {
+ return (size_t)-1;
}
- } else {
- ParseClass * PC;
- u32 val;
- unsigned j;
- bool scalar;
+ tag->value.string.content=
+ new u8[tag->value.string.length+1];
+ memcpy(
+ tag->value.string.content,
+ buffer,tag->value.string.length
+ );
+ tag->value.string.content[
+ tag->value.string.length
+ ]=0;
+ buffer +=tag->value.string.length;
+ buffsize-=tag->value.string.length;
+ done +=tag->value.string.length;
/*
- printf("."); fflush(stdout);
+ printf(
+ "\"%s\"\n"
+ ,tag->value.string.content
+ );
*/
- if (buffsize<ps->size) return (size_t)-1;
- switch (ps->type_id) {
- case BYTE: scalar=true; * dataptr =val= * buffer ; break;
- case WORD: scalar=true; *(u16*) dataptr =val=ltoh16(*(u16*) buffer) ; break;
- case DWORD: scalar=true; *(u32*) dataptr =val=ltoh32(*(u32*) buffer) ; break;
- case IPPORT: scalar=false; *(u32*) dataptr = lton32(*(u32*) buffer );
- *(u16*)(dataptr+4)= ltoh16(*(u16*)(buffer+4)); break;
- default:
- scalar=false;
- memcpy(dataptr,buffer,ps->size);
- }
+ break;
+
+ case 3:
+ if (buffsize<4) return (size_t)-1;
+ tag->value.dword=ltoh32(*(u32*)buffer);
+ buffer +=4;
+ buffsize-=4;
+ done +=4;
- if (ps->num_referer) {
- if (!scalar) {
- fprintf(
- stderr,
- "%s:%s:%i: Fatal: ParseClass::IncrementalRead: \n"
- "Type != BYTE, WORD, DWORD was used as array size subscript.\n"
- "type=%i (%s)\n",
- __FILE__,__FUNCTION__,__LINE__,ps->type_id,::type[ps->type_id].type_name
- );
- exit(1);
- }
-
- PC=*(ParseClass**)(data+size*(i+1)-sizeof(ParseClass*)*numPCs);
- for (j=0;j<ps->num_referer;++j,++PC) {
- PC->Resize(val);
- }
- }
+/*
+ printf("%u\n",tag->value.dword);
+*/
- dataptr +=ps->size;
- buffer +=ps->size;
- buffsize-=ps->size;
- done +=ps->size;
- }
+ break;
+
+ default:
+ fprintf(
+ stderr,
+ "%s:%s:%i: Fatal: ParseClass::"
+ "IncrementalRead: Unknown tag "
+ "type %i\n"
+ ,__FILE__,__FUNCTION__,__LINE__
+ ,tag->type
+ );
+ exit(1);
}
- dataptr+=numPCs*sizeof(ParseClass*);
- }
- } else { // if (IsArray())
- if (type->type_id==BITMAP) {
- fprintf(
- stderr,
- "%s:%s:%i: Fatal: ParseClass::IncrementalRead is not implemented for type->type_id==BITMAP.\n"
- ,__FILE__,__FUNCTION__,__LINE__
- );
- exit(1);
}
- if (type->type_id==TAG) {
/*
- printf("size=%i, type[TAG].len=%i\n",size,::type[TAG].len);
- printf("TAG\n");
+ printf("GAT (0x%02x)\n",(unsigned)*buffer);
*/
-
- for (
- tag=reinterpret_cast<struct tag *>(data);
- n;
- ++tag,--n
- ) {
+ } else {
/*
- printf("tag"); fflush(stdout);
+ printf("size=%i,n=%i,type->size=%i\n",size,n,type->size);
*/
- if (buffsize<1) return (size_t)-1;
- tag->type=*buffer;
- buffer +=1;
- buffsize-=1;
- done +=1;
+ if (buffsize<size*n) return (size_t)-1;
+ memcpy(data,buffer,size*n);
+ buffer +=size*n;
+ buffsize-=size*n;
+ done +=size*n;
+ }
+
+ return done;
+}
+
+void PrintScalarErrorMsgAndExit(const struct parsestruct * ps) {
+ fprintf(
+ stderr,
+ "%s:%s:%i: Fatal: ParseClass::IncrementalRead: \n"
+ "Type != BYTE, WORD, DWORD was used as array size subscript.\n"
+ "type=%i (%s)\n",
+ __FILE__,__FUNCTION__,__LINE__,ps->type_id,::type[ps->type_id].type_name
+ );
+ exit(1);
+}
+
+ParseClass * ParseClass::FirstParseClassPointer(int idx) {
+ return *(ParseClass**)(data+size*(idx+1)-sizeof(ParseClass*)*numPCs);
+}
+
+size_t ParseClass::IncrementalReadNonArray(
+ const u8 * buffer,size_t buffsize
+) {
+ size_t n=nume;
+ const struct parsestruct * ps;
+ size_t i,done;
+ u8 * dataptr;
+
+ done=0;
+
+ dataptr=data;
+
/*
- printf(" (0x%02x)",(unsigned)tag->type); fflush(stdout);
+ printf(
+ "size=%i, offset of %s=%i\n"
+ ,size,type->next->varname,type->next->offset
+ );
*/
+ for (i=0;i<n;++i) {
+/*
+ printf("i=%i\n",i);
+*/
+ for (ps=type;ps;ps=ps->next) {
+ if (ps->flags&PF_ARRAY0
+ || ps->type_id==STRUCT) {
+ u32 num;
- if (buffsize<2) return (size_t)-1;
- tag->id_len=ltoh16(*(u16*)buffer);
- buffer +=2;
- buffsize-=2;
- done +=2;
-
- if (buffsize<tag->id_len) return (size_t)-1;
- if (!tag->id_len) {
- fprintf(
- stderr,
- "%s:%s:%i: Fatal: ParseClass::IncrementalRead: Type id len = 0.\n"
- ,__FILE__,__FUNCTION__,__LINE__
- );
- exit(1);
- } else if (tag->id_len==1) {
- tag->id.number=*buffer;
- buffer +=1;
- buffsize-=1;
- done +=1;
/*
- printf(" id=0x%02x: ",tag->id.number); fflush(stdout);
+ if (!strcmp(
+ ps->counter_var->varname,
+ "num_tags"
+ )) {
+ Get(num,0,ps->counter_var->varname);
+ printf("num[0]=%i, ",num);
+ Get(num,1,ps->counter_var->varname);
+ printf("num[1]=%i, ",num);
+ Get(num,2,ps->counter_var->varname);
+ printf("num[2]=%i, ",num);
+ printf("i=%i\n",i);
+ }
*/
+
+ /*
+ * XXX: Struct without array is not
+ * defined, so I don't take care
+ * about that special case here at
+ * all.
+ */
+ /*
+ if (parent) {
+ parent->Get(
+ num,i,
+ ps->counter_var->varname
+ );
} else {
- tag->id.string=new u8[tag->id_len+1];
- memcpy(tag->id.string,buffer,tag->id_len);
- tag->id.string[tag->id_len]=0;
- buffer +=tag->id_len;
- buffsize-=tag->id_len;
- done +=tag->id_len;
+ */
+ Get(num,i,ps->counter_var->varname);
+ //}
+
/*
- printf(" id=%s: ",tag->id.string); fflush(stdout);
+ printf("num=%i\n",num);
*/
- }
- switch (tag->type) {
- case 2: // STRING
- if (buffsize<2) return (size_t)-1;
- tag->value.string.length=ltoh16(*(u16*)buffer);
- buffer +=2;
- buffsize-=2;
- done +=2;
-
- if (buffsize<tag->value.string.length) return (size_t)-1;
- tag->value.string.content=new u8[tag->value.string.length+1];
- memcpy(tag->value.string.content,buffer,tag->value.string.length);
- tag->value.string.content[tag->value.string.length]=0;
- buffer +=tag->value.string.length;
- buffsize-=tag->value.string.length;
- done +=tag->value.string.length;
-
+ if (num) {
+ size_t call_done;
+
+ ParseClass * PC;
+
+ PC=FirstParseClassPointer(i);
+ PC+=ps->referer_id;
+
+ call_done=PC->IncrementalRead(
+ buffer,buffsize,num
+ );
+ if (call_done==(size_t)-1) {
+ return call_done;
+ }
+ buffer +=call_done;
+ buffsize-=call_done;
+ done +=call_done;
/*
- printf("\"%s\"\n",tag->value.string.content);
+ printf(
+ "*buffer=0x%02x, "
+ "ps->next=%p\n"
+ ,(unsigned)*buffer
+ ,(void*)ps->next
+ );
*/
-
- break;
-
- case 3:
- if (buffsize<4) return (size_t)-1;
- tag->value.dword=ltoh32(*(u32*)buffer);
- buffer +=4;
- buffsize-=4;
- done +=4;
-
+ }
+ } else {
+ ParseClass * PC;
+ u32 val;
+ unsigned j;
+ bool scalar;
+
/*
- printf("%u\n",tag->value.dword);
+ printf("."); fflush(stdout);
*/
-
- break;
-
+ if (buffsize<ps->size) {
+ return (size_t)-1;
+ }
+
+ switch (ps->type_id) {
+ case BYTE: scalar=true; * dataptr =val= * buffer ; break;
+ case WORD: scalar=true; *(u16*) dataptr =val=ltoh16(*(u16*) buffer) ; break;
+ case DWORD: scalar=true; *(u32*) dataptr =val=ltoh32(*(u32*) buffer) ; break;
+ case IPPORT: scalar=false; *(u32*) dataptr = lton32(*(u32*) buffer );
+ *(u16*)(dataptr+4)= ltoh16(*(u16*)(buffer+4)); break;
default:
- fprintf(
- stderr,
- "%s:%s:%i: Fatal: ParseClass::IncrementalRead: Unknown tag type %i\n"
- ,__FILE__,__FUNCTION__,__LINE__,tag->type
- );
- exit(1);
+ scalar=false;
+ memcpy(dataptr,buffer,ps->size);
}
+
+ /*
+ * FIXME: This test should be moved to
+ * parse-ed2k.c, because if doesn't
+ * need to be repeated for each
+ * received packet.
+ */
+ if (ps->num_referer) {
+ if (!scalar) {
+ PrintScalarErrorMsgAndExit(ps);
+ }
+
+ PC=FirstParseClassPointer(i);
+ for (j=0;j<ps->num_referer;++j,++PC) {
+ PC->Resize(val);
+ }
+ }
+
+ dataptr +=ps->size;
+ buffer +=ps->size;
+ buffsize-=ps->size;
+ done +=ps->size;
}
-/*
- printf("GAT (0x%02x)\n",(unsigned)*buffer);
-*/
- } else {
-/*
- printf("size=%i,n=%i,type->size=%i\n",size,n,type->size);
-*/
- if (buffsize<size*n) return (size_t)-1;
- memcpy(data,buffer,size*n);
- buffer +=size*n;
- buffsize-=size*n;
- done +=size*n;
}
- } // if (IsArray()), else
+ dataptr+=numPCs*sizeof(ParseClass*);
+ }
return done;
}
+size_t ParseClass::IncrementalRead(
+ const u8 * buffer,size_t buffsize,size_t n
+) {
+/*
+ printf(
+ "%*s>> IncrementalRead(buffer=%p,buffsize=%u,n=%u)\n"
+ ,8*PClevel++,"",buffer,(int)buffsize,(int)n
+ );
+*/
+
+ if (nume!=n) {
+ Resize(n);
+ }
+
+ if (IsArray()) {
+ return IncrementalReadArray(buffer,buffsize);
+ } else {
+ return IncrementalReadNonArray(buffer,buffsize);
+ }
+}
+
bool ParseClass::Read(const u8 * buffer,size_t buffsize) {
size_t done;
@@ -539,8 +627,10 @@
if (done!=buffsize) {
fprintf(
stderr,
- "%s:%s:%i: Warning: done!=buffsize: buffsize=%u, done=%u.\n"
- ,__FILE__,__FUNCTION__,__LINE__,(unsigned)buffsize,(unsigned)done
+ "%s:%s:%i: Warning: done!=buffsize: buffsize=%u, "
+ "done=%u.\n"
+ ,__FILE__,__FUNCTION__,__LINE__
+ ,(unsigned)buffsize,(unsigned)done
);
}
@@ -550,6 +640,7 @@
bool ParseClass::Read(FILE * file) {
/*
* ISO/IEC 9899:1999 (E) §7.19.9.2(3)
+ *
* For a binary stream, the new position, measured in characters from
* the beginning of the file, is obtained by adding offset to the
* position specified by whence. The specified position is the
Index: ParseClass.h
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/ParseClass.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ParseClass.h 20 Nov 2003 14:41:11 -0000 1.6
+++ ParseClass.h 20 Nov 2003 16:21:24 -0000 1.7
@@ -45,10 +45,11 @@
#define ISARRAY(x) true
/*
- * Ok, bedboi, the format string of the server.met is:
- *
- * "<BYTE>magic=0xe0<DWORD>num_servers{<IPPORT>ipport<DWORD>num_tags<TAG>tag[num_tags]}server[num_servers]"
- *
+
+The format string of the server.met is:
+
+"<BYTE>magic=0xe0<DWORD>num_servers
+{<IPPORT>ipport<DWORD>num_tags<TAG>tag[num_tags]}server[num_servers]"
An example entry is:
@@ -84,18 +85,23 @@
server_met.Dword ("server[0].tag[1][0x86]" ) -> 0x692daa3b
server_met.Dword ("server[%i].tag[%i][%i]", 0,1,0x87 ) -> 0x00001b5f
-The first string is simply a format string, and the rest are the va_args. No problem -> vsprintf ...
+UPDATE: Now the method is called GetF(var &,const char * fmt,...) and the
+ ".ip" or ".port" of tje 4. and 5. example must be specified as part of
+ the fmt string. Another Method, SetF is available, too.
-The constructor will get a parsestruct pointer as returned by packet_description
-(or an equivalent function). Than you must set up (maybe simply copy) data
-structures to store values. A call of Read will follow, there you must read the
-data with types as instructed by parsestruct to your internal structures in a
-way, that you can easily look them up via the member functions Bitmap, Char,
-Byte, ...
+The first string is simply a format string, and the rest are the va_args. No
+problem -> vsprintf ...
+
+The constructor will get a parsestruct pointer as returned by
+packet_description (or an equivalent function). Than you must set up (maybe
+simply copy) data structures to store values. A call of Read will follow, there
+you must read the data with types as instructed by parsestruct to your internal
+structures in a way, that you can easily look them up via the member functions
+Bitmap, Char, Byte, ...
The sizes if the data types are stored in the type array (see parse-ed2k.h),
-Bitmap and String are special ones, because they are not fixed length. And there
-is a data type "TAG" which you must handle in the Read and Write methods.
+Bitmap and String are special ones, because they are not fixed length. And
+there is a data type "TAG" which you must handle in the Read and Write methods.
BTW: This will be a major function (as it will be used on receiving and sending
of every packet even as on reading and writing of every .met file, thus it
@@ -117,16 +123,20 @@
public:
struct panic {};
private:
- const struct parsestruct * type; // (Sub)type of this data
- unsigned char * data; // Pointer to the actual data
- size_t size; // Num chars per element
- size_t numPCs; // Num ParseClasses at the end of each element
- size_t nume; // Num elements (for array)
+ const struct parsestruct * type; // (Sub)type of this data
+ unsigned char * data; // Pointer to the actual data
+ size_t size; // Num chars per element
+ size_t numPCs; // Num PCs @ the end of each element
+ size_t nume; // Num elements (for array)
const class ParseClass * parent;
- ParseClass(const class ParseClass &); // No copy-constructor, plz
- ParseClass & operator =(const class ParseClass &); // And not assignment operator, too
- ParseClass(); // And no default constructor (which would mean a typeless data structure)
+ /*
+ * I want no copy-constructors, assignment operators and no
+ * default constructor (which would mean a typeless data structure)
+ */
+ ParseClass(const class ParseClass &);
+ ParseClass & operator =(const class ParseClass &);
+ ParseClass();
/*
* Calculate the size of this element according to current type.
@@ -174,13 +184,22 @@
size_t IncrementalRead(const u8 * buffer,size_t buffsize,size_t n);
/*
+ * Helpers for IncrementalRead.
+ */
+ ParseClass * FirstParseClassPointer(int idx);
+ size_t IncrementalReadNonArray(const u8 * buffer,size_t buffsize);
+ size_t IncrementalReadArray(const u8 * buffer,size_t buffsize);
+
+ /*
* Get
*
* Read the variable specified by expr at index index and return it in
* var. This may throw a ParseClass::panic, if the string in expr is
* not valid or if index is too big.
*/
- template <class T> void Get(T & var,size_t index,const char * expr) const {
+ template <class T> void Get(
+ T & var,size_t index,const char * expr
+ ) const {
const char * subexpr;
const struct parsestruct * ps;
bool array;
@@ -191,7 +210,8 @@
|| parseError(expr,&subexpr,&ps,&next_index,&array,&struc)) {
fprintf(
stderr,
- "%s:%s:%i: expr=\"%s\" is invalid or index=%i is out of range\n",
+ "%s:%s:%i: expr=\"%s\" is invalid or index=%i "
+ "is out of range\n",
__FILE__,__FUNCTION__,__LINE__,expr,index
);
abort();
@@ -213,23 +233,32 @@
ParseClass * PC=*(ParseClass**)
(data+size*(index+1)-sizeof(ParseClass*));
/*
- printf("PC=%p, ",reinterpret_cast<void*>(PC)); fflush(stdout);
+ printf("PC=%p, ",reinterpret_cast<void*>(PC));
+ fflush(stdout);
*/
if (struc) {
/*
printf("struct\n");
- printf(">>PC[ps->referer_id].Get(var,next_index,subexpr)\n");
+ printf(
+ ">>PC[ps->referer_id]."
+ "Get(var,next_index,subexpr)\n"
+ );
*/
PC[ps->referer_id].Get(var,next_index,subexpr);
/*
- printf("<<PC[ps->referer_id].Get(var,next_index,subexpr)\n");
+ printf(
+ "<<PC[ps->referer_id]."
+ "Get(var,next_index,subexpr)\n"
+ );
*/
} else {
/*
printf("!struct\n");
printf(
- "PC->data=%p, PC->size=%i, next_index=%i, PC->nume=%i\n"
- ,PC->data, PC->size, next_index, PC->nume
+ "PC->data=%p, PC->size=%i, "
+ "next_index=%i, PC->nume=%i\n"
+ ,PC->data,PC->size,
+ next_index,PC->nume
);
*/
var=*(T*)(PC->data+PC->size*next_index);
@@ -248,7 +277,9 @@
* This may throw a ParseClass::panic, if the string in expr is not
* valid or if index is too big.
*/
- template <class T> void Set(const T & var,size_t index,const char * expr) {
+ template <class T> void Set(
+ const T & var,size_t index,const char * expr
+ ) {
const char * subexpr;
const struct parsestruct * ps;
bool array;
@@ -260,7 +291,8 @@
|| parseError(expr,&subexpr,&ps,&next_index,&array,&struc)) {
fprintf(
stderr,
- "%s:%s:%i: expr=\"%s\" is invalid or index=%i is out of range\n",
+ "%s:%s:%i: expr=\"%s\" is invalid or index=%i "
+ "is out of range\n",
__FILE__,__FUNCTION__,__LINE__,expr,index
);
abort();
@@ -282,14 +314,18 @@
PC[ps->referer_id].Set(var,next_index,subexpr);
} else {
*(T*)(PC->data+PC->size*next_index)=var;
- /* An array MUST NOT be uses as subscript, so we don't
- * need to take care about that here.
+ /*
+ * An array MUST NOT be used as subscript, so
+ * we don't need to take care about that here.
*/
}
}
}
- void Construct(const class ParseClass * pc,const struct parsestruct * ps,size_t n=1) {
+ void Construct(
+ const class ParseClass * pc,
+ const struct parsestruct * ps,size_t n=1
+ ) {
assert(n>0);
type=ps;
@@ -302,7 +338,10 @@
Resize(n);
}
- ParseClass(const class ParseClass * pc,const struct parsestruct * ps,size_t n=1) {
+ ParseClass(
+ const class ParseClass * pc,
+ const struct parsestruct * ps,size_t n=1
+ ) {
Construct(pc,ps,n);
}
@@ -319,7 +358,8 @@
bool Read(FILE * file);
bool Read(const char * filename);
- bool Write(u8 * * buffer,size_t * buffsize) const; // *buffsize=(size_t)-1 means error
+ // *buffsize=(size_t)-1 means error
+ bool Write(u8 * * buffer,size_t * buffsize) const;
bool Write(FILE * file) const;
bool Write(const char * filename) const;
@@ -336,9 +376,12 @@
/-* Only valid for tags: *-/
char * String(const char * varname_fmt,...) PRINTF_FORMAT;
-// float Float (const char * varname_fmt,...) PRINTF_FORMAT; <--- Float not implemented at all
+ // Float is not implemented at all
+// float Float (const char * varname_fmt,...) PRINTF_FORMAT;
*/
- template <class T> void GetF(T & var,const char * fmt,...) const /* PRINTF_FORMAT(2,3) */ {
+ template <class T> void GetF(
+ T & var,const char * fmt,...
+ ) const /* PRINTF_FORMAT(2,3) */ {
char * expr;
va_list ap;
@@ -359,7 +402,9 @@
free(expr);
}
- template <class T> void SetF(const T & var,const char * fmt,...) /* PRINTF_FORMAT(2,3) */ {
+ template <class T> void SetF(
+ const T & var,const char * fmt,...
+ ) /* PRINTF_FORMAT(2,3) */ {
char * expr;
va_list ap;
Index: Socket.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/Socket.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Socket.cpp 8 Sep 2003 00:31:54 -0000 1.9
+++ Socket.cpp 20 Nov 2003 16:21:24 -0000 1.10
@@ -49,7 +49,11 @@
struct protoent * prent;
prent=getprotobyname("tcp");
if (!prent) {
- fprintf(stderr,"WARNING: getprotobyname(\"%s\") failed: %s\n",TCP?"tcp":"udp",strerror(errno));
+ fprintf(stderr,
+ "WARNING: getprotobyname(\"%s\") "
+ "failed: %s\n"
+ ,TCP?"tcp":"udp",strerror(errno)
+ );
return false;
}
tcp_protocol=prent->p_proto;
@@ -60,7 +64,11 @@
struct protoent * prent;
prent=getprotobyname("udp");
if (!prent) {
- fprintf(stderr,"WARNING: getprotobyname(\"%s\") failed: %s\n",TCP?"tcp":"udp",strerror(errno));
+ fprintf(stderr,
+ "WARNING: getprotobyname(\"%s\") "
+ "failed: %s\n"
+ ,TCP?"tcp":"udp",strerror(errno)
+ );
return false;
}
udp_protocol=prent->p_proto;
@@ -68,9 +76,16 @@
}
}
- fd=socket(AF_INET,TCP?SOCK_STREAM:SOCK_DGRAM,TCP?tcp_protocol:udp_protocol);
+ fd=socket(
+ AF_INET,
+ TCP?SOCK_STREAM:SOCK_DGRAM,
+ TCP?tcp_protocol:udp_protocol
+ );
if (fd<0) {
- fprintf(stderr,"WARNING: socket() failed: %s\n",strerror(errno));
+ fprintf(stderr,
+ "WARNING: socket() failed: %s\n"
+ ,strerror(errno)
+ );
return false;
}
@@ -87,13 +102,19 @@
Addr addr(INADDR_ANY,port);
if (bind(fd,addr.GetSa(),sizeof(sockaddr_in))) {
- fprintf(stderr,"WARNING: bind() to port %u filed: %s\n",(unsigned)addr.GetPort(),strerror(errno));
+ fprintf(
+ stderr,"WARNING: bind() to port %u filed: %s\n"
+ ,(unsigned)addr.GetPort(),strerror(errno)
+ );
return false;
}
state=TCP_BOUND;
if (listen(fd,LISTEN_QUEUE_SIZE)) {
- fprintf(stderr,"WARNING: listen() on port %u faied: %s\n",(unsigned)addr.GetPort(),strerror(errno));
+ fprintf(
+ stderr,"WARNING: listen() on port %u faied: %s\n"
+ ,(unsigned)addr.GetPort(),strerror(errno)
+ );
return false;
}
state=TCP_LISTENING;
@@ -110,7 +131,12 @@
if (get_errno()==EINPROGRESS) {
state=TCP_CONNECTING;
} else {
- fprintf(stderr,"WARNING: connect() to ip:port %lu:%u failed: %s\n",(unsigned long)addr.GetIP(),(unsigned)addr.GetPort(),strerror(errno));
+ fprintf(
+ stderr,"WARNING: connect() to ip:port %lu:%u "
+ "failed: %s\n"
+ ,(unsigned long)addr.GetIP()
+ ,(unsigned)addr.GetPort(),strerror(errno)
+ );
Close();
return false;
}
@@ -137,7 +163,10 @@
Addr addr(INADDR_ANY,port);
if (bind(fd,addr.GetSa(),sizeof(sockaddr_in))) {
- fprintf(stderr,"WARNING: bind on port %u filed: %s\n",addr.GetPort(),strerror(errno));
+ fprintf(
+ stderr,"WARNING: bind on port %u filed: %s\n"
+ ,addr.GetPort(),strerror(errno)
+ );
return false;
}
state=UDP_BOUND;
@@ -160,7 +189,9 @@
}
if (optval) {
errno=optval;
- fprintf(stderr,"getsockopt-optval=%i: %s\n",optval,strerror(optval));
+ fprintf(stderr,
+ "getsockopt-optval=%i: %s\n",optval,strerror(optval)
+ );
state=TCP_ERROR;
return false;
}
@@ -171,8 +202,12 @@
}
bool Socket::SendPacket(const Packet & packet) {
- if (state!=TCP_CONNECTED && state!=TCP_CONNECTING && state!=UDP_OPEN && state!=UDP_BOUND) {
- fprintf(stderr,"WARNING: state!=TCP_CONNECTED,TCP_CONNECTING,UDP_OPEN and UDP_BOUND in Socket::SendPacket()\n");
+ if (state!=TCP_CONNECTED && state!=TCP_CONNECTING
+ && state!=UDP_OPEN && state!=UDP_BOUND) {
+ fprintf(stderr,
+ "WARNING: state!=TCP_CONNECTED,TCP_CONNECTING,"
+ "UDP_OPEN and UDP_BOUND in Socket::SendPacket()\n"
+ );
errno=EINVAL;
return false;
}
@@ -189,13 +224,20 @@
// return write(fd,packet.GetPtr(),packet.GetSize())>=0;
return send(fd,packet.GetPtr(),packet.GetSize(),0)>=0;
} else {
- return sendto(fd,packet.GetPtr(),packet.GetSize(),0,packet.GetAddr().GetSa(),sizeof(sockaddr_in))>=0;
+ return sendto(
+ fd,packet.GetPtr(),packet.GetSize(),0,
+ packet.GetAddr().GetSa(),sizeof(sockaddr_in)
+ )>=0;
}
}
bool Socket::ReceivePacket(Packet & packet) {
- if (state!=TCP_CONNECTED && state!=TCP_CONNECTING && state!=UDP_BOUND) {
- fprintf(stderr,"WARNING: state!=TCP_CONNECTED,TCP_CONNECTING and UDP_BOUND in Socket::ReceivePacket()\n");
+ if (state!=TCP_CONNECTED && state!=TCP_CONNECTING
+ && state!=UDP_BOUND) {
+ fprintf(stderr,
+ "WARNING: state!=TCP_CONNECTED,TCP_CONNECTING "
+ "and UDP_BOUND in Socket::ReceivePacket()\n"
+ );
errno=EINVAL;
return false;
}
@@ -235,10 +277,11 @@
);
if (rc_recvfrom<0 || rc_recvfrom>=65536) {
- // Our buffer was not big enough. Note: We cannot recover the
- // data - it's lost. But that's no problem, because UDP is not
- // a save transmission method - the sender must expect some
- // packets to be lost. So simply return here.
+ // Our buffer was not big enough. Note: We cannot
+ // recover the data - it's lost. But that's no problem,
+ // because UDP is not a save transmission method - the
+ // sender must expect some packets to be lost. So
+ // simply return here.
return false;
}
@@ -257,7 +300,10 @@
socklen_t salen=sizeof(sa);
if (state!=TCP_LISTENING || peer.state!=CLOSED) {
- fprintf(stderr,"WARNING: this->state!=TCP_LISTENING or peer.state!=CLOSED in Socket::Accept()\n");
+ fprintf(stderr,
+ "WARNING: this->state!=TCP_LISTENING or "
+ "peer.state!=CLOSED in Socket::Accept()\n"
+ );
if (state!=TCP_LISTENING) {
errno=EINVAL;
return false;
@@ -287,7 +333,10 @@
state=CLOSED;
if (close(fd)<0) {
- fprintf(stderr,"WARNING: Couldn't close file descriptor: %s\n",strerror(errno));
+ fprintf(stderr,
+ "WARNING: Couldn't close file descriptor: %s\n"
+ ,strerror(errno)
+ );
return false;
}
Index: Socket.h
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/Socket.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Socket.h 29 Sep 2003 22:06:21 -0000 1.8
+++ Socket.h 20 Nov 2003 16:21:24 -0000 1.9
@@ -42,14 +42,14 @@
int fd;
Addr Address;
enum State {
- CLOSED, // Socket::Socket(),Socket::Close()
- TCP_SOCKET,UDP_SOCKET, // Socket::CreateSocket()
- TCP_BOUND,TCP_LISTENING, // Socket::TcpListen()
- TCP_CONNECTING, // Socket::TcpConnect()
- TCP_CONNECTED, // Socket::TcpConnect(),Socket::StillConnecting
- TCP_ERROR,
- UDP_OPEN, // Socket::UdpSender()
- UDP_BOUND, // Socket::UdpBind()
+ CLOSED, // Socket(),Close()
+ TCP_SOCKET,UDP_SOCKET, // CreateSocket()
+ TCP_BOUND,TCP_LISTENING, // TcpListen()
+ TCP_CONNECTING, // TcpConnect()
+ TCP_CONNECTED, // TcpConnect(),StillConnecting()
+ TCP_ERROR, //
+ UDP_OPEN, // UdpSender()
+ UDP_BOUND, // UdpBind()
___dummy___
} state;
Index: debug.h
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/debug.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- debug.h 8 Sep 2003 00:31:54 -0000 1.4
+++ debug.h 20 Nov 2003 16:21:24 -0000 1.5
@@ -43,7 +43,11 @@
inited_stddbg=1;\
init_stddbg();\
}\
- PRINTER("%*sEntering %s\n",level++,"",__FUNCTION__);\
+ PRINTER(\
+ "%*sEntering %s\n",\
+ level++,"",\
+ __FUNCTION__\
+ );\
} while(0)
# define LEAVE() do {\
@@ -51,7 +55,11 @@
inited_stddbg=1;\
init_stddbg();\
}\
- PRINTER("%*sLeaving %s\n",--level,"",__FUNCTION__);\
+ PRINTER(\
+ "%*sLeaving %s\n",\
+ --level,"",\
+ __FUNCTION__\
+ );\
return;\
} while(0)
@@ -60,21 +68,37 @@
inited_stddbg=1;\
init_stddbg();\
}\
- PRINTER("%*sReturning %s\n",--level,"",__FUNCTION__);\
+ PRINTER(\
+ "%*sReturning %s\n",\
+ --level,"",\
+ __FUNCTION__\
+ );\
return RV;\
} while(0)
# else // #ifdef HAVE_BTLINUXLIBRARY
# define ENTER() do {\
- PRINTER("%*sEntering %s\n",level++,"",__FUNCTION__);\
+ PRINTER(\
+ "%*sEntering %s\n",\
+ level++,"",\
+ __FUNCTION__\
+ );\
} while(0)
# define LEAVE() do {\
- PRINTER("%*sLeaving %s\n",--level,"",__FUNCTION__);\
+ PRINTER(\
+ "%*sLeaving %s\n",\
+ --level,"",\
+ __FUNCTION__\
+ );\
return;\
} while(0)
# define RETURN(RV) do {\
- PRINTER("%*sReturning %s\n",--level,"",__FUNCTION__);\
+ PRINTER(\
+ "%*sReturning %s\n",\
+ --level,"",\
+ __FUNCTION__\
+ );\
return RV;\
} while(0)
# endif // #ifdef HAVE_BTLINUXLIBRARY
Index: osdep.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/osdep.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- osdep.cpp 5 Sep 2003 15:01:00 -0000 1.6
+++ osdep.cpp 20 Nov 2003 16:21:24 -0000 1.7
@@ -38,7 +38,11 @@
void nonblocking(int fd) {
int arg = 1;
if (ioctl(fd,FIONBIO,&arg)) {
- fprintf(stderr,"WARNING: Couldn't set socket to non-blocking mode: %s\n",strerror(errno));
+ fprintf(stderr,
+ "WARNING: Couldn't set socket "
+ "to non-blocking mode: %s\n",
+ strerror(errno)
+ );
}
}
@@ -56,7 +60,11 @@
int flags;
if ((flags=fcntl(fd,F_GETFL))<0 || fcntl(fd,F_SETFL,flags|O_NONBLOCK)<0) {
- fprintf(stderr,"WARNING: Couldn't set socket to non-blocking mode: %s\n",strerror(errno));
+ fprintf(stderr,
+ "WARNING: Couldn't set socket "
+ "to non-blocking mode: %s\n",
+ strerror(errno)
+ );
}
}
Index: osdep.h
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/osdep.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- osdep.h 5 Sep 2003 15:01:00 -0000 1.8
+++ osdep.h 20 Nov 2003 16:21:24 -0000 1.9
@@ -75,7 +75,9 @@
static inline char * intp2charp(int * x) { return (char*)x; }
static inline char * voidp2charp(void * x) { return (char*)x; }
-static inline const char * cvoidp2ccharp(const void * x) { return (const char*)x; }
+static inline const char * cvoidp2ccharp(const void * x) {
+ return (const char*)x;
+}
typedef uint32_t in_addr_t;
Index: parse-ed2k.c
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/parse-ed2k.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- parse-ed2k.c 20 Nov 2003 14:43:01 -0000 1.11
+++ parse-ed2k.c 20 Nov 2003 16:21:24 -0000 1.12
@@ -22,6 +22,13 @@
* #define PRINT_PARSESTRUCT if you want to see the output
* of print_parsestruct and some[TM] other outputs.
*/
+// #define PRINT_PARSESTRUCT
+
+/*
+ * Keep this not too low as this directly limit the number of elements of a
+ * packet:
+ */
+#define MAX_NUM_VARS 32
#include "parse-ed2k.h"
@@ -72,6 +79,8 @@
/*
* Tag type specification:
* "<BYTE>type<BYTE>idlen<CHAR>id[idlen]<CONDITIONAL[type]>(2:<WORD>strlen<CHAR>string...
[truncated message content] |