2433N/A<!
DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" 2433N/A [<!ENTITY mdash "—">]>
2433N/A - Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") 2433N/A - Copyright (C) 2000, 2001 Internet Software Consortium. 2433N/A - Permission to use, copy, modify, and distribute this software for any 2433N/A - purpose with or without fee is hereby granted, provided that the above 2433N/A - copyright notice and this permission notice appear in all copies. 2433N/A - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 2433N/A - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 2433N/A - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 2433N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 2433N/A - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 2433N/A - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 2433N/A - PERFORMANCE OF THIS SOFTWARE. 2433N/A <
refentrytitle>lwres_buffer</
refentrytitle>
2433N/A <
refmiscinfo>BIND9</
refmiscinfo>
2433N/A <
holder>Internet Systems Consortium, Inc. ("ISC")</
holder>
2433N/A <
holder>Internet Software Consortium.</
holder>
2457N/A <
refname>lwres_buffer_init</
refname>
2433N/A <
refname>lwres_buffer_invalidate</
refname>
2457N/A <
refname>lwres_buffer_add</
refname>
2457N/A <
refname>lwres_buffer_subtract</
refname>
2477N/A <
refname>lwres_buffer_clear</
refname>
2433N/A <
refname>lwres_buffer_first</
refname>
2433N/A <
refname>lwres_buffer_forward</
refname>
2433N/A <
refname>lwres_buffer_back</
refname>
2433N/A <
refname>lwres_buffer_getuint8</
refname>
2433N/A <
refname>lwres_buffer_putuint8</
refname>
2433N/A <
refname>lwres_buffer_getuint16</
refname>
2433N/A <
refname>lwres_buffer_putuint16</
refname>
2433N/A <
refname>lwres_buffer_getuint32</
refname>
2433N/A <
refname>lwres_buffer_putuint32</
refname>
2433N/A <
refname>lwres_buffer_putmem</
refname>
2433N/A <
refname>lwres_buffer_getmem</
refname>
2433N/A <
refpurpose>lightweight resolver buffer management</
refpurpose>
2457N/A<
function>lwres_buffer_init</
function></
funcdef>
2457N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2457N/A <
paramdef>void *<
parameter>base</
parameter></
paramdef>
2457N/A <
paramdef>unsigned int <
parameter>length</
parameter></
paramdef>
2433N/A<
function>lwres_buffer_invalidate</
function></
funcdef>
2433N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2433N/A<
function>lwres_buffer_add</
function></
funcdef>
2433N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2433N/A <
paramdef>unsigned int <
parameter>n</
parameter></
paramdef>
2433N/A<
function>lwres_buffer_subtract</
function></
funcdef>
2433N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2433N/A <
paramdef>unsigned int <
parameter>n</
parameter></
paramdef>
2433N/A<
function>lwres_buffer_clear</
function></
funcdef>
2433N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2433N/A<
function>lwres_buffer_first</
function></
funcdef>
2433N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2433N/A<
function>lwres_buffer_forward</
function></
funcdef>
2433N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2433N/A <
paramdef>unsigned int <
parameter>n</
parameter></
paramdef>
2433N/A<
function>lwres_buffer_back</
function></
funcdef>
2433N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2457N/A <
paramdef>unsigned int <
parameter>n</
parameter></
paramdef>
2457N/A<
function>lwres_buffer_getuint8</
function></
funcdef>
2457N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2457N/A<
function>lwres_buffer_putuint8</
function></
funcdef>
2457N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2457N/A <
paramdef>lwres_uint8_t <
parameter>val</
parameter></
paramdef>
2457N/A<
function>lwres_buffer_getuint16</
function></
funcdef>
2457N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2457N/A<
function>lwres_buffer_putuint16</
function></
funcdef>
2457N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2457N/A <
paramdef>lwres_uint16_t <
parameter>val</
parameter></
paramdef>
2457N/A<
function>lwres_buffer_getuint32</
function></
funcdef>
2457N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2457N/A<
function>lwres_buffer_putuint32</
function></
funcdef>
2457N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2457N/A <
paramdef>lwres_uint32_t <
parameter>val</
parameter></
paramdef>
2457N/A<
function>lwres_buffer_putmem</
function></
funcdef>
2457N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2457N/A <
paramdef>const unsigned char *<
parameter>base</
parameter></
paramdef>
2457N/A <
paramdef>unsigned int <
parameter>length</
parameter></
paramdef>
2457N/A<
function>lwres_buffer_getmem</
function></
funcdef>
2457N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
2457N/A <
paramdef>unsigned char *<
parameter>base</
parameter></
paramdef>
2457N/A <
paramdef>unsigned int <
parameter>length</
parameter></
paramdef>
2457N/A These functions provide bounds checked access to a region of memory
2457N/A where data is being read or written.
2457N/A They are based on, and similar to, the
2457N/A <
literal>isc_buffer_</
literal>
2457N/A functions in the ISC library.
2457N/A A buffer is a region of memory, together with a set of related
2457N/A The <
emphasis>used region</
emphasis> and the
2457N/A <
emphasis>available</
emphasis> region are disjoint, and
2457N/A their union is the buffer's region.
2457N/A The used region extends from the beginning of the buffer region to the
2457N/A The available region extends from one byte greater than the last used
2457N/A byte to the end of the buffer's region.
2457N/A The size of the used region can be changed using various
2457N/A Initially, the used region is empty.
2457N/A The used region is further subdivided into two disjoint regions: the
2457N/A <
emphasis>consumed region</
emphasis> and the <
emphasis>remaining region</
emphasis>.
2457N/A The union of these two regions is the used region.
2457N/A The consumed region extends from the beginning of the used region to
2457N/A the byte before the <
emphasis>current</
emphasis> offset (if any).
2433N/A The <
emphasis>remaining</
emphasis> region the current pointer to the end
2433N/A The size of the consumed region can be changed using various
2433N/A Initially, the consumed region is empty.
2433N/A The <
emphasis>active region</
emphasis> is an (optional) subregion of the
2433N/A It extends from the current offset to an offset in the
2433N/A Initially, the active region is empty.
2433N/A If the current offset advances beyond the chosen offset,
2433N/A the active region will also be empty.
2433N/A /------------entire length---------------\\
2433N/A /----- used region -----\\/-- available --\\
2433N/A +----------------------------------------+
2433N/A +----------------------------------------+
2433N/A b == current pointer. Can be anywhere between a and d.
2433N/A c == active pointer. Meaningful between b and d.
2433N/A a-e == entire length of buffer.
2433N/A b-c == optional active region.
2433N/A <
para><
function>lwres_buffer_init()</
function>
2433N/A <
type>lwres_buffer_t</
type>
2433N/A and assocates it with the memory region of size
2433N/A <
parameter>length</
parameter>
2433N/A <
parameter>base.</
parameter>
2433N/A <
para><
function>lwres_buffer_invalidate()</
function>
2433N/A marks the buffer <
parameter>*b</
parameter>
2433N/A as invalid. Invalidating a buffer after use is not required,
2433N/A but makes it possible to catch its possible accidental use.
2433N/A <
function>lwres_buffer_add()</
function>
2433N/A <
function>lwres_buffer_subtract()</
function>
2433N/A respectively increase and decrease the used space in
2433N/A <
function>lwres_buffer_add()</
function>
2433N/A checks for buffer overflow and
2433N/A <
function>lwres_buffer_subtract()</
function>
2433N/A These functions do not allocate or deallocate memory.
2433N/A They just change the value of
2433N/A <
structfield>used</
structfield>.
2433N/A A buffer is re-initialised by
2433N/A <
function>lwres_buffer_clear()</
function>.
2433N/A <
structfield>used</
structfield>,
2433N/A <
structfield>current</
structfield>
2433N/A <
structfield>active</
structfield>
2433N/A <
para><
function>lwres_buffer_first</
function>
2433N/A makes the consumed region of buffer
2433N/A <
structfield>current</
structfield>
2433N/A to zero (the start of the buffer).
2433N/A <
para><
function>lwres_buffer_forward()</
function>
2433N/A increases the consumed region of buffer
2433N/A bytes, checking for overflow.
2433N/A <
function>lwres_buffer_back()</
function>
2433N/A bytes and checks for underflow.
2607N/A <
para><
function>lwres_buffer_getuint8()</
function>
2607N/A reads an unsigned 8-bit integer from
2607N/A <
function>lwres_buffer_putuint8()</
function>
2607N/A writes the unsigned 8-bit integer
2433N/A <
para><
function>lwres_buffer_getuint16()</
function>
2433N/A <
function>lwres_buffer_getuint32()</
function>
2433N/A <
function>lwres_buffer_putuint8()</
function>
2433N/A except that they respectively read an unsigned 16-bit or 32-bit integer
2433N/A <
function>lwres_buffer_putuint16()</
function>
2433N/A <
function>lwres_buffer_putuint32()</
function>
2433N/A writes the unsigned 16-bit or 32-bit integer
2433N/A Arbitrary amounts of data are read or written from a lightweight
2433N/A <
function>lwres_buffer_getmem()</
function>
2433N/A <
function>lwres_buffer_putmem()</
function>
2433N/A <
function>lwres_buffer_putmem()</
function>
2433N/A <
parameter>length</
parameter>
2433N/A <
parameter>base</
parameter>
2433N/A <
function>lwres_buffer_getmem()</
function>
2433N/A <
parameter>length</
parameter>
2433N/A <
parameter>base</
parameter>.