Board index » kylix » char * for LPBYTE, htons for HTONS would be OK?

char * for LPBYTE, htons for HTONS would be OK?


2005-03-07 10:30:44 AM
kylix1
Hello, I'm tyring to imigrate one of my Windows source to Linux using
Kylix and I got some error at this method below.
LPBYTE TACPacket::SaveHeaderToBuffer(LPBYTE buffer,int length)
{
if (length < PACKETHEADERSIZE)
throw TACPacketException(0,EXCEPTION_INSUFFICIENTDATA);
*((WORD *)buffer) = HTONS(ServiceType);
buffer[2] = PacketType;
buffer[3] = Command;
buffer[4] = Option1;
*((WORD *)(buffer + 5)) = HTONS(Option2);
LPBYTE pValue = (LPBYTE) &XMLMaskValue;
for (int i=0; i < 8; i++)
buffer[14 - i] = pValue[i];
return buffer + PACKETHEADERSIZE;
}
First, I got an "E2303 Type name expected" cause of LPBYTE type, so I
changed LPBYTE to char * and I could pass this error. Is that right?
Can I use char * instead of LPBYTE?
Second, at line "*((WORD *)buffer) = HTONS(ServiceType)", I got "E2268
Call to undefined function 'LOBYTE', 'HIBYTE', LOBYTE'.
So I changed HTONS to hons and finally I could compile this method.
It looks OK that using char * instaed of LPBYTE and hotns instead of
HTONS, I just want to make sure about that.
If anybody have any information about that, please let me know.
I hope there is a kind of LIST of variable type that list matching
variable type or function betwwen Linux and Windows for imigration.
Have a nice day~
 
 

Re:char * for LPBYTE, htons for HTONS would be OK?

Hello, I'm tyring to imigrate one of my Windows source to Linux using
Kylix and I got some error at this method below.
LPBYTE TACPacket::SaveHeaderToBuffer(LPBYTE buffer,int length)
{
if (length < PACKETHEADERSIZE)
throw TACPacketException(0,EXCEPTION_INSUFFICIENTDATA);
*((WORD *)buffer) = HTONS(ServiceType);
buffer[2] = PacketType;
buffer[3] = Command;
buffer[4] = Option1;
*((WORD *)(buffer + 5)) = HTONS(Option2);
LPBYTE pValue = (LPBYTE) &XMLMaskValue;
for (int i=0; i < 8; i++)
buffer[14 - i] = pValue[i];
return buffer + PACKETHEADERSIZE;
}
First, I got an "E2303 Type name expected" cause of LPBYTE type, so I
changed LPBYTE to char * and I could pass this error. Is that right?
Can I use char * instead of LPBYTE?
Second, at line "*((WORD *)buffer) = HTONS(ServiceType)", I got "E2268
Call to undefined function 'LOBYTE', 'HIBYTE', LOBYTE'.
So I changed HTONS to hons and finally I could compile this method.
It looks OK that using char * instaed of LPBYTE and hotns instead of
HTONS, I just want to make sure about that.
If anybody have any information about that, please let me know.
I hope there is a kind of LIST of variable type that list matching
variable type or function betwwen Linux and Windows for migration.
Have a nice day~