On Fri, Apr 30, 2004 at 03:01:24PM +0200, Biot Olivier wrote:
> I'd like to know what tvb_get_ptr() was intended to do
Return an pointer to a contiguous sequence of bytes from the tvbuff,
starting at the specified offset, with the specified length.
> and what it is really doing,
Returning an pointer to a contiguous sequence of bytes from the tvbuff,
starting at the specified offset, with the specified length. :-)
> AFAIK tvb_get_ptr() was intended to return a pointer to contiguous data of
> the specified length (maybe even after reassembly).
That's what it does.
However, it does not guarantee that there's a null byte at the end of
the contiguous data, so, unless the caller knows that there's a null
byte there, the resulting pointer cannot safely be handed to routines
that expect C strings.
> Should we provide a tvb_sscanf() function for implementing such
> functionality? If we have some open-source sscanf() code we can use (from
> GCC libc maybe), this could be done "easily", I guess.
We could, although I'm not a big fan of sscanf, which is why I suggested
doing the parse by hand.