Import bind-9.3.4
[dragonfly.git] / contrib / bind-9.3 / lib / lwres / man / lwres_buffer.3
1 .\" Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001 Internet Software Consortium.
3 .\" 
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.
7 .\" 
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.
15 .\"
16 .\" $Id: lwres_buffer.3,v 1.12.2.1.8.6 2006/06/29 13:02:31 marka Exp $
17 .\"
18 .hy 0
19 .ad l
20 .\"     Title: lwres_buffer
21 .\"    Author: 
22 .\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
23 .\"      Date: Jun 30, 2000
24 .\"    Manual: BIND9
25 .\"    Source: BIND9
26 .\"
27 .TH "LWRES_BUFFER" "3" "Jun 30, 2000" "BIND9" "BIND9"
28 .\" disable hyphenation
29 .nh
30 .\" disable justification (adjust text to left margin only)
31 .ad l
32 .SH "NAME"
33 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
34 .SH "SYNOPSIS"
35 .nf
36 #include <lwres/lwbuffer.h>
37 .fi
38 .HP 23
39 .BI "void lwres_buffer_init(lwres_buffer_t\ *b, void\ *base, unsigned\ int\ length);"
40 .HP 29
41 .BI "void lwres_buffer_invalidate(lwres_buffer_t\ *b);"
42 .HP 22
43 .BI "void lwres_buffer_add(lwres_buffer_t\ *b, unsigned\ int\ n);"
44 .HP 27
45 .BI "void lwres_buffer_subtract(lwres_buffer_t\ *b, unsigned\ int\ n);"
46 .HP 24
47 .BI "void lwres_buffer_clear(lwres_buffer_t\ *b);"
48 .HP 24
49 .BI "void lwres_buffer_first(lwres_buffer_t\ *b);"
50 .HP 26
51 .BI "void lwres_buffer_forward(lwres_buffer_t\ *b, unsigned\ int\ n);"
52 .HP 23
53 .BI "void lwres_buffer_back(lwres_buffer_t\ *b, unsigned\ int\ n);"
54 .HP 36
55 .BI "lwres_uint8_t lwres_buffer_getuint8(lwres_buffer_t\ *b);"
56 .HP 27
57 .BI "void lwres_buffer_putuint8(lwres_buffer_t\ *b, lwres_uint8_t\ val);"
58 .HP 38
59 .BI "lwres_uint16_t lwres_buffer_getuint16(lwres_buffer_t\ *b);"
60 .HP 28
61 .BI "void lwres_buffer_putuint16(lwres_buffer_t\ *b, lwres_uint16_t\ val);"
62 .HP 38
63 .BI "lwres_uint32_t lwres_buffer_getuint32(lwres_buffer_t\ *b);"
64 .HP 28
65 .BI "void lwres_buffer_putuint32(lwres_buffer_t\ *b, lwres_uint32_t\ val);"
66 .HP 25
67 .BI "void lwres_buffer_putmem(lwres_buffer_t\ *b, const\ unsigned\ char\ *base, unsigned\ int\ length);"
68 .HP 25
69 .BI "void lwres_buffer_getmem(lwres_buffer_t\ *b, unsigned\ char\ *base, unsigned\ int\ length);"
70 .SH "DESCRIPTION"
71 .PP
72 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
73 isc_buffer_
74 functions in the ISC library.
75 .PP
76 A buffer is a region of memory, together with a set of related subregions. The
77 \fIused region\fR
78 and the
79 \fIavailable\fR
80 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.
81 .PP
82 The used region is further subdivided into two disjoint regions: the
83 \fIconsumed region\fR
84 and the
85 \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 \fIcurrent\fR
87 offset (if any). The
88 \fIremaining\fR
89 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 .PP
91 The
92 \fIactive region\fR
93 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.
94 .PP
95 .sp
96 .RS 3n
97 .nf
98    /\-\-\-\-\-\-\-\-\-\-\-\-entire length\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\\\\
99    /\-\-\-\-\- used region \-\-\-\-\-\\\\/\-\- available \-\-\\\\
100    +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
101    | consumed  | remaining |                |
102    +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
103    a           b     c     d                e
104   a == base of buffer.
105   b == current pointer.  Can be anywhere between a and d.
106   c == active pointer.  Meaningful between b and d.
107   d == used pointer.
108   e == length of buffer.
109   a\-e == entire length of buffer.
110   a\-d == used region.
111   a\-b == consumed region.
112   b\-d == remaining region.
113   b\-c == optional active region.
114 .fi
115 .RE
116 .sp
117 .PP
118 \fBlwres_buffer_init()\fR
119 initializes the
120 \fBlwres_buffer_t\fR
121 \fI*b\fR
122 and assocates it with the memory region of size
123 \fIlength\fR
124 bytes starting at location
125 \fIbase.\fR
126 .PP
127 \fBlwres_buffer_invalidate()\fR
128 marks the buffer
129 \fI*b\fR
130 as invalid. Invalidating a buffer after use is not required, but makes it possible to catch its possible accidental use.
131 .PP
132 The functions
133 \fBlwres_buffer_add()\fR
134 and
135 \fBlwres_buffer_subtract()\fR
136 respectively increase and decrease the used space in buffer
137 \fI*b\fR
138 by
139 \fIn\fR
140 bytes.
141 \fBlwres_buffer_add()\fR
142 checks for buffer overflow and
143 \fBlwres_buffer_subtract()\fR
144 checks for underflow. These functions do not allocate or deallocate memory. They just change the value of
145 used.
146 .PP
147 A buffer is re\-initialised by
148 \fBlwres_buffer_clear()\fR. The function sets
149 used
150 ,
151 current
152 and
153 active
154 to zero.
155 .PP
156 \fBlwres_buffer_first\fR
157 makes the consumed region of buffer
158 \fI*p\fR
159 empty by setting
160 current
161 to zero (the start of the buffer).
162 .PP
163 \fBlwres_buffer_forward()\fR
164 increases the consumed region of buffer
165 \fI*b\fR
166 by
167 \fIn\fR
168 bytes, checking for overflow. Similarly,
169 \fBlwres_buffer_back()\fR
170 decreases buffer
171 \fIb\fR's consumed region by
172 \fIn\fR
173 bytes and checks for underflow.
174 .PP
175 \fBlwres_buffer_getuint8()\fR
176 reads an unsigned 8\-bit integer from
177 \fI*b\fR
178 and returns it.
179 \fBlwres_buffer_putuint8()\fR
180 writes the unsigned 8\-bit integer
181 \fIval\fR
182 to buffer
183 \fI*b\fR.
184 .PP
185 \fBlwres_buffer_getuint16()\fR
186 and
187 \fBlwres_buffer_getuint32()\fR
188 are identical to
189 \fBlwres_buffer_putuint8()\fR
190 except that they respectively read an unsigned 16\-bit or 32\-bit integer in network byte order from
191 \fIb\fR. Similarly,
192 \fBlwres_buffer_putuint16()\fR
193 and
194 \fBlwres_buffer_putuint32()\fR
195 writes the unsigned 16\-bit or 32\-bit integer
196 \fIval\fR
197 to buffer
198 \fIb\fR, in network byte order.
199 .PP
200 Arbitrary amounts of data are read or written from a lightweight resolver buffer with
201 \fBlwres_buffer_getmem()\fR
202 and
203 \fBlwres_buffer_putmem()\fR
204 respectively.
205 \fBlwres_buffer_putmem()\fR
206 copies
207 \fIlength\fR
208 bytes of memory at
209 \fIbase\fR
210 to
211 \fIb\fR. Conversely,
212 \fBlwres_buffer_getmem()\fR
213 copies
214 \fIlength\fR
215 bytes of memory from
216 \fIb\fR
217 to
218 \fIbase\fR.
219 .SH "COPYRIGHT"
220 Copyright \(co 2004, 2005 Internet Systems Consortium, Inc. ("ISC")