The c code seems to be walking through the list moving
bytes from src to dst, but the python code below seems
to take one byte from src, start counitng up to the
value from 1 and appending each and every value along
the way to dst, no?

-mike


--- Alan Gauld <[EMAIL PROTECTED]> wrote:

> > I am a noob to converting pointers in C++ to
> arrays in
> > python, although the first time I see it done, I
> will
> > have no problem. Can you help converting the below
> > (what I think is the 'decoder' section) to python?
> 
> It won't be working code but I think this is whats
> happening...
> 
> > UINT CCobsPackets::UnStuffData(unsigned char *src,
> > unsigned char *dst, UINT length)
> 
> def UnStuffData(src,dst,len):
> 
> > {
> > unsigned char *dstStart = dst;
> > unsigned char *end = src + length;
> 
> # I don't think these are needed for Pyhon.
> 
> > while (src < end)
> 
> for code in src:
> 
> > {
> > int code = *src++;
> > for (int i=1; i<code; i++) 
> > {
> > *dst++ = *src++;
> > }
> 
>     for i in range(1,code):
>        dst.append(i)
> 
> > if (code < 0xFF) 
> > {
> > *dst++ = 0;
> > }
> 
>    if code < 0xff
>        dst.append('\0')   # may not be needed in
> python...
> 
> > }
> > return (UINT)(dst - dstStart);
> > }



        
                
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to