lwres_buffer.docbook revision dafcb997e390efa4423883dafd100c975c4095d6
8c1aa8573dd85774ac8921dc0482b91d73e8b8b6Mark Andrews<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
8c1aa8573dd85774ac8921dc0482b91d73e8b8b6Mark Andrews<!--
8c1aa8573dd85774ac8921dc0482b91d73e8b8b6Mark Andrews - Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
96ab25294b028270eb1be867613df8a6c999b332David Lawrence - Copyright (C) 2001 Internet Software Consortium.
96ab25294b028270eb1be867613df8a6c999b332David Lawrence -
96ab25294b028270eb1be867613df8a6c999b332David Lawrence - Permission to use, copy, modify, and distribute this software for any
96ab25294b028270eb1be867613df8a6c999b332David Lawrence - purpose with or without fee is hereby granted, provided that the above
96ab25294b028270eb1be867613df8a6c999b332David Lawrence - copyright notice and this permission notice appear in all copies.
96ab25294b028270eb1be867613df8a6c999b332David Lawrence -
96ab25294b028270eb1be867613df8a6c999b332David Lawrence - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
e68de4a7dbf5b6a1b2ff3f4f4dd8adf80b80525bBrian Wellington - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
96ab25294b028270eb1be867613df8a6c999b332David Lawrence - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
96ab25294b028270eb1be867613df8a6c999b332David Lawrence - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
96ab25294b028270eb1be867613df8a6c999b332David Lawrence - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
5aa96829fdd12f30a2e9f717e66d44a4698b0675Andreas Gustafsson - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5aa96829fdd12f30a2e9f717e66d44a4698b0675Andreas Gustafsson - PERFORMANCE OF THIS SOFTWARE.
5aa96829fdd12f30a2e9f717e66d44a4698b0675Andreas Gustafsson-->
5aa96829fdd12f30a2e9f717e66d44a4698b0675Andreas Gustafsson
5aa96829fdd12f30a2e9f717e66d44a4698b0675Andreas Gustafsson<!-- $Id: lwres_buffer.docbook,v 1.4 2004/03/05 05:12:56 marka Exp $ -->
5aa96829fdd12f30a2e9f717e66d44a4698b0675Andreas Gustafsson
e2894b0e5007e49f5b21be9113e41419ca8489a0Brian Wellington<refentry>
e2894b0e5007e49f5b21be9113e41419ca8489a0Brian Wellington<refentryinfo>
e2894b0e5007e49f5b21be9113e41419ca8489a0Brian Wellington<date>Jun 30, 2000</date>
e2894b0e5007e49f5b21be9113e41419ca8489a0Brian Wellington</refentryinfo>
96ab25294b028270eb1be867613df8a6c999b332David Lawrence
845e0b5f968d4ac069ac8b802730467df8cd7136Mark Andrews<refmeta>
845e0b5f968d4ac069ac8b802730467df8cd7136Mark Andrews<refentrytitle>lwres_buffer</refentrytitle>
c4252cd10ba9a35ef03c53b97961a4c0b15fe44fAndreas Gustafsson<manvolnum>3</manvolnum>
c4252cd10ba9a35ef03c53b97961a4c0b15fe44fAndreas Gustafsson<refmiscinfo>BIND9</refmiscinfo>
c4252cd10ba9a35ef03c53b97961a4c0b15fe44fAndreas Gustafsson</refmeta>
b6747cf19dea764e5acaa164f23b70d54348d64cMark Andrews
5aa96829fdd12f30a2e9f717e66d44a4698b0675Andreas Gustafsson<refnamediv>
1318ddb52d8a8a22eae47f7d82137e74b9beacf1Mark Andrews<refname>lwres_buffer_init</refname>
de8e189332e884db065b921f84e3ee4922ad10e3David Lawrence<refname>lwres_buffer_invalidate</refname>
de8e189332e884db065b921f84e3ee4922ad10e3David Lawrence<refname>lwres_buffer_add</refname>
de8e189332e884db065b921f84e3ee4922ad10e3David Lawrence<refname>lwres_buffer_subtract</refname>
de8e189332e884db065b921f84e3ee4922ad10e3David Lawrence<refname>lwres_buffer_clear</refname>
de8e189332e884db065b921f84e3ee4922ad10e3David Lawrence<refname>lwres_buffer_first</refname>
de8e189332e884db065b921f84e3ee4922ad10e3David Lawrence<refname>lwres_buffer_forward</refname>
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence<refname>lwres_buffer_back</refname>
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence<refname>lwres_buffer_getuint8</refname>
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence<refname>lwres_buffer_putuint8</refname>
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence<refname>lwres_buffer_getuint16</refname>
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence<refname>lwres_buffer_putuint16</refname>
1c823819b73f17cbfd188d35962da196a48190fbAndreas Gustafsson<refname>lwres_buffer_getuint32</refname>
1c823819b73f17cbfd188d35962da196a48190fbAndreas Gustafsson<refname>lwres_buffer_putuint32</refname>
1c823819b73f17cbfd188d35962da196a48190fbAndreas Gustafsson<refname>lwres_buffer_putmem</refname>
1c823819b73f17cbfd188d35962da196a48190fbAndreas Gustafsson<refname>lwres_buffer_getmem</refname>
e405739af20dcdc6c7f604548e78806a0d1515c5Brian Wellington<refpurpose>lightweight resolver buffer management</refpurpose>
e405739af20dcdc6c7f604548e78806a0d1515c5Brian Wellington</refnamediv>
e405739af20dcdc6c7f604548e78806a0d1515c5Brian Wellington
428b78e56dc10ea220fadfed11242ceb1d51d0e3Andreas Gustafsson<refsynopsisdiv>
b719a598e77aada962b3a05cb00179dc929d3939Andreas Gustafsson
b719a598e77aada962b3a05cb00179dc929d3939Andreas Gustafsson<funcsynopsis>
b719a598e77aada962b3a05cb00179dc929d3939Andreas Gustafsson<funcsynopsisinfo>
b719a598e77aada962b3a05cb00179dc929d3939Andreas Gustafsson#include &lt;lwres/lwbuffer.h&gt;
428b78e56dc10ea220fadfed11242ceb1d51d0e3Andreas Gustafsson</funcsynopsisinfo>
428b78e56dc10ea220fadfed11242ceb1d51d0e3Andreas Gustafsson
428b78e56dc10ea220fadfed11242ceb1d51d0e3Andreas Gustafsson<funcprototype>
428b78e56dc10ea220fadfed11242ceb1d51d0e3Andreas Gustafsson
428b78e56dc10ea220fadfed11242ceb1d51d0e3Andreas Gustafsson<funcdef>
428b78e56dc10ea220fadfed11242ceb1d51d0e3Andreas Gustafssonvoid
428b78e56dc10ea220fadfed11242ceb1d51d0e3Andreas Gustafsson<function>lwres_buffer_init</function></funcdef>
428b78e56dc10ea220fadfed11242ceb1d51d0e3Andreas Gustafsson<paramdef>lwres_buffer_t *b</paramdef>
b74e73c5b4b299da20a6b196b68b9068d376ff35Mark Andrews<paramdef>void *base</paramdef>
b74e73c5b4b299da20a6b196b68b9068d376ff35Mark Andrews<paramdef>unsigned int length</paramdef>
b74e73c5b4b299da20a6b196b68b9068d376ff35Mark Andrews</funcprototype>
b74e73c5b4b299da20a6b196b68b9068d376ff35Mark Andrews
b74e73c5b4b299da20a6b196b68b9068d376ff35Mark Andrews<funcprototype>
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence<funcdef>
323b6387ce2575627427859b8668e7f27f090c4cMark Andrewsvoid
d68e4b66b1075e556b480f8bfb607aeba5da46f6Andreas Gustafsson<function>lwres_buffer_invalidate</function></funcdef>
d68e4b66b1075e556b480f8bfb607aeba5da46f6Andreas Gustafsson<paramdef>lwres_buffer_t *b</paramdef>
d68e4b66b1075e556b480f8bfb607aeba5da46f6Andreas Gustafsson</funcprototype>
d68e4b66b1075e556b480f8bfb607aeba5da46f6Andreas Gustafsson<funcprototype>
d68e4b66b1075e556b480f8bfb607aeba5da46f6Andreas Gustafsson<funcdef>
d68e4b66b1075e556b480f8bfb607aeba5da46f6Andreas Gustafssonvoid
d68e4b66b1075e556b480f8bfb607aeba5da46f6Andreas Gustafsson<function>lwres_buffer_add</function></funcdef>
e44d56866bd609e066380cbef414e6ce11a08976Andreas Gustafsson<paramdef>lwres_buffer_t *b</paramdef>
e44d56866bd609e066380cbef414e6ce11a08976Andreas Gustafsson<paramdef>unsigned int n</paramdef>
e44d56866bd609e066380cbef414e6ce11a08976Andreas Gustafsson</funcprototype>
e44d56866bd609e066380cbef414e6ce11a08976Andreas Gustafsson
84c4c99c9e2cf14fb9ef6f6815a9fdb824475423Michael Sawyer<funcprototype>
84c4c99c9e2cf14fb9ef6f6815a9fdb824475423Michael Sawyer<funcdef>
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrencevoid
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrence<function>lwres_buffer_subtract</function></funcdef>
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrence<paramdef>lwres_buffer_t *b</paramdef>
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrence<paramdef>unsigned int n</paramdef>
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrence</funcprototype>
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrence
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrence<funcprototype>
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrence<funcdef>
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrencevoid
0df2335526caaebd8639129fd0327a6cc97060eaDavid Lawrence<function>lwres_buffer_clear</function></funcdef>
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrence<paramdef>lwres_buffer_t *b</paramdef>
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrence</funcprototype>
8b31f5630f6345f686449f8a84c33c0813283e42Andreas Gustafsson
8b31f5630f6345f686449f8a84c33c0813283e42Andreas Gustafsson<funcprototype>
8b31f5630f6345f686449f8a84c33c0813283e42Andreas Gustafsson<funcdef>
8b31f5630f6345f686449f8a84c33c0813283e42Andreas Gustafssonvoid
8b31f5630f6345f686449f8a84c33c0813283e42Andreas Gustafsson<function>lwres_buffer_first</function></funcdef>
13c32cb589e571e9204dbb091e145809288c9c21David Lawrence<paramdef>lwres_buffer_t *b</paramdef>
13c32cb589e571e9204dbb091e145809288c9c21David Lawrence</funcprototype>
13c32cb589e571e9204dbb091e145809288c9c21David Lawrence
13c32cb589e571e9204dbb091e145809288c9c21David Lawrence<funcprototype>
822f118444dcaddaf977bc73e958b2f755e4ddfdAndreas Gustafsson<funcdef>
822f118444dcaddaf977bc73e958b2f755e4ddfdAndreas Gustafssonvoid
822f118444dcaddaf977bc73e958b2f755e4ddfdAndreas Gustafsson<function>lwres_buffer_forward</function></funcdef>
822f118444dcaddaf977bc73e958b2f755e4ddfdAndreas Gustafsson<paramdef>lwres_buffer_t *b</paramdef>
822f118444dcaddaf977bc73e958b2f755e4ddfdAndreas Gustafsson<paramdef>unsigned int n</paramdef>
822f118444dcaddaf977bc73e958b2f755e4ddfdAndreas Gustafsson</funcprototype>
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrence<funcprototype>
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence
8775909be9fc67180fc480115716f88174e74471James Brister<funcdef>
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrencevoid
406ce0cd9633188a79c008e8f7c8092fa54bc98cJames Brister<function>lwres_buffer_back</function></funcdef>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<paramdef>lwres_buffer_t *b</paramdef>
a797a75953e21b514427d188bf5d5051419c10adBrian Wellington<paramdef>unsigned int n</paramdef>
a797a75953e21b514427d188bf5d5051419c10adBrian Wellington</funcprototype>
a797a75953e21b514427d188bf5d5051419c10adBrian Wellington
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<funcprototype>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<funcdef>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrencelwres_uint8_t
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<function>lwres_buffer_getuint8</function></funcdef>
17d91fddb33cc6e0bf2dfacf7156bb1ebba197d8David Lawrence<paramdef>lwres_buffer_t *b</paramdef>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence</funcprototype>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<funcprototype>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<funcdef>
a38e5f0695a8ddf0b3cbb70b5a172a5c6dce994bDavid Lawrencevoid
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<function>lwres_buffer_putuint8</function></funcdef>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<paramdef>lwres_buffer_t *b</paramdef>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<paramdef>lwres_uint8_t val</paramdef>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence</funcprototype>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence
c244584cad2a71276e60919bf2c80c7d79dc073bDavid Lawrence<funcprototype>
abeb505bb6c1400dde1a40d0bff7b3a435666e1cMark Andrews<funcdef>
abeb505bb6c1400dde1a40d0bff7b3a435666e1cMark Andrewslwres_uint16_t
727eef0cbc8bf889ddb3b58eb89e9ea2c3b4b047Andreas Gustafsson<function>lwres_buffer_getuint16</function></funcdef>
727eef0cbc8bf889ddb3b58eb89e9ea2c3b4b047Andreas Gustafsson<paramdef>lwres_buffer_t *b</paramdef>
57b3597444bc8716459f0fb3022b2c12f4eee2aeAndreas Gustafsson</funcprototype>
727eef0cbc8bf889ddb3b58eb89e9ea2c3b4b047Andreas Gustafsson
727eef0cbc8bf889ddb3b58eb89e9ea2c3b4b047Andreas Gustafsson<funcprototype>
99524919752c9b9abe1814007732b86592011cc1Brian Wellington<funcdef>
26c86a6fc85c89447d23d4a3e34b11157a2ff6f4Andreas Gustafssonvoid
26c86a6fc85c89447d23d4a3e34b11157a2ff6f4Andreas Gustafsson<function>lwres_buffer_putuint16</function></funcdef>
26c86a6fc85c89447d23d4a3e34b11157a2ff6f4Andreas Gustafsson<paramdef>lwres_buffer_t *b</paramdef>
26c86a6fc85c89447d23d4a3e34b11157a2ff6f4Andreas Gustafsson<paramdef>lwres_uint16_t val</paramdef>
26c86a6fc85c89447d23d4a3e34b11157a2ff6f4Andreas Gustafsson</funcprototype>
b3157263ee12a5792737f09b708d3fc65ca99e01Andreas Gustafsson
b3157263ee12a5792737f09b708d3fc65ca99e01Andreas Gustafsson<funcprototype>
b3157263ee12a5792737f09b708d3fc65ca99e01Andreas Gustafsson<funcdef>
b3157263ee12a5792737f09b708d3fc65ca99e01Andreas Gustafssonlwres_uint32_t
b3157263ee12a5792737f09b708d3fc65ca99e01Andreas Gustafsson<function>lwres_buffer_getuint32</function></funcdef>
b3157263ee12a5792737f09b708d3fc65ca99e01Andreas Gustafsson<paramdef>lwres_buffer_t *b</paramdef>
b90d3f516fd62514ff0b06a6ee0311d7ab5fbbb4Brian Wellington</funcprototype>
b90d3f516fd62514ff0b06a6ee0311d7ab5fbbb4Brian Wellington
b90d3f516fd62514ff0b06a6ee0311d7ab5fbbb4Brian Wellington<funcprototype>
b35a009df86b4aa3793e87602c95af2a503ec0eeMark Andrews<funcdef>
b35a009df86b4aa3793e87602c95af2a503ec0eeMark Andrewsvoid
7bb1e299e133de5d530aa4cb545f4130aabf5235Andreas Gustafsson<function>lwres_buffer_putuint32</function></funcdef>
7bb1e299e133de5d530aa4cb545f4130aabf5235Andreas Gustafsson<paramdef>lwres_buffer_t *b</paramdef>
7bb1e299e133de5d530aa4cb545f4130aabf5235Andreas Gustafsson<paramdef>lwres_uint32_t val</paramdef>
7bb1e299e133de5d530aa4cb545f4130aabf5235Andreas Gustafsson</funcprototype>
482b9dae17bc5dc4e51b78d3c5b1a18c7c1adae9Andreas Gustafsson
482b9dae17bc5dc4e51b78d3c5b1a18c7c1adae9Andreas Gustafsson<funcprototype>
482b9dae17bc5dc4e51b78d3c5b1a18c7c1adae9Andreas Gustafsson<funcdef>
482b9dae17bc5dc4e51b78d3c5b1a18c7c1adae9Andreas Gustafssonvoid
34ea3c6fd940a8514b5ec609491f823263a735c7Michael Sawyer<function>lwres_buffer_putmem</function></funcdef>
34ea3c6fd940a8514b5ec609491f823263a735c7Michael Sawyer<paramdef>lwres_buffer_t *b</paramdef>
26c86a6fc85c89447d23d4a3e34b11157a2ff6f4Andreas Gustafsson<paramdef>const unsigned char *base</paramdef>
3c671ac666de8a7dcd7bd02afa20968da0b85bbdMark Andrews<paramdef>unsigned int length</paramdef>
8ae26e9f87560f9d2e495328d573c25af81c49beMark Andrews</funcprototype>
3c671ac666de8a7dcd7bd02afa20968da0b85bbdMark Andrews
3c671ac666de8a7dcd7bd02afa20968da0b85bbdMark Andrews<funcprototype>
3c671ac666de8a7dcd7bd02afa20968da0b85bbdMark Andrews<funcdef>
3c671ac666de8a7dcd7bd02afa20968da0b85bbdMark Andrewsvoid
3c671ac666de8a7dcd7bd02afa20968da0b85bbdMark Andrews<function>lwres_buffer_getmem</function></funcdef>
3c671ac666de8a7dcd7bd02afa20968da0b85bbdMark Andrews<paramdef>lwres_buffer_t *b</paramdef>
3c671ac666de8a7dcd7bd02afa20968da0b85bbdMark Andrews<paramdef>unsigned char *base</paramdef>
58c42ee18c186b2151ced62f64aa4ca23cff4a1dJames Brister<paramdef>unsigned int length</paramdef>
58c42ee18c186b2151ced62f64aa4ca23cff4a1dJames Brister</funcprototype>
58c42ee18c186b2151ced62f64aa4ca23cff4a1dJames Brister
58c42ee18c186b2151ced62f64aa4ca23cff4a1dJames Brister</funcsynopsis>
58c42ee18c186b2151ced62f64aa4ca23cff4a1dJames Brister</refsynopsisdiv>
58c42ee18c186b2151ced62f64aa4ca23cff4a1dJames Brister
58c42ee18c186b2151ced62f64aa4ca23cff4a1dJames Brister<refsect1>
26c86a6fc85c89447d23d4a3e34b11157a2ff6f4Andreas Gustafsson
5dc6a24e8b6808f03e7a9bc6530d646ebba927dbMark Andrews<title>DESCRIPTION</title>
5dc6a24e8b6808f03e7a9bc6530d646ebba927dbMark Andrews<para>
242dfd9cc6901a5e02dae94acdecdb91e78ea07cMark AndrewsThese functions provide bounds checked access to a region of memory
77771185071bf74d53378f1a3099a04d2af5153eBrian Wellingtonwhere data is being read or written.
77771185071bf74d53378f1a3099a04d2af5153eBrian WellingtonThey are based on, and similar to, the
77771185071bf74d53378f1a3099a04d2af5153eBrian Wellington<literal>isc_buffer_</literal>
77771185071bf74d53378f1a3099a04d2af5153eBrian Wellingtonfunctions in the ISC library.
0d5d8e2bbf2c0c129f0416f24758a0925ce12be8James Brister</para>
0d5d8e2bbf2c0c129f0416f24758a0925ce12be8James Brister<para>
0d5d8e2bbf2c0c129f0416f24758a0925ce12be8James BristerA buffer is a region of memory, together with a set of related
0d5d8e2bbf2c0c129f0416f24758a0925ce12be8James Bristersubregions.
99f3a24e69edbb19e4fe7f2fb0a72c478f8c3cafJames BristerThe <emphasis>used region</emphasis> and the
99f3a24e69edbb19e4fe7f2fb0a72c478f8c3cafJames Brister<emphasis>available</emphasis> region are disjoint, and
aa79283a0d97d5d77d3c17bcb1756035eabe647aAndreas Gustafssontheir union is the buffer's region.
aa79283a0d97d5d77d3c17bcb1756035eabe647aAndreas GustafssonThe used region extends from the beginning of the buffer region to the
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrencelast used byte.
aa79283a0d97d5d77d3c17bcb1756035eabe647aAndreas GustafssonThe available region extends from one byte greater than the last used
aa79283a0d97d5d77d3c17bcb1756035eabe647aAndreas Gustafssonbyte to the end of the buffer's region.
aa79283a0d97d5d77d3c17bcb1756035eabe647aAndreas GustafssonThe size of the used region can be changed using various
aa79283a0d97d5d77d3c17bcb1756035eabe647aAndreas Gustafssonbuffer commands.
aa79283a0d97d5d77d3c17bcb1756035eabe647aAndreas GustafssonInitially, the used region is empty.
aa79283a0d97d5d77d3c17bcb1756035eabe647aAndreas Gustafsson</para>
aa79283a0d97d5d77d3c17bcb1756035eabe647aAndreas Gustafsson<para>
aa79283a0d97d5d77d3c17bcb1756035eabe647aAndreas GustafssonThe used region is further subdivided into two disjoint regions: the
f204bdd8e6703ff0ef1adf0a2c407202418a936dDavid Lawrence<emphasis>consumed region</emphasis> and the <emphasis>remaining region</emphasis>.
0bfcec250f9705a1211d0374f0fc1049960de84bMark AndrewsThe union of these two regions is the used region.
0bfcec250f9705a1211d0374f0fc1049960de84bMark AndrewsThe consumed region extends from the beginning of the used region to
b5f24a6988e04710bee0281b03b7e168358ac868Andreas Gustafssonthe byte before the <emphasis>current</emphasis> offset (if any).
b5f24a6988e04710bee0281b03b7e168358ac868Andreas GustafssonThe <emphasis>remaining</emphasis> region the current pointer to the end of the used
379bd2c19cec393f56a2e9c42cc87fc8213a1b62James Bristerregion.
379bd2c19cec393f56a2e9c42cc87fc8213a1b62James BristerThe size of the consumed region can be changed using various
379bd2c19cec393f56a2e9c42cc87fc8213a1b62James Bristerbuffer commands.
379bd2c19cec393f56a2e9c42cc87fc8213a1b62James BristerInitially, the consumed region is empty.
0df2335526caaebd8639129fd0327a6cc97060eaDavid Lawrence</para>
379bd2c19cec393f56a2e9c42cc87fc8213a1b62James Brister<para>
379bd2c19cec393f56a2e9c42cc87fc8213a1b62James BristerThe <emphasis>active region</emphasis> is an (optional) subregion of the remaining
c24265935e70d17279153b3cde43e3f6c3527577Andreas Gustafssonregion.
c24265935e70d17279153b3cde43e3f6c3527577Andreas GustafssonIt extends from the current offset to an offset in the
bedfa169b4cc5511b34c0c4a54c5b8aae364babeJames Bristerremaining region.
bedfa169b4cc5511b34c0c4a54c5b8aae364babeJames BristerInitially, the active region is empty.
bedfa169b4cc5511b34c0c4a54c5b8aae364babeJames BristerIf the current offset advances beyond the chosen offset,
bedfa169b4cc5511b34c0c4a54c5b8aae364babeJames Bristerthe active region will also be empty.
bedfa169b4cc5511b34c0c4a54c5b8aae364babeJames Brister</para>
bedfa169b4cc5511b34c0c4a54c5b8aae364babeJames Brister<para>
d85552c450141012e7cbeaacc77fb9575b0bb4cbJames Brister<programlisting>
d85552c450141012e7cbeaacc77fb9575b0bb4cbJames Brister
d85552c450141012e7cbeaacc77fb9575b0bb4cbJames Brister /------------entire length---------------\\
47c196192afa37b2dea728e52579779f190bf07fJames Brister /----- used region -----\\/-- available --\\
47c196192afa37b2dea728e52579779f190bf07fJames Brister +----------------------------------------+
29196ffb72a1337c72ffd6d52f1c8348f84c644eJames Brister | consumed | remaining | |
47c196192afa37b2dea728e52579779f190bf07fJames Brister +----------------------------------------+
adf82221858138f295bce732e86dcac34645692eJames Brister a b c d e
f3b52d9fe5e7e851adecad4eec8952cceda47592Brian Wellington
94c5757a7a2d98b4de3e7a68cfe330d59450f09eAndreas Gustafsson a == base of buffer.
f3b52d9fe5e7e851adecad4eec8952cceda47592Brian Wellington b == current pointer. Can be anywhere between a and d.
94c5757a7a2d98b4de3e7a68cfe330d59450f09eAndreas Gustafsson c == active pointer. Meaningful between b and d.
94c5757a7a2d98b4de3e7a68cfe330d59450f09eAndreas Gustafsson d == used pointer.
94c5757a7a2d98b4de3e7a68cfe330d59450f09eAndreas Gustafsson e == length of buffer.
94c5757a7a2d98b4de3e7a68cfe330d59450f09eAndreas Gustafsson
f3b52d9fe5e7e851adecad4eec8952cceda47592Brian Wellington a-e == entire length of buffer.
71a4339351de0d8233d61025a667ec4dc3e0f868James Brister a-d == used region.
71a4339351de0d8233d61025a667ec4dc3e0f868James Brister a-b == consumed region.
71a4339351de0d8233d61025a667ec4dc3e0f868James Brister b-d == remaining region.
71a4339351de0d8233d61025a667ec4dc3e0f868James Brister b-c == optional active region.
71a4339351de0d8233d61025a667ec4dc3e0f868James Brister</programlisting>
71a4339351de0d8233d61025a667ec4dc3e0f868James Brister</para>
71a4339351de0d8233d61025a667ec4dc3e0f868James Brister<para>
0380c44d0238a88e167526954d630d071739ed28Mark Andrews<function>lwres_buffer_init()</function>
0380c44d0238a88e167526954d630d071739ed28Mark Andrewsinitializes the
0380c44d0238a88e167526954d630d071739ed28Mark Andrews<type>lwres_buffer_t</type>
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews<parameter>*b</parameter>
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrewsand assocates it with the memory region of size
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews<parameter>length</parameter>
36bcb04af27e050ddc04b2ff37dbeafc84538fd4Brian Wellingtonbytes starting at location
36bcb04af27e050ddc04b2ff37dbeafc84538fd4Brian Wellington<parameter>base.</parameter>
36bcb04af27e050ddc04b2ff37dbeafc84538fd4Brian Wellington</para>
36bcb04af27e050ddc04b2ff37dbeafc84538fd4Brian Wellington<para>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<function>lwres_buffer_invalidate()</function>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrencemarks the buffer
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<parameter>*b</parameter>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrenceas invalid. Invalidating a buffer after use is not required,
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrencebut makes it possible to catch its possible accidental use.
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence</para>
ed71ea51c6ecb5d7d659b6e6a20f6b3f5c2678c6David Lawrence<para>
9c11326b18c69b9b2fd6102d80fbd568ae6bd31eAndreas GustafssonThe functions
ed71ea51c6ecb5d7d659b6e6a20f6b3f5c2678c6David Lawrence<function>lwres_buffer_add()</function>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrenceand
9c11326b18c69b9b2fd6102d80fbd568ae6bd31eAndreas Gustafsson<function>lwres_buffer_subtract()</function>
c78dc8b001ba46ef1edb784635c3ba7b3e4456ceJames Bristerrespectively increase and decrease the used space in
c78dc8b001ba46ef1edb784635c3ba7b3e4456ceJames Bristerbuffer
c78dc8b001ba46ef1edb784635c3ba7b3e4456ceJames Brister<parameter>*b</parameter>
c78dc8b001ba46ef1edb784635c3ba7b3e4456ceJames Bristerby
c78dc8b001ba46ef1edb784635c3ba7b3e4456ceJames Brister<parameter>n</parameter>
c78dc8b001ba46ef1edb784635c3ba7b3e4456ceJames Bristerbytes.
d5399cc351a549db957185993b320a3bffa40e41James Brister<function>lwres_buffer_add()</function>
d5399cc351a549db957185993b320a3bffa40e41James Bristerchecks for buffer overflow and
d5399cc351a549db957185993b320a3bffa40e41James Brister<function>lwres_buffer_subtract()</function>
d5399cc351a549db957185993b320a3bffa40e41James Bristerchecks for underflow.
40f349ad1f2f0a63ef2784b8affcd44dc660b39cJames BristerThese functions do not allocate or deallocate memory.
40f349ad1f2f0a63ef2784b8affcd44dc660b39cJames BristerThey just change the value of
40f349ad1f2f0a63ef2784b8affcd44dc660b39cJames Brister<structfield>used</structfield>.
ac3b769801d794993e9eb6065b2f7144ffcfc9acMark Andrews</para>
ac3b769801d794993e9eb6065b2f7144ffcfc9acMark Andrews<para>
69b691c9624f31e59b8d128ada902a82127c15a3James BristerA buffer is re-initialised by
69b691c9624f31e59b8d128ada902a82127c15a3James Brister<function>lwres_buffer_clear()</function>.
69b691c9624f31e59b8d128ada902a82127c15a3James BristerThe function sets
69b691c9624f31e59b8d128ada902a82127c15a3James Brister<structfield>used</structfield> ,
69b691c9624f31e59b8d128ada902a82127c15a3James Brister<structfield>current</structfield>
dba20696eb808075d849e5a4cc8d854555869fb2Brian Wellingtonand
dba20696eb808075d849e5a4cc8d854555869fb2Brian Wellington<structfield>active</structfield>
98c2f9a11185b8a5dd601798990612beb6d1578eJames Bristerto zero.
98c2f9a11185b8a5dd601798990612beb6d1578eJames Brister</para>
98c2f9a11185b8a5dd601798990612beb6d1578eJames Brister<para>
98c2f9a11185b8a5dd601798990612beb6d1578eJames Brister<function>lwres_buffer_first</function>
98c2f9a11185b8a5dd601798990612beb6d1578eJames Bristermakes the consumed region of buffer
98c2f9a11185b8a5dd601798990612beb6d1578eJames Brister<parameter>*p</parameter>
98c2f9a11185b8a5dd601798990612beb6d1578eJames Bristerempty by setting
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<structfield>current</structfield>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrenceto zero (the start of the buffer).
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence</para>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<para>
705cb05a187558959d20ec2c31e06de8e96f61b2David Lawrence<function>lwres_buffer_forward()</function>
705cb05a187558959d20ec2c31e06de8e96f61b2David Lawrenceincreases the consumed region of buffer
705cb05a187558959d20ec2c31e06de8e96f61b2David Lawrence<parameter>*b</parameter>
a3c0a79b61edfd6a021c080d4b368c9c962fcad6Andreas Gustafssonby
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<parameter>n</parameter>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrencebytes, checking for overflow.
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid LawrenceSimilarly,
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<function>lwres_buffer_back()</function>
0b056755b2f423ba5f6adac8f7851d78f7d11437David Lawrencedecreases buffer
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<parameter>b</parameter>'s
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrenceconsumed region by
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<parameter>n</parameter>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrencebytes and checks for underflow.
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence</para>
174a4f7b80af7f7a33cd9a098c13af23e5ec2a28David Lawrence<para>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<function>lwres_buffer_getuint8()</function>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrencereads an unsigned 8-bit integer from
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<parameter>*b</parameter>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrenceand returns it.
174a4f7b80af7f7a33cd9a098c13af23e5ec2a28David Lawrence<function>lwres_buffer_putuint8()</function>
0640343258a99230c62e39dfbbe1505e3a970ee8Andreas Gustafssonwrites the unsigned 8-bit integer
0640343258a99230c62e39dfbbe1505e3a970ee8Andreas Gustafsson<parameter>val</parameter>
dccfe96a449d135d1b3806a9ab8fd7481d017c8bAndreas Gustafssonto buffer
dccfe96a449d135d1b3806a9ab8fd7481d017c8bAndreas Gustafsson<parameter>*b</parameter>.
dccfe96a449d135d1b3806a9ab8fd7481d017c8bAndreas Gustafsson</para>
dccfe96a449d135d1b3806a9ab8fd7481d017c8bAndreas Gustafsson<para>
d98c74e2ec5b96bd22aa4ed6d893e8993787493bMichael Graff<function>lwres_buffer_getuint16()</function>
d98c74e2ec5b96bd22aa4ed6d893e8993787493bMichael Graffand
d98c74e2ec5b96bd22aa4ed6d893e8993787493bMichael Graff<function>lwres_buffer_getuint32()</function>
d98c74e2ec5b96bd22aa4ed6d893e8993787493bMichael Graffare identical to
d03d4524993ecf5da72694907cb8581eadbe5c4dBrian Wellington<function>lwres_buffer_putuint8()</function>
d03d4524993ecf5da72694907cb8581eadbe5c4dBrian Wellingtonexcept that they respectively read an unsigned 16-bit or 32-bit integer
d03d4524993ecf5da72694907cb8581eadbe5c4dBrian Wellingtonin network byte order from
75f6c57d9544aa77a3b1a04587b4702c07343c90Brian Wellington<parameter>b</parameter>.
75f6c57d9544aa77a3b1a04587b4702c07343c90Brian WellingtonSimilarly,
75f6c57d9544aa77a3b1a04587b4702c07343c90Brian Wellington<function>lwres_buffer_putuint16()</function>
c8df84cb389994b4eaf549f5851e70d18e2d063fAndreas Gustafssonand
c8df84cb389994b4eaf549f5851e70d18e2d063fAndreas Gustafsson<function>lwres_buffer_putuint32()</function>
f34984369fbc87f6cc5c5d1059303377a1724d79James Bristerwrites the unsigned 16-bit or 32-bit integer
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<parameter>val</parameter>
b092aef75539b462d24b460b67ac49edb79aaff8Andreas Gustafssonto buffer
7cd4c3ddd1baf5f2b204562fdba3da37c716cc78Andreas Gustafsson<parameter>b</parameter>,
76a191c4202a4839e4ce598ec91f0c0d12f630aaAndreas Gustafssonin network byte order.
76a191c4202a4839e4ce598ec91f0c0d12f630aaAndreas Gustafsson</para>
76a191c4202a4839e4ce598ec91f0c0d12f630aaAndreas Gustafsson<para>
76a191c4202a4839e4ce598ec91f0c0d12f630aaAndreas GustafssonArbitrary amounts of data are read or written from a lightweight
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrenceresolver buffer with
fef059dcec0f7f83b09b9ce30b91b21a51d9c481Andreas Gustafsson<function>lwres_buffer_getmem()</function>
fef059dcec0f7f83b09b9ce30b91b21a51d9c481Andreas Gustafssonand
174a4f7b80af7f7a33cd9a098c13af23e5ec2a28David Lawrence<function>lwres_buffer_putmem()</function>
5f80c1428b9b7235fc9c1c80aa505457c3043504Brian Wellingtonrespectively.
5f80c1428b9b7235fc9c1c80aa505457c3043504Brian Wellington<function>lwres_buffer_putmem()</function>
174a4f7b80af7f7a33cd9a098c13af23e5ec2a28David Lawrencecopies
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington<parameter>length</parameter>
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellingtonbytes of memory at
b3aaa872e12e5c8658271bde8e4dd85d015e823fAndreas Gustafsson<parameter>base</parameter>
b3aaa872e12e5c8658271bde8e4dd85d015e823fAndreas Gustafssonto
b3aaa872e12e5c8658271bde8e4dd85d015e823fAndreas Gustafsson<parameter>b</parameter>.
b3aaa872e12e5c8658271bde8e4dd85d015e823fAndreas GustafssonConversely,
b3aaa872e12e5c8658271bde8e4dd85d015e823fAndreas Gustafsson<function>lwres_buffer_getmem()</function>
b3aaa872e12e5c8658271bde8e4dd85d015e823fAndreas Gustafssoncopies
b3aaa872e12e5c8658271bde8e4dd85d015e823fAndreas Gustafsson<parameter>length</parameter>
389f2ccc2f5f00a11a14114d40492f7ac8249fa7Olafur Gudmundssonbytes of memory from
389f2ccc2f5f00a11a14114d40492f7ac8249fa7Olafur Gudmundsson<parameter>b</parameter>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrenceto
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence<parameter>base</parameter>.
6deb631b20b7e212d9a350759e472fa60f9e92e4David Lawrence</para>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence</refsect1>
b1d234eb75e2804e09d89178a76df39c321db51bBrian Wellington</refentry>
9151d6e15cb9c639a3dca083d7f6e9094f6b89caDavid Lawrence