MAN page from Trustix bind-light-devel-9.2.2-9tr.i586.rpm
Updated: Jun 30, 2000Index
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
voidlwres_buffer_init(lwres_buffer_t *b, void *base, unsigned int length);
voidlwres_buffer_add(lwres_buffer_t *b, unsigned int n);
voidlwres_buffer_subtract(lwres_buffer_t *b, unsigned int n);
voidlwres_buffer_forward(lwres_buffer_t *b, unsigned int n);
voidlwres_buffer_back(lwres_buffer_t *b, unsigned int n);
voidlwres_buffer_putuint8(lwres_buffer_t *b, lwres_uint8_t val);
voidlwres_buffer_putuint16(lwres_buffer_t *b, lwres_uint16_t val);
voidlwres_buffer_putuint32(lwres_buffer_t *b, lwres_uint32_t val);
voidlwres_buffer_putmem(lwres_buffer_t *b, const unsigned char *base, unsigned int length);
voidlwres_buffer_getmem(lwres_buffer_t *b, unsigned char *base, unsigned int length);
These functions provide bounds checked access to a region of memorywhere data is being read or written.They are based on, and similar to, theisc_buffer_functions in the ISC library.
A buffer is a region of memory, together with a set of relatedsubregions.The used region and theavailable region are disjoint, andtheir union is the buffer's region.The used region extends from the beginning of the buffer region to thelast used byte.The available region extends from one byte greater than the last usedbyte to the end of the buffer's region.The size of the used region can be changed using variousbuffer commands.Initially, the used region is empty.
The used region is further subdivided into two disjoint regions: theconsumed 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 tothe byte before the current offset (if any).The remaining region the current pointer to the end of the usedregion.The size of the consumed region can be changed using variousbuffer commands.Initially, the consumed region is empty.
The active region is an (optional) subregion of the remainingregion.It extends from the current offset to an offset in theremaining 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 thelwres_buffer_t*band assocates it with the memory region of sizelengthbytes starting at locationbase.
lwres_buffer_invalidate()marks the buffer*bas invalid. Invalidating a buffer after use is not required,but makes it possible to catch its possible accidental use.
The functionslwres_buffer_add()andlwres_buffer_subtract()respectively increase and decrease the used space inbuffer*bbynbytes.lwres_buffer_add()checks for buffer overflow andlwres_buffer_subtract()checks for underflow.These functions do not allocate or deallocate memory.They just change the value ofused.
A buffer is re-initialised bylwres_buffer_clear().The function setsused ,currentandactiveto zero.
lwres_buffer_firstmakes the consumed region of buffer*pempty by settingcurrentto zero (the start of the buffer).
lwres_buffer_forward()increases the consumed region of buffer*bbynbytes, checking for overflow.Similarly,lwres_buffer_back()decreases bufferb'sconsumed region bynbytes and checks for underflow.
lwres_buffer_getuint8()reads an unsigned 8-bit integer from*band returns it.lwres_buffer_putuint8()writes the unsigned 8-bit integervalto buffer*b.
lwres_buffer_getuint16()andlwres_buffer_getuint32()are identical tolwres_buffer_putuint8()except that they respectively read an unsigned 16-bit or 32-bit integer in network byte order fromb.Similarly,lwres_buffer_putuint16()andlwres_buffer_putuint32()writes the unsigned 16-bit or 32-bit integervalto bufferb,in network byte order.
Arbitrary amounts of data are read or written from a lightweightresolver buffer withlwres_buffer_getmem()andlwres_buffer_putmem()respectively.lwres_buffer_putmem()copieslengthbytes of memory atbasetob.Conversely,lwres_buffer_getmem()copieslengthbytes of memory frombtobase.
This document was created byman2html,using the manual pages.