493N/A<!
DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
493N/A - Copyright (C) 2000, 2001 Internet Software Consortium. 1466N/A - Permission to use, copy, modify, and distribute this software for any 1356N/A - purpose with or without fee is hereby granted, provided that the above 493N/A - copyright notice and this permission notice appear in all copies. 493N/A - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM 493N/A - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL 493N/A - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL 493N/A - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, 493N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 493N/A - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 1466N/A - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 493N/A - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1466N/A <
refentrytitle>lwres_buffer</
refentrytitle>
1466N/A <
refmiscinfo>BIND9</
refmiscinfo>
970N/A<
refname>lwres_buffer_init</
refname>
1466N/A<
refname>lwres_buffer_invalidate</
refname>
970N/A<
refname>lwres_buffer_add</
refname>
970N/A<
refname>lwres_buffer_subtract</
refname>
970N/A<
refname>lwres_buffer_clear</
refname>
493N/A<
refname>lwres_buffer_first</
refname>
493N/A<
refname>lwres_buffer_forward</
refname>
1466N/A<
refname>lwres_buffer_back</
refname>
493N/A<
refname>lwres_buffer_getuint8</
refname>
493N/A<
refname>lwres_buffer_putuint8</
refname>
493N/A<
refname>lwres_buffer_getuint16</
refname>
493N/A<
refname>lwres_buffer_putuint16</
refname>
493N/A<
refname>lwres_buffer_getuint32</
refname>
493N/A<
refname>lwres_buffer_putuint32</
refname>
493N/A<
refname>lwres_buffer_putmem</
refname>
493N/A<
refname>lwres_buffer_getmem</
refname>
493N/A<
refpurpose>lightweight resolver buffer management</
refpurpose>
1466N/A<
function>lwres_buffer_init</
function></
funcdef>
493N/A<
paramdef>lwres_buffer_t *b</
paramdef>
493N/A<
paramdef>void *base</
paramdef>
493N/A<
paramdef>unsigned int length</
paramdef>
493N/A<
function>lwres_buffer_invalidate</
function></
funcdef>
493N/A<
paramdef>lwres_buffer_t *b</
paramdef>
493N/A<
function>lwres_buffer_add</
function></
funcdef>
493N/A<
paramdef>lwres_buffer_t *b</
paramdef>
493N/A<
paramdef>unsigned int n</
paramdef>
1466N/A<
function>lwres_buffer_subtract</
function></
funcdef>
1466N/A<
paramdef>lwres_buffer_t *b</
paramdef>
493N/A<
paramdef>unsigned int n</
paramdef>
493N/A<
function>lwres_buffer_clear</
function></
funcdef>
493N/A<
paramdef>lwres_buffer_t *b</
paramdef>
493N/A<
function>lwres_buffer_first</
function></
funcdef>
493N/A<
paramdef>lwres_buffer_t *b</
paramdef>
970N/A<
function>lwres_buffer_forward</
function></
funcdef>
1466N/A<
paramdef>lwres_buffer_t *b</
paramdef>
970N/A<
paramdef>unsigned int n</
paramdef>
493N/A<
function>lwres_buffer_back</
function></
funcdef>
493N/A<
paramdef>lwres_buffer_t *b</
paramdef>
493N/A<
paramdef>unsigned int n</
paramdef>
493N/A<
function>lwres_buffer_getuint8</
function></
funcdef>
493N/A<
paramdef>lwres_buffer_t *b</
paramdef>
1466N/A<
function>lwres_buffer_putuint8</
function></
funcdef>
1466N/A<
paramdef>lwres_buffer_t *b</
paramdef>
1466N/A<
paramdef>lwres_uint8_t val</
paramdef>
493N/A<
function>lwres_buffer_getuint16</
function></
funcdef>
493N/A<
paramdef>lwres_buffer_t *b</
paramdef>
493N/A<
function>lwres_buffer_putuint16</
function></
funcdef>
493N/A<
paramdef>lwres_buffer_t *b</
paramdef>
493N/A<
paramdef>lwres_uint16_t val</
paramdef>
493N/A<
function>lwres_buffer_getuint32</
function></
funcdef>
493N/A<
paramdef>lwres_buffer_t *b</
paramdef>
493N/A<
function>lwres_buffer_putuint32</
function></
funcdef>
493N/A<
paramdef>lwres_buffer_t *b</
paramdef>
493N/A<
paramdef>lwres_uint32_t val</
paramdef>
970N/A<
function>lwres_buffer_putmem</
function></
funcdef>
1466N/A<
paramdef>lwres_buffer_t *b</
paramdef>
493N/A<
paramdef>const unsigned char *base</
paramdef>
1466N/A<
paramdef>unsigned int length</
paramdef>
493N/A<
function>lwres_buffer_getmem</
function></
funcdef>
493N/A<
paramdef>lwres_buffer_t *b</
paramdef>
493N/A<
paramdef>unsigned char *base</
paramdef>
493N/A<
paramdef>unsigned int length</
paramdef>
493N/A<
title>DESCRIPTION</
title>
493N/AThese functions provide bounds checked access to a region of memory
493N/Awhere data is being read or written.
493N/AThey are based on, and similar to, the
493N/A<
literal>isc_buffer_</
literal>
493N/Afunctions in the ISC library.
493N/AA buffer is a region of memory, together with a set of related
1466N/AThe <
emphasis>used region</
emphasis> and the
1466N/A<
emphasis>available</
emphasis> region are disjoint, and
1466N/Atheir union is the buffer's region.
1466N/AThe used region extends from the beginning of the buffer region to the
493N/AThe available region extends from one byte greater than the last used
493N/Abyte to the end of the buffer's region.
493N/AThe size of the used region can be changed using various
493N/AInitially, the used region is empty.
493N/AThe used region is further subdivided into two disjoint regions: the
851N/A<
emphasis>consumed region</
emphasis> and the <
emphasis>remaining region</
emphasis>.
851N/AThe union of these two regions is the used region.
493N/AThe consumed region extends from the beginning of the used region to
493N/Athe byte before the <
emphasis>current</
emphasis> offset (if any).
493N/AThe <
emphasis>remaining</
emphasis> region the current pointer to the end of the used
970N/AThe size of the consumed region can be changed using various
970N/AInitially, the consumed region is empty.
1356N/AThe <
emphasis>active region</
emphasis> is an (optional) subregion of the remaining
1466N/AIt extends from the current offset to an offset in the
1466N/AInitially, the active region is empty.
1466N/AIf the current offset advances beyond the chosen offset,
1356N/Athe active region will also be empty.
1356N/A /------------entire length---------------\\
1356N/A /----- used region -----\\/-- available --\\
1003N/A +----------------------------------------+
1003N/A +----------------------------------------+
1356N/A b == current pointer. Can be anywhere between a and d.
1356N/A c == active pointer. Meaningful between b and d.
1356N/A a-e == entire length of buffer.
493N/A a-b == consumed region.
493N/A b-d == remaining region.
493N/A b-c == optional active region.
493N/A<
function>lwres_buffer_init()</
function>
493N/A<
type>lwres_buffer_t</
type>
591N/Aand assocates it with the memory region of size
591N/A<
parameter>length</
parameter>
1466N/A<
parameter>base.</
parameter>
493N/A<
function>lwres_buffer_invalidate()</
function>
493N/A<
parameter>*b</
parameter>
1466N/Aas invalid. Invalidating a buffer after use is not required,
493N/Abut makes it possible to catch its possible accidental use.
493N/A<
function>lwres_buffer_add()</
function>
493N/A<
function>lwres_buffer_subtract()</
function>
493N/Arespectively increase and decrease the used space in
493N/A<
parameter>*b</
parameter>
493N/A<
function>lwres_buffer_add()</
function>
606N/Achecks for buffer overflow and
606N/A<
function>lwres_buffer_subtract()</
function>
606N/AThese functions do not allocate or deallocate memory.
493N/AThey just change the value of
493N/A<
structfield>used</
structfield>.
493N/AA buffer is re-initialised by
493N/A<
function>lwres_buffer_clear()</
function>.
493N/A<
structfield>used</
structfield> ,
493N/A<
structfield>current</
structfield>
493N/A<
structfield>active</
structfield>
493N/A<
function>lwres_buffer_first</
function>
493N/Amakes the consumed region of buffer
493N/A<
parameter>*p</
parameter>
493N/A<
structfield>current</
structfield>
493N/Ato zero (the start of the buffer).
1466N/A<
function>lwres_buffer_forward()</
function>
493N/Aincreases the consumed region of buffer
493N/A<
parameter>*b</
parameter>
493N/A<
parameter>n</
parameter>
493N/Abytes, checking for overflow.
493N/A<
function>lwres_buffer_back()</
function>
493N/A<
parameter>b</
parameter>'s
493N/A<
parameter>n</
parameter>
493N/Abytes and checks for underflow.
493N/A<
function>lwres_buffer_getuint8()</
function>
493N/Areads an unsigned 8-bit integer from
493N/A<
parameter>*b</
parameter>
493N/A<
function>lwres_buffer_putuint8()</
function>
493N/Awrites the unsigned 8-bit integer
493N/A<
parameter>val</
parameter>
493N/A<
parameter>*b</
parameter>.
493N/A<
function>lwres_buffer_getuint16()</
function>
970N/A<
function>lwres_buffer_getuint32()</
function>
970N/A<
function>lwres_buffer_putuint8()</
function>
970N/Aexcept that they respectively read an unsigned 16-bit or 32-bit integer
970N/A<
parameter>b</
parameter>.
587N/A<
function>lwres_buffer_putuint16()</
function>
493N/A<
function>lwres_buffer_putuint32()</
function>
493N/Awrites the unsigned 16-bit or 32-bit integer
493N/A<
parameter>val</
parameter>
493N/A<
parameter>b</
parameter>,
970N/AArbitrary amounts of data are read or written from a lightweight
970N/A<
function>lwres_buffer_getmem()</
function>
970N/A<
function>lwres_buffer_putmem()</
function>
970N/A<
function>lwres_buffer_putmem()</
function>
970N/A<
parameter>length</
parameter>
970N/A<
parameter>base</
parameter>
970N/A<
parameter>b</
parameter>.
970N/A<
function>lwres_buffer_getmem()</
function>
970N/A<
parameter>length</
parameter>
970N/A<
parameter>b</
parameter>
970N/A<
parameter>base</
parameter>.