1 .\" Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001 Internet Software Consortium.
4 .\" Permission to use, copy, modify, and distribute this software for any
5 .\" purpose with or without fee is hereby granted, provided that the above
6 .\" copyright notice and this permission notice appear in all copies.
8 .\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 .\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 .\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11 .\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 .\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13 .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 .\" PERFORMANCE OF THIS SOFTWARE.
16 .\" $Id: lwres_buffer.3,v 1.12.2.1.8.5 2005/10/13 02:33:58 marka Exp $
20 .\" ** You probably do not want to edit this file directly **
21 .\" It was generated using the DocBook XSL Stylesheets (version 1.69.1).
22 .\" Instead of manually editing it, you probably should edit the DocBook XML
23 .\" source for it and then use the DocBook XSL Stylesheets to regenerate it.
24 .TH "LWRES_BUFFER" "3" "Jun 30, 2000" "BIND9" "BIND9"
25 .\" disable hyphenation
27 .\" disable justification (adjust text to left margin only)
30 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
33 #include <lwres/lwbuffer.h>
36 \fBvoid\ \fBlwres_buffer_init\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBvoid\ *base\fR\fB, \fR\fBunsigned\ int\ length\fR\fB);\fR
38 \fBvoid\ \fBlwres_buffer_invalidate\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB);\fR
40 \fBvoid\ \fBlwres_buffer_add\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBunsigned\ int\ n\fR\fB);\fR
42 \fBvoid\ \fBlwres_buffer_subtract\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBunsigned\ int\ n\fR\fB);\fR
44 \fBvoid\ \fBlwres_buffer_clear\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB);\fR
46 \fBvoid\ \fBlwres_buffer_first\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB);\fR
48 \fBvoid\ \fBlwres_buffer_forward\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBunsigned\ int\ n\fR\fB);\fR
50 \fBvoid\ \fBlwres_buffer_back\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBunsigned\ int\ n\fR\fB);\fR
52 \fBlwres_uint8_t\ \fBlwres_buffer_getuint8\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB);\fR
54 \fBvoid\ \fBlwres_buffer_putuint8\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBlwres_uint8_t\ val\fR\fB);\fR
56 \fBlwres_uint16_t\ \fBlwres_buffer_getuint16\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB);\fR
58 \fBvoid\ \fBlwres_buffer_putuint16\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBlwres_uint16_t\ val\fR\fB);\fR
60 \fBlwres_uint32_t\ \fBlwres_buffer_getuint32\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB);\fR
62 \fBvoid\ \fBlwres_buffer_putuint32\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBlwres_uint32_t\ val\fR\fB);\fR
64 \fBvoid\ \fBlwres_buffer_putmem\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBconst\ unsigned\ char\ *base\fR\fB, \fR\fBunsigned\ int\ length\fR\fB);\fR
66 \fBvoid\ \fBlwres_buffer_getmem\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBunsigned\ char\ *base\fR\fB, \fR\fBunsigned\ int\ length\fR\fB);\fR
69 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
71 functions in the ISC library.
73 A buffer is a region of memory, together with a set of related subregions. The
77 region are disjoint, and their union is the buffer's region. The used region extends from the beginning of the buffer region to the last used byte. 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 buffer commands. Initially, the used region is empty.
79 The used region is further subdivided into two disjoint regions: the
82 \fIremaining region\fR. 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
86 region the current pointer to the end of the used region. The size of the consumed region can be changed using various buffer commands. Initially, the consumed region is empty.
90 is an (optional) subregion of the remaining region. It extends from the current offset to an offset in the remaining region. Initially, the active region is empty. If the current offset advances beyond the chosen offset, the active region will also be empty.
93 /\-\-\-\-\-\-\-\-\-\-\-\-entire length\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\\\\
94 /\-\-\-\-\- used region \-\-\-\-\-\\\\/\-\- available \-\-\\\\
95 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
96 | consumed | remaining | |
97 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
100 b == current pointer. Can be anywhere between a and d.
101 c == active pointer. Meaningful between b and d.
103 e == length of buffer.
104 a\-e == entire length of buffer.
106 a\-b == consumed region.
107 b\-d == remaining region.
108 b\-c == optional active region.
112 \fBlwres_buffer_init()\fR
114 \fBlwres_buffer_t\fR\fI*b\fR
115 and assocates it with the memory region of size
117 bytes starting at location
120 \fBlwres_buffer_invalidate()\fR
123 as invalid. Invalidating a buffer after use is not required, but makes it possible to catch its possible accidental use.
126 \fBlwres_buffer_add()\fR
128 \fBlwres_buffer_subtract()\fR
129 respectively increase and decrease the used space in buffer
134 \fBlwres_buffer_add()\fR
135 checks for buffer overflow and
136 \fBlwres_buffer_subtract()\fR
137 checks for underflow. These functions do not allocate or deallocate memory. They just change the value of
140 A buffer is re\-initialised by
141 \fBlwres_buffer_clear()\fR. The function sets
149 \fBlwres_buffer_first\fR
150 makes the consumed region of buffer
154 to zero (the start of the buffer).
156 \fBlwres_buffer_forward()\fR
157 increases the consumed region of buffer
161 bytes, checking for overflow. Similarly,
162 \fBlwres_buffer_back()\fR
164 \fIb\fR's consumed region by
166 bytes and checks for underflow.
168 \fBlwres_buffer_getuint8()\fR
169 reads an unsigned 8\-bit integer from
172 \fBlwres_buffer_putuint8()\fR
173 writes the unsigned 8\-bit integer
178 \fBlwres_buffer_getuint16()\fR
180 \fBlwres_buffer_getuint32()\fR
182 \fBlwres_buffer_putuint8()\fR
183 except that they respectively read an unsigned 16\-bit or 32\-bit integer in network byte order from
185 \fBlwres_buffer_putuint16()\fR
187 \fBlwres_buffer_putuint32()\fR
188 writes the unsigned 16\-bit or 32\-bit integer
191 \fIb\fR, in network byte order.
193 Arbitrary amounts of data are read or written from a lightweight resolver buffer with
194 \fBlwres_buffer_getmem()\fR
196 \fBlwres_buffer_putmem()\fR
198 \fBlwres_buffer_putmem()\fR
205 \fBlwres_buffer_getmem()\fR