head 1.2; access; symbols perseant-exfatfs-base-20250801:1.2 perseant-exfatfs-base-20240630:1.2 perseant-exfatfs:1.2.0.6 perseant-exfatfs-base:1.2 netbsd-8-3-RELEASE:1.1.1.11.8.1 cjep_sun2x:1.2.0.4 cjep_sun2x-base:1.2 cjep_staticlib_x-base1:1.2 cjep_staticlib_x:1.2.0.2 cjep_staticlib_x-base:1.2 phil-wifi-20200421:1.2 phil-wifi-20200411:1.2 phil-wifi-20200406:1.2 netbsd-8-2-RELEASE:1.1.1.11.8.1 netbsd-8-1-RELEASE:1.1.1.11.8.1 netbsd-8-1-RC1:1.1.1.11.8.1 pgoyette-compat-merge-20190127:1.1.1.12 pgoyette-compat-20190127:1.1.1.12 pgoyette-compat-20190118:1.1.1.12 pgoyette-compat-1226:1.1.1.12 pgoyette-compat-1126:1.1.1.12 pgoyette-compat-1020:1.1.1.12 pgoyette-compat-0930:1.1.1.12 pgoyette-compat-0906:1.1.1.12 netbsd-7-2-RELEASE:1.1.1.8.2.3 pgoyette-compat-0728:1.1.1.12 netbsd-8-0-RELEASE:1.1.1.11.8.1 phil-wifi:1.1.1.12.0.6 phil-wifi-base:1.1.1.12 pgoyette-compat-0625:1.1.1.12 netbsd-8-0-RC2:1.1.1.11.8.1 pgoyette-compat-0521:1.1.1.12 pgoyette-compat-0502:1.1.1.12 pgoyette-compat-0422:1.1.1.12 netbsd-8-0-RC1:1.1.1.11.8.1 pgoyette-compat-0415:1.1.1.12 bind-9-10-7:1.1.1.12 pgoyette-compat-0407:1.1.1.12 pgoyette-compat-0330:1.1.1.12 pgoyette-compat-0322:1.1.1.12 pgoyette-compat-0315:1.1.1.12 netbsd-7-1-2-RELEASE:1.1.1.8.2.2.2.1 pgoyette-compat:1.1.1.12.0.4 pgoyette-compat-base:1.1.1.12 netbsd-7-1-1-RELEASE:1.1.1.8.2.2.2.1 matt-nb8-mediatek:1.1.1.11.8.1.0.2 matt-nb8-mediatek-base:1.1.1.11.8.1 perseant-stdc-iso10646:1.1.1.12.0.2 perseant-stdc-iso10646-base:1.1.1.12 bind-9-10-5-P2:1.1.1.12 bind-9-10-5-P1:1.1.1.12 netbsd-8:1.1.1.11.0.8 netbsd-8-base:1.1.1.11 prg-localcount2-base3:1.1.1.11 prg-localcount2-base2:1.1.1.11 prg-localcount2-base1:1.1.1.11 prg-localcount2:1.1.1.11.0.6 prg-localcount2-base:1.1.1.11 pgoyette-localcount-20170426:1.1.1.11 bouyer-socketcan-base1:1.1.1.11 bind-9-10-4-P8:1.1.1.11 pgoyette-localcount-20170320:1.1.1.11 netbsd-7-1:1.1.1.8.2.2.0.2 netbsd-7-1-RELEASE:1.1.1.8.2.2 netbsd-7-1-RC2:1.1.1.8.2.2 bind-9-10-4-P6:1.1.1.11 netbsd-7-nhusb-base-20170116:1.1.1.8.2.2 bouyer-socketcan:1.1.1.11.0.4 bouyer-socketcan-base:1.1.1.11 bind-9-10-4-P5:1.1.1.11 pgoyette-localcount-20170107:1.1.1.11 netbsd-7-1-RC1:1.1.1.8.2.2 pgoyette-localcount-20161104:1.1.1.11 bind-9-10-4-P4:1.1.1.11 netbsd-7-0-2-RELEASE:1.1.1.8.2.1.2.1 bind-9-10-4-P3:1.1.1.11 localcount-20160914:1.1.1.11 netbsd-7-nhusb:1.1.1.8.2.1.0.4 netbsd-7-nhusb-base:1.1.1.8.2.1 pgoyette-localcount-20160806:1.1.1.11 pgoyette-localcount-20160726:1.1.1.11 pgoyette-localcount:1.1.1.11.0.2 pgoyette-localcount-base:1.1.1.11 bind-9-10-4-P1:1.1.1.11 netbsd-7-0-1-RELEASE:1.1.1.8.2.1 bind-9-10-3-P4:1.1.1.10 bind-9-10-3-P3:1.1.1.10 bind-9-10-3-P2:1.1.1.10 netbsd-7-0:1.1.1.8.2.1.0.2 netbsd-7-0-RELEASE:1.1.1.8.2.1 bind-9-10-2-P4:1.1.1.10 netbsd-7-0-RC3:1.1.1.8.2.1 bind-9-10-2-P3:1.1.1.10 netbsd-7-0-RC2:1.1.1.8.2.1 bind-9-10-2-P2:1.1.1.10 netbsd-7-0-RC1:1.1.1.8.2.1 bind-9-10-1-P1:1.1.1.10 netbsd-6-0-6-RELEASE:1.1.1.6.4.1 netbsd-6-1-5-RELEASE:1.1.1.6.4.1 netbsd-7:1.1.1.8.0.2 netbsd-7-base:1.1.1.8 bind-9-10-0-P2:1.1.1.8 yamt-pagecache-base9:1.1.1.7 yamt-pagecache-tag8:1.1.1.6.2.1 netbsd-6-1-4-RELEASE:1.1.1.6.4.1 netbsd-6-0-5-RELEASE:1.1.1.6.4.1 tls-earlyentropy:1.1.1.7.0.10 tls-earlyentropy-base:1.1.1.8 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.7 riastradh-drm2-base3:1.1.1.7 bind-9-10-0b1:1.1.1.7 netbsd-6-1-3-RELEASE:1.1.1.6.4.1 netbsd-6-0-4-RELEASE:1.1.1.6.4.1 bind-9-9-5b1:1.1.1.7 netbsd-6-1-2-RELEASE:1.1.1.6.4.1 netbsd-6-0-3-RELEASE:1.1.1.6.4.1 netbsd-6-1-1-RELEASE:1.1.1.6.4.1 bind-9-9-3-P2:1.1.1.7 riastradh-drm2-base2:1.1.1.7 riastradh-drm2-base1:1.1.1.7 riastradh-drm2:1.1.1.7.0.4 riastradh-drm2-base:1.1.1.7 netbsd-6-1:1.1.1.6.4.1.0.6 netbsd-6-0-2-RELEASE:1.1.1.6.4.1 netbsd-6-1-RELEASE:1.1.1.6.4.1 khorben-n900:1.1.1.7.0.8 netbsd-6-1-RC4:1.1.1.6.4.1 netbsd-6-1-RC3:1.1.1.6.4.1 agc-symver:1.1.1.7.0.6 agc-symver-base:1.1.1.7 netbsd-6-1-RC2:1.1.1.6.4.1 netbsd-6-1-RC1:1.1.1.6.4.1 yamt-pagecache-base8:1.1.1.7 netbsd-6-0-1-RELEASE:1.1.1.6.4.1 yamt-pagecache-base7:1.1.1.7 bind-9-9-2-P1:1.1.1.7 matt-nb6-plus-nbase:1.1.1.6.4.1 yamt-pagecache-base6:1.1.1.7 netbsd-6-0:1.1.1.6.4.1.0.4 netbsd-6-0-RELEASE:1.1.1.6.4.1 netbsd-6-0-RC2:1.1.1.6.4.1 tls-maxphys:1.1.1.7.0.2 tls-maxphys-base:1.1.1.8 matt-nb6-plus:1.1.1.6.4.1.0.2 matt-nb6-plus-base:1.1.1.6.4.1 netbsd-6-0-RC1:1.1.1.6.4.1 bind-9-9-1-P1:1.1.1.7 yamt-pagecache-base5:1.1.1.6 yamt-pagecache-base4:1.1.1.6 netbsd-6:1.1.1.6.0.4 netbsd-6-base:1.1.1.6 yamt-pagecache-base3:1.1.1.6 yamt-pagecache-base2:1.1.1.6 yamt-pagecache:1.1.1.6.0.2 yamt-pagecache-base:1.1.1.6 bind-9-9-0a1:1.1.1.6 bind-9-8-0-P4:1.1.1.5 cherry-xenmp:1.1.1.4.0.2 cherry-xenmp-base:1.1.1.4 bind-9-8-0-P2:1.1.1.4 bind9-8-0rc1:1.1.1.4 bouyer-quota2-nbase:1.1.1.4 bouyer-quota2:1.1.1.3.0.2 bouyer-quota2-base:1.1.1.4 matt-mips64-premerge-20101231:1.1.1.3 bind-9-7-2-P3:1.1.1.3 bind-9-7-2b1:1.1.1.2 bind-9-7-0rc1:1.1.1.2 matt-premerge-20091211:1.1.1.2 bind-9-7-0-b1:1.1.1.2 bind-9-6-1-P1:1.1.1.1 jym-xensuspend-base:1.1.1.1 jym-xensuspend:1.1.1.1.0.2 jym-xensuspend-nbase:1.1.1.1 bind9-6-1b1:1.1.1.1 ISC:1.1.1; locks; strict; comment @# @; 1.2 date 2019.05.10.09.14.58; author wiz; state dead; branches; next 1.1; commitid SEgY3sFTlDvvDDmB; 1.1 date 2009.03.22.15.02.42; author christos; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2009.03.22.15.02.42; author christos; state Exp; branches 1.1.1.1.2.1; next 1.1.1.2; 1.1.1.2 date 2009.10.25.00.02.52; author christos; state Exp; branches; next 1.1.1.3; 1.1.1.3 date 2010.12.02.14.23.37; author christos; state Exp; branches 1.1.1.3.2.1; next 1.1.1.4; 1.1.1.4 date 2011.02.15.19.38.53; author christos; state Exp; branches; next 1.1.1.5; 1.1.1.5 date 2011.07.05.21.31.06; author spz; state Exp; branches; next 1.1.1.6; 1.1.1.6 date 2011.09.11.17.19.56; author christos; state Exp; branches 1.1.1.6.2.1 1.1.1.6.4.1; next 1.1.1.7; 1.1.1.7 date 2012.06.04.17.57.05; author christos; state Exp; branches 1.1.1.7.2.1 1.1.1.7.10.1; next 1.1.1.8; 1.1.1.8 date 2014.07.08.04.50.00; author spz; state Exp; branches 1.1.1.8.2.1; next 1.1.1.9; commitid Mcep1OIjY5QWWwHx; 1.1.1.9 date 2014.12.10.02.25.34; author christos; state Exp; branches; next 1.1.1.10; commitid ZA8gmIRTml5lcr1y; 1.1.1.10 date 2014.12.10.03.31.36; author christos; state Exp; branches; next 1.1.1.11; commitid Kjjxv3fot5DZyr1y; 1.1.1.11 date 2016.05.26.15.45.53; author christos; state Exp; branches 1.1.1.11.8.1; next 1.1.1.12; commitid rNgyUOhc6UpKu08z; 1.1.1.12 date 2017.06.15.15.22.51; author christos; state Exp; branches 1.1.1.12.6.1; next ; commitid AgIo44k7APizZtVz; 1.1.1.1.2.1 date 2009.03.22.15.02.42; author jym; state dead; branches; next 1.1.1.1.2.2; 1.1.1.1.2.2 date 2009.05.13.18.51.45; author jym; state Exp; branches; next ; 1.1.1.3.2.1 date 2011.02.17.11.59.10; author bouyer; state Exp; branches; next ; 1.1.1.6.2.1 date 2012.10.30.18.54.35; author yamt; state Exp; branches; next ; 1.1.1.6.4.1 date 2012.06.06.18.18.31; author bouyer; state Exp; branches 1.1.1.6.4.1.4.1 1.1.1.6.4.1.6.1; next 1.1.1.6.4.2; 1.1.1.6.4.2 date 2014.12.25.17.54.32; author msaitoh; state Exp; branches; next 1.1.1.6.4.3; commitid DOs7YhzjNdulQr3y; 1.1.1.6.4.3 date 2017.04.25.19.54.34; author snj; state Exp; branches; next ; commitid tS2hfyOu155P7XOz; 1.1.1.6.4.1.4.1 date 2014.12.31.11.59.08; author msaitoh; state Exp; branches; next 1.1.1.6.4.1.4.2; commitid UwPiTbNnARsHGb4y; 1.1.1.6.4.1.4.2 date 2017.04.25.22.02.01; author snj; state Exp; branches; next ; commitid Mh89qlSRw0ICPXOz; 1.1.1.6.4.1.6.1 date 2014.12.26.03.08.38; author msaitoh; state Exp; branches; next 1.1.1.6.4.1.6.2; commitid yqTOlsoWsWVLUu3y; 1.1.1.6.4.1.6.2 date 2017.04.25.20.53.57; author snj; state Exp; branches; next ; commitid w3an9o5yFMZisXOz; 1.1.1.7.2.1 date 2014.08.19.23.46.35; author tls; state Exp; branches; next ; commitid jTnpym9Qu0o4R1Nx; 1.1.1.7.10.1 date 2014.08.10.07.06.44; author tls; state Exp; branches; next ; commitid vuZWZSMzG2mZFMLx; 1.1.1.8.2.1 date 2014.12.22.03.28.47; author msaitoh; state Exp; branches 1.1.1.8.2.1.2.1 1.1.1.8.2.1.4.1; next 1.1.1.8.2.2; commitid s9mHA4qvt0AE9Z2y; 1.1.1.8.2.2 date 2016.10.14.12.01.34; author martin; state Exp; branches 1.1.1.8.2.2.2.1; next 1.1.1.8.2.3; commitid cv7oxX6XYIZfG6qz; 1.1.1.8.2.3 date 2017.06.20.17.09.56; author snj; state Exp; branches; next ; commitid 9D6h68tqKy82q8Wz; 1.1.1.8.2.1.2.1 date 2016.10.14.11.42.51; author martin; state Exp; branches; next 1.1.1.8.2.1.2.2; commitid 0Q0oidhFkBBMz6qz; 1.1.1.8.2.1.2.2 date 2017.06.20.16.40.25; author snj; state Exp; branches; next ; commitid 3tX9hN0zVj6Ff8Wz; 1.1.1.8.2.1.4.1 date 2017.01.18.08.46.17; author skrll; state Exp; branches; next ; commitid M6f3RyDtiAR3wqCz; 1.1.1.8.2.2.2.1 date 2017.06.20.17.02.27; author snj; state Exp; branches; next ; commitid GxuFZUGrvwdun8Wz; 1.1.1.11.8.1 date 2017.06.21.18.03.49; author snj; state Exp; branches; next ; commitid jnXpTnVXWnBaGgWz; 1.1.1.12.6.1 date 2019.06.10.21.44.31; author christos; state dead; branches; next ; commitid jtc8rnCzWiEEHGqB; desc @@ 1.2 log @Remove src/external/bsd/bind - latest version is in src/external/mpl/bind This directory was already unhooked from the build (in August 2018). ok christos@@ @ text @
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
#include <lwres/lwbuffer.h>
void
lwres_buffer_init( |
lwres_buffer_t * | b, |
| void * | base, | |
| unsigned int |
length); |
void
lwres_buffer_invalidate( |
lwres_buffer_t * |
b); |
void
lwres_buffer_add( |
lwres_buffer_t * | b, |
| unsigned int |
n); |
void
lwres_buffer_subtract( |
lwres_buffer_t * | b, |
| unsigned int |
n); |
void
lwres_buffer_clear( |
lwres_buffer_t * |
b); |
void
lwres_buffer_first( |
lwres_buffer_t * |
b); |
void
lwres_buffer_forward( |
lwres_buffer_t * | b, |
| unsigned int |
n); |
void
lwres_buffer_back( |
lwres_buffer_t * | b, |
| unsigned int |
n); |
lwres_uint8_t
lwres_buffer_getuint8( |
lwres_buffer_t * |
b); |
void
lwres_buffer_putuint8( |
lwres_buffer_t * | b, |
| lwres_uint8_t |
val); |
lwres_uint16_t
lwres_buffer_getuint16( |
lwres_buffer_t * |
b); |
void
lwres_buffer_putuint16( |
lwres_buffer_t * | b, |
| lwres_uint16_t |
val); |
lwres_uint32_t
lwres_buffer_getuint32( |
lwres_buffer_t * |
b); |
void
lwres_buffer_putuint32( |
lwres_buffer_t * | b, |
| lwres_uint32_t |
val); |
void
lwres_buffer_putmem( |
lwres_buffer_t * | b, |
| const unsigned char * | base, | |
| unsigned int |
length); |
void
lwres_buffer_getmem( |
lwres_buffer_t * | b, |
| unsigned char * | base, | |
| unsigned int |
length); |
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
isc_buffer_
functions in the ISC library.
A buffer is a region of memory, together with a set of related subregions. The used region and the available 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.
The used region is further subdivided into two disjoint regions: the consumed region and the remaining region. 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 current offset (if any). The remaining 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.
The active region 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.
/------------entire length---------------\\
/----- used region -----\\/-- available --\\
+----------------------------------------+
| consumed | remaining | |
+----------------------------------------+
a b c d e
a == base of buffer.
b == current pointer. Can be anywhere between a and d.
c == active pointer. Meaningful between b and d.
d == used pointer.
e == length of buffer.
a-e == entire length of buffer. a-d == used region. a-b == consumed region. b-d == remaining region. b-c == optional active region.
lwres_buffer_init()
initializes the
lwres_buffer_t
*b
and assocates it with the memory region of size
length
bytes starting at location
base.
lwres_buffer_invalidate()
marks the buffer *b
as invalid. Invalidating a buffer after use is not required,
but makes it possible to catch its possible accidental use.
The functions
lwres_buffer_add()
and
lwres_buffer_subtract()
respectively increase and decrease the used space in
buffer
*b
by
n
bytes.
lwres_buffer_add()
checks for buffer overflow and
lwres_buffer_subtract()
checks for underflow.
These functions do not allocate or deallocate memory.
They just change the value of
used.
A buffer is re-initialised by
lwres_buffer_clear().
The function sets
used,
current
and
active
to zero.
lwres_buffer_first
makes the consumed region of buffer
*p
empty by setting
current
to zero (the start of the buffer).
lwres_buffer_forward()
increases the consumed region of buffer
*b
by
n
bytes, checking for overflow.
Similarly,
lwres_buffer_back()
decreases buffer
b's
consumed region by
n
bytes and checks for underflow.
lwres_buffer_getuint8()
reads an unsigned 8-bit integer from
*b
and returns it.
lwres_buffer_putuint8()
writes the unsigned 8-bit integer
val
to buffer
*b.
lwres_buffer_getuint16()
and
lwres_buffer_getuint32()
are identical to
lwres_buffer_putuint8()
except that they respectively read an unsigned 16-bit or 32-bit integer
in network byte order from
b.
Similarly,
lwres_buffer_putuint16()
and
lwres_buffer_putuint32()
writes the unsigned 16-bit or 32-bit integer
val
to buffer
b,
in network byte order.
Arbitrary amounts of data are read or written from a lightweight
resolver buffer with
lwres_buffer_getmem()
and
lwres_buffer_putmem()
respectively.
lwres_buffer_putmem()
copies
length
bytes of memory at
base
to
b.
Conversely,
lwres_buffer_getmem()
copies
length
bytes of memory from
b
to
base.