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/

Reply via email to