]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/bind9/lib/lwres/man/lwres_buffer.3
MFC r363988:
[FreeBSD/stable/9.git] / contrib / bind9 / lib / lwres / man / lwres_buffer.3
1 .\" Copyright (C) 2004, 2005, 2007, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001 Internet Software Consortium.
3 .\" 
4 .\" Permission to use, copy, modify, and/or 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 .hy 0
17 .ad l
18 '\" t
19 .\"     Title: lwres_buffer
20 .\"    Author: 
21 .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
22 .\"      Date: 2007-06-18
23 .\"    Manual: BIND9
24 .\"    Source: ISC
25 .\"  Language: English
26 .\"
27 .TH "LWRES_BUFFER" "3" "2007\-06\-18" "ISC" "BIND9"
28 .\" -----------------------------------------------------------------
29 .\" * Define some portability stuff
30 .\" -----------------------------------------------------------------
31 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32 .\" http://bugs.debian.org/507673
33 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
34 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35 .ie \n(.g .ds Aq \(aq
36 .el       .ds Aq '
37 .\" -----------------------------------------------------------------
38 .\" * set default formatting
39 .\" -----------------------------------------------------------------
40 .\" disable hyphenation
41 .nh
42 .\" disable justification (adjust text to left margin only)
43 .ad l
44 .\" -----------------------------------------------------------------
45 .\" * MAIN CONTENT STARTS HERE *
46 .\" -----------------------------------------------------------------
47 .SH "NAME"
48 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
49 .SH "SYNOPSIS"
50 .sp
51 .ft B
52 .nf
53 #include <lwres/lwbuffer\&.h>
54 .fi
55 .ft
56 .HP \w'void\ lwres_buffer_init('u
57 .BI "void lwres_buffer_init(lwres_buffer_t\ *" "b" ", void\ *" "base" ", unsigned\ int\ " "length" ");"
58 .HP \w'void\ lwres_buffer_invalidate('u
59 .BI "void lwres_buffer_invalidate(lwres_buffer_t\ *" "b" ");"
60 .HP \w'void\ lwres_buffer_add('u
61 .BI "void lwres_buffer_add(lwres_buffer_t\ *" "b" ", unsigned\ int\ " "n" ");"
62 .HP \w'void\ lwres_buffer_subtract('u
63 .BI "void lwres_buffer_subtract(lwres_buffer_t\ *" "b" ", unsigned\ int\ " "n" ");"
64 .HP \w'void\ lwres_buffer_clear('u
65 .BI "void lwres_buffer_clear(lwres_buffer_t\ *" "b" ");"
66 .HP \w'void\ lwres_buffer_first('u
67 .BI "void lwres_buffer_first(lwres_buffer_t\ *" "b" ");"
68 .HP \w'void\ lwres_buffer_forward('u
69 .BI "void lwres_buffer_forward(lwres_buffer_t\ *" "b" ", unsigned\ int\ " "n" ");"
70 .HP \w'void\ lwres_buffer_back('u
71 .BI "void lwres_buffer_back(lwres_buffer_t\ *" "b" ", unsigned\ int\ " "n" ");"
72 .HP \w'lwres_uint8_t\ lwres_buffer_getuint8('u
73 .BI "lwres_uint8_t lwres_buffer_getuint8(lwres_buffer_t\ *" "b" ");"
74 .HP \w'void\ lwres_buffer_putuint8('u
75 .BI "void lwres_buffer_putuint8(lwres_buffer_t\ *" "b" ", lwres_uint8_t\ " "val" ");"
76 .HP \w'lwres_uint16_t\ lwres_buffer_getuint16('u
77 .BI "lwres_uint16_t lwres_buffer_getuint16(lwres_buffer_t\ *" "b" ");"
78 .HP \w'void\ lwres_buffer_putuint16('u
79 .BI "void lwres_buffer_putuint16(lwres_buffer_t\ *" "b" ", lwres_uint16_t\ " "val" ");"
80 .HP \w'lwres_uint32_t\ lwres_buffer_getuint32('u
81 .BI "lwres_uint32_t lwres_buffer_getuint32(lwres_buffer_t\ *" "b" ");"
82 .HP \w'void\ lwres_buffer_putuint32('u
83 .BI "void lwres_buffer_putuint32(lwres_buffer_t\ *" "b" ", lwres_uint32_t\ " "val" ");"
84 .HP \w'void\ lwres_buffer_putmem('u
85 .BI "void lwres_buffer_putmem(lwres_buffer_t\ *" "b" ", const\ unsigned\ char\ *" "base" ", unsigned\ int\ " "length" ");"
86 .HP \w'void\ lwres_buffer_getmem('u
87 .BI "void lwres_buffer_getmem(lwres_buffer_t\ *" "b" ", unsigned\ char\ *" "base" ", unsigned\ int\ " "length" ");"
88 .SH "DESCRIPTION"
89 .PP
90 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
91 isc_buffer_
92 functions in the ISC library\&.
93 .PP
94 A buffer is a region of memory, together with a set of related subregions\&. The
95 \fIused region\fR
96 and the
97 \fIavailable\fR
98 region are disjoint, and their union is the buffer\*(Aqs 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\*(Aqs region\&. The size of the used region can be changed using various buffer commands\&. Initially, the used region is empty\&.
99 .PP
100 The used region is further subdivided into two disjoint regions: the
101 \fIconsumed region\fR
102 and the
103 \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
104 \fIcurrent\fR
105 offset (if any)\&. The
106 \fIremaining\fR
107 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\&.
108 .PP
109 The
110 \fIactive region\fR
111 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\&.
112 .PP
113 .if n \{\
114 .RS 4
115 .\}
116 .nf
117    /\-\-\-\-\-\-\-\-\-\-\-\-entire length\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\e\e
118    /\-\-\-\-\- used region \-\-\-\-\-\e\e/\-\- available \-\-\e\e
119    +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
120    | consumed  | remaining |                |
121    +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
122    a           b     c     d                e
123 .fi
124 .if n \{\
125 .RE
126 .\}
127 .PP
128 .if n \{\
129 .RS 4
130 .\}
131 .nf
132   a == base of buffer\&.
133   b == current pointer\&.  Can be anywhere between a and d\&.
134   c == active pointer\&.  Meaningful between b and d\&.
135   d == used pointer\&.
136   e == length of buffer\&.
137 .fi
138 .if n \{\
139 .RE
140 .\}
141 .PP
142 .if n \{\
143 .RS 4
144 .\}
145 .nf
146   a\-e == entire length of buffer\&.
147   a\-d == used region\&.
148   a\-b == consumed region\&.
149   b\-d == remaining region\&.
150   b\-c == optional active region\&.
151 .fi
152 .if n \{\
153 .RE
154 .\}
155 .PP
156 \fBlwres_buffer_init()\fR
157 initializes the
158 \fBlwres_buffer_t\fR\fI*b\fR
159 and assocates it with the memory region of size
160 \fIlength\fR
161 bytes starting at location
162 \fIbase\&.\fR
163 .PP
164 \fBlwres_buffer_invalidate()\fR
165 marks the buffer
166 \fI*b\fR
167 as invalid\&. Invalidating a buffer after use is not required, but makes it possible to catch its possible accidental use\&.
168 .PP
169 The functions
170 \fBlwres_buffer_add()\fR
171 and
172 \fBlwres_buffer_subtract()\fR
173 respectively increase and decrease the used space in buffer
174 \fI*b\fR
175 by
176 \fIn\fR
177 bytes\&.
178 \fBlwres_buffer_add()\fR
179 checks for buffer overflow and
180 \fBlwres_buffer_subtract()\fR
181 checks for underflow\&. These functions do not allocate or deallocate memory\&. They just change the value of
182 \fIused\fR\&.
183 .PP
184 A buffer is re\-initialised by
185 \fBlwres_buffer_clear()\fR\&. The function sets
186 \fIused\fR,
187 \fIcurrent\fR
188 and
189 \fIactive\fR
190 to zero\&.
191 .PP
192 \fBlwres_buffer_first\fR
193 makes the consumed region of buffer
194 \fI*p\fR
195 empty by setting
196 \fIcurrent\fR
197 to zero (the start of the buffer)\&.
198 .PP
199 \fBlwres_buffer_forward()\fR
200 increases the consumed region of buffer
201 \fI*b\fR
202 by
203 \fIn\fR
204 bytes, checking for overflow\&. Similarly,
205 \fBlwres_buffer_back()\fR
206 decreases buffer
207 \fIb\fR\*(Aqs consumed region by
208 \fIn\fR
209 bytes and checks for underflow\&.
210 .PP
211 \fBlwres_buffer_getuint8()\fR
212 reads an unsigned 8\-bit integer from
213 \fI*b\fR
214 and returns it\&.
215 \fBlwres_buffer_putuint8()\fR
216 writes the unsigned 8\-bit integer
217 \fIval\fR
218 to buffer
219 \fI*b\fR\&.
220 .PP
221 \fBlwres_buffer_getuint16()\fR
222 and
223 \fBlwres_buffer_getuint32()\fR
224 are identical to
225 \fBlwres_buffer_putuint8()\fR
226 except that they respectively read an unsigned 16\-bit or 32\-bit integer in network byte order from
227 \fIb\fR\&. Similarly,
228 \fBlwres_buffer_putuint16()\fR
229 and
230 \fBlwres_buffer_putuint32()\fR
231 writes the unsigned 16\-bit or 32\-bit integer
232 \fIval\fR
233 to buffer
234 \fIb\fR, in network byte order\&.
235 .PP
236 Arbitrary amounts of data are read or written from a lightweight resolver buffer with
237 \fBlwres_buffer_getmem()\fR
238 and
239 \fBlwres_buffer_putmem()\fR
240 respectively\&.
241 \fBlwres_buffer_putmem()\fR
242 copies
243 \fIlength\fR
244 bytes of memory at
245 \fIbase\fR
246 to
247 \fIb\fR\&. Conversely,
248 \fBlwres_buffer_getmem()\fR
249 copies
250 \fIlength\fR
251 bytes of memory from
252 \fIb\fR
253 to
254 \fIbase\fR\&.
255 .SH "AUTHOR"
256 .PP
257 \fBInternet Systems Consortium, Inc\&.\fR
258 .SH "COPYRIGHT"
259 .br
260 Copyright \(co 2004, 2005, 2007, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
261 .br
262 Copyright \(co 2000, 2001 Internet Software Consortium.
263 .br