Ok, so what I have now is:

Boolean SARaddSegment(Int32 pos, Boolean last, char *data, UInt32 size, int 
type, GlobalsType *g)
{
  SARPtr tmp, sar;
  Int32 j = 0;
        
        sar = g->segment;
        while(sar != NULL)
        {
                
                if (pos == sar->pos)
                {
                        return(false); // We already added this segment, I 
hope...
                }
                sar = sar->next;
        }

        tmp = Malloc(sizeof(SARType));
        MemSet(tmp,sizeof(SARType),0);
        ErrFatalDisplayIf (!tmp, "Malloc Failed");
        tmp->pos = pos;
        tmp->last = last;
        if (type == 2)
                tmp->size = size-4;
        else
                tmp->size = size;
        tmp->data = Malloc(tmp->size+1);
        ErrFatalDisplayIf (!tmp->data, "Malloc Failed");
        if (type == 2) {
                for (j=0; j<(tmp->size);j++)
                        tmp->data[j] = data[j+4];
        } else {
                for (j=0; j<(tmp->size);j++)
                        tmp->data[j] = data[j];
        }

        tmp->next = g->segment;
        g->segment = tmp;
                        
return(true);
}

Boolean SARreassemble(char *buf, Int16 buflen, GlobalsType *g)
{
  SARPtr tmp;
  Int32 o = 0, j = 0;
  UInt32 offset = 0;
  Boolean finished = false;
  Int32 lastpkt = 0;


        tmp = g->segment;

        while (tmp != NULL) {
                if (tmp->last) {
                        lastpkt = tmp->pos;
                        break;
                }

                tmp = tmp->next;
        }

        tmp = g->segment;
        while(!finished)
        {
                while(tmp != NULL){
                        if (tmp->pos == o)
                                break;
                        else
                                tmp = tmp->next;                        
                }

                if (MemPtrSize(buf) < (offset+tmp->size+1))
                        MemPtrResize(buf, offset+tmp->size+1);

                for (j=0; j<(tmp->size);j++)
                        buf[j+offset] = tmp->data[j];
                offset += tmp->size;

                if (o == lastpkt)
                        finished = true;

                o++; // increase offeset

                tmp = g->segment; // start over 
        }

        return true;
}

The data is being copied (no fatal errors), but the problem I am having is that 
some of the data is either not being copied to the final buffer in 
SARreassemble, or that the data is corrupt. Unfortunatly I do not have an 
example of the data that is being corrupted at the moment.

Basically WAP packets are sent over UDP/IP (WDP), and they are sent as a bunch 
of octets representing the data.

I.e. the WSP equivilant of the HTTP GET header is 0x04, saving two bytes in a 
message.

Thanks,
Donald
To unsubscribe send an email to  [EMAIL PROTECTED]
-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to