98N/A - Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") 1276N/A - Copyright (C) 2001 Internet Software Consortium. 1276N/A - Permission to use, copy, modify, and distribute this software for any 98N/A - purpose with or without fee is hereby granted, provided that the above 98N/A - copyright notice and this permission notice appear in all copies. 919N/A - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 919N/A - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 919N/A - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 919N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 919N/A - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 919N/A - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 919N/A - PERFORMANCE OF THIS SOFTWARE. 98N/ACONTENT="Modular DocBook HTML Stylesheet Version 1.79"></
HEAD 493N/A>lwres_buffer_init, lwres_buffer_invalidate, lwres_buffer_add, lwres_buffer_subtract, lwres_buffer_clear, lwres_buffer_first, lwres_buffer_forward, lwres_buffer_back, lwres_buffer_getuint8, lwres_buffer_putuint8, lwres_buffer_getuint16, lwres_buffer_putuint16, lwres_buffer_getuint32, lwres_buffer_putuint32, lwres_buffer_putmem, lwres_buffer_getmem -- lightweight resolver buffer management</
DIV 98N/ACLASS="REFSYNOPSISDIV" 98N/ACLASS="FUNCSYNOPSIS" >(lwres_buffer_t *b, void *base, unsigned int length);</
CODElwres_buffer_invalidate</
CODE>(lwres_buffer_t *b);</
CODE>(lwres_buffer_t *b, unsigned int n);</
CODElwres_buffer_subtract</
CODE>(lwres_buffer_t *b, unsigned int n);</
CODE>(lwres_buffer_t *b);</
CODE>(lwres_buffer_t *b);</
CODElwres_buffer_forward</
CODE>(lwres_buffer_t *b, unsigned int n);</
CODE>(lwres_buffer_t *b, unsigned int n);</
CODElwres_buffer_getuint8</
CODE>(lwres_buffer_t *b);</
CODElwres_buffer_putuint8</
CODE>(lwres_buffer_t *b, lwres_uint8_t val);</
CODElwres_buffer_getuint16</
CODE>(lwres_buffer_t *b);</
CODElwres_buffer_putuint16</
CODE>(lwres_buffer_t *b, lwres_uint16_t val);</
CODElwres_buffer_getuint32</
CODE>(lwres_buffer_t *b);</
CODElwres_buffer_putuint32</
CODE>(lwres_buffer_t *b, lwres_uint32_t val);</
CODElwres_buffer_putmem</
CODE>(lwres_buffer_t *b, const unsigned char *base, unsigned int length);</
CODElwres_buffer_getmem</
CODE>(lwres_buffer_t *b, unsigned char *base, unsigned int length);</
CODE>These functions provide bounds checked access to a region of memory
where data is being read or written.
They are based on, and similar to, the
functions in the ISC library.</
P>A buffer is a region of memory, together with a set of related
> region are disjoint, and
their union is the buffer's region.
The used region extends from the beginning of the buffer region to the
The available region extends from one byte greater than the last used
byte to the end of the buffer's region.
The size of the used region can be changed using various
Initially, the used region is empty.</
P>The used region is further subdivided into two disjoint regions: the
The union of these two regions is the used region.
The consumed region extends from the beginning of the used region to
the byte before the <
SPAN> region the current pointer to the end of the used
The size of the consumed region can be changed using various
Initially, the consumed region is empty.</
P> is an (optional) subregion of the remaining
It extends from the current offset to an offset in the
Initially, the active region is empty.
If the current offset advances beyond the chosen offset,
the active region will also be empty.</
P /------------entire length---------------\\
/----- used region -----\\/-- available --\\
+----------------------------------------+
| consumed | remaining | |
+----------------------------------------+
b == current pointer. Can be anywhere between a and d.
c == active pointer. Meaningful between b and d.
a-e == entire length of buffer.
b-c == optional active region.</
PRE>lwres_buffer_init()</
CODEand assocates it with the memory region of size
bytes starting at location
>lwres_buffer_invalidate()</
CODEas invalid. Invalidating a buffer after use is not required,
but makes it possible to catch its possible accidental use.</
P>lwres_buffer_add()</
CODE>lwres_buffer_subtract()</
CODErespectively increase and decrease the used space in
>lwres_buffer_add()</
CODEchecks for buffer overflow and
>lwres_buffer_subtract()</
CODEThese functions do not allocate or deallocate memory.
They just change the value of
>A buffer is re-initialised by
>lwres_buffer_clear()</
CODE>lwres_buffer_first</
CODEmakes the consumed region of buffer
to zero (the start of the buffer).</
P>lwres_buffer_forward()</
CODEincreases the consumed region of buffer
bytes, checking for overflow.
>lwres_buffer_back()</
CODEbytes and checks for underflow.</
P>lwres_buffer_getuint8()</
CODEreads an unsigned 8-bit integer from
>lwres_buffer_putuint8()</
CODEwrites the unsigned 8-bit integer
>lwres_buffer_getuint16()</
CODE>lwres_buffer_getuint32()</
CODE>lwres_buffer_putuint8()</
CODEexcept that they respectively read an unsigned 16-bit or 32-bit integer
in network byte order from
>lwres_buffer_putuint16()</
CODE>lwres_buffer_putuint32()</
CODEwrites the unsigned 16-bit or 32-bit integer
in network byte order.</
P>Arbitrary amounts of data are read or written from a lightweight
>lwres_buffer_getmem()</
CODE>lwres_buffer_putmem()</
CODE>lwres_buffer_putmem()</
CODE>lwres_buffer_getmem()</
CODE