PageRenderTime 20ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/bind9/lib/lwres/man/lwres_buffer.3

https://bitbucket.org/freebsd/freebsd-head/
Unknown | 233 lines | 233 code | 0 blank | 0 comment | 0 complexity | d1fd97d1a46890c399adbf8f08f15b90 MD5 | raw file
  1.\" Copyright (C) 2004, 2005, 2007 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.\" $Id$
 17.\"
 18.hy 0
 19.ad l
 20.\"     Title: lwres_buffer
 21.\"    Author: 
 22.\" Generator: DocBook XSL Stylesheets v1.71.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"
 33lwres_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
 72These 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
 73isc_buffer_
 74functions in the ISC library.
 75.PP
 76A buffer is a region of memory, together with a set of related subregions. The
 77\fIused region\fR
 78and the
 79\fIavailable\fR
 80region 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
 82The used region is further subdivided into two disjoint regions: the
 83\fIconsumed region\fR
 84and 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
 87offset (if any). The
 88\fIremaining\fR
 89region 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
 91The
 92\fIactive region\fR
 93is 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.RS 4
 96.nf
 97   /\-\-\-\-\-\-\-\-\-\-\-\-entire length\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\\\\
 98   /\-\-\-\-\- used region \-\-\-\-\-\\\\/\-\- available \-\-\\\\
 99   +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
100   | consumed  | remaining |                |
101   +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
102   a           b     c     d                e
103.fi
104.RE
105.sp
106.PP
107.RS 4
108.nf
109  a == base of buffer.
110  b == current pointer.  Can be anywhere between a and d.
111  c == active pointer.  Meaningful between b and d.
112  d == used pointer.
113  e == length of buffer.
114.fi
115.RE
116.sp
117.PP
118.RS 4
119.nf
120  a\-e == entire length of buffer.
121  a\-d == used region.
122  a\-b == consumed region.
123  b\-d == remaining region.
124  b\-c == optional active region.
125.fi
126.RE
127.sp
128.PP
129\fBlwres_buffer_init()\fR
130initializes the
131\fBlwres_buffer_t\fR
132\fI*b\fR
133and assocates it with the memory region of size
134\fIlength\fR
135bytes starting at location
136\fIbase.\fR
137.PP
138\fBlwres_buffer_invalidate()\fR
139marks the buffer
140\fI*b\fR
141as invalid. Invalidating a buffer after use is not required, but makes it possible to catch its possible accidental use.
142.PP
143The functions
144\fBlwres_buffer_add()\fR
145and
146\fBlwres_buffer_subtract()\fR
147respectively increase and decrease the used space in buffer
148\fI*b\fR
149by
150\fIn\fR
151bytes.
152\fBlwres_buffer_add()\fR
153checks for buffer overflow and
154\fBlwres_buffer_subtract()\fR
155checks for underflow. These functions do not allocate or deallocate memory. They just change the value of
156used.
157.PP
158A buffer is re\-initialised by
159\fBlwres_buffer_clear()\fR. The function sets
160used,
161current
162and
163active
164to zero.
165.PP
166\fBlwres_buffer_first\fR
167makes the consumed region of buffer
168\fI*p\fR
169empty by setting
170current
171to zero (the start of the buffer).
172.PP
173\fBlwres_buffer_forward()\fR
174increases the consumed region of buffer
175\fI*b\fR
176by
177\fIn\fR
178bytes, checking for overflow. Similarly,
179\fBlwres_buffer_back()\fR
180decreases buffer
181\fIb\fR's consumed region by
182\fIn\fR
183bytes and checks for underflow.
184.PP
185\fBlwres_buffer_getuint8()\fR
186reads an unsigned 8\-bit integer from
187\fI*b\fR
188and returns it.
189\fBlwres_buffer_putuint8()\fR
190writes the unsigned 8\-bit integer
191\fIval\fR
192to buffer
193\fI*b\fR.
194.PP
195\fBlwres_buffer_getuint16()\fR
196and
197\fBlwres_buffer_getuint32()\fR
198are identical to
199\fBlwres_buffer_putuint8()\fR
200except that they respectively read an unsigned 16\-bit or 32\-bit integer in network byte order from
201\fIb\fR. Similarly,
202\fBlwres_buffer_putuint16()\fR
203and
204\fBlwres_buffer_putuint32()\fR
205writes the unsigned 16\-bit or 32\-bit integer
206\fIval\fR
207to buffer
208\fIb\fR, in network byte order.
209.PP
210Arbitrary amounts of data are read or written from a lightweight resolver buffer with
211\fBlwres_buffer_getmem()\fR
212and
213\fBlwres_buffer_putmem()\fR
214respectively.
215\fBlwres_buffer_putmem()\fR
216copies
217\fIlength\fR
218bytes of memory at
219\fIbase\fR
220to
221\fIb\fR. Conversely,
222\fBlwres_buffer_getmem()\fR
223copies
224\fIlength\fR
225bytes of memory from
226\fIb\fR
227to
228\fIbase\fR.
229.SH "COPYRIGHT"
230Copyright \(co 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
231.br
232Copyright \(co 2000, 2001 Internet Software Consortium.
233.br