000
02.06.2007, 22:11 Uhr
~Lee
Gast
|
kann mir jemand den folgenen quelltext kommentieren? Ich würd den gerne in eine andere sprache übertragen (ist nur ein ausschnit).
also... hier der QT:
C++: |
void libtbb_client_send_login(TBBCLIENT *theTBBClient, const char *usernick, const char *userpassword, const char *userloginname, const char *inputchan, const char *inputchanpassword, const char *inputsubchan, const char *inputclientstring) { // printf("libtbb_client_login()\n"); UDPDATA data; char header[]={0xf4, 0xbe, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00}; char crc32[4]={0x00, 0x00, 0x00, 0x00}; char body[]={0x09,0x54,0x65,0x61,0x6d,0x53,0x70,0x65,0x61,0x6b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; char clientstring[0x1e]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; char bodypart2[]= {0x02,0x00,0x00,0x00,0x20,0x00,0x3c,0x00,0x01}; char registeredlogin[]={0x01}; char loginname[0x1d]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; char loginpassword[0x1d]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; char nick[0x1d]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; unsigned char buffer[500]; unsigned char *pBuffer; unsigned long icrc32; char *pcrc32; *theTBBClient->inputchan='\0'; *theTBBClient->inputchanpassword='\0'; *theTBBClient->inputsubchan='\0'; if(!(inputchan==NULL)) strcpy(theTBBClient->inputchan, inputchan);
if(!(inputchanpassword==NULL)) strcpy(theTBBClient->inputchanpassword, inputchanpassword);
if(!(inputsubchan==NULL)) { strcpy(theTBBClient->inputsubchan, inputsubchan); }
pBuffer=buffer; memcpy(&nick[3], usernick, strlen(usernick)); nick[2]=strlen(usernick); //printf("ok\n"); //printf("ok %s\n", userpassword); if(!(userpassword==NULL)) { memcpy(&loginpassword[2], userpassword, strlen(userpassword)); loginpassword[1]=strlen(userpassword); } if(!(userloginname==NULL)) { memcpy(&loginname[1], userloginname, strlen(userloginname)); loginname[0]=strlen(userloginname); registeredlogin[0]=0x02; } if(!(inputclientstring==NULL)) { memcpy(&clientstring[1], inputclientstring, strlen(inputclientstring)); clientstring[0]=strlen(inputclientstring); } memcpy(pBuffer, header, sizeof(header)); pBuffer=pBuffer+sizeof(header); memcpy(pBuffer, crc32, sizeof(crc32)); pBuffer=pBuffer+sizeof(crc32); memcpy(pBuffer, body, sizeof(body)); pBuffer=pBuffer+sizeof(body);
memcpy(pBuffer, clientstring, sizeof(clientstring)); pBuffer=pBuffer+sizeof(clientstring); memcpy(pBuffer, bodypart2, sizeof(bodypart2)); pBuffer=pBuffer+sizeof(bodypart2); memcpy(pBuffer, registeredlogin, sizeof(registeredlogin)); pBuffer=pBuffer+sizeof(registeredlogin); memcpy(pBuffer, loginname, sizeof(loginname)); pBuffer=pBuffer+sizeof(loginname);
memcpy(pBuffer, loginpassword, sizeof(loginpassword)); pBuffer=pBuffer+sizeof(loginpassword); memcpy(pBuffer, nick, sizeof(nick)); pBuffer=pBuffer+sizeof(nick); crc32_gen_table();
icrc32 = crc32_get_crc(buffer, 180);
pcrc32 = (char *)&icrc32; // printf("crc32: %x %x %x %x\n", (unsigned char)pcrc32[0], (unsigned char)pcrc32[1], (unsigned char)pcrc32[2], (unsigned char)pcrc32[3]); buffer[0x10]=(unsigned char)pcrc32[0]; buffer[0x11]=(unsigned char)pcrc32[1]; buffer[0x12]=(unsigned char)pcrc32[2]; buffer[0x13]=(unsigned char)pcrc32[3];
data.theBytes=buffer; data.size=180; udpsenddata(&theTBBClient->theUDPSocket, data); theTBBClient->connected=2; theTBBClient->lastserverdata = libtbb_gettime();
}
|
danke im vorraus |