Merge from vendor branch AWK:
[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.5 2005/10/13 02:33:58 marka Exp $
17 .\"
18 .hy 0
19 .ad l
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
26 .nh
27 .\" disable justification (adjust text to left margin only)
28 .ad l
29 .SH "NAME"
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
31 .SH "SYNOPSIS"
32 .nf
33 #include <lwres/lwbuffer.h>
34 .fi
35 .HP 23
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
37 .HP 29
38 \fBvoid\ \fBlwres_buffer_invalidate\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB);\fR
39 .HP 22
40 \fBvoid\ \fBlwres_buffer_add\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBunsigned\ int\ n\fR\fB);\fR
41 .HP 27
42 \fBvoid\ \fBlwres_buffer_subtract\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBunsigned\ int\ n\fR\fB);\fR
43 .HP 24
44 \fBvoid\ \fBlwres_buffer_clear\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB);\fR
45 .HP 24
46 \fBvoid\ \fBlwres_buffer_first\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB);\fR
47 .HP 26
48 \fBvoid\ \fBlwres_buffer_forward\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBunsigned\ int\ n\fR\fB);\fR
49 .HP 23
50 \fBvoid\ \fBlwres_buffer_back\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBunsigned\ int\ n\fR\fB);\fR
51 .HP 36
52 \fBlwres_uint8_t\ \fBlwres_buffer_getuint8\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB);\fR
53 .HP 27
54 \fBvoid\ \fBlwres_buffer_putuint8\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBlwres_uint8_t\ val\fR\fB);\fR
55 .HP 38
56 \fBlwres_uint16_t\ \fBlwres_buffer_getuint16\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB);\fR
57 .HP 28
58 \fBvoid\ \fBlwres_buffer_putuint16\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBlwres_uint16_t\ val\fR\fB);\fR
59 .HP 38
60 \fBlwres_uint32_t\ \fBlwres_buffer_getuint32\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB);\fR
61 .HP 28
62 \fBvoid\ \fBlwres_buffer_putuint32\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBlwres_uint32_t\ val\fR\fB);\fR
63 .HP 25
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
65 .HP 25
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
67 .SH "DESCRIPTION"
68 .PP
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
70 isc_buffer_
71 functions in the ISC library.
72 .PP
73 A buffer is a region of memory, together with a set of related subregions. The
74 \fIused region\fR
75 and the
76 \fIavailable\fR
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.
78 .PP
79 The used region is further subdivided into two disjoint regions: the
80 \fIconsumed region\fR
81 and 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
83 \fIcurrent\fR
84 offset (if any). The
85 \fIremaining\fR
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.
87 .PP
88 The
89 \fIactive region\fR
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.
91 .PP
92 .nf
93    /\-\-\-\-\-\-\-\-\-\-\-\-entire length\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\\\\
94    /\-\-\-\-\- used region \-\-\-\-\-\\\\/\-\- available \-\-\\\\
95    +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
96    | consumed  | remaining |                |
97    +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
98    a           b     c     d                e
99   a == base of buffer.
100   b == current pointer.  Can be anywhere between a and d.
101   c == active pointer.  Meaningful between b and d.
102   d == used pointer.
103   e == length of buffer.
104   a\-e == entire length of buffer.
105   a\-d == used region.
106   a\-b == consumed region.
107   b\-d == remaining region.
108   b\-c == optional active region.
109 .fi
110 .sp
111 .PP
112 \fBlwres_buffer_init()\fR
113 initializes the
114 \fBlwres_buffer_t\fR\fI*b\fR
115 and assocates it with the memory region of size
116 \fIlength\fR
117 bytes starting at location
118 \fIbase.\fR
119 .PP
120 \fBlwres_buffer_invalidate()\fR
121 marks the buffer
122 \fI*b\fR
123 as invalid. Invalidating a buffer after use is not required, but makes it possible to catch its possible accidental use.
124 .PP
125 The functions
126 \fBlwres_buffer_add()\fR
127 and
128 \fBlwres_buffer_subtract()\fR
129 respectively increase and decrease the used space in buffer
130 \fI*b\fR
131 by
132 \fIn\fR
133 bytes.
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
138 used.
139 .PP
140 A buffer is re\-initialised by
141 \fBlwres_buffer_clear()\fR. The function sets
142 used
143 ,
144 current
145 and
146 active
147 to zero.
148 .PP
149 \fBlwres_buffer_first\fR
150 makes the consumed region of buffer
151 \fI*p\fR
152 empty by setting
153 current
154 to zero (the start of the buffer).
155 .PP
156 \fBlwres_buffer_forward()\fR
157 increases the consumed region of buffer
158 \fI*b\fR
159 by
160 \fIn\fR
161 bytes, checking for overflow. Similarly,
162 \fBlwres_buffer_back()\fR
163 decreases buffer
164 \fIb\fR's consumed region by
165 \fIn\fR
166 bytes and checks for underflow.
167 .PP
168 \fBlwres_buffer_getuint8()\fR
169 reads an unsigned 8\-bit integer from
170 \fI*b\fR
171 and returns it.
172 \fBlwres_buffer_putuint8()\fR
173 writes the unsigned 8\-bit integer
174 \fIval\fR
175 to buffer
176 \fI*b\fR.
177 .PP
178 \fBlwres_buffer_getuint16()\fR
179 and
180 \fBlwres_buffer_getuint32()\fR
181 are identical to
182 \fBlwres_buffer_putuint8()\fR
183 except that they respectively read an unsigned 16\-bit or 32\-bit integer in network byte order from
184 \fIb\fR. Similarly,
185 \fBlwres_buffer_putuint16()\fR
186 and
187 \fBlwres_buffer_putuint32()\fR
188 writes the unsigned 16\-bit or 32\-bit integer
189 \fIval\fR
190 to buffer
191 \fIb\fR, in network byte order.
192 .PP
193 Arbitrary amounts of data are read or written from a lightweight resolver buffer with
194 \fBlwres_buffer_getmem()\fR
195 and
196 \fBlwres_buffer_putmem()\fR
197 respectively.
198 \fBlwres_buffer_putmem()\fR
199 copies
200 \fIlength\fR
201 bytes of memory at
202 \fIbase\fR
203 to
204 \fIb\fR. Conversely,
205 \fBlwres_buffer_getmem()\fR
206 copies
207 \fIlength\fR
208 bytes of memory from
209 \fIb\fR
210 to
211 \fIbase\fR.