Donald C. Kirker wrote:
I am having problems retrieving the server session id from a wtp/wsp pdu. If the session id is only 2 octets long (i.e. 0x81 0x24) then it successfully retrieves the proper id, but when the id is longer than 2 octets (i.e. 5 octets long; 0x85 0x9c 0xe1 0xa4 0x35) it only retrieves the last two octets of the uintvar. I can figure out what is wrong. I have tried about 3 different functions and all return the same results. Please help. Below is the code I am currently using. You pass in the buffer of data (an unsigned char) as instr and the current offset as i, the function is supposed to get the full session id and return it as an int.
int getUintVar(char *instr, int i) { int v = 0; unsigned char c; int count;
for (count = 0; count < 5; count++) {
c = instr[i+count];
if (c < 0) return -1;
v = (v << 7)|(c & 0x7f);
if (!(c & 0x80)) {
return(v);
}
}
}
Probably int is a UInt16. Each octet is (by definition) 8 bits long, so you can't store more than 2 octets in the variable. I don't know what exactly you want to store, if it's up to 4 octets you should use UInt32 instead.
Luciano Stertz
Thanks in advanced for the help, Donald
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
