Thank you all for your help. Ben, I think I misunderstood my own question (the second one). When I got home I looked at the UIntVar encoder I pulled from Kannel and ported to the PalmOS and discovered that they used UInt32 (I feel kind of stupid not looking at what integer type they used before posting). There was also a comment in the source code that answered my question:
/* A uintvar is defined to be up to 32 bits large, so it will * fit in 5 octets. */ And, I don't know why I put in that "if" statement. Anyway, thanks again. Everything works perfectly (tested and confirmed). -Donald "Ben Combee" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > At 03:10 PM 10/8/2004, you wrote: > >So then if I used the following should I expect it to work? > > > >UInt32 getUintVar(char *instr, int i) > >{ > > UInt32 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); > > } > > } > >} > > > > > >What about storing 5 octets since the OMA's (WAP Forum's) spec for UIntVar > >is that it can be a maximum of 5 octets long? > > A few quick problems: > > Since c is an unsigned char, it will never be less than zero, making the > test "if (c <0)" always be false. > > If a UIntVar has to be able to store 5 octets, you'll need to declare is as > "unsigned long long" and use a 64-bit value. A UInt32 can only hold > 4-bytes of data. > > > -- Ben Combee, Technical Lead, Developer Services, PalmSource, Inc. > "Combee on Palm OS" weblog: http://palmos.combee.net/ > Developer Fourm Archives: http://news.palmos.com/read/all_forums/ > > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
